private void GameLoaded(StateType state) { StateManager.GameStateChanged -= GameLoaded; InitPlayers(); LoadGameData(); SelectedUnit = ActivePlayer.UnitInTurn; TurnTimer.StartTimer(); }
public void ChangeTurn() { _playerIndex++; if (_playerIndex >= AllPlayers.Length) { _playerIndex = 0; } ActivePlayer.StartTurn(); TurnTimer.Stop(); TurnTimer.Reset(); TurnTimer.StartTimer(); OnTurnChanged(); }
IEnumerator OnGameStart() { // Clear history of cards, this will be useful later for rematches CardLogic.CardsCreatedThisGame.Clear(); CreatureLogic.CreaturesCreatedThisGame.Clear(); // assign player to variables p1 = GameObject.FindGameObjectWithTag("P1"); p2 = GameObject.FindGameObjectWithTag("P2"); // set an int to 0/1 to decide who starts (0=p1|1=p2) randomDecider = Random.Range(0, 2); // Assign player to variables Player whoGoesFirst = Player.players[randomDecider]; Player whoGoesSecond = whoGoesFirst.otherPlayer; // Set whogoesfirst to first player whichPlayersTurn = whoGoesFirst; // Delay start by 2 seconds yield return(new WaitForSeconds(2f)); // Both Draw 4 cards for (int i = 0; i < 4; i++) { whoGoesFirst.DrawASingleCard(true); whoGoesSecond.DrawASingleCard(true); } // First persons first extra card is drawn whoGoesFirst.DrawASingleCard(true); whoGoesFirst.ActivateMyTurn(); timer.StartTimer(); }