Example #1
0
 void Evade()
 {
     detectDistance();
     if (enemyAI.state != Utilities.state.Dodging && enemyAI.state != Utilities.state.Blocking)
     {
         if (enemyAI.my.transform.position.x <= enemyAI.location.x - 1)
         {
             enemyAI.movementX = 0.6f;
         }
         if (enemyAI.my.transform.position.x >= enemyAI.location.x + 1)
         {
             enemyAI.movementX = -0.6f;
         }
         //En caso que la ataquen desde al lado, cumpla el random y este en movimiento la IA evadera el ataque
         if (enemyAI.dodge && enemyAI.GetComponent <Rigidbody2D>().velocity.x >= 3.5f && enemyAI.direction.y < 0.3 && enemyAI.direction.y > -0.3)
         {
             int num = enemyAI.RandomNum();
             if (num >= 50)
             {
                 if (direction == 1)
                 {
                     enemyAI.my.dodge(Utilities.direction.Right);
                     enemyAI.state = Utilities.state.Dodging;
                 }
                 if (direction == 2)
                 {
                     enemyAI.my.dodge(Utilities.direction.Left); enemyAI.state = Utilities.state.Dodging;
                 }
                 enemyAI.dodge = false;
                 enemyAI.startDelay();
             }
         }
         //En caso de que este quieta y sobrepase el random lo bloqueara
         else if (enemyAI.dodge && enemyAI.GetComponent <Rigidbody2D>().velocity.x <= 3.5f && enemyAI.direction.y < 0.3 && enemyAI.direction.y > -0.3)
         {
             int num = enemyAI.RandomNum();
             if (num >= 50)
             {
                 enemyAI.state = Utilities.state.Blocking;
                 enemyAI.my.spotDodge();
                 enemyAI.dodge = false;
                 enemyAI.startblockDelay();
             }
         }
     }
     enemyAI.checkFacingDirection();
 }
Example #2
0
    void Attack()
    {
        detectDistance();
        if (enemyAI.state != Utilities.state.Attacking && enemyAI.state != Utilities.state.Hit)
        {
            if (enemyAI.my.transform.position.x <= enemyAI.location.x - 1)
            {
                enemyAI.movementX = 0.6f;
            }
            if (enemyAI.my.transform.position.x >= enemyAI.location.x + 1)
            {
                enemyAI.movementX = -0.6f;
            }
            if (enemyAI.my.isGrounded || enemyAI.my.isOnPlatform)
            {
                //IA puede atacar y el target esta en angulo que le permiten atacar a su lado realiza estos ataques
                if (enemyAI.attack && enemyAI.GetComponent <Rigidbody2D>().velocity.x <= 3.5f && enemyAI.direction.y < 0.4 + enemyAI.augmentAngl && enemyAI.direction.y > -0.4 - enemyAI.augmentAngl)
                {
                    enemyAI.state = Utilities.state.Attacking;
                    int num = enemyAI.RandomNum();
                    if (num >= 60)
                    {
                        enemyAI.my.attacks.startAttack(Utilities.attackType.BasicFloorSide);
                    }
                    else if (num >= 30 && num < 60)
                    {
                        enemyAI.my.attacks.startAttack(Utilities.attackType.SpecialSide);
                    }
                    else if (num >= 0 && num < 30)
                    {
                        enemyAI.my.attacks.startAttack(Utilities.attackType.SpecialDown);
                    }

                    enemyAI.attack = false;
                    enemyAI.startDelay();
                }
                //Si el angulo esta por encima de ella utilizara los ataques hacia arriba
                else if (enemyAI.attack && enemyAI.direction.y > 0.3 && enemyAI.direction.x < 0.4 + enemyAI.augmentAngl && enemyAI.direction.x > -0.4 - enemyAI.augmentAngl)
                {
                    enemyAI.state = Utilities.state.Attacking;
                    int num = enemyAI.RandomNum();
                    if (num >= 40)
                    {
                        enemyAI.my.attacks.startAttack(Utilities.attackType.BasicFloorUp);
                    }
                    else if (num >= 0 && num < 40)
                    {
                        enemyAI.my.attacks.startAttack(Utilities.attackType.SpecialUp);
                    }

                    enemyAI.attack = false;
                    enemyAI.startDelay();
                }
            }
            else
            {
                //Esta en el aire y el target esta a su lado utiliza estos ataques
                if (enemyAI.attack && enemyAI.direction.y < 0.4 && enemyAI.direction.y > -0.4 - enemyAI.augmentAngl)
                {
                    enemyAI.state = Utilities.state.Attacking;
                    int num = enemyAI.RandomNum();
                    if (num >= 50)
                    {
                        enemyAI.my.attacks.startAttack(Utilities.attackType.BasicAirSide);
                    }
                    else if (num >= 25 && num < 50)
                    {
                        enemyAI.my.attacks.startAttack(Utilities.attackType.SpecialSide);
                    }
                    else if (num >= 0 && num < 25)
                    {
                        enemyAI.my.attacks.startAttack(Utilities.attackType.SpecialDown);
                    }

                    enemyAI.attack = false;
                    enemyAI.startDelay();
                }
                //esta en el aire y por encima de ella
                else if (enemyAI.attack && enemyAI.direction.y > 0.3 && enemyAI.direction.x < 0.4 + enemyAI.augmentAngl && enemyAI.direction.x > -0.4 - enemyAI.augmentAngl)
                {
                    enemyAI.state = Utilities.state.Attacking;
                    int num = enemyAI.RandomNum();
                    if (num >= 30)
                    {
                        enemyAI.my.attacks.startAttack(Utilities.attackType.BasicAirUp);
                    }
                    else if (num >= 0 && num < 30)
                    {
                        enemyAI.my.attacks.startAttack(Utilities.attackType.SpecialUp);
                    }

                    enemyAI.attack = false;
                    enemyAI.startDelay();
                }
                //Esta por debajo de ella
                else if (enemyAI.attack)
                {
                    enemyAI.state = Utilities.state.Attacking;
                    enemyAI.my.attacks.startAttack(Utilities.attackType.BasicAirDown);

                    enemyAI.attack = false;
                    enemyAI.startDelay();
                }
            }
            if (enemyAI.immune)
            {
                enemyAI.becomeHittable();
            }
        }
        enemyAI.checkFacingDirection();
    }