Exemple #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);
    }
Exemple #2
0
    bool CanISeparate(Movement_Action.Direction dir, out uint return_next_tile_x, out uint return_next_tile_y)
    {
        //This function is to calculate the tile behind the enemy
        //and see if the enemy should attack or he can separate and then attack
        int tile_x_enemy = GetComponent <Movement_Action>().GetCurrentTileX();
        int tile_y_enemy = GetComponent <Movement_Action>().GetCurrentTileY();

        bool can_i_separate_b = false;

        uint next_tile_x = 0;
        uint next_tile_y = 0;

        //This switch is only to set the direction opposite of the player
        //to see if it is possible walk
        switch (dir)
        {
        case Movement_Action.Direction.DIR_NORTH:
            next_tile_x = (uint)tile_x_enemy;
            next_tile_y = (uint)tile_y_enemy + 1;
            break;

        case Movement_Action.Direction.DIR_WEST:
            next_tile_x = (uint)tile_x_enemy + 1;
            next_tile_y = (uint)tile_y_enemy;
            break;

        case Movement_Action.Direction.DIR_SOUTH:
            next_tile_x = (uint)tile_x_enemy;
            next_tile_y = (uint)tile_y_enemy - 1;
            break;

        case Movement_Action.Direction.DIR_EAST:
            next_tile_x = (uint)tile_x_enemy - 1;
            next_tile_y = (uint)tile_y_enemy;
            break;
        }

        //We want to return if it is possible and also if we already did the calcules
        //to know what tile should we move we can take advantage of

        can_i_separate_b = GetLinkedObject("map").GetComponent <Pathfinder>().IsWalkableTile(next_tile_x, next_tile_y);

        return_next_tile_x = next_tile_x;
        return_next_tile_y = next_tile_y;

        return(can_i_separate_b);
    }
Exemple #3
0
    protected override void InCombatDecesion()
    {
        //Attack action
        if (InRange())
        {
            bool attack_ready = attack_timer >= attack_cooldown;

            if (!GetComponent <Movement_Action>().LookingAtPlayer())
            {
                current_action.Interupt();
                next_action = GetComponent <FacePlayer_Action>();
                return;
            }

            else if (shield_block_timer >= shield_block_cd && player.GetComponent <CharactersManager>().GetCurrentCharacterName() == "Jaime")
            {
                MovementController.Direction player_dir = GetLinkedObject("player_obj").GetComponent <MovementController>().GetPlayerDirection();
                Movement_Action.Direction    enemy_dir  = GetComponent <Movement_Action>().SetDirection();
                if (player_dir == MovementController.Direction.NORTH && enemy_dir == Movement_Action.Direction.DIR_SOUTH ||
                    player_dir == MovementController.Direction.SOUTH && enemy_dir == Movement_Action.Direction.DIR_NORTH ||
                    player_dir == MovementController.Direction.EAST && enemy_dir == Movement_Action.Direction.DIR_WEST ||
                    player_dir == MovementController.Direction.WEST && enemy_dir == Movement_Action.Direction.DIR_EAST)
                {
                    next_action = GetComponent <ShieldBlock_Action>();
                }
                return;
            }

            else if (attack_ready)
            {
                attack_timer = 0.0f;
                state        = AI_STATE.AI_ATTACKING;
                Attack_Action action = GetComponent <Attack_Action>();
                action.SetDamage(attack_damage);
                current_action = action;
                current_action.ActionStart();
                return;
            }
            else
            {
                state          = AI_STATE.AI_IDLE;
                current_action = GetComponent <IdleAttack_Action>();
                current_action.ActionStart();
                return;
            }
        }
        else if (player_detected == true && Disable_Movement_Gameplay_Debbuger == false)
        {
            if (player.GetComponent <CharactersManager>().GetCurrentCharacterName() == "Jaime")
            {
                GetComponent <ChasePlayer_Action>().SetBlocking(false);
                GetComponent <ChasePlayer_Action>().ActionStart();
                current_action = GetComponent <ChasePlayer_Action>();
            }
            else
            {
                GetComponent <ChasePlayer_Action>().SetBlocking(true);
                GetComponent <ChasePlayer_Action>().ActionStart();
                current_action = GetComponent <ChasePlayer_Action>();
            }

            return;
        }
    }
    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);
    }
Exemple #5
0
    protected override void InCombatDecesion()
    {
        Debug.Log("In Combat Decision");
        int tiles_to_player = GetDistanceInRange();

        if (tiles_to_player == 1)
        {
            if (!GetComponent <Movement_Action>().LookingAtPlayer())
            {
                current_action.Interupt();
                next_action = GetComponent <FacePlayer_Action>();
                return;
            }

            //We need the direction to know if behind of the enemy there is
            //a tile wakable to make our separate or not.
            Movement_Action.Direction current_dir = GetComponent <Movement_Action>().SetDirection();

            uint next_tile_x = 0;
            uint next_tile_y = 0;

            if (CanISeparate(current_dir, out next_tile_x, out next_tile_y))
            {
                int attack_type_value = rand.Next(1, 10);
                RandomAttack(attack_type_value, next_tile_x, next_tile_y);
                return;
            }
            else
            {
                bool attack_ready = attack_timer >= attack_cooldown;
                if (attack_ready)
                {
                    attack_timer = 0.0f;
                    state        = AI_STATE.AI_ATTACKING;
                    SpearAttack_Action action = GetComponent <SpearAttack_Action>();
                    action.IsMeleeAttack(true);
                    action.SetDamage(attack_damage);
                    current_action = action;
                    current_action.ActionStart();
                    return;
                }
                else
                {
                    state          = AI_STATE.AI_IDLE;
                    current_action = GetComponent <IdleAttack_Action>();
                    current_action.ActionStart();
                    return;
                }
            }
        }
        else if (tiles_to_player == 2)
        {
            if (!GetComponent <Movement_Action>().LookingAtPlayer())
            {
                current_action.Interupt();
                next_action = GetComponent <FacePlayer_Action>();
                return;
            }

            bool attack_ready = attack_timer >= attack_cooldown;
            if (attack_ready)
            {
                attack_timer = 0.0f;
                state        = AI_STATE.AI_ATTACKING;
                SpearAttack_Action action = GetComponent <SpearAttack_Action>();
                action.IsMeleeAttack(false);
                action.SetDamage(attack_damage);
                current_action = action;
                current_action.ActionStart();
                return;
            }
            else
            {
                state          = AI_STATE.AI_IDLE;
                current_action = GetComponent <IdleAttack_Action>();
                current_action.ActionStart();
                return;
            }
        }

        if (player_detected == true && Disable_Movement_Gameplay_Debbuger == false)
        {
            GetComponent <ChasePlayer_Action>().ActionStart();
            current_action = GetComponent <ChasePlayer_Action>();
            return;
        }
    }