void Start()
    {
        map    = GetLinkedObject("map");
        player = GetLinkedObject("player");

        align          = GetComponent <Align_Steering>();
        arrive         = GetComponent <Arrive_Steering>();
        seek           = GetComponent <Seek_Steering>();
        anim_comp      = GetComponent <CompAnimation>();
        transform_comp = GetComponent <Transform>();
        audio_comp     = GetComponent <CompAudio>();

        player_t = GetLinkedObject("player_obj");

        BT bt = GetComponent <EnemySword_BT>();

        if (bt == null)
        {
            bt = GetComponent <EnemyShield_BT>();
        }
        if (bt == null)
        {
            bt = GetComponent <EnemySpear_BT>();
        }
        if (bt == null)
        {
            bt = GetComponent <Boss_BT>();
        }

        float interpolation = bt.GetCurrentInterpolation();

        current_max_vel       = hurt_max_vel + (max_vel - hurt_max_vel) * interpolation;
        current_max_accel     = hurt_accel + (max_accel - hurt_accel) * interpolation;
        current_max_rot_vel   = hurt_max_rot_vel + (max_rot_vel - hurt_max_rot_vel) * interpolation;
        current_max_rot_accel = hurt_max_rot_accel + (max_rot_accel - hurt_max_rot_accel) * interpolation;

        Vector3 fw = transform_comp.GetForwardVector();

        path = new List <PathNode>();

        //Set Occupied tile in Pathfinder
        tile = new PathNode(0, 0);
        tile.SetCoords((int)(transform_comp.position.x / tile_size + Mathf.Epsilon), (int)(transform_comp.position.z / tile_size + Mathf.Epsilon));
        map.GetComponent <Pathfinder>().UpdateOccupiedTiles(gameObject.GetName(), tile);

        //Set direction
        SetDirection();

        //Sideways animation speeds
        anim_comp.SetClipDuration("WalkRight", sideways_anim_speed);
        anim_comp.SetClipDuration("WalkLeft", sideways_anim_speed);
        anim_comp.SetClipDuration("WalkBack", sideways_anim_speed);
        anim_comp.SetClipDuration("WalkFront", sideways_anim_speed);

        blocking = false;

        path.Clear();
    }
    public override bool ActionStart()
    {
        player = GetLinkedObject("target").GetComponent <CharactersManager>();

        if (player == null)
        {
            Debug.Log("[error] Attack Action Start: Player is null!");
        }

        anim_comp  = GetComponent <CompAnimation>();
        audio_comp = GetComponent <CompAudio>();

        if (player.dying == false)
        {
            anim_comp.SetClipDuration("Attack", attack_duration);
            anim_comp.PlayAnimationNode("Attack");
            Debug.Log("Back to Attack", Department.IA);
            audio_comp.PlayEvent("Enemy1_Slash");
        }


        damage_done   = false;
        shield_attack = false;

        //Interrupt player action
        return(true);
    }
 public override bool ActionStart()
 {
     comp_animation = GetComponent <CompAnimation>();
     comp_audio     = GetComponent <CompAudio>();
     comp_animation.PlayAnimationNode("Draw");
     comp_animation.SetClipDuration("Draw", duration);
     return(true);
 }
Exemple #4
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);
    }
Exemple #5
0
 public override bool ActionStart()
 {
     state = SWA_STATE.PRE_APPLY;
     anim  = GetComponent <CompAnimation>();
     anim.SetTransition("ToAttack");
     anim.SetClipDuration("Attack", attack_duration);
     player = GetLinkedObject("target").GetComponent <CharactersManager>();
     //Interrupt player action
     return(true);
 }
Exemple #6
0
 public override bool ActionStart()
 {
     GetComponent <Align_Steering>().SetEnabled(false);
     GetComponent <Arrive_Steering>().SetEnabled(false);
     GetComponent <Seek_Steering>().SetEnabled(false);
     //GetComponent<CompAnimation>().SetTransition("ToStun");
     anim_comp = GetComponent <CompAnimation>();
     anim_comp.SetClipDuration("Stun", stun_duration);
     anim_comp.PlayAnimationNode("Stun");
     return(true);
 }
    public override bool ActionStart()
    {
        anim_comp  = GetComponent <CompAnimation>();
        audio_comp = GetComponent <CompAudio>();

        anim_comp.PlayAnimationNode("Die");
        //TODO_AI: Die audio
        audio_comp.PlayEvent("Enemy_SwordDrop");

        //PLAY COMBAT MUSIC
        Audio.ChangeState("MusicState", "None");
        GetLinkedObject("event_manager").GetComponent <PerceptionManager>().player_seen = false;
        Debug.Log("COMBAT OFF", Department.PLAYER, Color.BLUE);

        StatsScore.KillEnemy();

        //Play Dead Audio
        if (GetComponent <EnemyShield_BT>() != null)
        {
            audio_comp.PlayEvent("Enemy3_Dead");
        }
        else if (GetComponent <EnemySpear_BT>() != null)
        {
            audio_comp.PlayEvent("Enemy2_Dead");
        }
        else if (GetComponent <EnemySword_BT>() != null)
        {
            audio_comp.PlayEvent("Enemy1_Dead");
        }

        //Deactivate Listener
        if (GetComponent <SpearGuard_Listener>() != null)
        {
            GetComponent <SpearGuard_Listener>().SetEnabled(false);
        }
        else if (GetComponent <ShieldGuard_Listener>() != null)
        {
            GetComponent <ShieldGuard_Listener>().SetEnabled(false);
        }
        else if (GetComponent <SwordGuard_Listener>() != null)
        {
            GetComponent <SwordGuard_Listener>().SetEnabled(false);
        }

        anim_comp.SetClipDuration("Die", duration);
        GetComponent <CompCollider>().CollisionActive(false);
        return(true);
    }
    public override bool ActionStart()
    {
        anim_comp = GetComponent <CompAnimation>();

        anim_comp.SetTransition("ToSheatheSword");
        //TODO_AI: Audio disengage?
        //GetComponent<CompAudio>().PlayEvent("Dracarys");
        anim_comp.SetClipDuration("Sheathe Sword", duration);


        //PLAY COMBAT MUSIC
        Audio.ChangeState("MusicState", "None");
        GetLinkedObject("event_manager").GetComponent <PerceptionManager>().player_seen = false;
        Debug.Log("COMBAT OFF", Department.PLAYER, Color.BLUE);

        return(true);
    }
Exemple #9
0
    public override bool ActionStart()
    {
        state     = SWA_STATE.PRE_APPLY;
        anim_comp = GetComponent <CompAnimation>();

        player = GetLinkedObject("target").GetComponent <CharactersManager>();


        if (player.dying == false)
        {
            anim_comp.SetClipDuration("Attack", attack_duration);
            anim_comp.PlayAnimationNode("Attack");
            GetComponent <CompAudio>().PlayEvent("Enemy2_Slash");
        }

        //Interrupt player action
        return(true);
    }
    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);
    }