Exemple #1
0
        public void Enter(Player player, int mode, params object[] args)
        {
            if (player == null)
            {
                return;
            }

            EntityRepresentStateName.PlayState(player._PlayerAnimator, mode, RepresentStateDef.IDLE);
        }
Exemple #2
0
        public float _JumpForce = 50.0f; // 跳跃施加的力
        public void Enter(Player player, int mode, params object[] args)
        {
            if (player == null)
            {
                return;
            }

            if (player.CanMove())
            {
                EntityRepresentStateName.PlayState(player._PlayerAnimator, mode, RepresentStateDef.JUMP);
                if (player is LocalPlayer)
                {
                    player._World._NetworkManager._MessageSender.SendPlayerKeyPress(PlayerControl.JumpBegin());
                }
                //player._PlayerRigidbody.AddForce(Vector3.up * _JumpForce, ForceMode.Impulse);
            }
        }
Exemple #3
0
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            ////Debug.Log("On StateEnter ");

            // 为了防止从AnyState再次进入状态导致动作抽风
            animator.SetInteger("action", (int)RepresentStateDef.NONE);

            // 获取当前状态
            RepresentStateDef representState = EntityRepresentStateName.GetStateByHash(stateInfo.shortNameHash);

            if (representState == RepresentStateDef.NONE)
            {
                return;
            }

            PlayerController representEntity = animator.gameObject.GetComponent <PlayerController>();

            if (representEntity == null)
            {
                representEntity = animator.gameObject.transform.parent.GetComponent <PlayerController>();
            }

            if (representEntity == null)
            {
                return;
            }

            Player entity = representEntity.player;

            entity._RepresentState = representState;             // 记录表现状态

            // 获取表现状态对应的逻辑状态
            LogicStateDef logicState = Represent2LogicMap.GetLogicState(representState);

            if (logicState == LogicStateDef.NONE)
            {
                return;
            }

            // 进入逻辑状态
            entity.ChangeState(logicState);
        }