void OnScavengeButtonClicked() { GameState.State state = gameStateManager.GetState(); if (state != GameState.State.SCAVENGING) { gameStateManager.ChangeState(GameState.State.SCAVENGING); int random = Random.Range(0, scavengingLocations.Count); foreach (var scavengingLocation in scavengingLocations) { if (random == 0) { ScavengingLocation.ScavengeResult result = scavengingLocation.Value.location.Scavenge(); result.PrintResult(); break; } else { --random; } } gameStateManager.ChangeState(GameState.State.END_OF_DAY); } }
// Update is called once per frame void Update() { GameState.State state = gameState.getGameState(); if (state == GameState.State.GAME_RUNNING) { if (currentTile == null) { float stackHeight = getStackHeight(); movementDirection = getMovementDirection(); currentTile = objectPool.getPooledObject().transform; currentTile.SetParent(transform); currentTile.localPosition = movementDirection * movementBounds + new Vector3(previousTile.localPosition.x, stackHeight, previousTile.localPosition.z); currentTile.localScale = previousTile.transform.localScale; currentTile.GetComponent <MeshRenderer>().material = baseMaterial; currentTile.GetComponent <MeshRenderer>().material.color = colorProvider.getNextColor(); outOfBoundsCollider.center = movementDirection * -1 * movementBounds + new Vector3(0, stackHeight, 0); } else { handleInput(); moveCurrentTile(); } } else if (state == GameState.State.GAME_STARTING_PHASE_ONE) { resetStack(); gameState.resetScore(); gameState.setGameState(GameState.State.GAME_STARTING_PHASE_TWO); } }
void OnGameStateChange(GameState.State state) { for (int i = 0; i < transform.childCount; i++) { transform.GetChild(i).gameObject.SetActive(state == requiredState); } }
// GameState -------------------------------- void OnGameStateChanged(GameState.State newState, GameState.State previousState) { if (previousState == GameState.State.CHARACTER_SELECT) { SetWhenCanGatherWater(); SetWhenCanGatherFood(); } switch (newState) { case GameState.State.STATUS: DisableGatherFood(); DisableGatherWater(); resourcesGUI.SetActive(true); break; case GameState.State.DAY: resourcesGUI.SetActive(true); break; default: resourcesGUI.SetActive(false); break; } }
public void SetState(GameState.State state) { switch (state) { case GameState.State.PAUSED: SetState(statePaused); break; case GameState.State.PRE_THROW: SetState(statePreThrow); break; case GameState.State.THROWING: SetState(stateThrowing); break; case GameState.State.DISC_IN_PLAY: SetState(stateDiscInPlay); break; case GameState.State.STROKE_COMPLETE: SetState(stateStrokeComplete); break; case GameState.State.HOLE_COMPLETE: SetState(stateHoleComplete); break; case GameState.State.COURSE_COMPLETE: SetState(stateCourseComplete); break; } }
void OnGameStateChange(GameState.State state) { foreach (Behaviour component in gameObject.GetComponents(typeof(Behaviour))) { component.enabled = state == requiredState; } }
// Update is called once per frame void Update() { GameState.State state = gameState.getGameState(); scoreText.text = gameState.getScore().ToString(); switch (state) { case GameState.State.GAME_NOT_STARTED: scoreText.enabled = false; highScoreListText.enabled = false; startPromptText.enabled = true; checkForInput(); break; case GameState.State.GAME_STARTING_PHASE_ONE: case GameState.State.GAME_STARTING_PHASE_TWO: case GameState.State.GAME_RUNNING: scoreText.enabled = true; highScoreListText.enabled = false; startPromptText.enabled = false; break; case GameState.State.GAME_OVER: scoreText.enabled = true; highScoreListText.text = getHighScoreListString(gameState.getHighScores(), highScoreListTitle); highScoreListText.enabled = true; startPromptText.enabled = true; checkForInput(); break; } }
public void OnGameStateChange() { GameState.State newState = GameManager.GetInstance().GetState(); for (int i = 0; i < uiObjects.Length; i++) { uiObjects [i].UpdateState(newState); } }
public static int Duration(GameState.State state) { if (!StateDurationTime.ContainsKey(state)) { LogSaver.Log("[!!!] StateDurationTime не установлено для " + state.ToString()); throw new Exception("StateDurationTime не установлено"); } return(StateDurationTime[state]); }
void ControlFunctions(GameState.State state) { foreach (var pair in functionsToCall) { if (state == pair.state) { pair.funcions?.Invoke(); } } }
public void ChangeState(GameState.State state) { lock (gameState) { gameState.state = state; SetStateTimer(state); } BroadcastMessage(GameMessage.StateChangedMessage(state)); }
void ControlComponents(GameState.State state) { foreach (var pair in componentsToControl) { if (pair.behaviours.Length > 0) { foreach (var behavior in pair.behaviours) { behavior.enabled = state == pair.state; } } } }
// GameState -------------------------------- void OnGameStateChanged(GameState.State newState, GameState.State previousState) { switch (newState) { case GameState.State.NIGHT: EnableDefendButton(); break; default: DisableDefendButton(); break; } }
public void SwitchState(GameState.State nextState) { if (currentState != null && currentState.GetStateType() == nextState) { return; } currentState.End(this); currentState = stateList [nextState]; currentState.Start(this); UIManager.GetInstance().OnGameStateChange(); //Debug.Log (this.name + " SwitchState : " + nextState.ToString ()); }
// GameState -------------------------------- void OnGameStateChanged(GameState.State newState, GameState.State previousState) { switch (newState) { case GameState.State.DAY: EnableDayTimeGUI(); break; default: DisableDayTimeGUI(); DisableEndDayGUI(); break; } }
public void pauseGo() { if (!isPaused) { curState = GameState.CurrentState; Time.timeScale = 0; isPaused = true; GameState.ChangeState(GameState.State.Paused); } else { GameState.ChangeState(curState); Time.timeScale = 1; isPaused = false; } }
void OnRestButtonClicked() { GameState.State state = gameStateManager.GetState(); if (state != GameState.State.RESTING) { gameStateManager.ChangeState(GameState.State.RESTING); DefendingManager.RaidResult result = defendingManager.Raid(minimumMaterialsLost, maximumMaterialsLost, 0, 0, minimumSurvivorsDieing, maximumSurvivorsDieing); result.PrintResult(); gameStateManager.ChangeState(GameState.State.END_OF_DAY); } }
private void CheckState(GameState.State newState) { switch (newState) { case GameState.State.PAUSE: case GameState.State.GAME_OVER: _isInteractive = false; CreateDrawEntity(Vector3.zero, Vector3.zero, true); break; case GameState.State.PLAY: _isInteractive = true; break; } }
void OnDefendButtonClicked() { GameState.State state = gameStateManager.GetState(); if (state != GameState.State.DEFENDING) { gameStateManager.ChangeState(GameState.State.DEFENDING); RaidResult result = Raid(minimumMaterialsLost, maximumMaterialsLost, minimumCharacterInjuries, maximumCharacterInjuries, minimumSurvivorsDieing, maximumSurvivorsDieing); result.PrintResult(); gameStateManager.ChangeState(GameState.State.END_OF_DAY); } }
// GUI -------------------------------------- // GameState -------------------------------- void OnGameStateChanged(GameState.State newState, GameState.State previousState) { switch (newState) { case GameState.State.DAY: text.gameObject.SetActive(true); SetStoryForDay(); break; case GameState.State.END_OF_DAY: default: text.gameObject.SetActive(false); break; } }
public void UpdateState(GameState.State newState) { if (state != newState) { if (gameObject.activeSelf) { Hide(); } } else { if (!gameObject.activeSelf) { Show(); } } }
private void CheckInteractive(GameState.State newState) { switch (newState) { case GameState.State.GAME_OVER: m_IsInteractive = false; m_Pressed = false; break; case GameState.State.PAUSE: m_IsInteractive = false; break; case GameState.State.PLAY: m_IsInteractive = true; break; } }
// GameState -------------------------------- void OnGameStateChanged(GameState.State newState, GameState.State previousState) { switch (newState) { case GameState.State.DAY: storageButton.gameObject.SetActive(true); itemText.gameObject.SetActive(false); break; case GameState.State.STORAGE: itemText.gameObject.SetActive(true); break; default: storageButton.gameObject.SetActive(false); break; } }
void Update() { GameState.State state = gameStateManager.GetState(); switch (state) { case GameState.State.HOME: case GameState.State.STATUS: case GameState.State.UPGRADE_HOME: case GameState.State.UPGRADE_TRAITS: case GameState.State.STORAGE: case GameState.State.CRAFTING: case GameState.State.WATER: case GameState.State.FARM: UpdateTime(); UpdateDay(); break; } }
void OnGameStateChanged(GameState.State newState, GameState.State previousState) { if (selectedButton && selectedText) { ColorBlock colors = selectedButton.colors; colors.normalColor = Color.white; colors.highlightedColor = Color.gray; selectedButton.colors = colors; selectedText.color = Color.black; } switch (newState) { case GameState.State.UPGRADE_HOME: selectedButton = upgradeHomeButton; selectedText = homeText; break; case GameState.State.UPGRADE_TRAITS: selectedButton = upgradeTraitsButton; selectedText = traitsText; break; default: selectedButton = null; selectedText = null; break; } if (selectedButton && selectedText) { ColorBlock colors = selectedButton.colors; colors.normalColor = Color.black; colors.highlightedColor = Color.black; selectedButton.colors = colors; selectedText.color = Color.white; } }
void ControlRigidbody(GameState.State _state) { if (isFrozen) { if (state == _state) { rb.isKinematic = false; rb.velocity = storedVelocity; isFrozen = false; } } else { if (state != _state) { storedVelocity = rb.velocity; rb.velocity = Vector3.zero; rb.isKinematic = true; isFrozen = true; } } }
public void ChangeState(GameState.State newState) { switch (newState) { case GameState.State.DAY: if (foregroundManager.GetState() == ForegroundManager.State.IN) { foregroundManager.FadeOut(); } break; case GameState.State.END_OF_DAY: if (foregroundManager.GetState() == ForegroundManager.State.OUT) { foregroundManager.FadeIn(); } break; } previousState = currentState; currentState = newState; OnGameStateChanged(); }
// GameState -------------------------------- void OnGameStateChanged(GameState.State newState, GameState.State previousState) { if (previousState == GameState.State.CHARACTER_SELECT) { CreateCharacter(); characterNameGUI.text = character.name; // Turn off selection GUI characterSelectionGUI.SetActive(false); } switch (newState) { case GameState.State.DAY: case GameState.State.STATUS: ActivateCharacterName(); break; default: DeactivateCharacterName(); break; } }
void Start() { board = new Board(); // instantiates and draws gamestate = new GameState(4, board, firstPlayerAI); tradeManager = new TradeManager(gamestate, this); humanCardCounts = new GameObject[5]; tradeThisText = new GameObject[5]; forThisText = new GameObject[5]; tradeThis = new GameObject[5]; forThis = new GameObject[5]; turnInfoText = new GameObject[gamestate.numPlayers]; BuildPlayerTurnWindow(); BuildSelectionPanel(); BuildHumanPlayerHandDisplay(); BuildEndTurnButton(); BuildDiceRoller(); BuildTradePanel(); lastAIActionTime = EPOCH; curState = gamestate.IncrementState(); // initial increment }
// GameState -------------------------------- void OnGameStateChanged(GameState.State newState, GameState.State previousState) { switch (newState) { case GameState.State.STATUS: EnableCharacterStatus(); break; case GameState.State.DAY: EnableStatusButton(); DisableCharacterStatus(); DisableHydrate(); DisableFeed(); break; case GameState.State.END_OF_DAY: default: DisableCharacterStatus(); DisableHydrate(); DisableFeed(); DisableStatusButton(); break; } }
private void SetStateTimer(GameState.State state) { stateTimer.Stop(); stateTimer.Interval = Timing.Duration(state); stateTimer.Start(); }
void Start() { board = new Board (); // instantiates and draws gamestate = new GameState (4, board, firstPlayerAI); tradeManager = new TradeManager (gamestate, this); humanCardCounts = new GameObject[5]; tradeThisText = new GameObject[5]; forThisText = new GameObject[5]; tradeThis = new GameObject[5]; forThis = new GameObject[5]; turnInfoText = new GameObject[gamestate.numPlayers]; BuildPlayerTurnWindow (); BuildSelectionPanel (); BuildHumanPlayerHandDisplay (); BuildEndTurnButton (); BuildDiceRoller (); BuildTradePanel (); lastAIActionTime = EPOCH; curState = gamestate.IncrementState (); // initial increment }
private void IncrementState() { //Things to do before incrementing state switch (curState) { case GameState.State.placeSettlement: break; case GameState.State.placeRoad: break; case GameState.State.roll: if(rollForAI || !gamestate.GetCurrentTurnPlayer().isAI) ShowHideDice(); break; case GameState.State.robber: break; case GameState.State.trade: if(!gamestate.GetCurrentTurnPlayer().isAI) ShowHideTrade(true); break; case GameState.State.place: if(!gamestate.GetCurrentTurnPlayer().isAI) { ShowHideSelector(); ShowHideEndTurnButton(); } break; case GameState.State.end: break; default: break; } curState = gamestate.IncrementState (); //Things to do after switch (curState) { case GameState.State.placeSettlement: UpdateTurnInfo("Placing Settlement", gamestate.GetCurrentTurnPlayer().id);break; case GameState.State.placeRoad: UpdateTurnInfo("Placing Road", gamestate.GetCurrentTurnPlayer().id);break; case GameState.State.roll: UpdateTurnInfo("Rolling", gamestate.GetCurrentTurnPlayer().id); if(rollForAI || !gamestate.GetCurrentTurnPlayer().isAI) ShowHideDice(); break; case GameState.State.robber: UpdateTurnInfo("Moving Robber", gamestate.GetCurrentTurnPlayer().id);break; case GameState.State.trade: if(!gamestate.GetCurrentTurnPlayer().isAI) { ShowHideTrade(true); ShowHideEndTurnButton(); } UpdateTurnInfo("Trading", gamestate.GetCurrentTurnPlayer().id);break; case GameState.State.place: if(!gamestate.GetCurrentTurnPlayer().isAI) ShowHideSelector(); UpdateTurnInfo("Placing", gamestate.GetCurrentTurnPlayer().id);break; case GameState.State.end: UpdateTurnInfo("WINNER!", gamestate.GetCurrentTurnPlayer().id);break; default: UpdateTurnInfo("What is going on!?!", gamestate.GetCurrentTurnPlayer().id);break; } }