Example #1
0
        // 공격 모션 속도.
        protected void  attack_motion_speed_control()
        {
            chrBehaviorEnemy mine         = this.behavior;
            BasicAction      basic_action = mine.basic_action;

            if (this.melee_attack.step.get_current() == MeleeAttackAction.STEP.ATTACK)
            {
                float current_time    = this.melee_attack.step.get_time();
                float furikaburi_time = 0.38f + 0.3f;

                float play_speed = 0.5f;

                if (current_time < furikaburi_time)
                {
                    // 머리 위로 높이 쳐들 때까지 서서히 느리게.

                    float rate = Mathf.Clamp01(Mathf.InverseLerp(0.0f, furikaburi_time, current_time));

                    play_speed = Mathf.Lerp(0.3f, 0.1f, rate);
                }
                else
                {
                    // 내리 휘두를 때가지 단숨에 빨라진다.

                    float rate = Mathf.Clamp01(Mathf.InverseLerp(furikaburi_time, furikaburi_time + 0.3f, current_time));

                    play_speed = Mathf.Lerp(0.1f, 0.7f, rate);
                }

                basic_action.setMotionPlaySpeed(play_speed);
            }
        }
Example #2
0
        public override void    execute()
        {
            chrBehaviorEnemy mine         = this.behavior;
            BasicAction      basic_action = mine.basic_action;

            if (this.finish_child())
            {
                this.step.set_next(STEP.MOVE);
            }

            chrBehaviorPlayer target_player = this.behavior.selectTargetPlayer(float.MaxValue, float.MaxValue);

            this.melee_attack.target_player = target_player;

            // ---------------------------------------------------------------- //
            // 다음 상태로 이동하는지 체크합니다.

            switch (this.step.do_transition())
            {
            // 걷는 중.
            case STEP.MOVE:
            {
                do
                {
                    if (target_player == null)
                    {
                        break;
                    }
                    if (!this.behavior.isInAttackRange(target_player.control))
                    {
                        break;
                    }

                    //

                    this.push(this.melee_attack);
                    this.step.sleep();
                } while(false);
            }
            break;

            // 멈춰 있다.
            case STEP.REST:
            {
                if (this.step.get_time() > 1.0f)
                {
                    this.step.set_next(STEP.MOVE);
                }

                do
                {
                    if (target_player == null)
                    {
                        break;
                    }
                    if (!this.behavior.isInAttackRange(target_player.control))
                    {
                        break;
                    }

                    //

                    this.push(this.melee_attack);
                    this.step.sleep();
                } while(false);
            }
            break;
            }

            // ---------------------------------------------------------------- //
            // 상태가 전환됐을 때의 초기화.

            while (this.step.get_next() != STEP.NONE)
            {
                switch (this.step.do_initialize())
                {
                // 걷는 중.
                case STEP.MOVE:
                {
                }
                break;
                }
            }

            // ---------------------------------------------------------------- //
            // 각 상태에서의 실행 처리.

            switch (this.step.do_execution(Time.deltaTime))
            {
            // 걷는 중.
            case STEP.MOVE:
            {
                do
                {
                    if (target_player == null)
                    {
                        break;
                    }

                    basic_action.move_dir = MathUtility.calcDirection(mine.control.getPosition(), target_player.control.getPosition());

                    basic_action.setMoveMotionSpeed(1.0f);
                    basic_action.setMoveSpeed(0.6f);

                    basic_action.setMotionPlaySpeed(0.6f);

                    basic_action.executeMove();
                } while(false);
            }
            break;

            // 멈춰있다.
            case STEP.REST:
            {
                basic_action.setMoveMotionSpeed(0.0f);
            }
            break;
            }

            this.spring.execute(Time.deltaTime);

            if (this.spring.isMoving())
            {
                this.scale = Mathf.InverseLerp(-1.0f, 1.0f, this.spring.position);
                this.scale = Mathf.Lerp(1.0f, 2.0f, this.scale);
            }

            this.control.transform.localScale = Vector3.one * this.scale;

            // ---------------------------------------------------------------- //

            this.execute_child();

            if (this.child == this.melee_attack)
            {
                this.attack_motion_speed_control();
            }
        }