public void UpdateMachine(float time) { if (states.Count == 0) { return; } if (currentStateID == EOrcMovementStates.None) { currentState = defaultState; currentStateID = defaultStateID; } if (currentState == null) { return; } goalID = currentState.CheckTransition(); if (goalID != currentStateID) { currentState.Exit(); TransitionState(goalID); currentStateID = goalID; this.concurrentCanRun = currentState.ConcurrentStateCanRun; currentState.Enter(); if (StateChanged != null) { StateChanged(); } } currentState.Update(time); }
public void Reset() { currentState.Exit(); currentStateID = defaultStateID; currentState = defaultState; defaultState.Enter(); }
public OrcWalkState(float movementSpeed, bool concurrentCanRun, ref IMove orcMove, EOrcMovementStates currentStateID, ref IOrcMovementLogic control, ref Animator animator) { this.movementSpeed = movementSpeed; this.concurrentCanRun = concurrentCanRun; this.orcMove = orcMove; this.currentStateID = currentStateID; this.control = control; this.animator = animator; }
public OrcDrivenUpState(float speedOfDrivenUp, float timeToWaitForWakeUp, bool concurrentCanRun, ref IMove orcMove, EOrcMovementStates currentStateID, ref IOrcMovementLogic control) { this.speedofDrivenUp = speedOfDrivenUp; this.timeToWaitForWakeUp = timeToWaitForWakeUp; this.concurrentCanRun = concurrentCanRun; this.orcMove = orcMove; this.currentStateID = currentStateID; this.control = control; this.elapsedTime = 0; }
public OrcFallState(float lastMoveMultiplier, Vector3 fallVector, bool concurrentCanRun, ref IMove orcMove, EOrcMovementStates currentStateID, ref IOrcMovementLogic control, ref Animator animator) { this.lastMoveMultiplier = lastMoveMultiplier; this.gravityVector = fallVector; this.concurrentCanRun = concurrentCanRun; this.orcMove = orcMove; this.currentStateID = currentStateID; this.control = control; this.animator = animator; }
public void Update(float time) { animator.SetFloat(posXHash, control.InputInfo.PosY, dampTime, time); animator.SetFloat(posYHash, control.InputInfo.PosX, dampTime, time); if (control.InputInfo.PosY == 0 && control.InputInfo.PosX == 0) { currentStateID = EOrcMovementStates.Idle; return; } else { currentStateID = EOrcMovementStates.Walking; orcMove.Move(control.InputInfo.PosX, control.InputInfo.PosY, movementSpeed, time); } }
public void TransitionState(EOrcMovementStates goal) { currentState = states.Find(x => x.StateType == goal); }
public void SetDefaultState(IState <IOrcMovementLogic, EOrcMovementStates> state) { defaultState = state; defaultStateID = state.StateType; }