Ejemplo n.º 1
0
    public void CashOut()
    {
        if (canCashOut)
        {
            if (playerTurn == (int)Player_Turn.mary)
            {
                SoundManager.Instance.CashOutButtonSound();
                //Reset placed pieces and set temp blood points
                for (int i = 0; i < spelplan.GetComponent <Spelplan>().gridArray.GetLength(0); i++)
                {
                    for (int j = 0; j < spelplan.GetComponent <Spelplan>().gridArray.GetLength(1); j++)
                    {
                        if (spelplan.GetComponent <Spelplan>().gridArray[i, j].GetComponent <Owner>().owned == (int)Tile_State.player1 && spelplan.GetComponent <Spelplan>().gridArray[i, j].GetComponent <Owner>().specialState == 0)
                        {
                            marysTempPoints++;
                            spelplan.GetComponent <Spelplan>().gridArray[i, j].GetComponent <Owner>().resetMary();
                        }
                    }
                }

                enemyBloodPointsText.transform.DOShakePosition(0.4f + marysTempPoints * 0.5f, 3 + marysTempPoints, 25, 10);

                if (marysTempPoints > 0)
                {
                    enemyAnimations.animator.SetTrigger("Damaged");
                }

                if (lastMove.enemyHellStaffActivePower == true && DataAcrossScenes.EnemyChosenStaff == (int)Chosen_Staff.hell)
                {
                    marysHealth -= marysTempPoints + 1;
                    playerBloodPointsText.transform.DOShakePosition(0.4f + marysTempPoints * 0.5f, 3 + marysTempPoints, 25, 10);
                }

                if (DataAcrossScenes.PlayerChosenStaff == (int)Chosen_Staff.night)
                {
                    darknightStaff.DarkNightStaffPassiveAbility();
                }

                enemyHealth -= (marysTempPoints + 1) * maryDamageMultiplier;
                dialogueTrigger.EnemyHurts();
                dialogueTrigger.MaryCashOut();
                marysTempPoints = 0;
                lastMove.maryCashedOutThisTurn = true;

                GameOver();
            }
            else if (playerTurn == (int)Player_Turn.enemy)
            {
                SoundManager.Instance.CashOutButtonSound();

                for (int i = 0; i < spelplan.GetComponent <Spelplan>().gridArray.GetLength(0); i++)
                {
                    for (int j = 0; j < spelplan.GetComponent <Spelplan>().gridArray.GetLength(1); j++)
                    {
                        if (spelplan.GetComponent <Spelplan>().gridArray[i, j].GetComponent <Owner>().owned == (int)Tile_State.player2 &&
                            spelplan.GetComponent <Spelplan>().gridArray[i, j].GetComponent <Owner>().specialState == 0)
                        {
                            enemyTempPoints++;
                            spelplan.GetComponent <Spelplan>().gridArray[i, j].GetComponent <Owner>().resetEnemy();
                        }
                    }
                }

                playerBloodPointsText.transform.DOShakePosition(0.4f + enemyTempPoints * 0.5f, 3 + enemyTempPoints, 25, 10);

                if (enemyTempPoints > 0)
                {
                    characterAnimations.animator.SetTrigger("Damaged");
                }

                if (lastMove.playerHellStaffActivePower == true)
                {
                    enemyHealth -= enemyTempPoints + 1;
                    enemyBloodPointsText.transform.DOShakePosition(0.4f + enemyTempPoints * 0.5f, 3 + enemyTempPoints, 25, 10);
                }

                if (DataAcrossScenes.EnemyChosenStaff == (int)Chosen_Staff.night)
                {
                    darknightStaff.DarkNightStaffPassiveAbility();
                }

                marysHealth -= (enemyTempPoints + 1) * enemyDamageMultiplier;
                dialogueTrigger.EnemyAttack();
                dialogueTrigger.MaryTakingDamage();
                enemyTempPoints = 0;
                lastMove.enemyCashedOutThisTurn = true;

                GameOver();
            }

            foreach (Transform child in GameObject.Find("Spelplan").transform)
            {
                child.GetComponent <Owner>().skeletonMark = false;
            }

            UpdateBloodPoints();
            canCashOut = false;
            CheckCanCashOut();
        }
    }