Esempio n. 1
0
    public void Calculate()
    {
        if (matrixArea.CardCount() > 0 && operatorArea.CardCount() > 0)
        {
            cam.BaseEffect();

            CancelInvoke("HintOrTaunt");

            locked = true;

            Card c  = matrixArea.PopCard();
            Card oc = operatorArea.PopCard();
            int  op = oc.GetOperation();

            if (op == 0)
            {
                resultMatrix.Add(c.GetMatrix());
            }

            if (op == 1)
            {
                resultMatrix.Subtract(c.GetMatrix());
            }

            if (op == 2)
            {
                resultMatrix.Multiply(c.GetMatrix());
            }

            EffectManager.Instance.AddEffect(0, c.transform.position);
            EffectManager.Instance.AddEffect(0, oc.transform.position);

            Destroy(c.gameObject);
            Destroy(oc.gameObject);

            handArea.SpawnCards(1, 1);

            calcButton.ChangeVisibility(false);

            int winner = resultMatrix.CheckLines(playerNum, opponentNum);

            roundEnded = false;

            if (winner != -1 && currentTurn == 0)
            {
                playerBlock.face.Emote(Face.Emotion.Happy);
                opponentBlock.face.Emote(Face.Emotion.Sad);
                roundEnded = true;

                DisplayText("You win!", nextButton, 1f);
            }

            if (winner != -1 && currentTurn == 1)
            {
                opponentBlock.face.Emote(Face.Emotion.Happy);
                playerBlock.face.Emote(Face.Emotion.Sad);
                roundEnded = true;

                DisplayText("You lose!", retryButton, 1f);
            }

            turnNumber++;
            currentTurn = (currentTurn + 1) % 2;

//			currentTurn = 0; // always player turn

            if (!roundEnded)
            {
                UpdateTurnIndicators();

                AudioManager.Instance.Highpass(currentTurn == 1);
            }
            else
            {
                turnIndicators [0].Hide();
                turnIndicators [1].Hide();
            }

            if (turnNumber >= 4 && currentTurn == 0)
            {
                ProgressManager.Instance.SpaceTutorial();
            }

            CancelInvoke("HintOrTaunt");

            if (currentTurn == 0 && !roundEnded)
            {
                bubble.CheckQueuedMessages();
                Invoke("HintOrTaunt", Random.Range(5f, 20f));
            }

            if (currentTurn == 1 && !roundEnded)
            {
                OpponentTurn();
            }

            if (!roundEnded)
            {
                locked = false;
            }
            else
            {
                AudioManager.Instance.Highpass(true);
            }
        }
    }