Exemple #1
0
        public void SetUserData(NpcStateUserData data)
        {
            if (data == null)
            {
                return;
            }

            CurrentState = data.CurrentState;
            NextState    = data.NextState;
        }
Exemple #2
0
        public bool Walk()
        {
            if (!CanChangeState(NpcStateType.Walk))
            {
                return(false);
            }

            NextState = NpcStateType.Walk;

            return(true);
        }
Exemple #3
0
        public bool Stand()
        {
            if (!CanChangeState(NpcStateType.Stand))
            {
                return(false);
            }

            NextState = NpcStateType.Stand;

            return(true);
        }
Exemple #4
0
        public bool Jump()
        {
            if (!CanChangeState(NpcStateType.Jump))
            {
                return(false);
            }

            NextState = NpcStateType.Jump;

            return(true);
        }
Exemple #5
0
        public void Init(Npc npc)
        {
            Owner = npc;

            States = new NpcBaseState[]
            {
                new NpcStandState(Owner),
                new NpcWalkState(Owner),
                new NpcJumpState(Owner),
                new NpcDeadState(Owner)
            };

            CurrentState = NpcStateType.Stand;
            NextState    = NpcStateType.Invalid;
        }
Exemple #6
0
        private void ChangeState()
        {
            if (Owner == null)
            {
                return;
            }

            if (CurrentState != NpcStateType.Invalid)
            {
                States[(int)CurrentState].Exit();
            }

            CurrentState = NextState;
            NextState    = NpcStateType.Invalid;

            var state = States[(int)CurrentState];

            state.Enter();
        }
Exemple #7
0
 public override bool CanChange(NpcStateType State)
 {
     return(base.CanChange(State));
 }
Exemple #8
0
 public virtual bool CanChange(NpcStateType State)
 {
     return(true);
 }
Exemple #9
0
        public bool CanChangeState(NpcStateType type)
        {
            var state = States[(int)CurrentState];

            return(state.CanChange(type));
        }