Beispiel #1
0
        public void ChangeToState(GameStates newState)
        {
            if (newState == _gameStateRepository.CurrentState)
            {
                return;
            }

            var currentSet = _controlSetRepository.CurrentControlSet;
            var nextSet    = _controlSetFactory.CreateControlsForState(newState, currentSet);

            RemoveOldComponents(currentSet, nextSet);
            AddNewComponents(nextSet);

            _gameStateRepository.CurrentState       = newState;
            _controlSetRepository.CurrentControlSet = nextSet;
        }
Beispiel #2
0
        private void SetUpInitialControlSet()
        {
            var controls = _controlSetFactory.CreateControlsForState(
                GameStates.Initial,
                _controlSetRepository.CurrentControlSet);

            _controlSetRepository.CurrentControlSet = controls;

            //since the controls are being created in Initialize(), adding them to the default game
            //  doesn't call the Initialize() method on any controls, so it must be done here
            foreach (var xnaControl in _controlSetRepository.CurrentControlSet.AllComponents)
            {
                xnaControl.Initialize();
            }
        }