Ejemplo n.º 1
0
        ///Returns true if a transitions was valid and thus made
        public bool CheckTransitions()
        {
            for (var i = 0; i < outConnections.Count; i++)
            {
                var connection = (FSMConnection)outConnections[i];
                var condition  = connection.condition;

                if (!connection.isActive)
                {
                    continue;
                }

                if ((condition != null && condition.CheckCondition(graphAgent, graphBlackboard)) || (condition == null && status != Status.Running))
                {
                    AppEventsManager.Publish_StateTransition(
                        (FSMState)connection.sourceNode,
                        (FSMState)connection.targetNode
                        );

                    FSM.EnterState((FSMState)connection.targetNode);
                    connection.status = Status.Success; //editor vis
                    return(true);
                }

                connection.status = Status.Failure; //editor vis
            }

            return(false);
        }
Ejemplo n.º 2
0
 protected override void OnEnter()
 {
     base.OnEnter();
     AppEventsManager.Publish_StatePreEnter(this);
     AppEventsManager.Publish_StateEnter(this);
     uiManager.QueueOnUIEnterSequence(OnUIEnterSequence);
 }
Ejemplo n.º 3
0
        /*
         |-------------------
         |   Logic
         |-------------------
         */
        private async UniTask OnUIEnterSequence()
        {
            try
            {
                if (triggerOnUIEnter)
                {
                    List <UISceneBase> uiScenes = activeScenes.Select(x => x.value).ToList();
                    uiManager.UnlistenPlayerActionPreviousUI();
                    await uiManager.HidePreviousUI(uiScenes);

                    uiManager.DeactivatePreviousUI(uiScenes);

                    if (placeOnUIStateStack)
                    {
                        uiManager.UpdateStateStackOnEnter(this);
                    }
                    ActivateMyUIScene();
                    await ShowMyUIScene();

                    ListenPlayerAction();
                }
            }
            catch (System.Exception ex)
            {
                UnityEngine.Debug.LogError($"{ex.GetType()} : {ex.Message}\n{ex.StackTrace}");
            }

            AppEventsManager.Publish_StatePostEnter(this);
            await UniTask.CompletedTask;
        }
Ejemplo n.º 4
0
        protected override async void OnExit()
        {
            if (!placeOnUIStateStack && triggerOnUIEnter)
            {
                await HideMyUIScene();

                DeactivateMyUIScene();
            }

            UnlistenPlayerAction();
            AppEventsManager.Publish_StateExit(this);
            base.OnExit();
        }
Ejemplo n.º 5
0
        public void GoToState(UIBaseState targetState)
        {
            NodeCanvas.StateMachines.FSM fsm = uiGraph.behaviour;

            UIBaseState currState = null;

            if (uiStateStack.Count > 1)
            {
                currState = uiStateStack[uiStateStack.Count - 1];
            }
            AppEventsManager.Publish_StateTransition(currState, targetState);
            //Debug.Log($"GOTO STATE {targetState.name} in [{fsm.name}]");
            fsm.TriggerState(targetState.name);
        }
Ejemplo n.º 6
0
        public bool GoToPreviousState()
        {
            if (!AppEventsManager.CanPublishAppAction)
            {
                return(true);
            }
            if (uiStateStack.Count > 1)
            {
                var currState   = uiStateStack[uiStateStack.Count - 1];
                var targetState = uiStateStack[uiStateStack.Count - 2];

                AppEventsManager.Publish_StateTransition(currState, targetState);
                uiGraph.TriggerState(targetState.name);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 7
0
        new public void Update()
        {
            if (outConnections.Count == 0)
            {
                return;
            }

            status = Status.Running;

            for (var i = 0; i < outConnections.Count; i++)
            {
                var connection = (FSMConnection)outConnections[i];
                var condition  = connection.condition;

                if (!connection.isActive || condition == null)
                {
                    continue;
                }

                if (dontRetriggerStates)
                {
                    if (FSM.currentState == (FSMState)connection.targetNode && FSM.currentState.status == Status.Running)
                    {
                        continue;
                    }
                }

                if (condition.CheckCondition(graphAgent, graphBlackboard))
                {
                    AppEventsManager.Publish_StateTransition(
                        FSM.currentState,
                        (FSMState)connection.targetNode
                        );

                    FSM.EnterState((FSMState)connection.targetNode);
                    connection.status = Status.Success; //editor vis
                    return;
                }

                connection.status = Status.Failure; //editor vis
            }
        }
Ejemplo n.º 8
0
 private void BackToMainMenu()
 {
     AppEventsManager.Publish_AppAction(AppAction.GOTO_START_STATE);
 }
Ejemplo n.º 9
0
 private void GoToInGameState()
 {
     AppEventsManager.Publish_AppAction(AppAction.GOTO_IN_GAME_STATE);
 }
Ejemplo n.º 10
0
 private void HandleButtonBackToMainMenuClicked()
 {
     AppEventsManager.Publish_PlayerAction(PlayerAction.BACK_TO_MAIN_MENU);
 }
Ejemplo n.º 11
0
 private void HandleButtonRetryClicked()
 {
     AppEventsManager.Publish_PlayerAction(PlayerAction.START_GAME);
 }
Ejemplo n.º 12
0
 private void HandleButtonQuitClicked()
 {
     AppEventsManager.Publish_PlayerAction(PlayerAction.QUIT_GAME);
 }
Ejemplo n.º 13
0
 protected void GoToPreviousState()
 {
     AppEventsManager.Publish_AppAction(AppAction.GOTO_PREVIOUS_STATE);
 }
Ejemplo n.º 14
0
 private void GoToGameOverState()
 {
     _gameSignal.GameOverSignal.Fire();
     AppEventsManager.Publish_AppAction(AppAction.GOTO_GAME_OVER_STATE);
 }