Initial commit.

This commit is contained in:
2019-07-01 14:33:21 +02:00
parent 92a04d779e
commit baa2e0279d
1624 changed files with 3204958 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c988559f114704842adb43bdb2e16f59
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+13
View File
@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimEnd : MonoBehaviour {
// Use this for initialization
public void setAnimState(int state)
{
Debug.Log("setAnimState: " + state + " !");
if (state==1) Gamestate.Instance.setAnimPlaying(false);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 70fd9fc2600f14c448df156acf16f48a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+53
View File
@@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AspectRatio : MonoBehaviour {
// Use this for initialization
// Use this for initialization
void Start()
{
Screen.orientation = ScreenOrientation.LandscapeLeft;
// set the desired aspect ratio (the values in this example are
// hard-coded for 16:9, but you could make them into public
// variables instead so you can set them at design time)
float targetaspect = 9.0f / 16.0f;
// determine the game window's current aspect ratio
float windowaspect = (float)Screen.width / (float)Screen.height;
// current viewport height should be scaled by this amount
float scaleheight = windowaspect / targetaspect;
// obtain camera component so we can modify its viewport
Camera camera = GetComponent<Camera>();
// if scaled height is less than current height, add letterbox
if (scaleheight < 1.0f)
{
Rect rect = camera.rect;
rect.width = 1.0f;
rect.height = scaleheight;
rect.x = 0;
rect.y = (1.0f - scaleheight) / 2.0f;
camera.rect = rect;
}
else // add pillarbox
{
float scalewidth = 1.0f / scaleheight;
Rect rect = camera.rect;
rect.width = scalewidth;
rect.height = 1.0f;
rect.x = (1.0f - scalewidth) / 2.0f;
rect.y = 0;
camera.rect = rect;
}
}
}
+13
View File
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: a98d30a1ba4f73c4c98a2185586dcb7f
timeCreated: 1528526545
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+307
View File
@@ -0,0 +1,307 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class Calibrate : MonoBehaviour {
public Camera cam;
private int touchCount = 0;
private float targetTime = 1.0f;
public Text Fingercount;
private string game="blinking";
public GameObject finger1;
public GameObject finger2;
public GameObject finger3;
public GameObject finger4;
public GameObject finger5;
public GameObject finger6;
public GameObject finger7;
public GameObject finger8;
public GameObject finger9;
public GameObject finger10;
private bool logged = false;
//private Color color1 = Color.green;
//private Color color2 = Color.cyan;
private int counter=1;
private Touch[] sortedTouches = new Touch[10];// Input.touches;
// Use this for initialization
void Start () {
//Camera.main.aspect = 1536f / 2048f;
finger1.GetComponent<SpriteRenderer>().enabled = false;
finger2.GetComponent<SpriteRenderer>().enabled = false;
finger3.GetComponent<SpriteRenderer>().enabled = false;
finger4.GetComponent<SpriteRenderer>().enabled = false;
finger5.GetComponent<SpriteRenderer>().enabled = false;
finger6.GetComponent<SpriteRenderer>().enabled = false;
finger7.GetComponent<SpriteRenderer>().enabled = false;
finger8.GetComponent<SpriteRenderer>().enabled = false;
finger9.GetComponent<SpriteRenderer>().enabled = false;
finger10.GetComponent<SpriteRenderer>().enabled = false;
Vector3 pos = cam.ScreenToWorldPoint(finger1.transform.position);
pos.z = 0.0f;
finger1.transform.position = pos;
pos = cam.ScreenToWorldPoint(finger2.transform.position);
pos.z = 0.0f;
finger2.transform.position = pos;
pos = cam.ScreenToWorldPoint(finger3.transform.position);
pos.z = 0.0f;
finger3.transform.position = pos;
pos = cam.ScreenToWorldPoint(finger4.transform.position);
pos.z = 0.0f;
finger4.transform.position = pos;
pos = cam.ScreenToWorldPoint(finger5.transform.position);
pos.z = 0.0f;
finger5.transform.position = pos;
pos = cam.ScreenToWorldPoint(finger6.transform.position);
pos.z = 0.0f;
finger6.transform.position = pos;
pos = cam.ScreenToWorldPoint(finger7.transform.position);
pos.z = 0.0f;
finger7.transform.position = pos;
pos = cam.ScreenToWorldPoint(finger8.transform.position);
pos.z = 0.0f;
finger8.transform.position = pos;
pos = cam.ScreenToWorldPoint(finger9.transform.position);
pos.z = 0.0f;
finger9.transform.position = pos;
pos = cam.ScreenToWorldPoint(finger10.transform.position);
pos.z = 0.0f;
finger10.transform.position = pos;
//game = "blinking";
}
void timerEnded()
{
//do your stuff here.
sortTouches();
/*Gamestate.Instance.setTouchPoints(sortedTouches);
Debug.Log("cal: " + Gamestate.Instance.getTouchPoints()[0].position.ToString());
Debug.Log("cal: " + Gamestate.Instance.getTouchPoints()[1].position.ToString());
Debug.Log("cal: " + Gamestate.Instance.getTouchPoints()[2].position.ToString());
Debug.Log("cal: " + Gamestate.Instance.getTouchPoints()[3].position.ToString());
Debug.Log("cal: " + Gamestate.Instance.getTouchPoints()[4].position.ToString());
Debug.Log("cal: " + Gamestate.Instance.getTouchPoints()[5].position.ToString());
Debug.Log("cal: " + Gamestate.Instance.getTouchPoints()[6].position.ToString());
Debug.Log("cal: " + Gamestate.Instance.getTouchPoints()[7].position.ToString());
Debug.Log("cal: " + Gamestate.Instance.getTouchPoints()[8].position.ToString());
Debug.Log("cal: " + Gamestate.Instance.getTouchPoints()[9].position.ToString());
*/
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startIntro();
}
private void sortTouches()
{
List<Touch> touches = new List<Touch>();// Input.touches;
touches = Input.touches.OrderBy(t => t.position.y).ToList();
Touch t1 = touches[0];
Touch t2 = touches[1];
//Thumbs
if (t1.position.x < t2.position.x)
{
sortedTouches[0] = t2;
sortedTouches[5] = t1;
} else
{
sortedTouches[0] = t1;
sortedTouches[5] = t2;
}
touches.RemoveRange(0, 2);
touches = touches.OrderBy(t => t.position.x).ToList();
sortedTouches[9] = touches.First<Touch>();
touches.RemoveAt(0);
sortedTouches[8] = touches.First<Touch>();
touches.RemoveAt(0);
sortedTouches[7] = touches.First<Touch>();
touches.RemoveAt(0);
sortedTouches[6] = touches.First<Touch>();
touches.RemoveAt(0);
sortedTouches[4] = touches.First<Touch>();
touches.RemoveAt(0);
sortedTouches[3] = touches.First<Touch>();
touches.RemoveAt(0);
sortedTouches[2] = touches.First<Touch>();
touches.RemoveAt(0);
sortedTouches[1] = touches.First<Touch>();
}
// Update is called once per frame
void Update () {
switch (game)
{
case "running":
if (!logged)
{
Debug.Log("running");
logged = true;
}
foreach (Touch touch in Input.touches)
{
switch (touch.phase)
{
case TouchPhase.Began:
touchCount += 1;
Fingercount.text = touchCount.ToString();
break;
case TouchPhase.Ended:
touchCount -= 1;
Fingercount.text = touchCount.ToString();
break;
default:
break;
}
}
if (touchCount == 10)
{
targetTime -= Time.deltaTime;
if (targetTime <= 0.0f)
{
timerEnded();
}
}
break;
case "blinking":
targetTime -= Time.deltaTime;
//float t = Mathf.PingPong(Time.time, duration) / duration;
//cam.backgroundColor = Color.Lerp(color1, color2, t);
if (targetTime <= 0.0f)
{
Debug.Log("targetTime: " + targetTime.ToString());
Debug.Log("Time.deltaTime: " + Time.deltaTime.ToString());
Debug.Log("counter: "+counter.ToString());
switch (counter)
{
case 1:
finger1.GetComponent<SpriteRenderer>().enabled = true;
counter = 2;
targetTime = 0.5f;
break;
case 2:
finger2.GetComponent<SpriteRenderer>().enabled = true;
counter = 3;
targetTime = 0.5f;
break;
case 3:
finger3.GetComponent<SpriteRenderer>().enabled = true;
counter = 4;
targetTime = 0.5f;
break;
case 4:
finger4.GetComponent<SpriteRenderer>().enabled = true;
counter = 5;
targetTime = 0.5f;
break;
case 5:
finger5.GetComponent<SpriteRenderer>().enabled = true;
counter = 6;
targetTime = 0.5f;
break;
case 6:
finger6.GetComponent<SpriteRenderer>().enabled = true;
counter = 7;
targetTime = 0.5f;
break;
case 7:
finger7.GetComponent<SpriteRenderer>().enabled = true;
counter = 8;
targetTime = 0.5f;
break;
case 8:
finger8.GetComponent<SpriteRenderer>().enabled = true;
counter = 9;
targetTime = 0.5f;
break;
case 9:
finger9.GetComponent<SpriteRenderer>().enabled = true;
counter = 10;
targetTime = 0.5f;
break;
case 10:
finger10.GetComponent<SpriteRenderer>().enabled = true;
counter = 11;
targetTime = 0.5f;
break;
case 11:
finger1.GetComponent<SpriteRenderer>().enabled = false;
finger2.GetComponent<SpriteRenderer>().enabled = false;
finger3.GetComponent<SpriteRenderer>().enabled = false;
finger4.GetComponent<SpriteRenderer>().enabled = false;
finger5.GetComponent<SpriteRenderer>().enabled = false;
finger6.GetComponent<SpriteRenderer>().enabled = false;
finger7.GetComponent<SpriteRenderer>().enabled = false;
finger8.GetComponent<SpriteRenderer>().enabled = false;
finger9.GetComponent<SpriteRenderer>().enabled = false;
finger10.GetComponent<SpriteRenderer>().enabled = false;
counter = 12;
targetTime = 0.5f;
break;
case 12:
finger1.GetComponent<SpriteRenderer>().enabled = true;
finger2.GetComponent<SpriteRenderer>().enabled = true;
finger3.GetComponent<SpriteRenderer>().enabled = true;
finger4.GetComponent<SpriteRenderer>().enabled = true;
finger5.GetComponent<SpriteRenderer>().enabled = true;
finger6.GetComponent<SpriteRenderer>().enabled = true;
finger7.GetComponent<SpriteRenderer>().enabled = true;
finger8.GetComponent<SpriteRenderer>().enabled = true;
finger9.GetComponent<SpriteRenderer>().enabled = true;
finger10.GetComponent<SpriteRenderer>().enabled = true;
counter = 13;
targetTime = 0.5f;
break;
case 13:
finger1.GetComponent<SpriteRenderer>().enabled = false;
finger2.GetComponent<SpriteRenderer>().enabled = false;
finger3.GetComponent<SpriteRenderer>().enabled = false;
finger4.GetComponent<SpriteRenderer>().enabled = false;
finger5.GetComponent<SpriteRenderer>().enabled = false;
finger6.GetComponent<SpriteRenderer>().enabled = false;
finger7.GetComponent<SpriteRenderer>().enabled = false;
finger8.GetComponent<SpriteRenderer>().enabled = false;
finger9.GetComponent<SpriteRenderer>().enabled = false;
finger10.GetComponent<SpriteRenderer>().enabled = false;
targetTime = 2.0f;
game = "running";
break;
}
}
break;
}
}
}
+13
View File
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 953b108201e93174b8057840cfeaeddf
timeCreated: 1528378781
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+20
View File
@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CorrectResponse : MonoBehaviour
{
public Image image;
public Animator animator;
// Update is called once per frame
void Update()
{
animator.Play("StarMove", -1, 0f);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: da82bf87de56583439e13844fe1f049a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+863
View File
@@ -0,0 +1,863 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using UnityEngine.Video;
using TMPro;
public class CountGame : MonoBehaviour
{
public List<Trial> trials = new List<Trial>();
public RawImage TutorialPlayer;
public VideoClip count_tut;
private VideoPlayer vp;
private VideoSource videoSource;
//Audio
private AudioSource audioSource;
//public Text number;
public TMP_Text number;
public TMP_Text level;
public Camera cam;
private string game;
public SpriteRenderer background;
private int touchCount = 0;
const float sw= 1.5f;//stopwatch
private float targetTime = sw;
private float maxTargetTime = sw; //must be = targetTime
private float targetTime2 = 0.1f;
private float targetTime3 = 1.0f;
private float targetTime4 = 0.8f;
private ArrayList completed5 = new ArrayList();
private ArrayList completed10 = new ArrayList();
private int stage;
//private UnityEngine.Random rnd = new UnityEngine.Random();
private int count = 0;
private int score = 0;
private int[] numbers10 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
private int[] numbers5 = { 1, 2, 3, 4, 5 };
private ArrayList s_numbers10 = new ArrayList();
private ArrayList s_numbers5 = new ArrayList();
private int[] numberCount = { 0, 0, 0, 0, 0 };
private int[] numberCount10 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
public new List<AudioSource> audio = new List<AudioSource>();
public Button startButton;
public Button exitButton;
public Image fuel;
public Image progressBar;
public Image EvaluateTimer;
public GameObject[] hand = new GameObject[10];
private bool[] fingers = new bool[10];
private int trialCount = 0;
private bool logged = false;
private bool logged2 = false;
private bool logged3 = false;
//private float duration = 0.2f;
//private Color color1 = Color.blue;
//private Color color2 = Color.green;
//private Color color3 = Color.blue;
//private Color color4 = Color.red;
private int fingerCount=0;
private Trial trial;
public GameObject scoreStar;
public GameObject Finn;
//private Vector3 posStar = new Vector3();
//private int scoreCount = 0;
private bool evaluated=false;
private int response = 0;
private bool tutorialIsPlaying;
private bool playNextTrial;
private int error_count=0;
private bool kurze_pause=false;
//private bool switched=false;
private void Awake()
{
scoreStar.SetActive(false);
background.GetComponent<Animator>().SetInteger("fade", 0);
background.GetComponent<Animator>().Play("Background_Idle", -1, 0f);
StartCoroutine(prepareVideo());
}
IEnumerator prepareVideo() {
vp = gameObject.AddComponent<VideoPlayer>();
//Add AudioSource
audioSource = gameObject.AddComponent<AudioSource>();
//Disable Play on Awake for both Video and Audio
vp.playOnAwake = false;
audioSource.playOnAwake = false;
vp.source = VideoSource.VideoClip;
vp.audioOutputMode = VideoAudioOutputMode.AudioSource;
//Assign the Audio from Video to AudioSource to be played
vp.EnableAudioTrack(0, true);
vp.SetTargetAudioSource(0, audioSource);
audioSource.volume = 0.8f;
//We want to play from video clip not from url
vp.clip = count_tut;
//Set video To Play then prepare Audio to prevent Buffering
vp.Prepare();
//Wait until video is prepared
while (!vp.isPrepared)
{
Debug.Log("Preparing Video");
yield return null;
}
Debug.Log("Done Preparing Video");
//Assign the Texture from Video to RawImage to be displayed
TutorialPlayer.texture = vp.texture;
}
void Start()
{
number.text = " ";
number.gameObject.SetActive(false);
level.text = "LEVEL " + Gamestate.Instance.getLevel();
foreach (GameObject go in hand)
{
go.GetComponent<SpriteRenderer>().enabled = false;
}
for(int i=0; i<10;i++)
{
fingers[i] = false;
}
s_numbers10 = new ArrayList(reshuffle(numbers10));
s_numbers5 = new ArrayList(numbers5);
progressBar.fillAmount = 0;
EvaluateTimer.fillAmount=0;
EvaluateTimer.fillClockwise = true;
stage = 1;
}
int[] reshuffle(int[] numbers)
{
// Knuth shuffle algorithm :: courtesy of Wikipedia :)
for (int t = 0; t < numbers.Length; t++)
{
int tmp = numbers[t];
int r = UnityEngine.Random.Range(t, numbers.Length);
numbers[t] = numbers[r];
numbers[r] = tmp;
}
return numbers;
}
int selectRandomNumber_5()
{
if (s_numbers5.Count == 0) s_numbers5 = new ArrayList(reshuffle(numbers5));
int r = (int)s_numbers5[0];
s_numbers5.RemoveAt(0);
return r;
}
int selectRandomNumber_10()
{
if (s_numbers10.Count == 0) s_numbers10 = new ArrayList(reshuffle(numbers10));
int r = (int)s_numbers10[0];
s_numbers10.RemoveAt(0);
return r;
}
public void setProgressBar(int val)
{
Debug.Log("setProgressBar: " + val.ToString());
float t = Gamestate.Instance.getNumberTrials()*10f;
progressBar.fillAmount = val / t;
}
public void setEvaluateTimer(float val)
{
Debug.Log("setEvaluate: " + val.ToString());
//float t = Gamestate.Instance.getNumberTrials()*10f;
EvaluateTimer.fillAmount = val/maxTargetTime;//(Gamestate.Instance.getNumberTrials()*10) ;
}
void evaluateTouchInput()
{
foreach (Touch touch in Input.touches)
{
TouchSer tser = new TouchSer();
tser.TouchID = touch.fingerId.ToString();
tser.Timestamp = touch.deltaTime.ToString();
tser.X = touch.position.x;
tser.Y = touch.position.y;
trial.T.Add(tser);
}
Debug.Log("trial.t.:" + trial.T.Count.ToString());
Debug.Log("-------------------------------");
Debug.Log("count: " + count.ToString());
Debug.Log("touchCount: " + touchCount.ToString());
Debug.Log("+++++++++++++++++++++++++++++++");
evaluated = true;
//targetTime = 2.0f;
//targetTime2 = 0.1f;
fingerCount = 0;
//do your stuff here.
for (int i=0; i<10; i++)
{
if (fingers[i] == true) fingerCount += 1;
}
if (fingerCount == count)
{
Debug.Log("Level: " + Gamestate.Instance.getLevel());
Debug.Log("parsed Level: " + int.Parse(Gamestate.Instance.getLevel()).ToString());
trial.Correct = "y";
error_count = 0;
if (stage == 1)
{
numberCount[count - 1] += 1;
if (numberCount[count - 1] >= Gamestate.Instance.getMaxCorrect())
completed5.Add(count);
}
if (stage == 2)
{
numberCount10[count - 1] += 1;
if (numberCount10[count - 1] >= Gamestate.Instance.getMaxCorrect())
completed10.Add(count);
}
if (completed5.Count == 5)
{
stage = 2;
}
score = score + 10;
audio[11].Play();
scoreStar.SetActive(true);
scoreStar.GetComponent<Animator>().Play("StarMove", -1, 0f);
setProgressBar(score);
if (int.Parse(Gamestate.Instance.getLevel()) > 1)
{
audio[count - 1].Play();
}
if (int.Parse(Gamestate.Instance.getLevel()) > 2)
{
audio[count - 1].Play();
number.text = count.ToString();
//Debug.Log("------ GameState.getAnimPlaying: " + Gamestate.Instance.getAnimPlaying());
//if (!Gamestate.Instance.getAnimPlaying())
number.GetComponent<Animator>().Play("NumberAnim2", -1, 0f);
}
response = 1;
//game = "green_blink";
}
else
{
//game = "wrong";
//game = "red_blink";
number.text = " ";
//number.GetComponent<Animator>().Play("NumberAnim", -1, 0f);
audio[12].Play();
trial.Correct = "n";
response = 2;
error_count +=1;
}
}
void Update()
{
switch (game)
{
case "running":
if (!logged)
{
Debug.Log("running");
logged = true;
}
targetTime -= Time.deltaTime;
if (fingers[0] == true) {
//if (!EvaluateTimer.GetComponent<SpriteRenderer>().enabled) EvaluateTimer.GetComponent<SpriteRenderer>().enabled=true;
setEvaluateTimer(targetTime);
}
if (targetTime <= 0.0f & fingers[0] == true)
{
game = "evaluate";
break;
//evaluateTouchInput();
}
foreach (Touch touch in Input.touches)
{
switch (touch.phase)
{
case TouchPhase.Began:
Debug.Log("phase began");
touchCount += 1;
fingers[touchCount-1] = true;
audio[13].Play();
if (int.Parse(Gamestate.Instance.getLevel()) > 1)
{
audio[touchCount-1].Play();
}
if (touchCount < count & touchCount < 10)
{
hand[touchCount].GetComponent<SpriteRenderer>().enabled = true;
hand[touchCount].GetComponent<Animator>().SetBool("fadeout", false);
hand[touchCount].GetComponent<Animator>().Play("StarFadeIn", -1,0f);
}
targetTime = sw;
break;
case TouchPhase.Ended:
Debug.Log("phase ended");
if (touchCount > 1) touchCount -= 1;
fingers[touchCount] = false;
hand[touchCount+1].GetComponent<Animator>().SetBool("fadeout", true);
hand[touchCount+1].GetComponent<SpriteRenderer>().enabled = false;
targetTime = sw;
break;
default:
break;
}
}
break;
case "evaluate":
if (!logged2)
{
Debug.Log("evaluate");
logged2 = true;
}
if (!evaluated) evaluateTouchInput();
targetTime3 -= Time.deltaTime;
if (targetTime3 <= 0.0f)
{
if (response == 1) game = "green_blink";
if (response == 2) game = "red_blink";
trials.Add(trial);
}
break;
case "kurze_pause":
targetTime3 -= Time.deltaTime;
//level.text ="Weiter so!!!";
//tutorialIsPlaying=false;
//game="tutorial";
if (targetTime3 <= 0.0f)
{
if (Input.touchCount > 0) {
background.GetComponent<Animator>().SetInteger("fade", 2);
Debug.Log("-------------------------------------------------HALBZEIT---------------------------------------");
level.text = " ";
kurze_pause=true;
Finn.SetActive(false);
game = "next_trial";
//trials.Add(trial);
}
}
break;
case "green_blink":
targetTime -= Time.deltaTime;
//float t = Mathf.PingPong(Time.time, duration) / duration;
//cam.backgroundColor = Color.Lerp(color1, color2, t);
if (targetTime <= 0.0f)
{
number.text = " ";
for (int i = 0; i < 10; i++)
{
hand[i].GetComponent<Animator>().SetBool("fadeout", true);
}
targetTime2 -= Time.deltaTime;
if (targetTime2 <= 0.0f) {
playNextTrial=false;//nextTrial();
game="next_trial";
}
}
break;
case "red_blink":
targetTime -= Time.deltaTime;
//float t2 = Mathf.PingPong(Time.time, duration) / duration;
//cam.backgroundColor = Color.Lerp(color3, color4, t2);
if (targetTime <= 0.0f)
{
//cam.backgroundColor = Color.blue;
number.text = " ";
for (int i = 0; i < 10; i++)
{
hand[i].GetComponent<Animator>().SetBool("fadeout", true);
}
if (error_count >= 5) {
tutorialIsPlaying=false;
game="tutorial";
break;
}
targetTime2 -= Time.deltaTime;
if (targetTime2 <= 0.0f) {
playNextTrial=false;//nextTrial();
game="next_trial";
}
}
break;
case "tutorial":
targetTime4 -= Time.deltaTime;
//background = GetComponent<Animator>().SetBool("fadeout", true);
background.GetComponent<Animator>().SetInteger("fade", 1);
exitButton.gameObject.SetActive(false);
startButton.gameObject.SetActive(false);
fuel.gameObject.SetActive(false);
progressBar.gameObject.SetActive(false);
level.text=" ";
//background.GetComponent<Animator>().Play("Background_Fader", -1,0f);
if (targetTime4 <= 0.0f)
{
if(!tutorialIsPlaying) {
Debug.Log("background anim state1 = "+background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash.ToString());
StartCoroutine(playTutorial());
}
}
break;
case "next_trial":
if(!playNextTrial) nextTrial();
break;
case "ending":
if (!logged3)
{
Debug.Log("ended");
number.text = " ";
trialCount = 0;
/* switch(Gamestate.Instance.getLevel())
{
case "1":
if(!switched)
{
Gamestate.Instance.setLevel("2");
switched = true;
}
break;
case "2":
if(!switched)
{
Gamestate.Instance.setLevel("3");
switched = true;
}
break;
}*/
targetTime -= Time.deltaTime;
//float t = Mathf.PingPong(Time.time, duration) / duration;
//cam.backgroundColor = Color.Lerp(color1, color2, t);
if (targetTime <= 0.0f)
{
logged3 = true;
trial.Score=score;
Gamestate.Instance.setGamePoints(score);
//foreach(Trial t in trials) {
// dump(t);
//}
savePlayerData();
//cam.backgroundColor = Color.black;
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startScoreScene();
}
}
break;
}
}
public void startProc() {
if (Gamestate.Instance.getTutorial())
{
tutorialIsPlaying=false;
Debug.Log("background anim state0 = "+background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash.ToString());
game="tutorial";
//return;
} else
{
playNextTrial = false;
game="next_trial";//nextTrial();
}
}
/* Start of the game. Starts by pressing the play-button*/
public void nextTrial()
{
background.GetComponent<Animator>().SetInteger("fade",3);
targetTime4 = 0.8f;
Debug.Log("background anim state3 = "+background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash.ToString());
//background.GetComponent<Animator>().SetInteger("fade",0);
progressBar.gameObject.SetActive(true);
level.text = " ";
foreach (GameObject go in hand)
{
go.GetComponent<SpriteRenderer>().enabled = false;
}
for (int i = 0; i < fingerCount; i++)
{
hand[i].GetComponent<Animator>().SetBool("fadeout", false);
}
if (trialCount > 0 && trialCount < Gamestate.Instance.getNumberTrials() && trialCount % 8 == 0 && !kurze_pause) {
background.GetComponent<Animator>().SetInteger("fade",1);
exitButton.gameObject.SetActive(false);
startButton.gameObject.SetActive(false);
Finn.SetActive(true);
fuel.gameObject.transform.localPosition = new Vector3(311,-213,0);
progressBar.gameObject.transform.localPosition = new Vector3(311.6f,-232,0);
float i = UnityEngine.Random.value;
if (error_count < 3) {
if (i < 0.25) {
level.text = "Super !!!";
audio[14].PlayDelayed(0.2f);
} else if (i >=0.25 && i < 0.5) {
level.text = "Toll !!!";
audio[15].PlayDelayed(0.2f);
} else if (i >= 0.5 && i < 0.75) {
level.text = "Sehr gut !!!";
audio[16].PlayDelayed(0.2f);
} else {
level.text = "Prima !!!";
audio[17].PlayDelayed(0.2f);
}
} else {
level.text = "Bleib dran !!!";
audio[18].PlayDelayed(0.2f);
}
game= "kurze_pause";
return;
}
else if (trialCount < Gamestate.Instance.getNumberTrials())
{
game = "running";
}
else
{
targetTime = sw;
game = "ending";
return;
}
//background.GetComponent<Animator>().SetBool("fade_in",false);
playNextTrial=true;
kurze_pause=false;
Finn.SetActive(false);
fuel.gameObject.transform.localPosition = new Vector3(900,600,0);
progressBar.gameObject.transform.localPosition = new Vector3(900.6f,577.8f,0);
hand[0].GetComponent<SpriteRenderer>().enabled = true;
hand[0].GetComponent<Animator>().Play("StarFadeIn", -1, 0f);
trial = new Trial();
trial.ID = Gamestate.Instance.getID();
trial.Game = Gamestate.Instance.getGame();
trial.Level = Gamestate.Instance.getLevel();
trial.Date = DateTime.Now.Date.ToShortDateString();
trial.Time = DateTime.Now.TimeOfDay.ToString();
trial.Onset = Time.time.ToString();
trial.Correct2 = "e";
trial.T.Clear();
/*if (trialCount < Gamestate.Instance.getNumberTrials())
{
game = "running";
}
else
{
targetTime = sw;
game = "ending";
return;
}*/
evaluated = false;
Gamestate.Instance.setAnimPlaying(true);
scoreStar.SetActive(false);
startButton.gameObject.SetActive(false);
//exitButton.gameObject.SetActive(false);
exitButton.gameObject.SetActive(true);
fuel.gameObject.SetActive(true);
if (Gamestate.Instance.getLevel() == "1")
number.gameObject.SetActive(false);
else
number.gameObject.SetActive(true);
Debug.Log("nextTrial CountGame");
//count = numbers10[trialCount];// UnityEngine.Random.Range(1, 5);
if (stage == 1) count = selectRandomNumber_5();
if (stage == 2) count = selectRandomNumber_10();
//if (count ==109)
Debug.Log("count = " + count.ToString());
trial.R = count;
trial.Y=0;
trial.X=0;
trial.Op = "n";
touchCount = 0;
targetTime = sw;
targetTime2 = 0.1f;
targetTime3 = 1.0f;
for (int i = 0; i < 10; i++)
{
fingers[i] = false;
}
trialCount += 1;
trial.TrialCounter = trialCount;
//Debug.Log("bis hierher.............................");
}
public void exitGame()
{
//Gamestate.Instance.setGamePoints(score);
//Gamestate.Instance.setGame("Count");
//Gamestate.Instance.setLevel("1");
if(game != "ending") {
savePlayerData();
}
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.menuState();
}
private void OnApplicationPause(bool pauseStatus) {
if(game != "ending") {
savePlayerData();
}
}
private void OnApplicationQuit() {
if(game != "ending") {
savePlayerData();
}
}
public void savePlayerData()
{
// string bauen und zeilenweise rausschreiben
Debug.Log("save data on "+Application.persistentDataPath+"/playerData"+Gamestate.Instance.GetPlayerData().ID+".txt");
StreamWriter sw = new StreamWriter(Application.persistentDataPath+"/playerData"+Gamestate.Instance.getID()+".txt", true);
//File.Open(Application.persistentDataPath+"/playerData"+Gamestate.Instance.GetPlayerData().ID+".dat",FileMode.Append);
//BinaryFormatter bf = new BinaryFormatter();
string header= "Date Time TrialOnset ID Game Level Trial TargetNum1 TargetNum2 TargetNum3 TargetOp Score Correct Correct2 Attempt t1ID t1X t1Y t1deltaTime " +
"t2ID t2X t2Y t2deltaTime t3ID t3X t3Y t3deltaTime t4ID t4X t4Y t4deltaTime t5ID t5X t5Y t5deltaTime t6ID t6X t6Y t6deltaTime "+
"t7ID t7X t7Y t7deltaTime t8ID t8X t8Y t8deltaTime t9ID t9X t9Y t9deltaTime t10ID t10X t10Y t10deltaTime";
sw.WriteLine(header);
foreach (Trial t in trials)
{
string line = t.Date + " " + t.Time + " " + t.Onset + " " + t.ID + " " + t.Game + " " + t.Level + " " + t.TrialCounter + " " + t.X + " " + t.Y
+ " " + t.R + " " + t.Op + " " + t.Score + " " + t.Correct + " " + t.Correct2 + " " + t.Attempt;
int i=0;
foreach(TouchSer item in t.T) {
line = line + " " + item.TouchID + " " + item.X.ToString() + " " + item.Y.ToString() + " " + item.Timestamp;
i++;
}
for (int j = i; j <10; j++) {
line = line + " " + "99" + " " + "0" + " " + "0" + " " + "0";
}
Debug.Log("line: " + line);
//dump(trial);
sw.WriteLine(line);
}
sw.Close();
}
IEnumerator playTutorial()
{
tutorialIsPlaying = true;
TutorialPlayer.enabled=true;
//Add VideoPlayer to the GameObject
//Play Video
vp.Play();
//Play Sound
audioSource.Play();
Debug.Log("Playing Video");
while (vp.isPlaying)
{
//Debug.LogWarning("Video Time: " + Mathf.FloorToInt((float)vp.time));
yield return null;
}
//TutorialPlayer.GetComponent<Animator>().SetBool("fadeout",true);//.Play("tutorial2", -1, 0f);
TutorialPlayer.enabled = false;
background.GetComponent<Animator>().SetInteger("fade",2);
Debug.Log("background anim state2 = "+background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash.ToString());
//Debug.Log("background anim state3 = "+background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash.ToString());
/*var currentState = background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0);
while(currentState.fullPathHash == Animator.StringToHash("Base Layer.Player_standing"))
{
yield return null;
}*/
//yield return new WaitForSeconds(0.3f);
Debug.Log("Done Playing Video");
//background.GetComponent<Animator>().SetBool("fade_out", false);
//background.GetComponent<Animator>().SetBool("idle_in",false);
error_count=0;
playNextTrial=false;
//targetTime4 = 0.3f;
game="next_trial";
}
public void dump(Trial t) {
Debug.Log("------------------TRIAL-START------------------");
Debug.Log("date: " + t.Date);
Debug.Log("time: " + t.Time);
Debug.Log("trialOnset: " + t.Onset);
Debug.Log("game: " + t.Game);
Debug.Log("level: " + t.Level);
Debug.Log("score: " + t.Score);
Debug.Log("attempt_count: " + t.Attempt);
Debug.Log("ID: " + t.ID);
Debug.Log("Trial_counter: " + t.TrialCounter);
Debug.Log("Number: " + t.X);
Debug.Log("Number: " + t.Y);
Debug.Log("Number: " + t.R);
Debug.Log("Correct: " + t.Correct);
Debug.Log("Correct2: " + t.Correct2);
foreach (TouchSer item in t.T)
{
Debug.Log("touch.id: " + item.TouchID);
Debug.Log("touch.x: " + item.X.ToString());
Debug.Log("touch.y: " + item.Y.ToString());
Debug.Log("touch.time: " + item.Timestamp);
}
Debug.Log("------------------TRIAL-END------------------");
}
}
+13
View File
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: f5a7a88843d4c8348848ebcdcbfbf3e6
timeCreated: 1528615267
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+44
View File
@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EndScene : MonoBehaviour
{
public Image image;
private int count = 0;
public Sprite[] intro;
public Animator animator;
public new AudioSource endtheme;
public new AudioSource ufo;
void Start() {
endtheme.Play();
}
// Update is called once per frame
void Update()
{
if (animator.GetCurrentAnimatorStateInfo(0).normalizedTime > 1.0f)
{
if (count == 0) ufo.Play();
if (count == 2)
{
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.menuState();
}
else
{
//background.texture.LoadImage();
image.sprite = intro[count];// newSprite;
}
count += 1;
animator.Play("End_Fader", -1, 0f);
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1f57824c85993af4f9ac1901f86b388e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+136
View File
@@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameSelect : MonoBehaviour
{
public Button StartCount;
public Button StartSet;
public Button StartAdd;
public Button Options;
public Toggle Level1;
public Toggle Level2;
public Toggle Level3;
public new AudioSource audio;
//private string selectedGame;
//private List<string> games = new List<string>() { "Count", "Set", "Add" };
//private int selectedLevel;
//private List<string> levels = new List<string>() { "1", "2", "3" };
void Start()
{
//Camera.main.aspect = 1536f / 2048f;
//PopulateCountingDropdown();
//PopulateSetDropdown();
//PopulateAddDropdown();
//Dropdown_Counting.itemText.text = Gamestate.Instance.getLevel();
//Dropdown_Set.itemText.text = Gamestate.Instance.getLevel();
//Dropdown_Add.itemText.text = Gamestate.Instance.getLevel();
if (Gamestate.Instance.getMusic()) audio.Play();
else
{
audio.Stop();
}
if (Gamestate.Instance.getLevel() == "1")
{
Level1.isOn = true;
Level2.isOn = false;
Level3.isOn = false;
}
else if (Gamestate.Instance.getLevel() == "2")
{
Level2.isOn = true;
Level1.isOn = false;
Level3.isOn = false;
}
else if (Gamestate.Instance.getLevel() == "3")
{
Level3.isOn = true;
Level2.isOn = false;
Level1.isOn = false;
}
Debug.Log("GameSelect: intro " + Gamestate.Instance.getIntro());
Debug.Log("GameSelect: Tutorial " + Gamestate.Instance.getTutorial());
}
public void ToggleLevel1_Changed(int index)
{
if (Level1.isOn) Gamestate.Instance.setLevel("1");
else Gamestate.Instance.setLevel(" ");//startGame()
}
public void ToggleLevel2_Changed(int index)
{
if (Level2.isOn) Gamestate.Instance.setLevel("2");
else Gamestate.Instance.setLevel(" ");//startGame()
}
public void ToggleLevel3_Changed(int index)
{
if (Level3.isOn) Gamestate.Instance.setLevel("3");
else Gamestate.Instance.setLevel(" ");//startGame()
}
public void startCountGame()
{
print("Starting game");
if (Gamestate.Instance.getLevel()!= " ") {
Gamestate.Instance.setGame("Count");
Gamestate.Instance.setLevel(Gamestate.Instance.getLevel());
Gamestate.Instance.setAttemptCount(Gamestate.Instance.getAttemptCount()+1);
audio.Stop();
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startState();
}
}
public void startSetGame()
{
if (Gamestate.Instance.getLevel()!= " ") {
audio.Stop();
//print("Starting game");
Gamestate.Instance.setGame("Set");
Gamestate.Instance.setLevel(Gamestate.Instance.getLevel());
Gamestate.Instance.setAttemptSet(Gamestate.Instance.getAttemptSet()+1);
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startState();
}
}
public void startAddGame()
{
if (Gamestate.Instance.getLevel()!= " ") {
audio.Stop();
//print("Starting game");
Gamestate.Instance.setGame("Add");
Gamestate.Instance.setLevel(Gamestate.Instance.getLevel());
Gamestate.Instance.setAttemptAdd(Gamestate.Instance.getAttemptAdd()+1);
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startState();
}
}
public void startOptions()
{
//if (Gamestate.Instance.getLevel()!= " ") {
//audio.Stop();
//print("Starting game");
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startOptions();
//}
}
}
+13
View File
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 5164566c613667247b4ac1f1533b3f7f
timeCreated: 1528540887
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+38
View File
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameStart : MonoBehaviour {
public Dropdown Dropdown_Counting;
private string selectedLevel;
private List<String> levels = new List<string>() { "Count1", "Count2", "Count3" };
public new AudioSource audio;
void Start()
{
PopulateCountingDropdown();
}
public void Dropdown_IndexChanged(int index)
{
Gamestate.Instance.setLevel(levels[index]);
}
private void PopulateCountingDropdown()
{
Dropdown_Counting.AddOptions(levels);
}
private void startGame()
{
print("Starting game");
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startState();
}
}
+13
View File
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 05487910f0f4906438246a17ee19ffff
timeCreated: 1528471312
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+345
View File
@@ -0,0 +1,345 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using System;
public class Gamestate : MonoBehaviour {
// Declare properties
private static Gamestate instance;
private string activeGame = "Count"; // Active level
private string activeLevel = "1"; // Active level
//private string name; // Characters name
private int score; // Characters Experience Points
private float scoreProz;
//private Touch[] touchList;
private bool calibrate = true;
private int numberTrials = 4;//48
private int maxCount = 5;
private int maxCorrect = 3;
private bool intro = true;
private bool tutorial = true;
private bool music = true;
private bool animPlaying = false;
public struct PlayerData
{
public string ID;
public string level;
public int score;
public string game;
public string date;
public string time;
public int attempt_count;
public int attempt_set;
public int attempt_add;
/*public int x, y;
public Coords(int p1, int p2)
{
x = p1;
y = p2;
}*/
}
private PlayerData pdata;
// ---------------------------------------------------------------------------------------------------
// gamestate()
// ---------------------------------------------------------------------------------------------------
// Creates an instance of gamestate as a gameobject if an instance does not exist
// ---------------------------------------------------------------------------------------------------
public static Gamestate Instance
{
get
{
if (instance == null)
{
instance = new GameObject("Gamestate").AddComponent<Gamestate>();
}
return instance;
}
}
// Sets the instance to null when the application quits
public void OnApplicationQuit()
{
instance = null;
}
/*public void createPlayerData() {
pdata.ID = "Test";
pdata.game = "Count";
pdata.level = "1";
pdata.score = 0;
pdata.date ="01011999";
pdata.time="00:00:00";
pdata.attempt_count=0;
pdata.attempt_set=0;
pdata.attempt_add=0;
}*/
public void setPlayerData(PlayerData pd) {
pdata.ID = pd.ID;
pdata.attempt_add = pd.attempt_add;
pdata.attempt_count = pd.attempt_count;
pdata.attempt_set=pd.attempt_set;
pdata.date=pd.date;
pdata.game=pd.game;
pdata.level=pd.level;
pdata.score=pd.score;
pdata.time=pd.time;
}
// ---------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------
// startState()
// ---------------------------------------------------------------------------------------------------
// Creates a new game state
// ---------------------------------------------------------------------------------------------------
public void startState()
{
print("startState");
// Set default properties:
name = "My Character";
score = 0;
if (!calibrate)
{
// Load level 1
calibrate = true;
SceneManager.LoadScene("Calibrate");
} else
{
startIntro();
//SceneManager.LoadScene(activeGame+"1");
}
}
public void startIntro()
{
print("startIntro");
// Set default properties:
name = "My Character";
score = 0;
if (intro)
{
// Load level 1
//intro = false;
SceneManager.LoadScene("Intro");
} else
{
//if (tutorial) startTutorial();
//else
startGame();
}
}
public void startGame()
{
Debug.Log("start activeGame: " + activeGame.ToString());
SceneManager.LoadScene(activeGame + "1");
}
/*public void startTutorial()
{
Debug.Log("start activeGame: " + activeGame.ToString());
SceneManager.LoadScene("Tutorial");
}*/
public void startScoreScene()
{
SceneManager.LoadScene("ScoreScene");
}
public void startOptions()
{
SceneManager.LoadScene("OptionScene");
}
public void startEndScene()
{
SceneManager.LoadScene("EndScene");
}
public void menuState()
{
print("menuState");
// Set default properties:
SceneManager.LoadScene("GameStart");
//data.savePlayerInfo();
}
public string getLevel()
{
return activeLevel;
}
public void setLevel(string newLevel)
{
// Set activeLevel to newLevel
activeLevel = newLevel;
pdata.level=newLevel;
//data.setLevel(newLevel);
}
public void setIntro(bool value)
{
intro = value;
}
public void setTutorial(bool value)
{
tutorial = value;
}
public void setMusic(bool value)
{
music = value;
}
public bool getTutorial()
{
return tutorial;
}
public bool getIntro()
{
return intro;
}
public bool getMusic()
{
return music;
}
public string getGame()
{
return activeGame;
}
public void setGame(string newGame)
{
// Set activeLevel to newLevel
activeGame = newGame;
pdata.game = newGame;
//data.setGame(newGame);
}
public void setID(string id)
{
pdata.ID=id;
}
public string getID()
{
return pdata.ID;
}
public void setGamePoints(int points)
{
score = points;
scoreProz = numberTrials / points;
//data.setPoints(points);
}
public int getGamePoints()
{
return score;
}
public float getGamePointsProz()
{
return scoreProz;
}
public int getNumberTrials()
{
return numberTrials;
}
public void setNumberTrials(int numTrials)
{
// Set activeLevel to newLevel
numberTrials = numTrials;
//data.setLevel(newLevel);
}
public int getMaxCount()
{
return maxCount;
}
public void setAnimPlaying(bool state)
{
this.animPlaying = state;
}
public bool getAnimPlaying()
{
return this.animPlaying;
}
public int getMaxCorrect()
{
return maxCorrect;
}
public PlayerData GetPlayerData()
{
return pdata;
}
public void setDate(string newDate)
{
pdata.date=pdata.date + " " + newDate;
}
public string getDate()
{
return pdata.level;
}
public void setPoints(int points)
{
pdata.score=points;
}
public int getPoints()
{
return pdata.score;
}
public void setAttemptCount(int count)
{
pdata.attempt_count=count;
}
public int getAttemptCount()
{
return pdata.attempt_count;
}
public void setAttemptSet(int count)
{
pdata.attempt_set=count;
}
public int getAttemptSet()
{
return pdata.attempt_set;
}
public void setAttemptAdd(int count)
{
pdata.attempt_add=count;
}
public int getAttemptAdd()
{
return pdata.attempt_add;
}
//public void addTrial(Trial t) {
// data.tdata.addTrial(t);
//}
}
+13
View File
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 37ffae3603e644249b1de71fe6ed09c9
timeCreated: 1528459789
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+57
View File
@@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Intro : MonoBehaviour
{
public Image image;
private int count = 0;
public Sprite[] intro;
public new List<AudioSource> audio = new List<AudioSource>();
public Animator animator;
public void Start() {
audio[0].Play();
}
// Update is called once per frame
void Update()
{
if (animator.GetCurrentAnimatorStateInfo(0).normalizedTime > 1.0f || Input.touchCount >0)
{
if (count == 3)
{
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startGame();
/*if (Gamestate.Instance.getTutorial())
Gamestate.Instance.startTutorial();
else
{
Gamestate.Instance.startGame();
}*/
}
else
{
//background.texture.LoadImage();
image.sprite = intro[count];// newSprite;
audio[count].Stop();
audio[count+1].Play();
}
if (count < 2)
animator.Play("Intro_Fader", -1, 0f);
else
{
animator.Play("Intro_Fader2", -1, 0f);
}
count += 1;
Debug.Log("count: " + count.ToString());
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1b5774746d33dc94c8e74ab8d102cdf1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+16
View File
@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class levelgui : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
+13
View File
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: d995fb066cc583a418293fd379dc904e
timeCreated: 1528459798
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+72
View File
@@ -0,0 +1,72 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Runtime.Serialization.Formatters.Binary;
using System;
using System.IO;
public class LoaderScreen : MonoBehaviour
{
// Start is called before the first frame update
public InputField id;
public Button start;
void Start()
{
start.gameObject.SetActive(false);
}
public void OnEditEnded() {
//check if user is there///
///if not, create new user entry///
//Gamestate.Instance.createPlayerData();
Debug.Log("endEdit... " + id.text);
Gamestate.Instance.setID(id.text);
/*if (!loadPlayerData())
{
Debug.Log("File with ID: " + Application.persistentDataPath+ "/playerInfo"+Gamestate.Instance.GetPlayerData().ID + ".dat created...");
}*/
start.gameObject.SetActive(true);
//PlayerPrefs.SetString("ID",id.text);
//if user created activate button
}
public void startGameSelect() {
//if (!Gamestate.Instance.GetPlayerData().loadPlayerInfo())
// Gamestate.Instance.GetPlayerData().savePlayerInfo();
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.menuState();
}
public bool loadPlayerData() {
if (id.text != "99") {
if (File.Exists(Application.persistentDataPath+"/playerData"+Gamestate.Instance.GetPlayerData().ID+".dat")) {
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath+"/playerData"+Gamestate.Instance.GetPlayerData().ID+".dat", FileMode.Open);
Gamestate.PlayerData pd = (Gamestate.PlayerData)bf.Deserialize(file);
Gamestate.Instance.setPlayerData(pd);
file.Close();
return true;
}
else
{
File.Create(Application.persistentDataPath+"/playerData"+Gamestate.Instance.GetPlayerData().ID+".dat");
return false;
}
} else {
if (!File.Exists(Application.persistentDataPath+"/playerData"+Gamestate.Instance.GetPlayerData().ID+".dat")) {
File.Create(Application.persistentDataPath+"/playerData"+Gamestate.Instance.GetPlayerData().ID+".dat");
return false;
}
return true;
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a6c20e9ed08131a4b9705760f323046e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+120
View File
@@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Options : MonoBehaviour
{
public Button Back;
public Toggle Intro;
public Toggle Tutorial;
public InputField NumberTrials;
public Toggle Music;
//public AudioSource audio;
//private string selectedGame;
//private List<string> games = new List<string>() { "Count", "Set", "Add" };
//private int selectedLevel;
//private List<string> levels = new List<string>() { "1", "2", "3" };
public void Start()
{
Debug.Log("options started...");
NumberTrials.characterLimit = 2;
NumberTrials.contentType = InputField.ContentType.IntegerNumber;
Debug.Log("Tutorial is "+Tutorial.isOn.ToString());
Debug.Log("Intro is "+Intro.isOn.ToString());
Debug.Log("Music is "+Music.isOn.ToString());
Tutorial.isOn = Gamestate.Instance.getTutorial();
Intro.isOn = Gamestate.Instance.getIntro();
Music.isOn = Gamestate.Instance.getMusic();
NumberTrials.text = Gamestate.Instance.getNumberTrials().ToString();
}
public void OnEditEnded() {
int num = Int32.Parse(NumberTrials.text);
if (num > 48) {
num = 48;
NumberTrials.text = "48";
}
Gamestate.Instance.setNumberTrials(num);
}
public void ToggleTutorial_Changed()
{
//Debug.Log("index: "+ index.ToString());
//Tutorial.isOn = index;//Gamestate.Instance.getTutorial();
//Debug.Log("Tutorial: " + Tutorial.isOn.ToString());
if (Tutorial.isOn)
{
Gamestate.Instance.setTutorial(true);
Debug.Log("Tutorial is : "+Gamestate.Instance.getTutorial().ToString());
//value = false;
}
else
{
Gamestate.Instance.setTutorial(false);
Debug.Log("Tutorial is : "+Gamestate.Instance.getTutorial().ToString());
//value = true;
}
//startGame();
}
public void ToggleIntro_Changed()
{
//Debug.Log("Intro: " + Intro.isOn.ToString());
if (Tutorial.isOn)
{
Gamestate.Instance.setIntro(true);
Debug.Log("Intro is "+Gamestate.Instance.getIntro().ToString());
//value = false;
}
else
{
Gamestate.Instance.setIntro(false);
Debug.Log("Intro is "+Gamestate.Instance.getIntro().ToString());
//value = true;
}
//startGame();
}
public void ToggleMusic_Changed()
{
if (Music.isOn)
{
Gamestate.Instance.setMusic(true);
Debug.Log("Music is true!");
//value = false;
}
else
{
Gamestate.Instance.setMusic(false);
Debug.Log("Music is false!");
//value = true;
}
//startGame();
}
public void back()
{
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.menuState();
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e122d5405c46374987c1318afe0885b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+667
View File
@@ -0,0 +1,667 @@
// ArrayPrefs2 v 1.4
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
public class PlayerPrefsX
{
static private int endianDiff1;
static private int endianDiff2;
static private int idx;
static private byte[] byteBlock;
enum ArrayType { Float, Int32, Bool, String, Vector2, Vector3, Quaternion, Color }
public static bool SetBool(String name, bool value)
{
try
{
PlayerPrefs.SetInt(name, value ? 1 : 0);
}
catch
{
return false;
}
return true;
}
public static bool GetBool(String name)
{
return PlayerPrefs.GetInt(name) == 1;
}
public static bool GetBool(String name, bool defaultValue)
{
return (1 == PlayerPrefs.GetInt(name, defaultValue ? 1 : 0));
}
public static long GetLong(string key, long defaultValue)
{
int lowBits, highBits;
SplitLong(defaultValue, out lowBits, out highBits);
lowBits = PlayerPrefs.GetInt(key + "_lowBits", lowBits);
highBits = PlayerPrefs.GetInt(key + "_highBits", highBits);
// unsigned, to prevent loss of sign bit.
ulong ret = (uint)highBits;
ret = (ret << 32);
return (long)(ret | (ulong)(uint)lowBits);
}
public static long GetLong(string key)
{
int lowBits = PlayerPrefs.GetInt(key + "_lowBits");
int highBits = PlayerPrefs.GetInt(key + "_highBits");
// unsigned, to prevent loss of sign bit.
ulong ret = (uint)highBits;
ret = (ret << 32);
return (long)(ret | (ulong)(uint)lowBits);
}
private static void SplitLong(long input, out int lowBits, out int highBits)
{
// unsigned everything, to prevent loss of sign bit.
lowBits = (int)(uint)(ulong)input;
highBits = (int)(uint)(input >> 32);
}
public static void SetLong(string key, long value)
{
int lowBits, highBits;
SplitLong(value, out lowBits, out highBits);
PlayerPrefs.SetInt(key + "_lowBits", lowBits);
PlayerPrefs.SetInt(key + "_highBits", highBits);
}
public static bool SetVector2(String key, Vector2 vector)
{
return SetFloatArray(key, new float[] { vector.x, vector.y });
}
static Vector2 GetVector2(String key)
{
var floatArray = GetFloatArray(key);
if (floatArray.Length < 2)
{
return Vector2.zero;
}
return new Vector2(floatArray[0], floatArray[1]);
}
public static Vector2 GetVector2(String key, Vector2 defaultValue)
{
if (PlayerPrefs.HasKey(key))
{
return GetVector2(key);
}
return defaultValue;
}
public static bool SetVector3(String key, Vector3 vector)
{
return SetFloatArray(key, new float[] { vector.x, vector.y, vector.z });
}
public static Vector3 GetVector3(String key)
{
var floatArray = GetFloatArray(key);
if (floatArray.Length < 3)
{
return Vector3.zero;
}
return new Vector3(floatArray[0], floatArray[1], floatArray[2]);
}
public static Vector3 GetVector3(String key, Vector3 defaultValue)
{
if (PlayerPrefs.HasKey(key))
{
return GetVector3(key);
}
return defaultValue;
}
public static bool SetQuaternion(String key, Quaternion vector)
{
return SetFloatArray(key, new float[] { vector.x, vector.y, vector.z, vector.w });
}
public static Quaternion GetQuaternion(String key)
{
var floatArray = GetFloatArray(key);
if (floatArray.Length < 4)
{
return Quaternion.identity;
}
return new Quaternion(floatArray[0], floatArray[1], floatArray[2], floatArray[3]);
}
public static Quaternion GetQuaternion(String key, Quaternion defaultValue)
{
if (PlayerPrefs.HasKey(key))
{
return GetQuaternion(key);
}
return defaultValue;
}
public static bool SetColor(String key, Color color)
{
return SetFloatArray(key, new float[] { color.r, color.g, color.b, color.a });
}
public static Color GetColor(String key)
{
var floatArray = GetFloatArray(key);
if (floatArray.Length < 4)
{
return new Color(0.0f, 0.0f, 0.0f, 0.0f);
}
return new Color(floatArray[0], floatArray[1], floatArray[2], floatArray[3]);
}
public static Color GetColor(String key, Color defaultValue)
{
if (PlayerPrefs.HasKey(key))
{
return GetColor(key);
}
return defaultValue;
}
public static bool SetBoolArray(String key, bool[] boolArray)
{
// Make a byte array that's a multiple of 8 in length, plus 5 bytes to store the number of entries as an int32 (+ identifier)
// We have to store the number of entries, since the boolArray length might not be a multiple of 8, so there could be some padded zeroes
var bytes = new byte[(boolArray.Length + 7) / 8 + 5];
bytes[0] = System.Convert.ToByte(ArrayType.Bool); // Identifier
var bits = new BitArray(boolArray);
bits.CopyTo(bytes, 5);
Initialize();
ConvertInt32ToBytes(boolArray.Length, bytes); // The number of entries in the boolArray goes in the first 4 bytes
return SaveBytes(key, bytes);
}
public static bool[] GetBoolArray(String key)
{
if (PlayerPrefs.HasKey(key))
{
var bytes = System.Convert.FromBase64String(PlayerPrefs.GetString(key));
if (bytes.Length < 5)
{
Debug.LogError("Corrupt preference file for " + key);
return new bool[0];
}
if ((ArrayType)bytes[0] != ArrayType.Bool)
{
Debug.LogError(key + " is not a boolean array");
return new bool[0];
}
Initialize();
// Make a new bytes array that doesn't include the number of entries + identifier (first 5 bytes) and turn that into a BitArray
var bytes2 = new byte[bytes.Length - 5];
System.Array.Copy(bytes, 5, bytes2, 0, bytes2.Length);
var bits = new BitArray(bytes2);
// Get the number of entries from the first 4 bytes after the identifier and resize the BitArray to that length, then convert it to a boolean array
bits.Length = ConvertBytesToInt32(bytes);
var boolArray = new bool[bits.Count];
bits.CopyTo(boolArray, 0);
return boolArray;
}
return new bool[0];
}
public static bool[] GetBoolArray(String key, bool defaultValue, int defaultSize)
{
if (PlayerPrefs.HasKey(key))
{
return GetBoolArray(key);
}
var boolArray = new bool[defaultSize];
for (int i = 0; i < defaultSize; i++)
{
boolArray[i] = defaultValue;
}
return boolArray;
}
public static bool SetStringArray(String key, String[] stringArray)
{
var bytes = new byte[stringArray.Length + 1];
bytes[0] = System.Convert.ToByte(ArrayType.String); // Identifier
Initialize();
// Store the length of each string that's in stringArray, so we can extract the correct strings in GetStringArray
for (var i = 0; i < stringArray.Length; i++)
{
if (stringArray[i] == null)
{
Debug.LogError("Can't save null entries in the string array when setting " + key);
return false;
}
if (stringArray[i].Length > 255)
{
Debug.LogError("Strings cannot be longer than 255 characters when setting " + key);
return false;
}
bytes[idx++] = (byte)stringArray[i].Length;
}
try
{
PlayerPrefs.SetString(key, System.Convert.ToBase64String(bytes) + "|" + String.Join("", stringArray));
}
catch
{
return false;
}
return true;
}
public static String[] GetStringArray(String key)
{
if (PlayerPrefs.HasKey(key))
{
var completeString = PlayerPrefs.GetString(key);
var separatorIndex = completeString.IndexOf("|"[0]);
if (separatorIndex < 4)
{
Debug.LogError("Corrupt preference file for " + key);
return new String[0];
}
var bytes = System.Convert.FromBase64String(completeString.Substring(0, separatorIndex));
if ((ArrayType)bytes[0] != ArrayType.String)
{
Debug.LogError(key + " is not a string array");
return new String[0];
}
Initialize();
var numberOfEntries = bytes.Length - 1;
var stringArray = new String[numberOfEntries];
var stringIndex = separatorIndex + 1;
for (var i = 0; i < numberOfEntries; i++)
{
int stringLength = bytes[idx++];
if (stringIndex + stringLength > completeString.Length)
{
Debug.LogError("Corrupt preference file for " + key);
return new String[0];
}
stringArray[i] = completeString.Substring(stringIndex, stringLength);
stringIndex += stringLength;
}
return stringArray;
}
return new String[0];
}
public static String[] GetStringArray(String key, String defaultValue, int defaultSize)
{
if (PlayerPrefs.HasKey(key))
{
return GetStringArray(key);
}
var stringArray = new String[defaultSize];
for (int i = 0; i < defaultSize; i++)
{
stringArray[i] = defaultValue;
}
return stringArray;
}
public static bool SetIntArray(String key, int[] intArray)
{
return SetValue(key, intArray, ArrayType.Int32, 1, ConvertFromInt);
}
public static bool SetFloatArray(String key, float[] floatArray)
{
return SetValue(key, floatArray, ArrayType.Float, 1, ConvertFromFloat);
}
public static bool SetVector2Array(String key, Vector2[] vector2Array)
{
return SetValue(key, vector2Array, ArrayType.Vector2, 2, ConvertFromVector2);
}
public static bool SetVector3Array(String key, Vector3[] vector3Array)
{
return SetValue(key, vector3Array, ArrayType.Vector3, 3, ConvertFromVector3);
}
public static bool SetQuaternionArray(String key, Quaternion[] quaternionArray)
{
return SetValue(key, quaternionArray, ArrayType.Quaternion, 4, ConvertFromQuaternion);
}
public static bool SetColorArray(String key, Color[] colorArray)
{
return SetValue(key, colorArray, ArrayType.Color, 4, ConvertFromColor);
}
private static bool SetValue<T>(String key, T array, ArrayType arrayType, int vectorNumber, Action<T, byte[], int> convert) where T : IList
{
var bytes = new byte[(4 * array.Count) * vectorNumber + 1];
bytes[0] = System.Convert.ToByte(arrayType); // Identifier
Initialize();
for (var i = 0; i < array.Count; i++)
{
convert(array, bytes, i);
}
return SaveBytes(key, bytes);
}
private static void ConvertFromInt(int[] array, byte[] bytes, int i)
{
ConvertInt32ToBytes(array[i], bytes);
}
private static void ConvertFromFloat(float[] array, byte[] bytes, int i)
{
ConvertFloatToBytes(array[i], bytes);
}
private static void ConvertFromVector2(Vector2[] array, byte[] bytes, int i)
{
ConvertFloatToBytes(array[i].x, bytes);
ConvertFloatToBytes(array[i].y, bytes);
}
private static void ConvertFromVector3(Vector3[] array, byte[] bytes, int i)
{
ConvertFloatToBytes(array[i].x, bytes);
ConvertFloatToBytes(array[i].y, bytes);
ConvertFloatToBytes(array[i].z, bytes);
}
private static void ConvertFromQuaternion(Quaternion[] array, byte[] bytes, int i)
{
ConvertFloatToBytes(array[i].x, bytes);
ConvertFloatToBytes(array[i].y, bytes);
ConvertFloatToBytes(array[i].z, bytes);
ConvertFloatToBytes(array[i].w, bytes);
}
private static void ConvertFromColor(Color[] array, byte[] bytes, int i)
{
ConvertFloatToBytes(array[i].r, bytes);
ConvertFloatToBytes(array[i].g, bytes);
ConvertFloatToBytes(array[i].b, bytes);
ConvertFloatToBytes(array[i].a, bytes);
}
public static int[] GetIntArray(String key)
{
var intList = new List<int>();
GetValue(key, intList, ArrayType.Int32, 1, ConvertToInt);
return intList.ToArray();
}
public static int[] GetIntArray(String key, int defaultValue, int defaultSize)
{
if (PlayerPrefs.HasKey(key))
{
return GetIntArray(key);
}
var intArray = new int[defaultSize];
for (int i = 0; i < defaultSize; i++)
{
intArray[i] = defaultValue;
}
return intArray;
}
public static float[] GetFloatArray(String key)
{
var floatList = new List<float>();
GetValue(key, floatList, ArrayType.Float, 1, ConvertToFloat);
return floatList.ToArray();
}
public static float[] GetFloatArray(String key, float defaultValue, int defaultSize)
{
if (PlayerPrefs.HasKey(key))
{
return GetFloatArray(key);
}
var floatArray = new float[defaultSize];
for (int i = 0; i < defaultSize; i++)
{
floatArray[i] = defaultValue;
}
return floatArray;
}
public static Vector2[] GetVector2Array(String key)
{
var vector2List = new List<Vector2>();
GetValue(key, vector2List, ArrayType.Vector2, 2, ConvertToVector2);
return vector2List.ToArray();
}
public static Vector2[] GetVector2Array(String key, Vector2 defaultValue, int defaultSize)
{
if (PlayerPrefs.HasKey(key))
{
return GetVector2Array(key);
}
var vector2Array = new Vector2[defaultSize];
for (int i = 0; i < defaultSize; i++)
{
vector2Array[i] = defaultValue;
}
return vector2Array;
}
public static Vector3[] GetVector3Array(String key)
{
var vector3List = new List<Vector3>();
GetValue(key, vector3List, ArrayType.Vector3, 3, ConvertToVector3);
return vector3List.ToArray();
}
public static Vector3[] GetVector3Array(String key, Vector3 defaultValue, int defaultSize)
{
if (PlayerPrefs.HasKey(key))
{
return GetVector3Array(key);
}
var vector3Array = new Vector3[defaultSize];
for (int i = 0; i < defaultSize; i++)
{
vector3Array[i] = defaultValue;
}
return vector3Array;
}
public static Quaternion[] GetQuaternionArray(String key)
{
var quaternionList = new List<Quaternion>();
GetValue(key, quaternionList, ArrayType.Quaternion, 4, ConvertToQuaternion);
return quaternionList.ToArray();
}
public static Quaternion[] GetQuaternionArray(String key, Quaternion defaultValue, int defaultSize)
{
if (PlayerPrefs.HasKey(key))
{
return GetQuaternionArray(key);
}
var quaternionArray = new Quaternion[defaultSize];
for (int i = 0; i < defaultSize; i++)
{
quaternionArray[i] = defaultValue;
}
return quaternionArray;
}
public static Color[] GetColorArray(String key)
{
var colorList = new List<Color>();
GetValue(key, colorList, ArrayType.Color, 4, ConvertToColor);
return colorList.ToArray();
}
public static Color[] GetColorArray(String key, Color defaultValue, int defaultSize)
{
if (PlayerPrefs.HasKey(key))
{
return GetColorArray(key);
}
var colorArray = new Color[defaultSize];
for (int i = 0; i < defaultSize; i++)
{
colorArray[i] = defaultValue;
}
return colorArray;
}
private static void GetValue<T>(String key, T list, ArrayType arrayType, int vectorNumber, Action<T, byte[]> convert) where T : IList
{
if (PlayerPrefs.HasKey(key))
{
var bytes = System.Convert.FromBase64String(PlayerPrefs.GetString(key));
if ((bytes.Length - 1) % (vectorNumber * 4) != 0)
{
Debug.LogError("Corrupt preference file for " + key);
return;
}
if ((ArrayType)bytes[0] != arrayType)
{
Debug.LogError(key + " is not a " + arrayType.ToString() + " array");
return;
}
Initialize();
var end = (bytes.Length - 1) / (vectorNumber * 4);
for (var i = 0; i < end; i++)
{
convert(list, bytes);
}
}
}
private static void ConvertToInt(List<int> list, byte[] bytes)
{
list.Add(ConvertBytesToInt32(bytes));
}
private static void ConvertToFloat(List<float> list, byte[] bytes)
{
list.Add(ConvertBytesToFloat(bytes));
}
private static void ConvertToVector2(List<Vector2> list, byte[] bytes)
{
list.Add(new Vector2(ConvertBytesToFloat(bytes), ConvertBytesToFloat(bytes)));
}
private static void ConvertToVector3(List<Vector3> list, byte[] bytes)
{
list.Add(new Vector3(ConvertBytesToFloat(bytes), ConvertBytesToFloat(bytes), ConvertBytesToFloat(bytes)));
}
private static void ConvertToQuaternion(List<Quaternion> list, byte[] bytes)
{
list.Add(new Quaternion(ConvertBytesToFloat(bytes), ConvertBytesToFloat(bytes), ConvertBytesToFloat(bytes), ConvertBytesToFloat(bytes)));
}
private static void ConvertToColor(List<Color> list, byte[] bytes)
{
list.Add(new Color(ConvertBytesToFloat(bytes), ConvertBytesToFloat(bytes), ConvertBytesToFloat(bytes), ConvertBytesToFloat(bytes)));
}
public static void ShowArrayType(String key)
{
var bytes = System.Convert.FromBase64String(PlayerPrefs.GetString(key));
if (bytes.Length > 0)
{
ArrayType arrayType = (ArrayType)bytes[0];
Debug.Log(key + " is a " + arrayType.ToString() + " array");
}
}
private static void Initialize()
{
if (System.BitConverter.IsLittleEndian)
{
endianDiff1 = 0;
endianDiff2 = 0;
}
else
{
endianDiff1 = 3;
endianDiff2 = 1;
}
if (byteBlock == null)
{
byteBlock = new byte[4];
}
idx = 1;
}
private static bool SaveBytes(String key, byte[] bytes)
{
try
{
PlayerPrefs.SetString(key, System.Convert.ToBase64String(bytes));
}
catch
{
return false;
}
return true;
}
private static void ConvertFloatToBytes(float f, byte[] bytes)
{
byteBlock = System.BitConverter.GetBytes(f);
ConvertTo4Bytes(bytes);
}
private static float ConvertBytesToFloat(byte[] bytes)
{
ConvertFrom4Bytes(bytes);
return System.BitConverter.ToSingle(byteBlock, 0);
}
private static void ConvertInt32ToBytes(int i, byte[] bytes)
{
byteBlock = System.BitConverter.GetBytes(i);
ConvertTo4Bytes(bytes);
}
private static int ConvertBytesToInt32(byte[] bytes)
{
ConvertFrom4Bytes(bytes);
return System.BitConverter.ToInt32(byteBlock, 0);
}
private static void ConvertTo4Bytes(byte[] bytes)
{
bytes[idx] = byteBlock[endianDiff1];
bytes[idx + 1] = byteBlock[1 + endianDiff2];
bytes[idx + 2] = byteBlock[2 - endianDiff2];
bytes[idx + 3] = byteBlock[3 - endianDiff1];
idx += 4;
}
private static void ConvertFrom4Bytes(byte[] bytes)
{
byteBlock[endianDiff1] = bytes[idx];
byteBlock[1 + endianDiff2] = bytes[idx + 1];
byteBlock[2 - endianDiff2] = bytes[idx + 2];
byteBlock[3 - endianDiff1] = bytes[idx + 3];
idx += 4;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4d1a9a7216289cd46a9b4ad6c3876064
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+56
View File
@@ -0,0 +1,56 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ProgressBar : MonoBehaviour
{
public Image foregroundImage;
public int Value
{
get
{
if (foregroundImage != null)
return (int)(foregroundImage.fillAmount * 100);
else
return 0;
}
set
{
if (foregroundImage != null)
foregroundImage.fillAmount = value / 100f;
}
}
void Start()
{
//foregroundImage = gameObject.GetComponent<Image>();
Value = 0;
}
public void setValue(int val)
{
Value = val;
}
}
/*//Testing: this function will be called when Test Button is clicked
public void UpdateProgress()
{
Hashtable param = new Hashtable();
param.Add("from", 0.0f);
param.Add("to", 100);
param.Add("time", 5.0f);
param.Add("onupdate", "TweenedSomeValue");
param.Add("onComplete", "OnFullProgress");
param.Add("onCompleteTarget", gameObject);
iTween.ValueTo(gameObject, param);
}
public void OnFullProgress()
{
Value = 0;
}*/
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 18d47b5b6c7763549bbd22cdc986f233
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+142
View File
@@ -0,0 +1,142 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScoreScene : MonoBehaviour
{
public Image image;
//private int count = 0;
//public Sprite[] intro;
public new List<AudioSource> audio = new List<AudioSource>();
public Animator animator;
//private bool audio_play = false;
//private float timer1 = 0.1f; //fuellt den Pot
//private int val = 0;
public Text scoreText;
public Text motiveText;
private bool genug = false;
private bool touched = false;
private float timer2 = 1.0f; //wartet auf fade_out
private float timer0 = 1.0f; //wartet auf fade_in
private bool switched=false;
private void Start()
{
float t = Gamestate.Instance.getNumberTrials()*10f;
Debug.Log("ScoreScene: " + Gamestate.Instance.getNumberTrials());
Debug.Log("ScoreScene points: " + Gamestate.Instance.getGamePoints().ToString());
if (0 <= Gamestate.Instance.getGamePoints() & Gamestate.Instance.getGamePoints() < t*0.25f)
{
scoreText.text = "Du hast "+Gamestate.Instance.getGamePoints().ToString() +" Punkte gesammelt!";
motiveText.text = "Okay";
genug = false;
}
else
if (t*0.25f <= Gamestate.Instance.getGamePoints() & Gamestate.Instance.getGamePoints() < t*0.5f)
{
scoreText.text = "Du hast "+Gamestate.Instance.getGamePoints().ToString() +" Punkte gesammelt!";
motiveText.text = "Gut!";
genug = false;
}
else
if (t*0.5f <= Gamestate.Instance.getGamePoints() & Gamestate.Instance.getGamePoints() < t*0.75f)
{
scoreText.text = "Du hast "+Gamestate.Instance.getGamePoints().ToString() +" Punkte gesammelt!";
motiveText.text = "Sehr gut!!";
genug = true;
}
else
if (t*0.75f <= Gamestate.Instance.getGamePoints())
{
scoreText.text = "Du hast "+Gamestate.Instance.getGamePoints().ToString() +" Punkte gesammelt!";
motiveText.text = "Super!!!";
genug = true;
}
}
// Update is called once per frame
void Update()
{
timer0 -= Time.deltaTime;
if (timer0 <= 0)
{
//pot.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
//progressBar.GetComponent<Image>().color = new Color32(255, 255, 255, 255);
/*if (genug & !audio_play)
{
audio[0].Play();
//Gamestate.Instance.startEndScene();
audio_play = true;
}*/
if (Input.touchCount > 0 && !touched)
{
touched = true;
timer2 = 1.0f;
animator.SetBool("fadeout", true);
}
timer2 -= Time.deltaTime;
if (timer2 <= 0 && touched)
{
//animator.SetBool("fadeout", false);
//Debug.Log("----------------- timer2 <= 0....");
if (genug) {
switch(Gamestate.Instance.getLevel())
{
case "1":
if(!switched)
{
Gamestate.Instance.setLevel("2");
Gamestate.Instance.setTutorial(false);
switched = true;
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startGame();
}
break;
case "2":
if(!switched)
{
Gamestate.Instance.setLevel("3");
Gamestate.Instance.setTutorial(false);
switched = true;
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startGame();
}
break;
case "3":
if(!switched)
{
Gamestate.Instance.setLevel("3");
switched = true;
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startEndScene();
}
break;
}
}
else
{
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startGame();
}
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1a339d9052326a94fa1a02917f961c94
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+877
View File
@@ -0,0 +1,877 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using UnityEngine.Video;
using TMPro;
public class SetGame : MonoBehaviour
{
public List<Trial> trials = new List<Trial>();
public RawImage TutorialPlayer;
public VideoClip set_tut;
private VideoPlayer vp;
private VideoSource videoSource;
//Audio
private AudioSource audioSource;
public TMP_Text number;
public TMP_Text level;
public Camera cam;
private string game;
private string game_old;
public SpriteRenderer background;
private int touchCount = 0;
const float sw= 1.5f;//stopwatch
private float targetTime = sw;
private float maxTargetTime = sw; //must be = targetTime
private float targetTime2 = 0.1f;
private float targetTime3 = 1.0f;
private float targetTime4 = 0.8f;
private ArrayList completed5 = new ArrayList();
private ArrayList completed10 = new ArrayList();
private int stage;
//private UnityEngine.Random rnd = new UnityEngine.Random();
private int count = 0;
private int score = 0;
private int[] numbers10 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
private int[] numbers5 = { 1, 2, 3, 4, 5 };
private ArrayList s_numbers10 = new ArrayList();
private ArrayList s_numbers5 = new ArrayList();
private int[] numberCount = { 0, 0, 0, 0, 0 };
private int[] numberCount10 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
public new List<AudioSource> audio = new List<AudioSource>();
public Button startButton;
public Button exitButton;
public Image progressBar;
public Image fuel;
public Image EvaluateTimer;
public GameObject[] hand = new GameObject[10];
private bool[] fingers = new bool[10];
private float[] times = new float[10];
private int trialCount = 0;
private bool logged = false;
private bool logged2 = false;
private bool logged3 = false;
/*private float duration = 0.2f;
private Color color1 = Color.blue;
private Color color2 = Color.green;
private Color color3 = Color.blue;
private Color color4 = Color.red;*/
private int fingerCount=0;
private Trial trial;
public GameObject scoreStar;
public GameObject Finn;
//private Vector3 posStar = new Vector3();
//private int scoreCount = 0;
private bool evaluated=false;
private int response = 0;
private float minTime = 100000f;
private float maxTime = 0f;
private bool tutorialIsPlaying;
private bool playNextTrial;
private int error_count=0;
private bool kurze_pause=false;
//private bool switched=false;
private void Awake()
{
scoreStar.SetActive(false);
background.GetComponent<Animator>().SetInteger("fade", 0);
background.GetComponent<Animator>().Play("Background_Idle", -1, 0f);
StartCoroutine(prepareVideo());
}
IEnumerator prepareVideo() {
vp = gameObject.AddComponent<VideoPlayer>();
//Add AudioSource
audioSource = gameObject.AddComponent<AudioSource>();
//Disable Play on Awake for both Video and Audio
vp.playOnAwake = false;
audioSource.playOnAwake = false;
vp.source = VideoSource.VideoClip;
vp.audioOutputMode = VideoAudioOutputMode.AudioSource;
//Assign the Audio from Video to AudioSource to be played
vp.EnableAudioTrack(0, true);
vp.SetTargetAudioSource(0, audioSource);
audioSource.volume = 0.8f;
//We want to play from video clip not from url
vp.clip = set_tut;
//Set video To Play then prepare Audio to prevent Buffering
vp.Prepare();
//Wait until video is prepared
while (!vp.isPrepared)
{
Debug.Log("Preparing Video");
yield return null;
}
Debug.Log("Done Preparing Video");
//Assign the Texture from Video to RawImage to be displayed
TutorialPlayer.texture = vp.texture;
}
void Start()
{
number.text = " ";
number.gameObject.SetActive(false);
level.text = "LEVEL " + Gamestate.Instance.getLevel();
foreach (GameObject go in hand)
{
go.GetComponent<SpriteRenderer>().enabled = false;
}
for(int i=0; i<10;i++)
{
fingers[i] = false;
times[i] = 0.0f;
}
s_numbers10 = new ArrayList(reshuffle(numbers10));
s_numbers5 = new ArrayList(numbers5);
progressBar.fillAmount = 0;
EvaluateTimer.fillAmount=0;
EvaluateTimer.fillClockwise = true;
stage = 1;
}
int[] reshuffle(int[] numbers)
{
// Knuth shuffle algorithm :: courtesy of Wikipedia :)
for (int t = 0; t < numbers.Length; t++)
{
int tmp = numbers[t];
int r = UnityEngine.Random.Range(t, numbers.Length);
numbers[t] = numbers[r];
numbers[r] = tmp;
}
return numbers;
}
int selectRandomNumber_5()
{
if (s_numbers5.Count == 0) s_numbers5 = new ArrayList(reshuffle(numbers5));
int r = (int)s_numbers5[0];
s_numbers5.RemoveAt(0);
return r;
}
int selectRandomNumber_10()
{
if (s_numbers10.Count == 0) s_numbers10 = new ArrayList(reshuffle(numbers10));
int r = (int)s_numbers10[0];
s_numbers10.RemoveAt(0);
return r;
}
public void setProgressBar(int val)
{
Debug.Log("setProgressBar: " + val.ToString());
float t = Gamestate.Instance.getNumberTrials()*10f;
progressBar.fillAmount = val / t; //(float)(Gamestate.Instance.getNumberTrials()*10f);
}
public void setEvaluateTimer(float val)
{
Debug.Log("setEvaluate: " + val.ToString());
//float t = Gamestate.Instance.getNumberTrials()*10f;
EvaluateTimer.fillAmount = val/maxTargetTime;//(Gamestate.Instance.getNumberTrials()*10) ;
}
void evaluateTouchInput()
{
foreach (Touch touch in Input.touches)
{
TouchSer tser = new TouchSer();
tser.TouchID = touch.fingerId.ToString();
tser.Timestamp = touch.deltaTime.ToString();
tser.X = touch.position.x;
tser.Y = touch.position.y;
trial.T.Add(tser);
}
Debug.Log("trial.t.:" + trial.T.Count.ToString());
Debug.Log("-------------------------------");
Debug.Log("count: " + count.ToString());
Debug.Log("touchCount: " + touchCount.ToString());
Debug.Log("+++++++++++++++++++++++++++++++");
evaluated = true;
fingerCount = 0;
minTime = 1000000f;
maxTime = 0f;
//do your stuff here.
for (int i = 0; i < 10; i++)
{
Debug.Log("times[" + i + "]: " + times[i].ToString());
if (fingers[i] == true) fingerCount += 1;
if (times[i] != 0f)
{
if (times[i] < minTime) minTime = times[i];
if (times[i] > maxTime) maxTime = times[i];
}
}
Debug.Log("minTime: " + minTime.ToString());
Debug.Log("maxTime: " + maxTime.ToString());
if ((maxTime - minTime) > 0.15)
//start tutorial?
fingerCount = 0;
if (fingerCount == count)
{
Debug.Log("Level: " + Gamestate.Instance.getLevel());
Debug.Log("parsed Level: " + int.Parse(Gamestate.Instance.getLevel()).ToString());
trial.Correct = "y";
error_count = 0;
if (stage == 1)
{
numberCount[count - 1] += 1;
if (numberCount[count - 1] >= Gamestate.Instance.getMaxCorrect())
completed5.Add(count);
}
if (stage == 2)
{
numberCount10[count - 1] += 1;
if (numberCount10[count - 1] >= Gamestate.Instance.getMaxCorrect())
completed10.Add(count);
}
if (completed5.Count == 5)
{
stage = 2;
}
score = score + 10;
audio[11].Play();
scoreStar.SetActive(true);
scoreStar.GetComponent<Animator>().Play("StarMove", -1, 0f);
setProgressBar(score);
if (int.Parse(Gamestate.Instance.getLevel()) > 1)
{
audio[count - 1].Play();
}
if (int.Parse(Gamestate.Instance.getLevel()) > 2)
{
audio[count - 1].Play();
number.text = count.ToString();
//Debug.Log("------ GameState.getAnimPlaying: " + Gamestate.Instance.getAnimPlaying());
//if (!Gamestate.Instance.getAnimPlaying())
number.GetComponent<Animator>().Play("NumberAnim2", -1, 0f);
}
response = 1;
//game = "green_blink";
}
else
{
//game = "red_blink";
number.text = " ";
audio[12].Play();
trial.Correct = "n";
response = 2;
error_count +=1;
}
}
void Update()
{
switch (game)
{
case "running":
if (!logged)
{
Debug.Log("running");
logged = true;
}
targetTime -= Time.deltaTime;
if (fingers[0] == true) {
//if (!EvaluateTimer.GetComponent<SpriteRenderer>().enabled) EvaluateTimer.GetComponent<SpriteRenderer>().enabled=true;
setEvaluateTimer(targetTime);
}
if (targetTime <= 0.0f & fingers[0] == true)
{
game = "evaluate";
break;
//evaluateTouchInput();
}
foreach (Touch touch in Input.touches)
{
switch (touch.phase)
{
case TouchPhase.Began:
Debug.Log("phase began");
touchCount += 1;
times[touchCount - 1] = Time.time;
fingers[touchCount - 1] = true;
audio[13].Play();
//if (touchCount <= 10)
//{
//hand[touchCount].GetComponent<SpriteRenderer>().enabled = true;
//hand[touchCount].GetComponent<Animator>().SetBool("fadeout", false);
//hand[touchCount].GetComponent<Animator>().Play("StarFadeIn", -1, 0f);
//}
targetTime = sw;
break;
case TouchPhase.Ended:
Debug.Log("phase ended");
if (touchCount > 1) touchCount -= 1;
fingers[touchCount] = false;
//hand[touchCount + 1].GetComponent<Animator>().SetBool("fadeout", true);
//hand[touchCount + 1].GetComponent<SpriteRenderer>().enabled = false;
targetTime = sw;
break;
default:
break;
}
}
break;
case "evaluate":
if (!logged2)
{
Debug.Log("evaluate");
logged2 = true;
}
if (!evaluated) evaluateTouchInput();
targetTime3 -= Time.deltaTime;
if (targetTime3 <= 0.0f)
{
if (response == 1) game = "green_blink";
if (response == 2) game = "red_blink";
trials.Add(trial);
}
break;
case "kurze_pause":
targetTime3 -= Time.deltaTime;
//level.text ="Weiter so!!!";
//tutorialIsPlaying=false;
//game="tutorial";
if (targetTime3 <= 0.0f)
{
if (Input.touchCount > 0) {
background.GetComponent<Animator>().SetInteger("fade", 2);
Debug.Log("-------------------------------------------------HALBZEIT---------------------------------------");
level.text = " ";
kurze_pause=true;
Finn.SetActive(false);
game = "next_trial";
//trials.Add(trial);
}
}
break;
case "green_blink":
targetTime -= Time.deltaTime;
//float t = Mathf.PingPong(Time.time, duration) / duration;
//cam.backgroundColor = Color.Lerp(color1, color2, t);
if (targetTime <= 0.0f)
{
number.text = " ";
for (int i = 0; i < 10; i++)
{
hand[i].GetComponent<Animator>().SetBool("fadeout", true);
}
targetTime2 -= Time.deltaTime;
if (targetTime2 <= 0.0f) {
playNextTrial=false;//nextTrial();
game="next_trial";
}
}
break;
case "red_blink":
targetTime -= Time.deltaTime;
//float t2 = Mathf.PingPong(Time.time, duration) / duration;
//cam.backgroundColor = Color.Lerp(color3, color4, t2);
if (targetTime <= 0.0f)
{
//cam.backgroundColor = Color.black;
number.text = " ";
for (int i = 0; i < 10; i++)
{
hand[i].GetComponent<Animator>().SetBool("fadeout", true);
}
if (error_count >= 5) {
tutorialIsPlaying=false;
game="tutorial";
break;
}
targetTime2 -= Time.deltaTime;
if (targetTime2 <= 0.0f) {
playNextTrial=false;//nextTrial();
game="next_trial";
}
}
break;
case "tutorial":
targetTime4 -= Time.deltaTime;
//background = GetComponent<Animator>().SetBool("fadeout", true);
background.GetComponent<Animator>().SetInteger("fade", 1);
exitButton.gameObject.SetActive(false);
startButton.gameObject.SetActive(false);
fuel.gameObject.SetActive(false);
progressBar.gameObject.SetActive(false);
level.text=" ";
//background.GetComponent<Animator>().Play("Background_Fader", -1,0f);
if (targetTime4 <= 0.0f)
{
if(!tutorialIsPlaying) {
Debug.Log("background anim state1 = "+background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash.ToString());
StartCoroutine(playTutorial());
}
}
break;
case "next_trial":
if(!playNextTrial) nextTrial();
break;
case "ending":
if (!logged3)
{
Debug.Log("ended");
number.text = " ";
trialCount = 0;
/*switch(Gamestate.Instance.getLevel())
{
case "1":
if(!switched)
{
Gamestate.Instance.setLevel("2");
switched = true;
}
break;
case "2":
if(!switched)
{
Gamestate.Instance.setLevel("3");
switched = true;
}
break;
}*/
targetTime -= Time.deltaTime;
//float t = Mathf.PingPong(Time.time, duration) / duration;
//cam.backgroundColor = Color.Lerp(color1, color2, t);
if (targetTime <= 0.0f)
{
logged3 = true;
trial.Score=score;
Gamestate.Instance.setGamePoints(score);
//foreach(Trial t in trials) {
// dump(t);
//}
savePlayerData();
//cam.backgroundColor = Color.black;
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startScoreScene();
}
}
break;
}
}
public void startProc() {
if (Gamestate.Instance.getTutorial())
{
tutorialIsPlaying=false;
Debug.Log("background anim state0 = "+background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash.ToString());
game="tutorial";
//return;
} else
{
playNextTrial = false;
game="next_trial";//nextTrial();
}
}
/* Start of the game. Starts by pressing the play-button*/
public void nextTrial()
{
background.GetComponent<Animator>().SetInteger("fade",3);
targetTime4 = 0.8f;
Debug.Log("background anim state3 = "+background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash.ToString());
//background.GetComponent<Animator>().SetInteger("fade",0);
progressBar.gameObject.SetActive(true);
level.text = " ";
foreach (GameObject go in hand)
{
go.GetComponent<SpriteRenderer>().enabled = false;
}
if (trialCount > 0 && trialCount < Gamestate.Instance.getNumberTrials() && trialCount % 8 == 0 && !kurze_pause) {
background.GetComponent<Animator>().SetInteger("fade",1);
exitButton.gameObject.SetActive(false);
startButton.gameObject.SetActive(false);
Finn.SetActive(true);
fuel.gameObject.transform.localPosition = new Vector3(311,-213,0);
progressBar.gameObject.transform.localPosition = new Vector3(311.6f,-232,0);
float i = UnityEngine.Random.value;
if (error_count < 3) {
if (i < 0.25) {
level.text = "Super !!!";
audio[14].PlayDelayed(0.2f);
} else if (i >=0.25 && i < 0.5) {
level.text = "Toll !!!";
audio[15].PlayDelayed(0.2f);
} else if (i >= 0.5 && i < 0.75) {
level.text = "Sehr gut !!!";
audio[16].PlayDelayed(0.2f);
} else {
level.text = "Prima !!!";
audio[17].PlayDelayed(0.2f);
}
} else {
level.text = "Bleib dran !!!";
audio[18].PlayDelayed(0.2f);
}
game= "kurze_pause";
return;
}
else if (trialCount < Gamestate.Instance.getNumberTrials())
{
game = "running";
}
else
{
targetTime = sw;
game = "ending";
return;
}
//background.GetComponent<Animator>().SetBool("fade_in",false);
playNextTrial=true;
kurze_pause=false;
Finn.SetActive(false);
fuel.gameObject.transform.localPosition = new Vector3(900,600,0);
progressBar.gameObject.transform.localPosition = new Vector3(900.6f,577.8f,0);
trial = new Trial();
trial.ID = Gamestate.Instance.getID();
trial.Game = Gamestate.Instance.getGame();
trial.Level = Gamestate.Instance.getLevel();
trial.Date = DateTime.Now.Date.ToShortDateString();
trial.Time = DateTime.Now.TimeOfDay.ToString();
trial.Onset = Time.time.ToString();
trial.Correct2 = "e";
trial.T.Clear();
/*if (trialCount < Gamestate.Instance.getNumberTrials())// | completed10.Count != 10)
{
game = "running";
}
else
{
targetTime = sw;
game = "ending";
return;
}*/
evaluated = false;
Gamestate.Instance.setAnimPlaying(true);
scoreStar.SetActive(false);
startButton.gameObject.SetActive(false);
//exitButton.gameObject.SetActive(false);
exitButton.gameObject.SetActive(true);
fuel.gameObject.SetActive(true);
if (Gamestate.Instance.getLevel() == "1")
number.gameObject.SetActive(false);
else
number.gameObject.SetActive(true);
Debug.Log("nextTrial SetGame");
//count = numbers10[trialCount];// UnityEngine.Random.Range(1, 5);
if (stage == 1) count = selectRandomNumber_5();
if (stage == 2) count = selectRandomNumber_10();
//if (count ==109)
Debug.Log("count = " + count.ToString());
trial.R = count;
trial.Y=0;
trial.X=0;
trial.Op = "n";
touchCount = 0;
targetTime = sw;
targetTime2 = 0.1f;
targetTime3 = 1.0f;
/*foreach (GameObject go in hand)
{
go.GetComponent<SpriteRenderer>().enabled = false;
}*/
for (int i=0; i < count; i++)
{
hand[i].GetComponent<SpriteRenderer>().enabled = true;
hand[i].GetComponent<Animator>().SetBool("fadeout", false);
hand[i].GetComponent<Animator>().Play("StarFadeIn", -1, 0f);
}
for (int i = 0; i < 10; i++)
{
fingers[i] = false;
times[i] = 0.0f;
}
trialCount += 1;
trial.TrialCounter = trialCount;
}
public void exitGame()
{
//Gamestate.Instance.setGamePoints(score);
//Gamestate.Instance.setGame("Count");
//Gamestate.Instance.setLevel("1");
if(game != "ending") {
savePlayerData();
}
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.menuState();
}
private void OnApplicationPause(bool pauseStatus) {
if(game != "ending") {
savePlayerData();
}
}
private void OnApplicationQuit() {
if(game != "ending") {
savePlayerData();
}
}
public void savePlayerData()
{
// string bauen und zeilenweise rausschreiben
Debug.Log("save data on "+Application.persistentDataPath+"/playerData"+Gamestate.Instance.GetPlayerData().ID+".txt");
StreamWriter sw = new StreamWriter(Application.persistentDataPath+"/playerData"+Gamestate.Instance.getID()+".txt", true);
//File.Open(Application.persistentDataPath+"/playerData"+Gamestate.Instance.GetPlayerData().ID+".dat",FileMode.Append);
//BinaryFormatter bf = new BinaryFormatter();
string header= "Date Time TrialOnset ID Game Level Trial TargetNum1 TargetNum2 TargetNum3 TargetOp Score Correct Correct2 Attempt t1ID t1X t1Y t1deltaTime " +
"t2ID t2X t2Y t2deltaTime t3ID t3X t3Y t3deltaTime t4ID t4X t4Y t4deltaTime t5ID t5X t5Y t5deltaTime t6ID t6X t6Y t6deltaTime "+
"t7ID t7X t7Y t7deltaTime t8ID t8X t8Y t8deltaTime t9ID t9X t9Y t9deltaTime t10ID t10X t10Y t10deltaTime";
sw.WriteLine(header);
foreach (Trial t in trials)
{
string line = t.Date + " " + t.Time + " " + t.Onset + " " + t.ID + " " + t.Game + " " + t.Level + " " + t.TrialCounter + " " + t.X + " " + t.Y
+ " " + t.R + " " + t.Op + " " + t.Score + " " + t.Correct + " " + t.Correct2 + " " + t.Attempt;
int i=0;
foreach(TouchSer item in t.T) {
line = line + " " + item.TouchID + " " + item.X.ToString() + " " + item.Y.ToString() + " " + item.Timestamp;
i++;
}
for (int j = i; j <10; j++) {
line = line + " " + "99" + " " + "0" + " " + "0" + " " + "0";
}
Debug.Log("line: " + line);
//dump(trial);
sw.WriteLine(line);
}
sw.Close();
}
IEnumerator playTutorial()
{
tutorialIsPlaying = true;
TutorialPlayer.enabled=true;
//Add VideoPlayer to the GameObject
//Play Video
vp.Play();
//Play Sound
audioSource.Play();
Debug.Log("Playing Video");
while (vp.isPlaying)
{
//Debug.LogWarning("Video Time: " + Mathf.FloorToInt((float)vp.time));
yield return null;
}
//TutorialPlayer.GetComponent<Animator>().SetBool("fadeout",true);//.Play("tutorial2", -1, 0f);
TutorialPlayer.enabled = false;
background.GetComponent<Animator>().SetInteger("fade",2);
//yield return new WaitForSeconds(0.3f);
Debug.Log("background anim state2 = "+background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash.ToString());
//Debug.Log("background anim state3 = "+background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).fullPathHash.ToString());
/*var currentState = background.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0);
while(currentState.fullPathHash == Animator.StringToHash("Base Layer.Player_standing"))
{
yield return null;
}*/
//yield return new WaitForSeconds(0.3f);
Debug.Log("Done Playing Video");
error_count=0;
playNextTrial=false;
//targetTime4=0.3f;
game="next_trial";
}
public void dump(Trial t) {
Debug.Log("------------------TRIAL-START------------------");
Debug.Log("date: " + t.Date);
Debug.Log("time: " + t.Time);
Debug.Log("trialOnset: " + t.Onset);
Debug.Log("game: " + t.Game);
Debug.Log("level: " + t.Level);
Debug.Log("score: " + t.Score);
Debug.Log("attempt_count: " + t.Attempt);
Debug.Log("ID: " + t.ID);
Debug.Log("Trial_counter: " + t.TrialCounter);
Debug.Log("Number: " + t.X);
Debug.Log("Number: " + t.Y);
Debug.Log("Number: " + t.R);
Debug.Log("Correct: " + t.Correct);
Debug.Log("Correct2: " + t.Correct2);
foreach (TouchSer item in t.T)
{
Debug.Log("touch.id: " + item.TouchID);
Debug.Log("touch.x: " + item.X.ToString());
Debug.Log("touch.y: " + item.Y.ToString());
Debug.Log("touch.time: " + item.Timestamp);
}
Debug.Log("------------------TRIAL-END------------------");
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a53e15751e3671f419094988abc35833
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+57
View File
@@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
//[Serializable]
public class TouchSer {
private string touchID;
private float x;
private float y;
private string timestamp;
public string TouchID { get => touchID; set => touchID = value; }
public float X { get => x; set => x = value; }
public float Y { get => y; set => y = value; }
public string Timestamp { get => timestamp; set => timestamp = value; }
}
//[Serializable]
public class Trial
{
// Start is called before the first frame update
private string iD;
private int attempt;
private int score;
private string date;
private string time;
private string onset;
private string game;
private string level;
private int trialCounter;
private int x;
private int y;
private int r;
private string op;
private List<TouchSer> t = new List<TouchSer>();
private string correct;
private string correct2;
public List<TouchSer> T { get => t; set => t = value; }
public string Op { get => op; set => op = value; }
public int R { get => r; set => r = value; }
public int Y { get => y; set => y = value; }
public int X { get => x; set => x = value; }
public int TrialCounter { get => trialCounter; set => trialCounter = value; }
public string Level { get => level; set => level = value; }
public string Game { get => game; set => game = value; }
public string Time { get => time; set => time = value; }
public string Date { get => date; set => date = value; }
public string Correct { get => correct; set => correct = value; }
public string ID { get => iD; set => iD = value; }
public int Attempt { get => attempt; set => attempt = value; }
public int Score { get => score; set => score = value; }
public string Correct2 { get => correct; set => correct = value; }
public string Onset { get => onset; set => onset = value; }
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ba71007d05debe140bce331546bb47e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+99
View File
@@ -0,0 +1,99 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
public class Tutorial : MonoBehaviour
{
//Raw Image to Show Video Images [Assign from the Editor]
public RawImage image;
public VideoClip count_tut;
public VideoClip set_tut;
public VideoClip add_tut;
private VideoPlayer vp;
private VideoSource videoSource;
//Audio
private AudioSource audioSource;
// Update is called once per frame
private void Start() {
StartCoroutine(playTutorial());
}
IEnumerator playTutorial()
{
//Add VideoPlayer to the GameObject
vp = gameObject.AddComponent<VideoPlayer>();
//Add AudioSource
audioSource = gameObject.AddComponent<AudioSource>();
//Disable Play on Awake for both Video and Audio
vp.playOnAwake = false;
audioSource.playOnAwake = false;
vp.source = VideoSource.VideoClip;
vp.audioOutputMode = VideoAudioOutputMode.AudioSource;
//Assign the Audio from Video to AudioSource to be played
vp.EnableAudioTrack(0, true);
vp.SetTargetAudioSource(0, audioSource);
//We want to play from video clip not from url
vp.clip = count_tut;
if (Gamestate.Instance.getGame() == "Set") {
vp.clip = set_tut;
}
if (Gamestate.Instance.getGame() == "Add") {
vp.clip = add_tut;
}
//Set video To Play then prepare Audio to prevent Buffering
vp.Prepare();
//Wait until video is prepared
while (!vp.isPrepared)
{
Debug.Log("Preparing Video");
yield return null;
}
Debug.Log("Done Preparing Video");
//Assign the Texture from Video to RawImage to be displayed
image.texture = vp.texture;
//Play Video
vp.Play();
//Play Sound
audioSource.Play();
Debug.Log("Playing Video");
while (vp.isPlaying)
{
Debug.LogWarning("Video Time: " + Mathf.FloorToInt((float)vp.time));
yield return null;
}
image.GetComponent<Animator>().SetBool("fadeout",true);//.Play("tutorial2", -1, 0f);
yield return new WaitForSeconds(0.8f);
Debug.Log("Done Playing Video");
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startGame();
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0511fc355ebc41544ae920caf471b94c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: