Example #1
0
    private void OnTriggerExit2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            this.targetPlayer = null;
            this.state        = AIBattleState.IDLE;

            StopCoroutine(CheckSelfCondition());
            StopCoroutine(ExecuteScript());
        }
    }
Example #2
0
 IEnumerator CheckSelfCondition()
 {
     while (this.player != null)
     {
         int engageChance = UnityEngine.Random.Range(0, 100);
         if (engageChance < player.GetHP())
         {
             this.state = AIBattleState.ENGAGE;
         }
         else
         {
             this.state = AIBattleState.AVOID;
         }
         yield return(new WaitForSeconds(0.2F));
     }
     yield break;
 }
Example #3
0
    IEnumerator ExecuteScript()
    {
        while (this.state != AIBattleState.IDLE && targetPlayer != null)
        {
            if (this.state == AIBattleState.ENGAGE)
            {
                this.EngageTarget();
                float reAimDelay = UnityEngine.Random.Range(aimDelay.x, aimDelay.y);
                yield return(new WaitForSeconds(reAimDelay));
            }
            else if (this.state == AIBattleState.AVOID)
            {
                this.AvoidTarget();
                yield return(new WaitForSeconds(0.2F));
            }
        }

        if (targetPlayer == null)
        {
            this.state = AIBattleState.IDLE;
        }

        yield break;
    }