Exemplo n.º 1
0
 void AttackPlayer()
 {
     if (enemyPosition.ShouldBeAttacking())
     {
         enemyStates.SetEvent((int)EnemyStates.BaddieEvents.Attack);
     }
     else
     {
         enemyStates.SetEvent((int)EnemyStates.BaddieEvents.StopAttack);
     }
 }
 void FlinchDamage()
 {
     if (enemyStates.GetState() == (int)EnemyStates.BaddieStates.Damaged)
     {
         behaviourTimer += Time.deltaTime;
         if (behaviourTimer >= deactivateFlinchingTime)
         {
             enemyStates.SetEvent((int)EnemyStates.BaddieEvents.Recover);
             behaviourTimer = 0;
         }
     }
 }
 void CheckIfDead()
 {
     if (enemyHealth.GetHealth() <= 0)
     {
         enemyStates.SetEvent((int)EnemyStates.BaddieEvents.KnockedOut);
     }
 }
 void DetectPlayer()
 {
     if (enemyPosition.IsPlayerDetected())
     {
         enemyStates.SetEvent((int)EnemyStates.BaddieEvents.PlayerDetected);
     }
 }
 void Retreat()
 {
     if (enemyStates.GetState() == (int)EnemyStates.BaddieStates.Retreating)
     {
         behaviourTimer += Time.deltaTime;
         enemyMove.UpdateRetreat();
         if (behaviourTimer >= deactivateRetreatTime)
         {
             enemyStates.SetEvent((int)EnemyStates.BaddieEvents.StopRetreat);
             behaviourTimer = 0;
         }
     }
 }
Exemplo n.º 6
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "PlayerAttack")
     {
         if (enemyStates.GetState() != (int)EnemyStates.BaddieStates.Damaged &&
             enemyStates.GetState() != (int)EnemyStates.BaddieStates.Falling &&
             enemyStates.GetState() != (int)EnemyStates.BaddieStates.Down)
         {
             this.gameObject.GetComponent <EnemyHealth>().SetHealth(this.gameObject.GetComponent <EnemyHealth>().GetHealth() - PlayerAttack.instance.GetAttackDamage());
             HealthUI.instance.SetEnemyHealthSlider(this.gameObject.GetComponent <EnemyHealth>().maxHealth, this.gameObject.GetComponent <EnemyHealth>().GetHealth());
             HealthUI.instance.SetEnemyName(this.gameObject.name);
         }
         if (PlayerMachines.instance.GetComboMachine().GetState() == (int)PlayerCombo.ComboStates.ThirdPunch ||
             PlayerMachines.instance.GetPlayerStateMachine().GetState() == (int)PlayerStates.States.HeavyPunching ||
             PlayerMachines.instance.GetPlayerStateMachine().GetState() == (int)PlayerStates.States.AirKickIdle ||
             PlayerMachines.instance.GetPlayerStateMachine().GetState() == (int)PlayerStates.States.AirKickLeft ||
             PlayerMachines.instance.GetPlayerStateMachine().GetState() == (int)PlayerStates.States.AirKickRight)
         {
             enemyStates.SetEvent((int)EnemyStates.BaddieEvents.Fall);
             return;
         }
         enemyStates.SetEvent((int)EnemyStates.BaddieEvents.Hit);
     }
 }