Exemple #1
0
 protected static T GetControl <T>(IControlSet currentControlSet,
                                   GameControlIdentifier whichControl,
                                   Func <T> componentFactory)
     where T : class, IGameComponent
 {
     return((T)currentControlSet.FindComponentByControlIdentifier(whichControl) ?? componentFactory());
 }
Exemple #2
0
        public override IGameComponent FindComponentByControlIdentifier(GameControlIdentifier control)
        {
            switch (control)
            {
            case GameControlIdentifier.CreditsLabel: return(_creditsLabel);

            default: return(base.FindComponentByControlIdentifier(control));
            }
        }
        public override IGameComponent FindComponentByControlIdentifier(GameControlIdentifier control)
        {
            switch (control)
            {
            case GameControlIdentifier.CreateAccountButton:
                return(GameState == GameStates.CreateAccount ? _btnCreate : null);

            case GameControlIdentifier.CreateCharacterButton:
                return(GameState == GameStates.LoggedIn ? _btnCreate : null);

            case GameControlIdentifier.PersonDisplay2: return(_person2Picture);

            default: return(base.FindComponentByControlIdentifier(control));
            }
        }
        public override IGameComponent FindComponentByControlIdentifier(GameControlIdentifier control)
        {
            switch (control)
            {
            case GameControlIdentifier.Character1Panel: return(_characterInfoPanels[0]);

            case GameControlIdentifier.Character2Panel: return(_characterInfoPanels[1]);

            case GameControlIdentifier.Character3Panel: return(_characterInfoPanels[2]);

            case GameControlIdentifier.ChangePasswordButton: return(_changePasswordButton);

            default: return(base.FindComponentByControlIdentifier(control));
            }
        }
        public override IGameComponent FindComponentByControlIdentifier(GameControlIdentifier control)
        {
            switch (control)
            {
            case GameControlIdentifier.LoginPanelBackground: return(_loginPanelBackground);

            case GameControlIdentifier.LoginAccountName: return(_tbUsername);

            case GameControlIdentifier.LoginPassword: return(_tbPassword);

            case GameControlIdentifier.LoginButton: return(_btnLogin);

            case GameControlIdentifier.LoginCancel: return(_btnCancel);

            default: return(base.FindComponentByControlIdentifier(control));
            }
        }
Exemple #6
0
        public override IGameComponent FindComponentByControlIdentifier(GameControlIdentifier control)
        {
            switch (control)
            {
            case GameControlIdentifier.InitialCreateAccount: return(_createAccount);

            case GameControlIdentifier.InitialLogin: return(_login);

            case GameControlIdentifier.InitialViewCredits: return(_viewCredits);

            case GameControlIdentifier.InitialExitGame: return(_exitGame);

            case GameControlIdentifier.InitialVersionLabel: return(_versionInfo);

            case GameControlIdentifier.PersonDisplay1: return(_personPicture);

            default: return(base.FindComponentByControlIdentifier(control));
            }
        }
        private IXNATextBox AccountInputTextBoxCreationHelper(GameControlIdentifier whichControl)
        {
            int i;

            switch (whichControl)
            {
            case GameControlIdentifier.CreateAccountName: i = 0; break;

            case GameControlIdentifier.CreateAccountPassword: i = 1; break;

            case GameControlIdentifier.CreateAccountPasswordConfirm: i = 2; break;

            case GameControlIdentifier.CreateAccountRealName: i = 3; break;

            case GameControlIdentifier.CreateAccountLocation: i = 4; break;

            case GameControlIdentifier.CreateAccountEmail: i = 5; break;

            default: throw new ArgumentException("Invalid control specified for helper", nameof(whichControl));
            }

            //set the first  3 Y coord to start at 69  and move up by 51 each time
            //set the second 3 Y coord to start at 260 and move up by 51 each time
            var txtYCoord = (i < 3 ? 69 : 260) + i % 3 * 51;
            var drawArea  = new Rectangle(358, txtYCoord, 240, _textBoxBackground.Height);

            return(new XNATextBox(drawArea,
                                  Constants.FontSize08,
                                  _textBoxBackground,
                                  _textBoxLeft,
                                  _textBoxRight,
                                  _textBoxCursor)
            {
                LeftPadding = 4,
                MaxChars = 35,
                Text = "",
                DefaultText = " "
            });
        }
        public override IGameComponent FindComponentByControlIdentifier(GameControlIdentifier control)
        {
            switch (control)
            {
            case GameControlIdentifier.CreateAccountLabels: return(_labels);

            case GameControlIdentifier.CreateAccountName: return(_tbAccountName);

            case GameControlIdentifier.CreateAccountPassword: return(_tbPassword);

            case GameControlIdentifier.CreateAccountPasswordConfirm: return(_tbConfirm);

            case GameControlIdentifier.CreateAccountRealName: return(_tbRealName);

            case GameControlIdentifier.CreateAccountLocation: return(_tbLocation);

            case GameControlIdentifier.CreateAccountEmail: return(_tbEmail);

            case GameControlIdentifier.CreateAccountCancelButton: return(_btnCancel);

            default: return(base.FindComponentByControlIdentifier(control));
            }
        }
Exemple #9
0
        private IXNAButton MainButtonCreationHelper(GameControlIdentifier whichControl)
        {
            int i;

            switch (whichControl)
            {
            case GameControlIdentifier.InitialCreateAccount: i = 0; break;

            case GameControlIdentifier.InitialLogin: i = 1; break;

            case GameControlIdentifier.InitialViewCredits: i = 2; break;

            case GameControlIdentifier.InitialExitGame: i = 3; break;

            default: throw new ArgumentException("Invalid control specified for helper", nameof(whichControl));
            }

            var widthFactor  = _mainButtonTexture.Width / 2;
            var heightFactor = _mainButtonTexture.Height / 4;
            var outSource    = new Rectangle(0, i * heightFactor, widthFactor, heightFactor);
            var overSource   = new Rectangle(widthFactor, i * heightFactor, widthFactor, heightFactor);

            return(new XNAButton(_mainButtonTexture, new Vector2(26, 278 + i * 40), outSource, overSource));
        }
Exemple #10
0
 public IGameComponent FindComponentByControlIdentifier(GameControlIdentifier control)
 {
     return(null);
 }
Exemple #11
0
 public virtual IGameComponent FindComponentByControlIdentifier(GameControlIdentifier control)
 {
     return(control == GameControlIdentifier.BackgroundImage ? _backgroundImage : null);
 }