Exemplo n.º 1
0
        public override void OnUpdate(FSMBase _fsm)
        {
            HeroFSM fsm = (HeroFSM)_fsm;

            // 没血了就死
            if (fsm.parameter.hp <= 0)
            {
                fsm.Destroy();
            }

            return;
        }
Exemplo n.º 2
0
        public override void HandleInput(FSMBase _fsm)
        {
            HeroFSM fsm = (HeroFSM)_fsm;

            float x_Input = Input.GetAxisRaw("Horizontal");

            // 如果没速度了,该站立了
            if (Vector3.Dot(fsm.parameter.rb.velocity, new Vector3(1 * fsm.parameter.transform.localScale.x, 0, 0)) == 0)
            {
                fsm.TransactionState(HeroStates.idleState);
            }
        }
Exemplo n.º 3
0
        public override void OnUpdate(FSMBase _fsm)
        {
            HeroFSM fsm = (HeroFSM)_fsm;

            // 进入静止状态,重置跳跃次数
            fsm.parameter.jumpTimes = fsm.parameter.jumpLimit;

            // 人物角色移动方向在人物面朝方向的变量上有分量时,进入跑步状态
            if (Vector3.Dot(fsm.parameter.rb.velocity, new Vector3(1 * fsm.parameter.transform.localScale.x, 0, 0)) > 0)
            {
                fsm.TransactionState(runState);
            }

            return;
        }
Exemplo n.º 4
0
        public override void HandleInput(FSMBase _fsm)
        {
            HeroFSM fsm = (HeroFSM)_fsm;

            // 获取通用移动所有可能的输入
            float h_move   = Input.GetAxisRaw("Horizontal"); //左右移动
            bool  isCrouch = Input.GetKey(KeyCode.S);        //下蹲
            float jump     = Input.GetAxis("Jump");          //跳跃

            // 跳跃次数用完了便不允许跳跃
            if (--fsm.parameter.jumpTimes < 0)
            {
                jump = 0;
            }

            // 赋予左右移动的速度(奔跑或下蹲)与跳跃速度
            fsm.parameter.rb.velocity = new Vector2(isCrouch ? h_move * fsm.parameter.speedScale / 2 : h_move * fsm.parameter.speedScale,
                                                    jump != 0 ? jump * fsm.parameter.jumpScale : fsm.parameter.rb.velocity.y);

            // 转向
            fsm.parameter.transform.localScale = new Vector3(Vector3.Dot(fsm.parameter.rb.velocity, Vector3.right) == 0 ?
                                                             fsm.parameter.transform.localScale.x : Vector3.Dot(fsm.parameter.rb.velocity, Vector3.right) > 0 ? 1 : -1, 1, 1);
        }
Exemplo n.º 5
0
        public override void OnExit(FSMBase _fsm)
        {
            HeroFSM fsm = (HeroFSM)_fsm;

            return;
        }
Exemplo n.º 6
0
 public override void HandleInput(FSMBase _fsm)
 {
     HeroFSM fsm = (HeroFSM)_fsm;
 }
Exemplo n.º 7
0
        public override void OnEnter(FSMBase _fsm)
        {
            HeroFSM fsm = (HeroFSM)_fsm;

            fsm.parameter.anim.Play("Player_Idle");
        }
Exemplo n.º 8
0
 public override void OnEnter(FSMBase _fsm)
 {
     HeroFSM fsm = (HeroFSM)_fsm;
 }
Exemplo n.º 9
0
        public override void OnUpdate(FSMBase _fsm)
        {
            HeroFSM fsm = (HeroFSM)_fsm;

            return;
        }