Ejemplo n.º 1
0
        private void CreateMove()
        {
            GameMove gameMove = new GameMove(leavingSpot, landingSpot, gameObject);

            GameManager.Singleton.HandleNewMove(gameMove);
            //gameMove.Execute();
            //GameManager.OnValidMove?.Invoke();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Turn the card on top of the covered part of the pile, if there's one available and it's not flipped already.
 /// </summary>
 public void TurnNextCard()
 {
     if (currentPile.Count > 0)
     {
         var lastCard = currentPile.Last.Value;
         if (!lastCard.GetComponent <Card>().IsFaceUp)
         {
             GameMove gameMove = new GameMove(this, this, lastCard);
             GameManager.Singleton.HandleNewMove(gameMove);
         }
     }
 }
Ejemplo n.º 3
0
 public void HandleNewMove(GameMove move)
 {
     movesList.Push(move);
     AddPointsToScore(move.PointsAwarded);
     if (move.MoveType == MoveType.RECYCLE_WASTE)
     {
         AddPointsToScore(-100);
     }
     if (move.MoveType != MoveType.FLIP)
     {
         Moves++; // a flip is always associated to another move. So, increasing the counter will be done by the associated move;
     }
     move.Execute();
     OnValidMove?.Invoke();
 }
Ejemplo n.º 4
0
        public void UndoMove(GameMove moveToUndo)
        {
            switch (moveToUndo.MoveType)
            {
            case MoveType.FETCH_CARD:
            {
                UndoFetchCard(moveToUndo.Card);
                break;
            }

            case MoveType.RECYCLE_WASTE:
            {
                StartCoroutine(UndoRecycleWaste());
                break;
            }

            default:
            {
                Debug.LogError("[Deck] the move to undo doesn't belong to this object");
                break;
            }
            }
        }
Ejemplo n.º 5
0
        public void ExecuteMove(GameMove moveToExecute)
        {
            switch (moveToExecute.MoveType)
            {
            case MoveType.FETCH_CARD:
            {
                FetchCard();
                break;
            }

            case MoveType.RECYCLE_WASTE:
            {
                StartCoroutine(RecycleWaste());
                break;
            }

            default:
            {
                Debug.LogError("[Deck] the move to execute doesn't belong to this object");
                break;
            }
            }
        }
Ejemplo n.º 6
0
        public void ChooseButtonAction()
        {
            if (availableCards.Count == 0 && currentWastePile.Count == 0)
            {
                return;
            }

            GameMove gameMove;

            if (availableCards.Count == 0 && currentWastePile.Count > 0)
            {
                // create a "RecreateStock" Move
                gameMove = new GameMove(this, this, null);
            }
            else
            {
                //availableCardIndex = availableCardIndex - 1 < 0 ? availableCards.Count - 1 : availableCardIndex - 1;
                //lastCardFetched = DeckTopCard; // only for showing in the inspector
                gameMove = new GameMove(this, this, DeckTopCard);
            }
            // If there are still available cards, show a covered card sprite
            GameManager.Singleton.HandleNewMove(gameMove);
            deckImage.sprite = availableCards.Count > 0 ? deckSprites[0] : deckSprites[1];
        }