예제 #1
0
    public override bool ActionStart()
    {
        player.GetComponent<MovementController>().GetPlayerPos(out player_x, out player_y);
        objective = new PathNode(player_x, player_y);

        origin = GetComponent<Movement_Action>().GetCurrentTile();        

        movement_x = player_x * GetComponent<Movement_Action>().tile_size - trans.position.x;
        movement_z = player_y * GetComponent<Movement_Action>().tile_size - trans.position.z;

        float x_factor = movement_x / (Mathf.Abs(movement_x) + Mathf.Abs(movement_z));
        float z_factor = movement_z / (Mathf.Abs(movement_x) + Mathf.Abs(movement_z));

        speed_x = speed * x_factor;
        speed_z = speed * z_factor;

        movement_x = Mathf.Abs(movement_x);
        movement_z = Mathf.Abs(movement_z);

        //Set Anim Duration
        float duration = GetDuration();
        GetComponent<CompAnimation>().PlayAnimationNode("Charge");

        pushed = false;

        phase = Charge_Phase.CP_CHARGE;

        GetComponent<CompAudio>().PlayEvent("BossRun");
        GetComponent<CompAudio>().PlayEvent("AttackPreparation");

        return true;
    }
예제 #2
0
    // Update is called once per frame
    public override ACTION_RESULT ActionUpdate()
    {
        if (player_manager.dying)
        {
            Debug.Log("DON'T ATTACK PLAYER", Department.PLAYER, Color.YELLOW);
            return ACTION_RESULT.AR_FAIL; //Player is dead, don't attack
        }

        switch (phase)
        {
            case Charge_Phase.CP_CHARGE:
                Vector3 pos = new Vector3(trans.position);
                pos.x = pos.x + speed_x * Time.deltaTime;
                pos.z = pos.z + speed_z * Time.deltaTime;
                trans.position = pos;

                movement_x -= Mathf.Abs(speed_x) * Time.deltaTime;
                movement_z -= Mathf.Abs(speed_z) * Time.deltaTime;

                player.GetComponent<MovementController>().GetPlayerPos(out player_x, out player_y);
                float tile_size = GetComponent<Movement_Action>().tile_size;
                uint current_x = (uint)(pos.x / tile_size);
                uint current_y = (uint)(pos.z / tile_size);

                if (current_x == player_x && current_y == player_y && pushed == false)
                {
                    PathNode push_tile = GetPushTile();           
                    pushed = true;
                    if (player.GetComponent<CharactersManager>().Push(damage, push_tile) == true)
                        GetComponent<CompAudio>().PlayEvent("SwordHit");
                }

                if (movement_z <= 0.0f && movement_x <= 0.0f)
                {
                    Vector3 final_pos = new Vector3(trans.position);
                    final_pos.x = objective.GetTileX() * tile_size;
                    final_pos.z = objective.GetTileY() * tile_size;
                    trans.position = final_pos;

                    GetComponent<Movement_Action>().tile.SetCoords(objective.GetTileX(), objective.GetTileY());
                    GetComponent<Movement_Action>().ClearPath();
                    GetComponent<CompAnimation>().PlayAnimationNode("ChargeAttack");
                    GetComponent<CompAudio>().StopEvent("BossRun");
                    GetComponent<CompAudio>().PlayEvent("BossChargeHit");
                    phase = Charge_Phase.CP_ATTACK;

                    if (objective.GetTileX() == player_x && objective.GetTileY() == player_y && pushed == false)
                    {
                        PathNode push_tile = GetPushTile();
                        pushed = true;
                        if (player.GetComponent<CharactersManager>().Push(damage, push_tile) == true)
                            GetComponent<CompAudio>().PlayEvent("SwordHit");
                    }
                }
                break;

            case Charge_Phase.CP_ATTACK:
                if (GetComponent<CompAnimation>().IsAnimationStopped("ChargeAttack"))
                    return ACTION_RESULT.AR_SUCCESS;
                break;
        }

        return ACTION_RESULT.AR_IN_PROGRESS;
    }