private void CreateStateMachine() { switch (currentStateMachineType) { case StateMachineEnumTypes.START: currentStateMachine = new StartStateMachine(currentStateMachineType); break; case StateMachineEnumTypes.GAME: currentStateMachine = new GameStateMachine(currentStateMachineType); break; case StateMachineEnumTypes.GAMEOVER: currentStateMachine = new GameOverStateMachine(currentStateMachineType); break; case StateMachineEnumTypes.LOADING: currentStateMachine = new LoadingStateMachine(currentStateMachineType); break; case StateMachineEnumTypes.REPLAY: currentStateMachine = new ReplayStateParent(currentStateMachineType); break; } }
void Awake() { state.executingStateMachine = stateMachine = this; localTransform = base.transform; Represent(base.gameObject); OnAwake(); }
public override void Start(StateMachineBase _stateMachine) { base.Start(_stateMachine); SetUpRound(GamePlayManager.I.CurrentRound, GamePlayManager.I.currentLevel); CheckLifeCards(); stateMachine.NotifyTheStateIsOver(); }
public override void Start(StateMachineBase _stateMachine) { base.Start(_stateMachine); Debug.Log("CombatPhase iniziata"); for (int i = 0; i < GamePlayManager.I.GetNumberOfColumns(); i++) { List <CardData> cards = GamePlayManager.I.GetCardsInColumn(i); switch (cards.Count) { case 0: break; case 1: //Prende l'altro player e sottrae alla sua vita il valore dell'attacco della carta giocata GamePlayManager.I.GetOtherPlayer(GamePlayManager.I.GetPlayerOwner(cards[0])).Life -= cards[0].Attack; break; case 2: // fa il combattimento tra le due carte cards[0].Life -= cards[1].Attack; cards[1].Life -= cards[0].Attack; break; default: break; } } stateMachine.NotifyTheStateIsOver(); }
public override void Start(StateMachineBase _stateMachine) { base.Start(_stateMachine); CardView.OnBeginDragCard += OnBeginDrag; CardView.OnDragCard += OnDrag; CardView.OnDropCard += OnDrop; CurrentPlayerIndex = 0; Debug.Log("StrategicPhase iniziata"); }
private IEnumerator ChangeState(Enum state, object arg, StateMachineBase callingObject, GameState oldState, GameState newState) { yield return(StartCoroutine(oldState.ExitState())); yield return(StartCoroutine(newState.EnterStateArgs(arg))); callingObject.currentState = state; _currentState = newState; }
internal StateMachineContextBase(StateMachineBase <TState, TTransition, TPayload> stateMachine, StateMachineState <TState, TTransition, TPayload> currentState, TPayload payload) { this.stateMachine = stateMachine; this.Payload = payload; this.CurrentState = currentState; this.stateElapsedTime = Stopwatch.StartNew(); this.totalElapsedTime = Stopwatch.StartNew(); this.CurrentLifecycle = StateMachineLifetime.Running; this.tokenSource = new CancellationTokenSource(); }
private void GoToPhase3(InputAction.CallbackContext _context) { BossControllerBase bossCtrl = FindObjectOfType <BossControllerBase>(); if (bossCtrl != null && bossCtrl.IsSetuppedAndEnabled()) { StateMachineBase bossSM = bossCtrl.GetComponent <StateMachineBase>(); if (bossSM != null) { bossSM.GoToState("Phase3"); } } }
public override void OnInspectorGUI() { StateMachineBase stateMachine = (StateMachineBase)target; EditorGUILayout.LabelField("Previous State: " + stateMachine.lastState); EditorGUILayout.LabelField("Current State: " + stateMachine.currentState); EditorGUILayout.Separator(); DrawDefaultInspector(); if (stateMachine.lastState != stateMachine.currentState) { Repaint(); } }
public void SetState(Enum state, object arg, StateMachineBase callingObject) { GameState oldGameState = _currentState; // Set object state to an empty one callingObject.currentState = null; _currentState = _emptyState; // Create the new state Func <object, IEnumerator> enterState = callingObject.ConfigureDelegate <Func <object, IEnumerator> >(state, "EnterState", GameState.DoNothing); Func <IEnumerator> exitState = callingObject.ConfigureDelegate <Func <IEnumerator> >(state, "ExitState", GameState.DoNothing); GameState newGameState = new GameState(enterState, exitState); StartCoroutine(ChangeState(state, arg, callingObject, oldGameState, newGameState)); }
private const float MOVEMENT_STOP_SPEED = 3f; // how fast the camera's movement comes to a stop when an axis is zero #endregion void Awake() { //if the static instance of this camera is null, assign it if (m_instance == null) { m_instance = this; } //assign the states that this camera object will use m_stateMachine = new StateMachineBase(); m_followState = new State_Camera_Follow(this); m_orbitState = new State_Camera_Orbit(this); //store the initial values for resetting the camera's position later. SetDefaultValues(); }
/// <summary> /// Builds the state machine. /// </summary> /// <returns>The state machine.</returns> public IStateMachine <TState, TTransition, TPayload> Compile() { var stateMachine = new StateMachineBase <TState, TTransition, TPayload>(this.faultHandler); foreach (var state in this.states.Values) { stateMachine.AddState(new StateMachineState <TState, TTransition, TPayload>(state.State, stateMachine, state.OnEnter, state.OnEnterFaultHandler)); } foreach (var transition in this.states.Values.SelectMany(state => state.Transitions)) { stateMachine.AddTransition(transition.Message, transition.StartState.State, transition.EndState.State, transition.TransitionIntercepts); } return(stateMachine); }
public void SetState(Enum stateToActivate, StateMachineBase useStateMachine) { if (state.executingStateMachine == useStateMachine && stateToActivate == state.currentState) { return; } ChangingState(); state.currentState = stateToActivate; state.executingStateMachine = useStateMachine; if (useStateMachine != this) { useStateMachine.stateMachine = this; } state.executingStateMachine.state.currentState = stateToActivate; useStateMachine.Represent(gameObject); ConfigureCurrentState(); }
public StateCheckScore(StateMachineBase stateMachine) : base(stateMachine) { _host = (GameHost)stateMachine; }
public override void Start(StateMachineBase _stateMachine) { base.Start(_stateMachine); SetUpPlayers(GamePlayManager.I.currentLevel); stateMachine.NotifyTheStateIsOver(); }
public override void Start(StateMachineBase _stateMachine) { base.Start(_stateMachine); CheckWinner(); }
public override void Start(StateMachineBase _stateMachine) { base.Start(_stateMachine); SetupGameplay(); stateMachine.NotifyTheStateIsOver(); }
public StateWaitTurn(StateMachineBase stateMachine) : base(stateMachine) { _host = (GameHost)stateMachine; }
public StateCheckTurn(StateMachineBase stateMachine) : base(stateMachine) { _client = (GameClient)stateMachine; }
public StateWaitScore(StateMachineBase stateMachine) : base(stateMachine) { _client = (GameClient)stateMachine; }
public override void Start(StateMachineBase _stateMachine) { base.Start(_stateMachine); stateMachine.CreateNestedSM <InGameSM>(); }
public virtual void Start(StateMachineBase _stateMachine) { stateMachine = _stateMachine; }
public async Task PersistAsync(StateMachineBase stateMachine) { await _modelRepo.AddOrUpdateAsync(stateMachine.GetDto()); }
public StateResultHost(StateMachineBase stateMachine) : base(stateMachine) { _host = (GameHost)stateMachine; totalResponse = _host.Data.GetClientCount(); countResponse = 0; }
/// <summary> /// Caches previous states /// </summary> void ChangingState() { lastState = state.currentState; lastStateMachineBehaviour = state.executingStateMachine; _timeEnteredState = Time.time; }
public StateSettingHost(StateMachineBase stateMachine) : base(stateMachine) { _host = (GameHost)stateMachine; }
public void DestroyNestedSM(StateMachineBase _stateMachineToDestroy) { Destroy(_stateMachineToDestroy); }
public StateSettingClient(StateMachineBase stateMachine) : base(stateMachine) { _client = (GameClient)stateMachine; }
public StateResultClient(StateMachineBase stateMachine) : base(stateMachine) { _client = (GameClient)stateMachine; }
public StatePickLeader(StateMachineBase stateMachine) : base(stateMachine) { _host = (GameHost)stateMachine; }