Ejemplo n.º 1
0
    public override bool ActionStart()
    {
        Debug.Log("PUSH ANIMATION", Department.PHYSICS, Color.ORANGE);
        arrive_comp = GetComponent <Arrive_Steering>();
        GetComponent <Align_Steering>().SetEnabled(false);
        Movement_Action.Direction dir = GetComponent <Movement_Action>().GetDirection();

        move      = GetComponent <Movement_Action>();
        anim_comp = GetComponent <CompAnimation>();

        GetComponent <PerceptionSightEnemy>().GetPlayerTilePos(out int player_x, out int player_y);
        int tile_x = move.GetCurrentTileX();
        int tile_y = move.GetCurrentTileY();

        int dif_x = player_x - tile_x;
        int dif_y = player_y - tile_y;

        animation_clip_push = "Push";
        anim_comp.PlayAnimationNode("Push");

        target_x = move.GetCurrentTileX();
        target_y = move.GetCurrentTileY();

        target_x += (int)push_direction.x;
        target_y += (int)push_direction.z;

        return(true);
    }
Ejemplo n.º 2
0
    public override ACTION_RESULT ActionUpdate()
    {
        if (player.dying)
        {
            Debug.Log("DON'T ATTACK PLAYER", Department.PLAYER, Color.ORANGE);
            return(ACTION_RESULT.AR_FAIL); //Player is dead, don't attack
        }

        if (state == BWA_STATE.PRE_APPLY && GetComponent <CompAnimation>().IsAnimOverXTime(apply_damage_point))
        {
            anim.SetClipDuration("WideAttack", (attack_duration / (1.0f - apply_damage_point)));

            state = BWA_STATE.POST_APPLY;

            int enemy_tile_x = move.GetCurrentTileX();
            int enemy_tile_y = move.GetCurrentTileY();

            movement_ctrl.GetPlayerPos(out int player_tile_x, out int player_tile_y);
            audio.PlayEvent("BossSwordSwing");

            switch (move.GetDirection())
            {
            case Movement_Action.Direction.DIR_WEST:
                if ((enemy_tile_x - 1 == player_tile_x || enemy_tile_x == player_tile_x) && (player_tile_y == enemy_tile_y || player_tile_y == enemy_tile_y - 1 || player_tile_y == enemy_tile_y + 1))
                {
                    characters_manager.GetDamage(damage);
                }
                break;

            case Movement_Action.Direction.DIR_EAST:
                if ((enemy_tile_x + 1 == player_tile_x || enemy_tile_x == player_tile_x) && (player_tile_y == enemy_tile_y || player_tile_y == enemy_tile_y - 1 || player_tile_y == enemy_tile_y + 1))
                {
                    characters_manager.GetDamage(damage);
                }
                break;

            case Movement_Action.Direction.DIR_NORTH:
                if ((enemy_tile_y - 1 == player_tile_y || enemy_tile_y == player_tile_y) && (player_tile_x == enemy_tile_x || player_tile_x == enemy_tile_x - 1 || player_tile_x == enemy_tile_x + 1))
                {
                    characters_manager.GetDamage(damage);
                }
                break;

            case Movement_Action.Direction.DIR_SOUTH:
                if ((enemy_tile_y + 1 == player_tile_y || enemy_tile_y == player_tile_y) && (player_tile_x == enemy_tile_x || player_tile_x == enemy_tile_x - 1 || player_tile_x == enemy_tile_x + 1))
                {
                    characters_manager.GetDamage(damage);
                }
                break;
            }
        }
        else if (state == BWA_STATE.POST_APPLY && anim.IsAnimationStopped("WideAttack"))
        {
            state = BWA_STATE.WAITING;
            return(ACTION_RESULT.AR_SUCCESS);
        }
        return(ACTION_RESULT.AR_IN_PROGRESS);
    }
    public override bool ActionStart()
    {
        interupt = false;

        /*CompAudio audio = GetComponent<CompAudio>();
         * audio.PlayEvent("Enemy2_Hurt");
         * audio.PlayEvent("SwordHit");*/
        move       = GetComponent <Movement_Action>();
        anim_comp  = GetComponent <CompAnimation>();
        audio_comp = GetComponent <CompAudio>();


        if (next_dmg_type == Enemy_BT.ENEMY_GET_DAMAGE_TYPE.DEFAULT)
        {
            int tile_x              = move.GetCurrentTileX();
            int tile_y              = move.GetCurrentTileY();
            int player_x            = tile_x;
            int player_y            = tile_y;
            MovementController temp = GetLinkedObject("player_obj").GetComponent <MovementController>();
            if (temp != null)
            {
                temp.GetPlayerPos(out int x, out int y);
                player_x = x;
                player_y = y;
            }

            int dif_x = player_x - tile_x;
            int dif_y = player_y - tile_y;

            Movement_Action.Direction dir = move.GetDirection();

            switch (dir)
            {
            case Movement_Action.Direction.DIR_EAST:
                if (dif_x < 0)
                {
                    animation_clip = "HitBack";
                    anim_comp.PlayAnimationNode("HitBack");
                }
                else if (dif_x > 0)
                {
                    animation_clip = "HitFront";
                    anim_comp.PlayAnimationNode("HitFront");
                }
                else if (dif_y < 0)
                {
                    animation_clip = "HitLeft";
                    anim_comp.PlayAnimationNode("HitLeft");
                }
                else if (dif_y > 0)
                {
                    animation_clip = "HitRight";
                    anim_comp.PlayAnimationNode("HitRight");
                }
                break;

            case Movement_Action.Direction.DIR_NORTH:
                if (dif_x < 0)
                {
                    animation_clip = "HitLeft";
                    anim_comp.PlayAnimationNode("HitLeft");
                }
                else if (dif_x > 0)
                {
                    animation_clip = "HitRight";
                    anim_comp.PlayAnimationNode("HitRight");
                }
                else if (dif_y < 0)
                {
                    animation_clip = "HitFront";
                    anim_comp.PlayAnimationNode("HitFront");
                }
                else if (dif_y > 0)
                {
                    animation_clip = "HitBack";
                    anim_comp.PlayAnimationNode("HitBack");
                }
                break;

            case Movement_Action.Direction.DIR_SOUTH:
                if (dif_x < 0)
                {
                    animation_clip = "HitRight";
                    anim_comp.PlayAnimationNode("HitRight");
                }
                else if (dif_x > 0)
                {
                    animation_clip = "HitLeft";
                    anim_comp.PlayAnimationNode("HitLeft");
                }
                else if (dif_y < 0)
                {
                    animation_clip = "HitBack";
                    anim_comp.PlayAnimationNode("HitBack");
                }
                else if (dif_y > 0)
                {
                    animation_clip = "HitFront";
                    anim_comp.PlayAnimationNode("HitFront");
                }
                break;

            case Movement_Action.Direction.DIR_WEST:
                if (dif_x < 0)
                {
                    animation_clip = "HitFront";
                    anim_comp.PlayAnimationNode("HitFront");
                }
                else if (dif_x > 0)
                {
                    animation_clip = "HitBack";
                    anim_comp.PlayAnimationNode("HitBack");
                }
                else if (dif_y < 0)
                {
                    animation_clip = "HitRight";
                    anim_comp.PlayAnimationNode("HitRight");
                }
                else if (dif_y > 0)
                {
                    animation_clip = "HitLeft";
                    anim_comp.PlayAnimationNode("HitLeft");
                }
                break;
            }
        }

        else if (next_dmg_type == Enemy_BT.ENEMY_GET_DAMAGE_TYPE.FIREWALL)
        {
            animation_clip = "HitFire";
            anim_comp.PlayAnimationNode("HitFire");
        }

        anim_comp.SetClipDuration(animation_clip, duration);
        //TODO_AI: Hurt audio
        //GetComponent<CompAudio>().PlayEvent("JaimeHurt");
        return(true);
    }
Ejemplo n.º 4
0
    public BT FindEnemyByTile(int x, int y)
    {
        int size = sword_enemies.Count;

        for (int k = 0; k < size; k++)
        {
            GameObject enemy_t = sword_enemies[k];
            if (enemy_t != null)
            {
                Movement_Action temp_move = enemy_t.GetComponent <Movement_Action>();
                if (temp_move != null)
                {
                    int tile_x = temp_move.GetCurrentTileX();
                    int tile_y = temp_move.GetCurrentTileY();
                    if (x == tile_x && y == tile_y)
                    {
                        if (enemy_t.GetComponent <EnemySword_BT>() != null && enemy_t.GetComponent <EnemySword_BT>().GetCurrentHP() > 0)
                        {
                            return(enemy_t.GetComponent <EnemySword_BT>());
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    Debug.Log("[error] No movement action!");
                }
            }
            else
            {
                Debug.Log("[error] Sword enemy null!");
            }
        }

        size = lance_enemies.Count;

        for (int k = 0; k < size; k++)
        {
            GameObject enemy_t = lance_enemies[k];
            if (enemy_t != null)
            {
                Movement_Action temp_move = enemy_t.GetComponent <Movement_Action>();
                if (temp_move != null)
                {
                    int tile_x = temp_move.GetCurrentTileX();
                    int tile_y = temp_move.GetCurrentTileY();
                    if (x == tile_x && y == tile_y)
                    {
                        if (enemy_t.GetComponent <EnemySpear_BT>() != null && enemy_t.GetComponent <EnemySpear_BT>().GetCurrentHP() > 0)
                        {
                            return(enemy_t.GetComponent <EnemySpear_BT>());
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    Debug.Log("[error] No movement action!");
                }
            }
            else
            {
                Debug.Log("[error] Sowrd enemy null!");
            }
        }

        size = shield_enemies.Count;

        for (int k = 0; k < size; k++)
        {
            GameObject enemy_t = shield_enemies[k];
            if (enemy_t != null)
            {
                Movement_Action temp_move = enemy_t.GetComponent <Movement_Action>();
                if (temp_move != null)
                {
                    int tile_x = temp_move.GetCurrentTileX();
                    int tile_y = temp_move.GetCurrentTileY();
                    if (x == tile_x && y == tile_y)
                    {
                        if (enemy_t.GetComponent <EnemyShield_BT>() != null && enemy_t.GetComponent <EnemyShield_BT>().GetCurrentHP() > 0)
                        {
                            return(enemy_t.GetComponent <EnemyShield_BT>());
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    Debug.Log("[error] No movement action!");
                }
            }
            else
            {
                Debug.Log("[error] Sword enemy null!");
            }
        }

        if (boss != null)
        {
            Movement_Action t_move = boss.GetComponent <Movement_Action>();
            if (t_move != null)
            {
                int tile_x = t_move.GetCurrentTileX();
                int tile_y = t_move.GetCurrentTileY();
                if (x == tile_x && y == tile_y)
                {
                    return(boss.GetComponent <Boss_BT>());
                }
            }
            else
            {
                Debug.Log("[error] No movement action!");
            }
        }

        return(null);
    }