public void ExitStateStart(UIStateType stateType)
 {
     if (onExitStateStart != null)
     {
         onExitStateStart(stateType);
     }
 }
 public void ExitStateEnd(UIStateType stateType)
 {
     if (onExitStateEnd != null)
     {
         onExitStateEnd(stateType);
     }
 }
 public void EnterStateStart(UIStateType stateType)
 {
     if (onEnterStateStart != null)
     {
         onEnterStateStart(stateType);
     }
 }
 public void EnterStateEnd(UIStateType stateType)
 {
     if (onEnterStateEnd != null)
     {
         onEnterStateEnd(stateType);
     }
 }
Example #5
0
 public virtual void Start(params object[] args)
 {
     if (this.UIState == UIStateType.Awake)
     {
         this.UIState = UIStateType.Start;
         this.GameObject.SetActive(true);
         this.OnStart(args);
     }
 }
Example #6
0
 public virtual void Enable()
 {
     if (this.UIState == UIStateType.Start || this.UIState == UIStateType.Disable)
     {
         this.UIState = UIStateType.Enable;
         this.GameObject.SetActive(true);
         this.OnEnable();
         GameEventManager.Instance.RegisterEvent(UIProxy);
     }
 }
Example #7
0
 public virtual void Disable()
 {
     //只有状态为Start、Enable才能执行disable
     if (this.UIState == UIStateType.Start || this.UIState == UIStateType.Enable)
     {
         this.UIState = UIStateType.Disable;
         GameEventManager.Instance.RemoveEvent(UIProxy);
         OnDisable();
         this.GameObject.SetActive(false);
     }
 }
Example #8
0
        public static UIStateType Execute()
        {
            UIStateType nextState = UIStateType.LIST_ALL_BEERS;

            long totalPages, totalResults;

            UIBeersPerBrewery.gBeers = Beer.GetBeersRequest(Service.httpClient, "/beers", currentPage, searchTerm,
                                                            out currentPage, out totalPages, out totalResults);
            Beer.PrintList(UIBeersPerBrewery.gBeers);
            Console.WriteLine("Current page: {0}\nTotal pages {1}\nTotal results {2}",
                              currentPage, totalPages, totalResults);

            Console.WriteLine("Type \'..\' to go back!");
            Console.WriteLine("Type \'page n\' to view page \'n\'");
            //Console.WriteLine("Type 'name' to  search for beer name");
            Console.WriteLine("Type a number between 0 and {0} to view beer details", UIBeersPerBrewery.gBeers.Count);
            string cmd = Console.ReadLine();

            if (cmd == "..")
            {
                currentPage = 1;
                searchTerm  = "";
                return(UIStateType.MAIN_MENU);
            }
            if (cmd.Contains("page") && cmd.Length > 5)
            {
                string subcmd = cmd.Substring(5, cmd.Length - 5);
                int    page;
                if (Int32.TryParse(subcmd, out page) == true)
                {
                    currentPage = page;
                    return(UIStateType.LIST_ALL_BEERS);
                }
            }

            int beer;

            if (Int32.TryParse(cmd, out beer) == true && beer < UIBeersPerBrewery.gBeers.Count)
            {
                UIBeersPerBrewery.currentBeer = beer;
                return(UIStateType.BEER_DETAILS);
            }

            if (cmd.Contains("name") && cmd.Length > 5)
            {
                searchTerm = cmd.Substring(5, cmd.Length - 5);
                return(UIStateType.LIST_ALL_BEERS);
            }

            Console.WriteLine("Wrong format!");
            Console.ReadLine();

            return(nextState); // Allways return to main menu
        }
Example #9
0
        static void Main(string[] args)
        {
            UIStateType gState     = UIStateType.MAIN_MENU;
            UIStateType gNextState = UIStateType.ERROR;

            while (true)
            {
                Run(gState, out gNextState);
                gState = gNextState;
            }
        }
Example #10
0
        protected int GetSubstateIndex(UIStateType stateType)
        {
            for (var i = 0; i < SubStateList.Count; i++)
            {
                if (SubStateList[i].TargetState.Type == stateType)
                {
                    return(i);
                }
            }

            return(-1);
        }
        private UISceneState SceneStateByType(UIStateType stateType)
        {
            for (var i = 0; i < AllSceneStates.Length; i++)
            {
                if (AllSceneStates[i].State == stateType)
                {
                    return(AllSceneStates[i]);
                }
            }

            return(null);
        }
        private int SceneStateTransitionByType(UIStateType targetState)
        {
            for (var i = 0; i < CurrentState.Transitions.Count; i++)
            {
                if (CurrentState.Transitions[i].TargetState.State == targetState)
                {
                    return(i);
                }
            }

            return(-1);
        }
Example #13
0
        public static UIStateType Execute()
        {
            UIStateType nextState = UIStateType.MAIN_MENU;

            Print();
            int cmd = ReadCommand();

            if (cmd >= 0)
            {
                nextState = CmdToState[cmd];
            }

            return(nextState);
        }
Example #14
0
        private void ExitStateEnd(UIStateType stateType)
        {
            if (stateType != InitialSceneState.Type)
            {
                return;
            }

            UIStateMachine.Instance.onExitStateEnd -= ExitStateEnd;

            for (var i = 0; i < States.Length; i++)
            {
                States [i].parent = transform;
            }
        }
Example #15
0
        public bool OpenSubstate(UIStateType stateType)
        {
            if (UIStateMachine.Instance.LockTransitions || _runningTasks > 0)
            {
                                #if Debugging
                Debug.Log("There are still running tasks. Unable to open Substate " + stateType + ".");
                                #endif
                return(false);
            }

            _nextSubstateIndex = GetSubstateIndex(stateType);
            if (_nextSubstateIndex == -1)
            {
                                #if Debugging
                Debug.Log("Substate " + stateType + " was not found! Transition cancelled!");
                                #endif
                return(false);
            }

            if (_currentSubstateIndex != -1)
            {
                if (SubStateList[_currentSubstateIndex].TargetState.Type == stateType)
                {
                                        #if Debugging
                    Debug.Log("Cannot open the state " + stateType + " because it is currently open!");
                                        #endif
                    return(false);
                }

                if (SubStateList [_currentSubstateIndex].TargetState.HasRunningTasks)
                {
                                        #if Debugging
                    Debug.Log("Cannot open the state " + stateType + " because " + SubStateList [_currentSubstateIndex].TargetState.Type.ToString() + " still has running tasks!");
                                        #endif
                    return(false);
                }

                if (onSwitchingOutSubstateStart != null)
                {
                    onSwitchingOutSubstateStart(SubStateList[_currentSubstateIndex].TargetState.Type, stateType);
                }

                StartSwitchingOutSubState();
                return(true);
            }

            FinishSwitchingOutState();
            return(false);
        }
Example #16
0
 public virtual void Destroy()
 {
     Disable();
     if (this.UIState != UIStateType.Destroy)
     {
         this.OnDestroy();
         GameObject.Destroy(this.GameObject);
         this.GameObject             = null;
         this.Transform              = null;
         this.UIState                = UIStateType.Destroy;
         this.AnimationState         = AnimationStateType.Destroy;
         AwakeState                  = false;
         this.IsPlayingAniamtionTask = null;
     }
 }
Example #17
0
        public static UIStateType Execute()
        {
            UIStateType nextState = UIStateType.LIST_BEERS_PER_BREWERY;

            // currentBrewery should be a valid index here
            // obtain the link for the requested resource
            var nextLink = UIBreweriesListState.gBreweries[UIBreweriesListState.currentBrewery].links.beers.href;

            gBeers = Beer.GetBeersRequest(Service.httpClient, nextLink);

            if (gBeers != null)
            {
                Beer.PrintList(gBeers);
            }
            else
            {
                active    = false;
                nextState = UIStateType.LIST_ALL_BREWERIES;
                Console.WriteLine("Resource unavailable!\n");
                Console.ReadLine();
                return(nextState);
            }

            Console.WriteLine("Type '..' to go back!");
            Console.Write("Type the index of the beer in order too get more details about it: ");
            string command = Console.ReadLine();

            if (Int32.TryParse(command, out currentBeer) == true)
            {
                nextState = UIStateType.BEER_DETAILS;
                active    = true;
            }
            else
            {
                if (command == "..")
                {
                    nextState = UIStateType.LIST_ALL_BREWERIES; // going back
                }
                else
                {
                    Console.WriteLine("Wrong index!");
                    Console.ReadLine();
                }
                active = false;
            }

            return(nextState);
        }
        public void OpenState(UIStateType targetState)
        {
            if (LockTransitions || _runningTasks > 0)
            {
                Debug.Log("There are still tasks running! Transition from " + CurrentState.State + " to " + targetState + " cancelled!");
                return;
            }

            _currentStateTransitionIndex = SceneStateTransitionByType(targetState);
            if (_currentStateTransitionIndex == -1)
            {
                Debug.Log("Target state " + targetState + " is not a valid transition from state " + CurrentState.State);
                return;
            }

            StartSwitchOutCurrentState();
            FinishSwitchingOutCurrentState();
        }
Example #19
0
        public static UIStateType Execute()
        {
            UIStateType nextState = UIStateType.ERROR;

            Beer.PrintDetails(UIBeersPerBrewery.gBeers[UIBeersPerBrewery.currentBeer]);

            if (UIBeersPerBrewery.active)
            {
                nextState = UIStateType.LIST_BEERS_PER_BREWERY;
            }
            else
            {
                nextState = UIStateType.LIST_ALL_BEERS;
            }

            Console.WriteLine("Hit any key to go back!\n");
            Console.ReadLine();

            return(nextState);
        }
Example #20
0
        static private void Run(UIStateType state, out UIStateType nextState)
        {
            nextState = UIStateType.ERROR;
            switch (state)
            {
            case UIStateType.MAIN_MENU:
                nextState = UIMainMenuState.Execute();
                break;

            case UIStateType.LIST_ALL_BREWERIES:
                nextState = UIBreweriesListState.Execute();
                break;

            case UIStateType.LIST_ALL_BEERS:
                nextState = UIBeerList.Execute();
                break;

            case UIStateType.LIST_BEERS_PER_BREWERY:
                nextState = UIBeersPerBrewery.Execute();
                break;

            case UIStateType.SEARCH_BEER_BY_NAME:
                break;

            case UIStateType.BEER_DETAILS:
                nextState = UIBeerDetails.Execute();
                break;

            case UIStateType.ADD_BEER:
                nextState = UIAddBeer.Execute();
                break;

            default:
                Console.Clear();
                Console.WriteLine("ERROR");
                break;
            }
        }
Example #21
0
        public static UIStateType Execute()
        {
            UIStateType nextState = UIStateType.LIST_ALL_BREWERIES;

            gBreweries = Brewery.GetBrewriesRequest(Service.httpClient);
            Brewery.PrintList(gBreweries);

            Console.WriteLine("Type '..' to go back!");
            Console.Write("Command (shoud be an integer between 0 and {0}): ", gBreweries.Count - 1);
            string command = Console.ReadLine();

            if (Int32.TryParse(command, out currentBrewery) == true)
            {
                if (currentBrewery >= 0 && currentBrewery < gBreweries.Count)
                {
                    nextState = UIStateType.LIST_BEERS_PER_BREWERY;
                }
                else
                {
                    Console.WriteLine("\nInvalid input!\n");
                    Console.ReadLine();
                }
            }
            else
            {
                if (command == "..")
                {
                    nextState = UIStateType.MAIN_MENU; // going back
                }
                else
                {
                    Console.WriteLine("\nInvalid input!\n");
                    Console.ReadLine();
                }
            }

            return(nextState);
        }
Example #22
0
    public void TransitionTo(UIStateType type, object inputData = null)
    {
        switch (type)
        {
        case UIStateType.Gameplay:
            TransitionTo(Blackboard.GameplayState, inputData);
            break;

        case UIStateType.BlockedGameplay:
            TransitionTo(Blackboard.BlockedGameplayState, inputData);
            break;

        case UIStateType.ParameterSelection:
            TransitionTo(Blackboard.ParameterSelectionState, inputData);
            break;

        case UIStateType.Drawing:
            TransitionTo(Blackboard.DrawingState, inputData);
            break;

        default:
            throw new NotImplementedException();
        }
    }
Example #23
0
        public virtual void Awake()
        {
            if (this.UIState == UIStateType.None)
            {
                this.UIState = UIStateType.Awake;
                AwakeState   = true;

                //记录所有Canvas初始化的sortingOrder
                Canvas[] tempCanvases = this.GameObject.GetComponentsInChildren <Canvas>(true);
                CanvasDic = new Dictionary <Canvas, int>(tempCanvases.Length);
                for (int i = 0; i < tempCanvases.Length; i++)
                {
                    Canvas tempCanvas = tempCanvases[i];
                    CanvasDic[tempCanvas] = tempCanvas.sortingOrder;
                }

                if (this.UIContext.UIData.HasAnimation)
                {
                    this.Animator = this.GameObject.GetComponent <Animator>();
                }
                this.OnAwake();
                this.GameObject.SetActive(false);
            }
        }