public void SetUserData(NpcStateUserData data) { if (data == null) { return; } CurrentState = data.CurrentState; NextState = data.NextState; }
public bool Walk() { if (!CanChangeState(NpcStateType.Walk)) { return(false); } NextState = NpcStateType.Walk; return(true); }
public bool Stand() { if (!CanChangeState(NpcStateType.Stand)) { return(false); } NextState = NpcStateType.Stand; return(true); }
public bool Jump() { if (!CanChangeState(NpcStateType.Jump)) { return(false); } NextState = NpcStateType.Jump; return(true); }
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; }
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(); }
public override bool CanChange(NpcStateType State) { return(base.CanChange(State)); }
public virtual bool CanChange(NpcStateType State) { return(true); }
public bool CanChangeState(NpcStateType type) { var state = States[(int)CurrentState]; return(state.CanChange(type)); }