// Start is called before the first frame update void Start() { lastTime = Time.time; MazeGen.solve(MazeGen.mazeRaw, (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.x), (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.z), (int)Mathf.Round(GameObject.Find("Pole(Clone)").transform.position.x), (int)Mathf.Round(GameObject.Find("Pole(Clone)").transform.position.z)); }
// Update is called once per frame void Update() { //for (int i = 0; i < MazeGen.mazeRaw.Count; i++) //{ // Debug.Log(MazeGen.mazeRaw[i]); //} //Debug.Log("x: " + (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.x) + ", z: " + (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.z)); if ((Time.time - lastTime > 0.2f) && ((Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)))) { //if (!(Physics.Raycast(GameObject.Find("Player(Clone)").transform.position, GameObject.Find("Player(Clone)").transform.TransformDirection(Vector3.forward), 0.7f))) RaycastHit hit = new RaycastHit(); Ray ray = new Ray(GameObject.Find("Player(Clone)").transform.position, GameObject.Find("Player(Clone)").transform.forward); if (!Physics.Raycast(ray, out hit, 1) || (Physics.Raycast(ray, out hit, 1) && hit.collider.gameObject.name != "Fence(Clone)")) { MazeGen.solve(MazeGen.mazeRaw, (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.x), (int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.z), (int)Mathf.Round(GameObject.Find("Pole(Clone)").transform.position.x), (int)Mathf.Round(GameObject.Find("Pole(Clone)").transform.position.z)); StringBuilder str = new StringBuilder(MazeGen.mazeRaw[(int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.x)].ToString());//Set Current position as ' ' str[(int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.z)] = ' '; MazeGen.mazeRaw[(int)Mathf.Round(GameObject.Find("Player(Clone)").transform.position.x)] = str; StartCoroutine("Forward"); } lastTime = Time.time; } if ((Time.time - lastTime > 0.2f) && (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))) { StartCoroutine("Left"); lastTime = Time.time; using (StreamWriter sw = File.AppendText(Application.dataPath + Spawner.path)) { if (AudioCue.play.isPlaying) { //"ParticipantID,DataType,AttemptNumber,Movement,Error,AudioCue,Time,Gender,VideoGame" sw.WriteLine(MainMenu.ID + "," + MainMenu.trialType + "," + Spawner.attemptNumber + ",Turns Left" + ",N/A" + "," + AudioCue.currentlyPlaying + "," + Time.time + "," + Spawner.currentAudioType); sw.Close(); } else { //"ParticipantID,DataType,AttemptNumber,Movement,Error,AudioCue,Time,Gender,VideoGame" sw.WriteLine(MainMenu.ID + "," + MainMenu.trialType + "," + Spawner.attemptNumber + ",Turns Left" + ",N/A" + ",0" + "," + Time.time + "," + Spawner.currentAudioType); sw.Close(); } } } if ((Time.time - lastTime > 0.2f) && (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))) { StartCoroutine("Right"); lastTime = Time.time; using (StreamWriter sw = File.AppendText(Application.dataPath + Spawner.path)) { if (AudioCue.play.isPlaying) { //"ParticipantID,DataType,AttemptNumber,Movement,Error,AudioCue,Time,Gender,VideoGame" sw.WriteLine(MainMenu.ID + "," + MainMenu.trialType + "," + Spawner.attemptNumber + ",Turns Right" + ",N/A" + "," + AudioCue.currentlyPlaying + "," + Time.time + "," + Spawner.currentAudioType); sw.Close(); } else { //"ParticipantID,DataType,AttemptNumber,Movement,Error,AudioCue,Time,Gender,VideoGame" sw.WriteLine(MainMenu.ID + "," + MainMenu.trialType + "," + Spawner.attemptNumber + ",Turns Right" + ",N/A" + ",0" + "," + Time.time + "," + Spawner.currentAudioType); sw.Close(); } } } }