Example #1
0
        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;
            }
        }
Example #2
0
 void Awake()
 {
     state.executingStateMachine = stateMachine = this;
     localTransform = base.transform;
     Represent(base.gameObject);
     OnAwake();
 }
Example #3
0
 public override void Start(StateMachineBase _stateMachine)
 {
     base.Start(_stateMachine);
     SetUpRound(GamePlayManager.I.CurrentRound, GamePlayManager.I.currentLevel);
     CheckLifeCards();
     stateMachine.NotifyTheStateIsOver();
 }
Example #4
0
    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();
    }
Example #5
0
 public override void Start(StateMachineBase _stateMachine)
 {
     base.Start(_stateMachine);
     CardView.OnBeginDragCard += OnBeginDrag;
     CardView.OnDragCard      += OnDrag;
     CardView.OnDropCard      += OnDrop;
     CurrentPlayerIndex        = 0;
     Debug.Log("StrategicPhase iniziata");
 }
Example #6
0
    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;
    }
Example #7
0
 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();
 }
Example #8
0
    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");
            }
        }
    }
Example #9
0
    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();
        }
    }
Example #10
0
    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));
    }
Example #11
0
    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);
        }
Example #13
0
    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();
    }
Example #14
0
 public StateCheckScore(StateMachineBase stateMachine) : base(stateMachine)
 {
     _host = (GameHost)stateMachine;
 }
Example #15
0
 public override void Start(StateMachineBase _stateMachine)
 {
     base.Start(_stateMachine);
     SetUpPlayers(GamePlayManager.I.currentLevel);
     stateMachine.NotifyTheStateIsOver();
 }
Example #16
0
 public override void Start(StateMachineBase _stateMachine)
 {
     base.Start(_stateMachine);
     CheckWinner();
 }
Example #17
0
 public override void Start(StateMachineBase _stateMachine)
 {
     base.Start(_stateMachine);
     SetupGameplay();
     stateMachine.NotifyTheStateIsOver();
 }
Example #18
0
 public StateWaitTurn(StateMachineBase stateMachine) : base(stateMachine)
 {
     _host = (GameHost)stateMachine;
 }
Example #19
0
 public StateCheckTurn(StateMachineBase stateMachine) : base(stateMachine)
 {
     _client = (GameClient)stateMachine;
 }
Example #20
0
 public StateWaitScore(StateMachineBase stateMachine) : base(stateMachine)
 {
     _client = (GameClient)stateMachine;
 }
Example #21
0
 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());
 }
Example #24
0
 public StateResultHost(StateMachineBase stateMachine) : base(stateMachine)
 {
     _host         = (GameHost)stateMachine;
     totalResponse = _host.Data.GetClientCount();
     countResponse = 0;
 }
Example #25
0
 /// <summary>
 /// Caches previous states
 /// </summary>
 void ChangingState()
 {
     lastState = state.currentState;
     lastStateMachineBehaviour = state.executingStateMachine;
     _timeEnteredState         = Time.time;
 }
Example #26
0
 public StateSettingHost(StateMachineBase stateMachine) : base(stateMachine)
 {
     _host = (GameHost)stateMachine;
 }
Example #27
0
 public void DestroyNestedSM(StateMachineBase _stateMachineToDestroy)
 {
     Destroy(_stateMachineToDestroy);
 }
Example #28
0
 public StateSettingClient(StateMachineBase stateMachine) : base(stateMachine)
 {
     _client = (GameClient)stateMachine;
 }
Example #29
0
 public StateResultClient(StateMachineBase stateMachine) : base(stateMachine)
 {
     _client = (GameClient)stateMachine;
 }
Example #30
0
 public StatePickLeader(StateMachineBase stateMachine) : base(stateMachine)
 {
     _host = (GameHost)stateMachine;
 }