Beispiel #1
0
 protected static T GetControl <T>(IControlSet currentControlSet,
                                   GameControlIdentifier whichControl,
                                   Func <T> componentFactory)
     where T : class, IGameComponent
 {
     return((T)currentControlSet.FindComponentByControlIdentifier(whichControl) ?? componentFactory());
 }
        protected override void InitializeControlsHelper(IControlSet currentControlSet)
        {
            _tbAccountName = GetControl(currentControlSet, GameControlIdentifier.CreateAccountName, GetCreateAccountNameTextBox);
            _tbPassword    = GetControl(currentControlSet, GameControlIdentifier.CreateAccountPassword, GetCreateAccountPasswordTextBox);
            _tbConfirm     = GetControl(currentControlSet, GameControlIdentifier.CreateAccountPasswordConfirm, GetCreateAccountConfirmTextBox);
            _tbRealName    = GetControl(currentControlSet, GameControlIdentifier.CreateAccountRealName, GetCreateAccountRealNameTextBox);
            _tbLocation    = GetControl(currentControlSet, GameControlIdentifier.CreateAccountLocation, GetCreateAccountLocationTextBox);
            _tbEmail       = GetControl(currentControlSet, GameControlIdentifier.CreateAccountEmail, GetCreateAccountEmailTextBox);
            _btnCancel     = GetControl(currentControlSet, GameControlIdentifier.CreateAccountCancelButton, GetCreateAccountCancelButton);
            _labels        = GetControl(currentControlSet, GameControlIdentifier.CreateAccountLabels, GetCreateAccountLabels);

            _allComponents.Add(_tbAccountName);
            _allComponents.Add(_tbPassword);
            _allComponents.Add(_tbConfirm);
            _allComponents.Add(_tbRealName);
            _allComponents.Add(_tbLocation);
            _allComponents.Add(_tbEmail);
            _allComponents.Add(_btnCancel);
            _allComponents.Add(_labels);

            var textBoxes = _allComponents.OfType <IXNATextBox>().ToArray();

            _clickHandler = new TextBoxClickEventHandler(_dispatcher, textBoxes);
            _tabHandler   = new TextBoxTabEventHandler(_dispatcher, textBoxes);

            if (_dispatcher.Subscriber != null)
            {
                _dispatcher.Subscriber.Selected = false;
            }
            _dispatcher.Subscriber          = _tbAccountName;
            _dispatcher.Subscriber.Selected = true;

            base.InitializeControlsHelper(currentControlSet);
        }
        protected override void InitializeControlsHelper(IControlSet currentControlSet)
        {
            base.InitializeControlsHelper(currentControlSet);

            _loginPanelBackground = GetControl(currentControlSet, GameControlIdentifier.LoginPanelBackground, GetLoginPanelBackground);
            _tbUsername           = GetControl(currentControlSet, GameControlIdentifier.LoginAccountName, GetLoginUserNameTextBox);
            _tbPassword           = GetControl(currentControlSet, GameControlIdentifier.LoginPassword, GetLoginPasswordTextBox);
            _btnLogin             = GetControl(currentControlSet, GameControlIdentifier.LoginButton, GetLoginAccountButton);
            _btnCancel            = GetControl(currentControlSet, GameControlIdentifier.LoginCancel, GetLoginCancelButton);

            _allComponents.Add(_loginPanelBackground);
            _allComponents.Add(_tbUsername);
            _allComponents.Add(_tbPassword);
            _allComponents.Add(_btnLogin);
            _allComponents.Add(_btnCancel);

            _clickHandler = new TextBoxClickEventHandler(_dispatcher, _allComponents.OfType <IXNATextBox>().ToArray());
            _tabHandler   = new TextBoxTabEventHandler(_dispatcher, _allComponents.OfType <IXNATextBox>().ToArray());

            if (_dispatcher.Subscriber != null)
            {
                _dispatcher.Subscriber.Selected = false;
            }
            _dispatcher.Subscriber          = _tbUsername;
            _dispatcher.Subscriber.Selected = true;
        }
Beispiel #4
0
        public void InitializeControls(IControlSet currentControlSet)
        {
            if (!_resourcesInitialized)
            {
                throw new InvalidOperationException("Error initializing controls: resources have not yet been initialized");
            }
            if (_controlsInitialized)
            {
                throw new InvalidOperationException("Error initializing controls: controls have already been initialized");
            }

            if (GameState != GameStates.PlayingTheGame)
            {
                _backgroundImage = GetControl(currentControlSet, GameControlIdentifier.BackgroundImage, GetBackgroundImage);
                _allComponents.Add(_backgroundImage);
            }

            InitializeControlsHelper(currentControlSet);

            foreach (var control in XNAControlComponents)
            {
                control.AddControlToDefaultGame();
            }

            _controlsInitialized = true;
        }
        protected override void InitializeControlsHelper(IControlSet currentControlSet)
        {
            _controls = _hudControlsFactory.CreateHud();
            _allComponents.AddRange(_controls.Select(x => x.Value));

            base.InitializeControlsHelper(currentControlSet);
        }
Beispiel #6
0
        protected override void InitializeControlsHelper(IControlSet currentControlSet)
        {
            base.InitializeControlsHelper(currentControlSet);
            ExcludePersonPicture1();

            _creditsLabel = GetControl(currentControlSet, GameControlIdentifier.CreditsLabel, GetCreditsLabel);
            _allComponents.Add(_creditsLabel);
        }
        protected override void InitializeControlsHelper(IControlSet currentControlSet)
        {
            base.InitializeControlsHelper(currentControlSet);

            _changePasswordButton = GetControl(currentControlSet, GameControlIdentifier.ChangePasswordButton, GetPasswordButton);
            _characterInfoPanels.AddRange(_characterInfoPanelFactory.CreatePanels());

            _allComponents.Add(_changePasswordButton);
            _allComponents.AddRange(_characterInfoPanels);
        }
Beispiel #8
0
 private void AddNewComponents(IControlSet nextSet)
 {
     foreach (var component in nextSet.AllComponents.Except(nextSet.XNAControlComponents))
     {
         if (!Game.Components.Contains(component))
         {
             Game.Components.Add(component);
         }
     }
 }
        protected override void InitializeControlsHelper(IControlSet currentControlSet)
        {
            _btnCreate = GetControl(currentControlSet,
                                    GameState == GameStates.LoggedIn ? GameControlIdentifier.CreateCharacterButton : GameControlIdentifier.CreateAccountButton,
                                    GetCreateButton);
            _person2Picture = GetControl(currentControlSet, GameControlIdentifier.PersonDisplay2, GetPerson2Picture);

            _allComponents.Add(_btnCreate);
            _allComponents.Add(_person2Picture);

            base.InitializeControlsHelper(currentControlSet);
        }
Beispiel #10
0
        public IControlSet CreateControlsForState(GameStates newState, IControlSet currentControlSet)
        {
            if (_mainButtonController == null || _accountController == null ||
                _loginController == null || _characterManagementController == null)
            {
                throw new InvalidOperationException("Missing controllers - the Unity container was initialized incorrectly");
            }

            var controlSet = GetSetBasedOnState(newState);

            controlSet.InitializeResources(_nativeGraphicsManager, _contentManagerProvider.Content);
            controlSet.InitializeControls(currentControlSet);
            return(controlSet);
        }
Beispiel #11
0
        private void SwitchToThrottle()
        {
            if (controlSet != null)
            {
                UpdateControls(controlSet.GetSet());
                controlSet.CleanUp();
            }

            Throttle throttle = new Throttle(this);

            controlSet = throttle;
            controlSet.SetSet(controls);
            grd_diagram.Content = throttle;
        }
Beispiel #12
0
        private void SwitchToStickHornet()
        {
            if (controlSet != null)
            {
                UpdateControls(controlSet.GetSet());
                controlSet.CleanUp();
            }

            StickHornet stick = new StickHornet(this);

            controlSet = stick;
            controlSet.SetSet(controls);
            grd_diagram.Content = stick;
        }
Beispiel #13
0
        protected override void InitializeControlsHelper(IControlSet currentControlSet)
        {
            _createAccount = GetControl(currentControlSet, GameControlIdentifier.InitialCreateAccount, GetMainCreateAccountButton);
            _login         = GetControl(currentControlSet, GameControlIdentifier.InitialLogin, GetMainLoginButton);
            _viewCredits   = GetControl(currentControlSet, GameControlIdentifier.InitialViewCredits, GetViewCreditsButton);
            _exitGame      = GetControl(currentControlSet, GameControlIdentifier.InitialExitGame, GetExitButton);
            _versionInfo   = GetControl(currentControlSet, GameControlIdentifier.InitialVersionLabel, GetVersionInfoLabel);
            _personPicture = GetControl(currentControlSet, GameControlIdentifier.PersonDisplay1, GetPersonPicture1);

            _allComponents.Add(_createAccount);
            _allComponents.Add(_login);
            _allComponents.Add(_viewCredits);
            _allComponents.Add(_exitGame);
            _allComponents.Add(_versionInfo);
            _allComponents.Add(_personPicture);
        }
Beispiel #14
0
        private void RemoveOldComponents(IControlSet currentSet, IControlSet nextSet)
        {
            var componentsToRemove   = FindUnusedComponents(currentSet, nextSet);
            var disposableComponents = componentsToRemove
                                       .Where(x => !(x is PacketHandlerGameComponent))
                                       .OfType <IDisposable>()
                                       .ToList();

            foreach (var component in disposableComponents)
            {
                component.Dispose();
            }
            foreach (var component in componentsToRemove.Where(Game.Components.Contains))
            {
                Game.Components.Remove(component);
            }
        }
Beispiel #15
0
 private List <IGameComponent> FindUnusedComponents(IControlSet current, IControlSet next)
 {
     return(current.AllComponents
            .Where(component => !next.AllComponents.Contains(component))
            .ToList());
 }
Beispiel #16
0
 public void InitializeControls(IControlSet currentControlSet)
 {
 }
 public ControlSetRepository()
 {
     CurrentControlSet = new EmptyControlSet();
 }
        protected override void InitializeControlsHelper(IControlSet currentControlSet)
        {
            _backButton = GetControl(currentControlSet, GameControlIdentifier.BackButton, GetBackButton);

            _allComponents.Add(_backButton);
        }
Beispiel #19
0
 protected abstract void InitializeControlsHelper(IControlSet currentControlSet);