// Update is called once per frame void Update() { if (!victorious) { if (Input.GetKeyDown(KeyCode.DownArrow)) { turnCount++; turnDown(); statueArrowBottom.turnDown(); statueArrowTop.turnUp(); } else if (Input.GetKeyDown(KeyCode.UpArrow)) { turnCount++; turnUp(); statueArrowBottom.turnUp(); statueArrowTop.turnDown(); } else if (Input.GetKeyDown(KeyCode.RightArrow)) { turnCount++; turnRight(); statueArrowBottom.turnRight(); statueArrowTop.turnLeft(); } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { turnCount++; turnLeft(); statueArrowBottom.turnLeft(); statueArrowTop.turnRight(); } else if (Input.GetMouseButtonDown(0)) { logMoveData(); bool[] errorsPlayer = getErrorType(); if (!errorsPlayer[0] && !errorsPlayer[1] && !errorsPlayer[2]) { string newLoc = move(); moves++; countLeftRightSymmetry(newLoc); bool[] errorsBottom = statueArrowBottom.getErrorType(); if (errorsBottom[1]) { //if there is a statue collision sr.WriteLine(",-1,-1"); StartCoroutine(collisionHelper(SAB, SAT, SAB.transform.position, SAT.transform.position, 0.1f)); } else if (errorsBottom[2]) { //if there is a statue blocking sr.WriteLine(",-1,-1"); StartCoroutine(collisionHelper(SAB, SAT, SAB.transform.position, SAT.transform.position, 0.05f)); } else { bool[] errorsTop = statueArrowTop.getErrorType(); if (!errorsBottom[0]) { //not offscreen string newLocStatue = statueArrowBottom.move(); sr.Write("," + newLocStatue); } else { sr.Write(",-1"); } if (!errorsTop[0]) { // not offscreen string newLocStatue = statueArrowTop.move(); sr.WriteLine("," + newLocStatue); } else { sr.WriteLine(",-1"); } } } else if (errorsPlayer[1]) { //if player collides with statue (has to be top statue) StartCoroutine(collisionHelper(this.gameObject, SAT, transform.position, SAT.transform.position, 0.1f)); } else if (errorsPlayer[2]) { //if player is blocked by a statue (could be either one) if (predictedSquare == statueArrowBottom.square) { StartCoroutine(collisionHelperOneSided(this.gameObject, SAB, transform.position, 0.05f)); } else if (predictedSquare == statueArrowTop.square) { StartCoroutine(collisionHelperOneSided(this.gameObject, SAT, transform.position, 0.05f)); } } } else if (Input.GetKeyDown(KeyCode.R)) { logEndGameData(); reset(); } else if (Input.GetKeyDown(KeyCode.Escape)) { logEndGameData(); quit(); } else if (victory()) { logEndGameData(); sr.WriteLine("VICTORY\n"); sr.Flush(); //change later to allow player to play a new game displayOptions(); } } }
// Update is called once per frame void Update() { if (!victorious && !isColliding) { if (victory()) { victories++; logEndGameData(); resultStr += "OUTCOME,VICTORY,"; displayOptions(); } else if (controlsEnabled && Input.GetKeyDown(KeyCode.DownArrow)) { if (approximately(direction, Vector3.down)) { // move down tryMove(); } else { // turn down turns++; turnDown(); statueArrowBottom.turnDown(); statueArrowTop.turnUp(); } } else if (controlsEnabled && Input.GetKeyDown(KeyCode.UpArrow)) { if (approximately(direction, Vector3.up)) { // move up tryMove(); } else { turns++; turnUp(); statueArrowBottom.turnUp(); statueArrowTop.turnDown(); } } else if (controlsEnabled && Input.GetKeyDown(KeyCode.RightArrow)) { if (approximately(direction, Vector3.right)) { // move right tryMove(); } else { turns++; turnRight(); statueArrowBottom.turnRight(); statueArrowTop.turnLeft(); } } else if (controlsEnabled && Input.GetKeyDown(KeyCode.LeftArrow)) { if (approximately(direction, Vector3.left)) { // move left tryMove(); } else { turns++; turnLeft(); statueArrowBottom.turnLeft(); statueArrowTop.turnRight(); } } } }
public void act() { if (players < NUM_PLAYERS) { if (moves > MAX_MOVES || isStuck() || victory()) { logEndGameData(); resetForNewPlayer(); players++; } int randomTurn = (int)UnityEngine.Random.Range(0.0f, 4.0f); if (randomTurn == 0) { turnUp(); statueArrowBottom.turnUp(); statueArrowTop.turnDown(); } else if (randomTurn == 1) { turnRight(); statueArrowBottom.turnRight(); statueArrowTop.turnLeft(); } else if (randomTurn == 2) { turnDown(); statueArrowBottom.turnDown(); statueArrowTop.turnUp(); } else if (randomTurn == 3) { turnLeft(); statueArrowBottom.turnLeft(); statueArrowTop.turnRight(); } logMoveData(); if (canMove()) { move(); moves++; if (statueArrowBottom.canMove()) { statueArrowBottom.move(); } if (statueArrowTop.canMove()) { statueArrowTop.move(); } Debug.Log("ADDED new state " + stateToString()); if (!states_explored_list.Contains(stateToString())) { unique_states++; } states_explored_list.Add(stateToString()); } } else { finished = true; Application.Quit(); } }