Example #1
0
    // 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);
        }
    }
Example #2
0
 public void AddState(GameState state)
 {
     _gameStates.Add(state);
 }
Example #3
0
 public void AddAndLoad(GameState state)
 {
     _gameStates.Add(state);
     state.Load();
 }
Example #4
0
 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();
     }
 }
Example #5
0
        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();
            }
        }
Example #6
0
 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();
     }
 }
Example #7
0
 public void Respond()
 {
     State = GameState.OnRespond;
     Rules.Respond();
 }
Example #8
0
 public void Prepare()
 {
     State = GameState.OnPrepare;
     TurnCtx = new TurnContext();
 }
Example #9
0
 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());
 }
Example #10
0
 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());
 }
Example #11
0
 public void Determine()
 {
     State = GameState.OnDetermine;
 }
Example #12
0
 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();
     }
 }
Example #13
0
 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);
 }
Example #15
0
 internal StateEventArgs(GameState state) {
     this.state = state;
 }