Example #1
0
 public override bool ApplyDamage(float damage, ENEMY_GET_DAMAGE_TYPE damage_type)
 {
     base.ActivateHUD(spear_name);
     return(base.ApplyDamage(damage, damage_type));
 }
Example #2
0
    public override bool ApplyDamage(float damage, ENEMY_GET_DAMAGE_TYPE damage_type)
    {
        base.ActivateHUD(shield_name);

        switch (life_state)
        {
        case ENEMY_STATE.ENEMY_ALIVE:
            if (GetComponent <ShieldBlock_Action>().IsBlocking() == true || GetComponent <ChasePlayer_Action>().IsBlocking() == true)
            {
                if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREWALL)
                {
                    audio_comp.PlayEvent("Enemy3_Hurt");
                    return(base.ApplyDamage(damage, damage_type));
                }
                else if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREBALL)
                {
                    Debug.Log("FIREBALL BLOCKED!", Department.PLAYER, Color.RED);
                    audio_comp.PlayEvent("Enemy3_Hurt");
                    return(base.ApplyDamage(damage * fireball_pen, damage_type));
                }
                else if (damage_type == ENEMY_GET_DAMAGE_TYPE.ARROW)
                {
                    Debug.Log("ARROW BLOCKED!", Department.PLAYER, Color.RED);
                    audio_comp.PlayEvent("Enemy3_Hurt");
                    return(base.ApplyDamage(damage * arrow_pen, damage_type));
                }
                else if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREBREATH)
                {
                    Debug.Log("FIREBREATH BLOCKED!", Department.PLAYER, Color.RED);
                    audio_comp.PlayEvent("Enemy3_Hurt");
                    return(base.ApplyDamage(damage * firebreath_pen, damage_type));
                }
                else
                {
                    GetComponent <ShieldBlock_Action>().DecreaseBlockTime();
                    audio_comp.PlayEvent("Enemy3_ShieldBlock");
                    base.UpdateHUD();
                    return(false);
                }
            }
            else
            {
                return(base.ApplyDamage(damage, damage_type));
            }
            break;

        case ENEMY_STATE.ENEMY_DAMAGED:
            if (GetComponent <ShieldBlock_Action>().IsBlocking() == true || GetComponent <ChasePlayer_Action>().IsBlocking() == true)
            {
                if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREWALL)
                {
                    audio_comp.PlayEvent("Enemy3_Hurt");
                    return(base.ApplyDamage(damage, damage_type));
                }
                else if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREBALL)
                {
                    Debug.Log("FIREBALL BLOCKED!", Department.PLAYER, Color.RED);
                    audio_comp.PlayEvent("Enemy3_Hurt");
                    return(base.ApplyDamage(damage * fireball_pen, damage_type));
                }
                else if (damage_type == ENEMY_GET_DAMAGE_TYPE.ARROW)
                {
                    Debug.Log("ARROW BLOCKED!", Department.PLAYER, Color.RED);
                    audio_comp.PlayEvent("Enemy3_Hurt");
                    return(base.ApplyDamage(damage * arrow_pen, damage_type));
                }
                else if (damage_type == ENEMY_GET_DAMAGE_TYPE.FIREBREATH)
                {
                    Debug.Log("FIREBREATH BLOCKED!", Department.PLAYER, Color.RED);
                    audio_comp.PlayEvent("Enemy3_Hurt");
                    return(base.ApplyDamage(damage * firebreath_pen, damage_type));
                }
                else
                {
                    GetComponent <ShieldBlock_Action>().DecreaseBlockTime();
                    GetComponent <CompAnimation>().PlayAnimationNode("Block");
                    audio_comp.PlayEvent("Enemy3_ShieldBlock");
                    base.UpdateHUD();
                    return(false);
                }
            }
            else
            {
                audio_comp.PlayEvent("Enemy3_Hurt");
                return(base.ApplyDamage(damage, damage_type));
            }
            break;

        case ENEMY_STATE.ENEMY_STUNNED:
            audio_comp.PlayEvent("Enemy3_Hurt");
            return(base.ApplyDamage(damage, damage_type));

            break;

        case ENEMY_STATE.ENEMY_DEAD:
        default:
            break;
        }
        return(true);
    }
Example #3
0
    public virtual bool ApplyDamage(float damage, ENEMY_GET_DAMAGE_TYPE damage_type)
    {
        if (current_action.action_type != Action.ACTION_TYPE.PUSHBACK_ACTION)
        {
            Debug.Log("Yes push hit", Department.PHYSICS, Color.BLUE);

            if (GetComponent <EnemySpear_BT>() != null)
            {
                audio_comp.PlayEvent("Enemy2_Hurt");
            }

            if (GetComponent <EnemySword_BT>() != null)
            {
                audio_comp.PlayEvent("Enemy1_Hurt");
            }

            next_action = GetComponent <GetHit_Action>();
            GetComponent <GetHit_Action>().SetHitType(damage_type);
            // if (GetComponent<EnemySpear_BT>() == null)
            //  InterruptAction();
        }
        else
        {
            Debug.Log("Not push hit", Department.STAGE, Color.PINK);
        }

        if (current_action.action_type == Action.ACTION_TYPE.MOVE_ACTION || current_action.action_type == Action.ACTION_TYPE.INVESTIGATE_ACTION)
        {
            Debug.Log("TIME TO FIGHT", Department.PHYSICS, Color.PINK);

            current_action.Interupt();
            next_action = GetComponent <Engage_Action>();
            MovementController temp_move = player.GetComponent <MovementController>();
            GetComponent <PerceptionEmitter>().TriggerPlayerSeenEvent(10.0f, temp_move.curr_x, temp_move.curr_y, this.gameObject,
                                                                      GetComponent <Movement_Action>().GetCurrentTileX(), GetComponent <Movement_Action>().GetCurrentTileY());
        }

        current_hp -= damage;
        //ChangeTexturesToDamaged();

        current_interpolation = current_hp / total_hp;
        dmg_alpha            += 0.2f;
        if (current_hp <= 0)
        {
            //GetComponent<CompAnimation>().SetClipsSpeed(anim_speed);
            state      = AI_STATE.AI_DEAD;
            life_state = ENEMY_STATE.ENEMY_DEAD;

            if (gameObject.GetComponent <CompCollider>() != null)
            {
                gameObject.GetComponent <CompCollider>().CollisionActive(false);
            }
            next_action = GetComponent <Die_Action>();
            current_action.Interupt();
            if (GetComponent <EnemySword_BT>() != null)
            {
                enemies_manager.GetComponent <EnemiesManager>().DeleteSwordEnemy(GetComponent <EnemySword_BT>().gameObject);
            }
            else if (GetComponent <EnemyShield_BT>() != null)
            {
                enemies_manager.GetComponent <EnemiesManager>().DeleteShieldEnemy(GetComponent <EnemyShield_BT>().gameObject);
            }
            else if (GetComponent <EnemySpear_BT>() != null)
            {
                enemies_manager.GetComponent <EnemiesManager>().DeleteLanceEnemy(GetComponent <EnemySpear_BT>().gameObject);
            }
        }
        else if (life_state != ENEMY_STATE.ENEMY_DAMAGED && current_hp < total_hp * damaged_limit)
        {
            life_state = ENEMY_STATE.ENEMY_DAMAGED;
            //ChangeTexturesToDamaged();
        }

        UpdateHUD();

        return(true);
    }