Ejemplo n.º 1
0
        public LogicHandler(ResourceManager resourceManager, InputHandler inputHandler)
        {
            _resourceManager              = resourceManager;
            _inputHandler                 = inputHandler;
            _playerLogicHandler           = new PlayerLogicHandler();
            _roamLogicHandler             = new RoamLogicHandler(resourceManager);
            _startAndExitMenuLogicHandler = new StartAndExitMenuLogicHandler(resourceManager, inputHandler);
            _transitionHandler            = new TransitionHandler(resourceManager, _playerLogicHandler, _roamLogicHandler, _startAndExitMenuLogicHandler);

            GameStateHelper.ChangeState(GameStates.Start);
        }
Ejemplo n.º 2
0
        private void ExecuteStateTransition()
        {
            var transition = _transition as StateTransition;

            if (transition == null) // do we fade in here? no not necessariliy, this should never happen though
            {
                return;
            }

            // state transition only has the state we are going to.
            // this state is pretty much guaranteed to not be roam unless coming from exit menu resume or maybe from chat?
            // don't have to set transitioning to false since it will be handled elsewhere
            GameStateHelper.ChangeState(transition.DestinationState);
        }
Ejemplo n.º 3
0
 public void UpdateGameLogic()
 {
     if (_transitionHandler.Transitioning)
     {
         _transitionHandler.ContinueTransition();
     }
     else if (GameStateHelper.CurrentState == GameStates.Start)
     {
         GameStateHelper.ChangeState(GameStates.StartMenu);
     }
     else if (GameStateHelper.CurrentState == GameStates.StartMenu || GameStateHelper.CurrentState == GameStates.ExitMenu)
     {
         _startAndExitMenuLogicHandler.UpdateGameLogic();
     }
     else if (GameStateHelper.CurrentState == GameStates.Roam)
     {
         _roamLogicHandler.UpdateLogic();
     }
     else if (GameStateHelper.CurrentState == GameStates.Chat)
     {
     }
 }
Ejemplo n.º 4
0
        private void ExecuteRoamTransition()
        {
            var transition = _transition as RoamTransition;

            if (transition == null)
            {
                return;
            }

            if (transition.DestinationRegion == _roamLogicHandler.CurrentPlayerRegion && GameStateHelper.CurrentState == GameStates.Roam)
            {
                _roamLogicHandler.UpdatePlayerPositionWithTransition(transition);
                return;
            }

            var adjacentRegions = RegionLayout.RegionInfo[transition.DestinationRegion].AdjacentRegions;
            //var adjacentRegions = RegionMapper.GetAdjacentRegions(transition.DestinationRegion); // this is going to become regions to load
            var currentlyLoadedRegions = new List <RegionNames>(_roamLogicHandler.Regions.Keys.ToList()); // this is going to become regions to unload?

            List <RegionNames> regionsToLoad   = new List <RegionNames>();
            List <RegionNames> regionsToUnload = new List <RegionNames>();

            // load the destination region if it isn't already loaded (this will happen sometimes when loading files)
            if (!currentlyLoadedRegions.Contains(transition.DestinationRegion))
            {
                regionsToLoad.Add(transition.DestinationRegion);
            }

            // load everything this is adjacent to the region we are going to but isn't currently loaded
            foreach (var region in adjacentRegions)
            {
                if (!currentlyLoadedRegions.Contains(region))
                {
                    regionsToLoad.Add(region);
                }
            }

            // unload everything that is current loaded but no adjacent to the region we are currently going to
            foreach (var region in currentlyLoadedRegions)
            {
                if (!adjacentRegions.Contains(region))
                {
                    regionsToUnload.Add(region);
                }
            }

            _resourceManager.RequestRegionLoadUnload(regionsToLoad, regionsToUnload);

            // we can wait on load if we are loading new regions and fading
            if (transition.Fade)
            {
                _waitOnLoad = true;
            }

            _roamLogicHandler.UpdatePlayerPositionWithTransition(transition);

            if (GameStateHelper.CurrentState != GameStates.Roam)
            {
                GameStateHelper.ChangeState(GameStates.Roam);
            }
        }