// Update is called once per frame void Update() { if (firstFrame) { firstFrame = false; if (StatePreserver.Instance.gameStarted) { // spawn the first golden brick in the first round (no previous minigame) // this is called in the update method and not in Start() because the tiles // build their neighborhood relation during the Start() phase // however, relocate() recalculate the paths to the brick for the AIs which requires // a complete and correct tile neighborhood relation. brickManager.relocate(); } else { // restore golden brick location, this is done here for the same reason as the initial spawn foreach (GameObject t in GameObject.FindGameObjectsWithTag("Tile")) // for each tile { Tile tile = (t.GetComponent(typeof(Tile)) as Tile); if (t.transform.position.x == StatePreserver.Instance.boardState.brickTile.x && t.transform.position.z == StatePreserver.Instance.boardState.brickTile.z) { brickManager.restore(tile, t.transform); } } } } if (currentState == TurnState.MOVING_CAM_TO_DIE && camera.movementCompleted()) { rollDie(); } else if (currentState == TurnState.ROLLING_DIE && DieScript.isDone() && DieScript2.isDone()) { actionPoints = DieScript.rollResult + DieScript2.rollResult; currentState = TurnState.MOVING_CAM_TO_PLAYER; camera.moveToPlayer(activePlayer); } else if (currentState == TurnState.MOVING_CAM_TO_PLAYER && camera.movementCompleted()) { startNewTurn(); } else if (currentState == TurnState.ACCEPTING_INPUT && isAI() && actionPoints > 0) { takeActionAI(); } // else if (currentState == TurnState.ACCEPTING_INPUT && actionPoints <= 0) { // applyTileEffect(); // } else if (currentState == TurnState.EXECUTING_ACTION && (currentActionFSM == null || currentActionFSM.update()) && playerBelongings[activePlayer].animationsAreDone()) { currentActionFSM = null; if (!updateTruePartyState()) { if (playerData[activePlayer].currentTile().hasTrap() && !(playerData[activePlayer].currentTile().getTrapOwner().Equals(activePlayer))) { int creditsToRemove = Math.Min(5, playerBelongings[activePlayer].creditAmount()); playerBelongings[activePlayer].addCreditAmount(-creditsToRemove); actionPoints = Math.Max(actionPoints - 3, 0); currentState = TurnState.EXECUTING_ACTION; currentActionFSM = new RemoveTrap(playerData[activePlayer]); playerData[activePlayer].currentTile().setTrap(false, playerData[activePlayer].currentTile().getTrap()); } else if (actionPoints <= 0) { // turn is over! applyTileEffect(); } else { // await next input/action currentState = TurnState.ACCEPTING_INPUT; } } } else if (currentState == TurnState.APPLYING_TILE_EFFECT && currentActionFSM.update() && playerBelongings[activePlayer].animationsAreDone()) { if (!updateTruePartyState()) { currentState = TurnState.TURN_ENDED; currentActionFSM = null; } } else if (currentState == TurnState.TURN_ENDED) { finishTurn(); } else if (currentState == TurnState.SCOREBOARD) { for (int i = 0; i < 4; i++) { int place = PlayerPrefs.GetInt("PLAYER" + (i + 1).ToString() + "_PLACE"); // place: {1,2,3,4} -> credits {3,2,1,0} int reward = 4 - place; playerBelongings[i].addCreditAmount(reward); } currentState = TurnState.SCOREBOARD_END; } else if (currentState == TurnState.SCOREBOARD_END && playerBelongings[0].animationsAreDone() && playerBelongings[1].animationsAreDone() && playerBelongings[2].animationsAreDone() && playerBelongings[3].animationsAreDone()) { finishRound(); updateTruePartyState(); } foreach (PlayerAction action in interactions.actions) { if (currentState == TurnState.ACCEPTING_INPUT && actionPoints > 0) { if (action.type == PlayerAction.Type.SET_TRAP) { action.updateStatus(actionIsActive(action), currentTileHasNoTrap() && playerIsAloneOnTile() && canAfford(action)); } else { action.updateStatus(actionIsActive(action), canAfford(action)); } } else { action.updateStatus(false, false); } } updateHUD(); }
// Update is called once per frame void Update() { if (currentState == TurnState.MOVING_CAM_TO_DIE && camera.movementCompleted()) { rollDie(); } else if (currentState == TurnState.ROLLING_DIE && DieScript.isDone() && DieScript2.isDone()) { actionPoints = DieScript.rollResult + DieScript2.rollResult; currentState = TurnState.MOVING_CAM_TO_PLAYER; camera.moveToPlayer(activePlayer); } else if (currentState == TurnState.MOVING_CAM_TO_PLAYER && camera.movementCompleted()) { startNewTurn(); } else if (currentState == TurnState.ACCEPTING_INPUT && actionPoints <= 0) { applyTileEffect(); } else if (currentState == TurnState.EXECUTING_ACTION && (currentActionFSM == null || currentActionFSM.update()) && playerBelongings[activePlayer].animationsAreDone()) { currentActionFSM = null; if (!updateTruePartyState()) { if (playerData[activePlayer].currentTile().hasTrap() && !(playerData[activePlayer].currentTile().getTrapOwner().Equals(activePlayer))) { int creditsToRemove = Math.Min(5, playerBelongings[activePlayer].creditAmount()); playerBelongings[activePlayer].addCreditAmount(-creditsToRemove); actionPoints = Math.Max(actionPoints - 3, 0); playerData[activePlayer].currentTile().setTrap(false); currentState = TurnState.EXECUTING_ACTION; currentActionFSM = new RemoveTrap(activePlayer); } else if (actionPoints <= 0) { // turn is over! applyTileEffect(); } else { // await next input/action currentState = TurnState.ACCEPTING_INPUT; } } } else if (currentState == TurnState.APPLYING_TILE_EFFECT && currentActionFSM.update()) { if (!updateTruePartyState()) { currentState = TurnState.TURN_ENDED; currentActionFSM = null; } } else if (currentState == TurnState.TURN_ENDED) { finishTurn(); } foreach (PlayerAction action in interactions.actions) { if (currentState == TurnState.ACCEPTING_INPUT && actionPoints > 0) { action.updateStatus(actionIsActive(action), canAfford(action)); } else { action.updateStatus(false, false); } } updateHUD(); }
// Update is called once per frame void Update() { if (currentState == TurnState.MOVING_CAM_TO_DIE && camera.movementCompleted()) { rollDie(); } else if (currentState == TurnState.ROLLING_DIE && DieScript.isDone() && DieScript2.isDone()) { actionPoints = DieScript.rollResult + DieScript2.rollResult; currentState = TurnState.MOVING_CAM_TO_PLAYER; camera.moveToPlayer(activePlayer); } else if (currentState == TurnState.MOVING_CAM_TO_PLAYER && camera.movementCompleted()) { startNewTurn(); } else if (currentState == TurnState.ACCEPTING_INPUT && isAI() && actionPoints > 0) { takeActionAI(); } else if (currentState == TurnState.ACCEPTING_INPUT && actionPoints <= 0) { applyTileEffect(); } else if (currentState == TurnState.EXECUTING_ACTION && (currentActionFSM == null || currentActionFSM.update()) && playerBelongings[activePlayer].animationsAreDone()) { currentActionFSM = null; if (!updateTruePartyState()) { if (playerData[activePlayer].currentTile().hasTrap() && !(playerData[activePlayer].currentTile().getTrapOwner().Equals(activePlayer))) { int creditsToRemove = Math.Min(5, playerBelongings[activePlayer].creditAmount()); playerBelongings[activePlayer].addCreditAmount(-creditsToRemove); actionPoints = Math.Max(actionPoints - 3, 0); currentState = TurnState.EXECUTING_ACTION; currentActionFSM = new RemoveTrap(playerData[activePlayer]); playerData[activePlayer].currentTile().setTrap(false, playerData[activePlayer].currentTile().getTrap()); } else if (actionPoints <= 0) { // turn is over! applyTileEffect(); } else { // await next input/action currentState = TurnState.ACCEPTING_INPUT; } } } else if (currentState == TurnState.APPLYING_TILE_EFFECT && currentActionFSM.update()) { if (!updateTruePartyState()) { currentState = TurnState.TURN_ENDED; currentActionFSM = null; } } else if (currentState == TurnState.TURN_ENDED) { finishTurn(); } else if (currentState == TurnState.SCOREBOARD) { for (int i = 0; i < 4; i++) { int place = PlayerPrefs.GetInt("PLAYER" + i.ToString() + "_PLACE"); playerBelongings[i].addCreditAmount(4 - place + 1); } currentState = TurnState.SCOREBOARD_END; } else if (currentState == TurnState.SCOREBOARD_END && playerBelongings[0].animationsAreDone() && playerBelongings[1].animationsAreDone() && playerBelongings[2].animationsAreDone() && playerBelongings[3].animationsAreDone()) { finishRound(); updateTruePartyState(); } foreach (PlayerAction action in interactions.actions) { if (currentState == TurnState.ACCEPTING_INPUT && actionPoints > 0) { if (action.type == PlayerAction.Type.SET_TRAP) { action.updateStatus(actionIsActive(action), currentTileHasNoTrap() && playerIsAloneOnTile() && canAfford(action)); } else { action.updateStatus(actionIsActive(action), canAfford(action)); } } else { action.updateStatus(false, false); } } updateHUD(); }