Exemplo n.º 1
0
 void SetPlayerAction(EquipmentWrapper e, Equipment.Ability action)
 {
     if (e == null && action == null)
     {
         Inventory.Show(player);
     }
     else
     {
         playerCards.Clear();
         Equipment.Ability playerAction;
         bool remove = false;
         if (action != null)
         {
             playerAction = action;
         }
         else
         {
             remove = !e.NextAction(out playerAction);
         }
         Equipment.Ability enemyAction;
         var ee = enemy.GetAbility(out enemyAction);
         FlashText.Flash(enemyAction.name + "\n\n\n\n" + playerAction.name, Color.white);
         HandleAction(player, enemy, ref playerAction, ref enemyAction, playerAnimation, enemyAnimation);
         HandleAction(enemy, player, ref enemyAction, ref playerAction, enemyAnimation, playerAnimation);
         if (remove)
         {
             FlashText.Flash("Your " + e.equipment.name.ToLower() + " broke!", Color.red);
             player.RemoveEquipment(e);
         }
         if (ee != null)
         {
             enemy.RemoveEquipment(ee);
         }
         if (player.health <= 0 && enemy.health >= player.health)
         {
             StartCoroutine(BattleOver(player));
             return;
         }
         else if (enemy.health <= 0 && player.health > enemy.health)
         {
             StartCoroutine(BattleOver(enemy));
             return;
         }
         reward += 3;
         StartCoroutine(DelayedNextTurn());
     }
 }
Exemplo n.º 2
0
    public EquipmentWrapper GetAbility(out Equipment.Ability ability)
    {
        float sum = character.aggressive + character.defensive + character.utility;

        if (sum < 0.01f)
        {
            ability        = new Equipment.Ability();
            ability.name   = "Wait";
            ability.action = Equipment.Action.none;
            return(null);
        }
        float            rnd = Random.value * sum;
        EquipmentWrapper e   = null;

        if (rnd < character.aggressive)
        {
            for (int i = 0; i < equipment.Count; i++)
            {
                if ((equipment[i].equipment.type == Equipment.Type.aggressive || equipment[i].equipment.type == Equipment.Type.weapon) && equipment[i].cooldown <= 0)
                {
                    e = equipment[i];
                    int r = Random.Range(0, equipment.Count);
                    equipment[i] = equipment[r];
                    equipment[r] = e;
                    break;
                }
            }
            if (e == null)
            {
                float tmp = character.aggressive;
                character.aggressive = 0f;
                e = GetAbility(out ability);
                character.aggressive = tmp;
                return(e);
            }
        }
        else
        {
            rnd -= character.aggressive;
            if (rnd < character.defensive)
            {
                for (int i = 0; i < equipment.Count; i++)
                {
                    if ((equipment[i].equipment.type == Equipment.Type.armor || equipment[i].equipment.type == Equipment.Type.shield) && equipment[i].cooldown <= 0)
                    {
                        e = equipment[i];
                        int r = Random.Range(0, equipment.Count);
                        equipment[i] = equipment[r];
                        equipment[r] = e;
                        break;
                    }
                }
                if (e == null)
                {
                    float tmp = character.defensive;
                    character.defensive = 0f;
                    e = GetAbility(out ability);
                    character.defensive = tmp;
                    return(e);
                }
            }
            else
            {
                for (int i = 0; i < equipment.Count; i++)
                {
                    if (equipment[i].equipment.type == Equipment.Type.utility && equipment[i].cooldown <= 0)
                    {
                        e = equipment[i];
                        int r = Random.Range(0, equipment.Count);
                        equipment[i] = equipment[r];
                        equipment[r] = e;
                        break;
                    }
                }
                if (e == null)
                {
                    float tmp = character.utility;
                    character.utility = 0f;
                    e = GetAbility(out ability);
                    character.utility = tmp;
                    return(e);
                }
            }
        }
        if (!e.NextAction(out ability))
        {
            return(e);
        }
        return(null);
    }