Ejemplo n.º 1
0
    public void Challenge()
    {
        bonus = 0;
        foreach (HexTile tile in curr.nears)
        {
            if (tile.edifice == null)
            {
                continue;
            }

            if (tile.edifice.team == team)
            {
                bonus++;
            }
        }

        int  dice        = Mathf.FloorToInt(Random.Range(1.01f, 6.99f));
        int  totalAttack = manager.red[team] + bonus + dice;
        bool nearEnemy   = false;

        foreach (HexTile tile in curr.nears)
        {
            IDestroyable destroyable = (IDestroyable)tile.edifice;


            if (destroyable != null)
            {
                if (destroyable.team == team)
                {
                    continue;
                }

                nearEnemy = true;
                bool survived = destroyable.Hit(totalAttack);

                if (!survived)
                {
                    alive = false;
                }
            }
        }

        if (!nearEnemy)
        {
            return;
        }

        damageText.color = Color.yellow;
        damageText.text  = totalAttack.ToString();
        StartCoroutine("HitMotion");
        nearEnemy = false;
    }