// Changes the state of the game public void ToggleGameState(GameCore.GameState setState) { // Change the state of the game to the Start if (setState == GameCore.GameState.Start) { // Make the entire world recognize the game state GameCore.SetGameState(GameCore.GameState.Start); // Get the high score GameCore.GetHighScore(); // Toggle the active GUI to the StartGUI StartGUI.SetActive(true); InGameGUI.SetActive(false); GameOverGUI.SetActive(false); // Set the game up SetGame(); } // Change the state of the game to the InGame state else if (setState == GameCore.GameState.InGame) { // Make the entire world recognize the game state GameCore.SetGameState(GameCore.GameState.InGame); // Toggle the active GUI StartGUI.SetActive(false); InGameGUI.SetActive(true); GameOverGUI.SetActive(false); // Start the game StartGame(); } // Change the state of the game to the GameOver state else if (setState == GameCore.GameState.GameOver) { // Make the entire world recognize the game state GameCore.SetGameState(GameCore.GameState.GameOver); // Check and set the new score GameCore.NewScore(); if (GameCore.curScore > GameCore.highScore) { Debug.Log("New high score!"); } // Toggle the active GUI StartGUI.SetActive(false); InGameGUI.SetActive(false); GameOverGUI.SetActive(true); } }
public void AddState(GameState state) { _gameStates.Add(state); }
public void AddAndLoad(GameState state) { _gameStates.Add(state); state.Load(); }
public void SetTargets() { State = GameState.OnSetTargets; OnBeginSetTarget(this, new EventArgs()); if (autoEvent.WaitOne(15000)) { if (isFinishDeal) { isFinishDeal = false; throw new FinishDealCardsException(); } else { OnEndSetTarget(this, new EventArgs()); } } else { throw new TimeOutException(); } }
public void SelectThisOneCard(int cardIndex) { GameState[] s = new GameState[] { GameState.OnSelectCard, GameState.OnSetTargets, GameState.OnDealCard }; if (!s.Contains(State)) return; var card = currentPlayer.Cards[cardIndex]; if (dealedCardsInTurn.Any(c => c is Acid || c is Base) && (card is Acid || card is Base)) { OnCannotSelectThisCard(this, new EventArgs()); return; } else cardDress = new CardDress(card); if (State == GameState.OnSelectCard) { autoEvent.Set(); } else if (State == GameState.OnRespond) { } else { throw new ReSelectCardException(); } }
public void SelectOneCard() { State = GameState.OnSelectCard; targets.Clear(); OnBeginSelectOneCard(this, new EventArgs()); if (cardDress != null || autoEvent.WaitOne(15000)) { if (isFinishDeal) { isFinishDeal = false; throw new FinishDealCardsException(); } OnEndSelectOneCard(this, new EventArgs()); } else { throw new TimeOutException(); } }
public void Respond() { State = GameState.OnRespond; Rules.Respond(); }
public void Prepare() { State = GameState.OnPrepare; TurnCtx = new TurnContext(); }
public void GetCards() { State = GameState.OnGetCards; OnBeginGetCards(this, new EventArgs()); for (int i = 0; i < currentPlayer.CardCountToGet; i++) { if (availableCards.Count == 0) { RecycleCards(); } currentPlayer.Cards.Add(availableCards.TakeRandom()); } OnEndGetCards(this, new EventArgs()); }
public void DropCards() { State = GameState.OnDropCards; OnBeginDropCard?.Invoke(this, new EventArgs()); if (autoEvent.WaitOne(15000)) { } else { currentPlayer.Cards.MoveRangeTo(droppedCards, 0, CardsCountToDrop); } OnEndDropCard?.Invoke(this, new EventArgs()); }
public void Determine() { State = GameState.OnDetermine; }
public void DealOneCard() { State = GameState.OnDealCard; OnBeginDealCard(this, new EventArgs()); if (autoEvent.WaitOne(15000)) { if (isFinishDeal) { isFinishDeal = false; throw new FinishDealCardsException(); } else { TurnCtx.NeedReselect = false; OnEndDealCard(this, new EventArgs()); } } else { throw new TimeOutException(); } }
void AddControl(Control control, GameState state) { Controller.Add(control as InteractiveObject, state); }
public void Add(InteractiveObject obj, GameState state) { if(!interfaces.ContainsKey(state)) interfaces[state] = new List<InteractiveObject>(); if(!interfaces[state].Contains(obj)) interfaces[state].Add(obj); }
internal StateEventArgs(GameState state) { this.state = state; }