Esempio n. 1
0
 private void DontHaveEnoughStamina(SpellClass spell)
 {
     foreach (Transform ChosenCard in ButtonsCanvas.transform.GetChild(0))
     {
         if (ChosenCard.gameObject.name == spell.getNameSpell() && spell.getNameSpell() != "MagicRenewal")
         {
             float sum = playerManager.getTotalStaminaPlayer() - spell.getStaminaSpell();
             if (sum < 0)
             {
                 ChosenCard.gameObject.GetComponent <Button>().interactable = false;
             }
         }
     }
 }
Esempio n. 2
0
    public void pickAttacks(int rowPlayer, int coulmnPlayer, int _rowEnemy, int _coulmnEnemy)
    {
        rowEnemy    = _rowEnemy;
        coulmnEnemy = _coulmnEnemy;
        int  counter = 0;
        bool continu = false;


        while (continu == false)
        {
            bool staminafull = false;
            bool RemoteAttackOrToMuchStamina = false;
            bool doubleMovement = false;


            int num = (int)(Random.Range(0f, 501f));

            if (num <= 40)
            {
                number = 0;
            }
            else if (num <= 80 && num > 40)
            {
                number = 1;
            }
            else if (num <= 120 && num > 80)
            {
                number = 2;
            }
            else if (num <= 160 && num > 120)
            {
                number = 3;
            }
            else if (num <= 260 && num > 160)
            {
                number = 4;
            }
            else if (num <= 340 && num > 260)
            {
                number = 5;
            }
            else if (num <= 420 && num > 340)
            {
                number = 6;
            }
            else if (num <= 500 && num > 420)
            {
                number = 7;
            }


            Debug.Log("num: " + number);
            moves[counter] = movesArray[number];

            if (this.TotalStamina == this.Stamina && moves[counter] == attacks[2].getNameSpell())            //if the stamina full and the card is magic renewal
            {
                staminafull = true;
            }

            if ((counter >= 1 && (moves[1] == moves[0] || moves[1] == moves[2] || moves[0] == moves[2]) && moves[counter].Contains("Attack") == false))
            {
                //if there is movement to any direction twice
                doubleMovement = true;
            }

            if (moves[counter].Contains("Attack") == true)
            {
                //if the attack's stamina required is more than the current stamina or the enemy is too far from the player
                SpellClass attack = whichAtttack(moves[counter]);
                if ((attack.getStaminaSpell() > this.TotalStamina || (coulmnPlayer - coulmnEnemy == 3) || (coulmnPlayer - coulmnEnemy == -3) || (rowPlayer - rowEnemy == 2) || (rowPlayer - rowEnemy == -2)) && turn == 0)
                {
                    RemoteAttackOrToMuchStamina = true;
                }
            }

            if (doubleMovement == false && RemoteAttackOrToMuchStamina == false && staminafull == false)
            {
                for (int i = 0; i < attacks.Length; i++)
                {
                    if (moves[counter] == attacks[i].getNameSpell())
                    {
                        this.TotalStamina    -= attacks[i].getStaminaSpell();
                        staminaMoves[counter] = attacks[i].getStaminaSpell();
                        damageMoves[counter]  = attacks[i].getDamage();
                        Debug.Log(this.TotalStamina + " " + attacks[i].getNameSpell() + " " + attacks[i].getStaminaSpell());
                    }
                }
                counter++;
                if (counter > 2)
                {
                    continu = true;
                }
            }
            movement();
        }
        if ((!moves[0].Contains("Attack")) && (!moves[1].Contains("Attack")) && (!moves[2].Contains("Attack")) && turn > 0)
        {
            if (this.TotalStamina >= attacks[0].getStaminaSpell() && this.TotalStamina >= attacks[1].getStaminaSpell())
            {
                Debug.Log("no attack");
                int numMoves = (int)(Random.Range(0f, 3f));
                int atack    = (int)(Random.Range(0f, 2f));
                Debug.Log(atack + " pppppppppp " + numMoves);
                moves[numMoves] = attacks[atack].getNameSpell();

                this.TotalStamina     -= attacks[atack].getStaminaSpell();
                staminaMoves[numMoves] = attacks[atack].getStaminaSpell();
                damageMoves[numMoves]  = attacks[atack].getDamage();
            }
        }



        this.TotalStamina += 15;
        if (this.TotalStamina > this.Stamina)
        {
            this.TotalStamina = this.Stamina;
        }

        //moves[2] = "RollingStoneAttack";
        //staminaMoves[2] = attacks[1].getStaminaSpell();
        //this.TotalStamina -= attacks[1].getStaminaSpell();
        for (int i = 0; i < moves.Length; i++)
        {
            Debug.Log("000099999999 " + moves[i]);
            Debug.Log("Llllllllllll " + staminaMoves[i] + " " + i);
        }

        Debug.Log(this.TotalStamina + " jjjjjjjj");
        turn++;
    }