Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
 public void Reset()
 {
     currentState.Exit();
     currentStateID = defaultStateID;
     currentState   = defaultState;
     defaultState.Enter();
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
0
    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);
        }
    }
Exemplo n.º 7
0
 public void TransitionState(EOrcMovementStates goal)
 {
     currentState = states.Find(x => x.StateType == goal);
 }
Exemplo n.º 8
0
 public void SetDefaultState(IState <IOrcMovementLogic, EOrcMovementStates> state)
 {
     defaultState   = state;
     defaultStateID = state.StateType;
 }