Example #1
0
 //
 public IEnumerator Orders()
 {
     Stats target = new Stats();
     Stats[] targets;
     Stats user;
     for(int i = 0; i < _amountOfContracts; i++)
     {
         switch(_userActions[i]._type)
         {
             case "attack":
                 target = getEnemyStats(_userActions[i]._target);
                 user = getPlayerStats(_userActions[i]._user);
                 _battleGUI.setBattleText(user._name+" attacked "+target._name+" for "+target.TakeDamage(user)+" damage");
                 yield return new WaitForSeconds(2f);
                 if(target._currentHealth <= 0)
                 {
                     target.Feint();
                     _battleGUI.setBattleText(target._name+" has fallen.");
                 }
                 break;
             case "defend":
                 target = getPlayerStats(_userActions[i]._target);
                 user = getPlayerStats(_userActions[i]._user);
                 target.Shielded(user);
                 _battleGUI.setBattleText(user._name+" defended "+target._name);
                 break;
             case "special":
                 user = getPlayerStats(_userActions[i]._user);
                 if(!user._spAttack._name.Contains("group"))
                 {
                     targets = new Stats[1];
                     if(!user._spAttack._name.Contains("heal"))
                     {
                         targets[0] = getEnemyStats(_userActions[i]._target);
                     }
                     else
                     {
                         targets[0] = getPlayerStats(_userActions[i]._target);
                     }
                 }
                 else
                 {
                     targets = new Stats[_amountOfEnemys];
                     if(!user._spAttack._name.Contains("heal"))
                     {
                         for(int x = 0; x < _amountOfEnemys; x++)
                         {
                             targets[x] = _enemyStats[x];
                         }
                     }
                     else
                     {
                         for(int x = 0; x < _amountOfEnemys; x++)
                         {
                             targets[x] = _partyStats[x];
                         }
                     }
                 }
                 _battleGUI.setBattleText(user.UseSpecial(targets));
                 yield return new WaitForSeconds(2f);
                 for(int x = 0; x < targets.Length; x++)
                 {
                     if(targets[x]._currentHealth <= 0)
                     {
                         targets[x].Feint();
                         _battleGUI.setBattleText(". "+targets[x]._name+" has fallen.");
                         yield return new WaitForSeconds(2f);
                     }
                 }
                 break;
             default:
                 break;
         }
         if(EnemysAllDead())
         {
             break;
         }
     }
     if (!EnemysAllDead ())
     {
         _battleGUI.setBattleText ("Enemy turn.");
         yield return new WaitForSeconds (2f);
         for (int i = 0; i < _amountOfEnemys; i++)
         {
             if(_enemyStats[i]._alive)
             {
                 _battleGUI.setBattleText (_enemyAI [i].State ());
                 yield return new WaitForSeconds (2f);
                 if(ContractsAllDead())
                 {
                     break;
                 }
             }
             else{}
         }
         _attacking = false;
         _battleGUI.setBattleText ("Your turn.");
         yield return null;
     }
     else
     {
         _attacking = false;
         _battleGUI.setBattleText("All enemys defeated, you have won the battle.");
         _endingBattle = true;
         _won = true;
         _indicator.gameObject.SetActive(false);
         StopCoroutine(Orders());
     }
     if (ContractsAllDead ())
     {
         _battleGUI.setBattleText("All your contracts have fallen in battle, you have lost.");
         _endingBattle = true;
         _indicator.gameObject.SetActive(false);
         StopCoroutine(Orders());
     }
     for (int i = 0; i < _userActions.Length; i++)
     {
         _partyStats[i]._defended = false;
         _partyStats[i].ResetStat("defence");
         _partyStats[i].ResetStat("resistance");
         if(_partyStats[i]._spAttack != null)
         {
             if(_partyStats[i]._spAttack._currentTime < _partyStats[i]._spAttack._rechargeTime)
             {
                 _partyStats[i]._spAttack._currentTime++;
             }
         }
         _userActions [i] = new Action ();
     }
     _indicator.SetActive (true);
     SetIndicator (_contracts [0]);
 }