Esempio n. 1
0
 public void PickCard()
 {
     _currentCard = new RecomposedCard();
     _currentCard.SetCard(_currentDeck.PickCard(), _currentDeck.PickCard());
     UIManager.GetInstance().SetImageSprite(playerNumber, true, _currentCard.GetCardType(true), _currentCard.GetCardAmount(true));
     UIManager.GetInstance().SetImageSprite(playerNumber, false, _currentCard.GetCardType(false), _currentCard.GetCardAmount(false));
     //_currentCard.CardToString();
 }
Esempio n. 2
0
 public void ResetHavePlayed()
 {
     _havePlayed    = false;
     _currentCard   = null;
     _currentAction = -1;
     UIManager.GetInstance().ShowSelection(playerNumber, true, false);
     UIManager.GetInstance().ShowSelection(playerNumber, false, false);
 }
Esempio n. 3
0
    public void Resolve(RecomposedCard player0Card, RecomposedCard player1Card, int player0Choice, int player1Choice)
    {
        if (_resolving)
        {
            return;
        }

        _resolving = true;

        StartCoroutine(ShowResolution(player0Card, player1Card, player0Choice, player1Choice));
    }
Esempio n. 4
0
    private IEnumerator ShowResolution(RecomposedCard player0Card, RecomposedCard player1Card, int player0Choice, int player1Choice)
    {
        Actions player0Action = player0Card.GetSelectedAction(player0Choice);
        Actions player1Action = player1Card.GetSelectedAction(player1Choice);

        player0Action.InitResolution();
        player1Action.InitResolution();

        //Go at least one time in the loop
        while ((player0Action.GetResolutionAmount() > 0 || player1Action.GetResolutionAmount() > 0) && !_mustEndTurn)
        {
            //The first time we go there
            if (player0Action.GetCanAct() && player1Action.GetCanAct())
            {
                int resolution = Resolution(player0Action, player1Action);

                Debug.Log("resolution " + resolution);

                if (resolution == 0)
                {
                    player0Action.ExecuteAction(0, _masterBoard, player1Action);
                    player1Action.ExecuteAction(1, _masterBoard, player0Action);
                }
                else if (resolution == -1)
                {
                    player0Action.ExecuteAction(0, _masterBoard, player1Action);
                }
                else if (resolution == 1)
                {
                    player1Action.ExecuteAction(1, _masterBoard, player0Action);
                }
                else if (resolution == 3) // special case
                {
                    player0Action.ExecuteAction(0, _masterBoard, player1Action);
                    player1Action.ExecuteAction(1, _masterBoard, player0Action);
                    break;
                }
                else
                {
                    _mustEndTurn = true;
                    break; // end the turn
                }
            }
            else if (player0Action.GetCanAct())
            {
                player0Action.ExecuteAction(0, _masterBoard, player1Action);
            }
            else if (player1Action.GetCanAct())
            {
                player1Action.ExecuteAction(1, _masterBoard, player0Action);
            }
            player0Action.UpdateAction();
            player1Action.UpdateAction();
            yield return(null);
        }

        yield return(new WaitForSeconds(2.0f));

        player0Action.ResetAction();
        player1Action.ResetAction();
        _mustEndTurn = false;

        _masterBoard.DebugBoard();
        GameManager.GetInstance().SetGameState(GameState.ENDTURN);
        _resolving = false;
    }