public void Load() { this.ConfirmationButton = new Texture2DSubstitude("Sprites\\Buttons\\Start"); this.ConfirmationButtonLocation = new Rectangle2D(Constant.ConfirmationButtonPositionX, Constant.ConfirmationButtonPositionY, Constant.ConfirmationButtonWidth, Constant.ConfirmationButtonHeight); this.NameField = new Text("", true, Constant.InputBoxLeftCorner, Constant.NameFieldPositionY, Constant.NameFieldWidth, Constant.InputBoxHeight, Constant.NameFieldDelay, Color.Black, true, Constant.NameFontPath); this.NameFieldDescription = new Text("Please enter a name for your character", false, Constant.InputBoxLeftCorner, Constant.NameFieldDescriptionPositionY, Constant.NameFieldDescriptionWidth, Constant.InputBoxHeight, Constant.NameFieldDescriptionDelay, Color.White, false, Constant.NameFontPath); }
//Updates the number of collected items. public virtual void Update(GameTime gameTime) { string counter = String.Format("{0}", Stomper.Counter); InventoryCounterText = new Text(counter, false, (int)this.ItemPicture.Position.X - DistanceBetweenCounterAndPicture, (int)this.ItemPicture.Position.Y - DistanceBetweenCounterAndPicture, 1, 1, 0, Color.Brown, false, Constant.NameFontPath); InventoryCounterText.Update(gameTime, false); }
public void Update(GameTime gameTime) { var mouseState = Mouse.GetState(); if(this.ConfirmationButtonLocation.AsRectangle().Contains(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed) { try { Character character = null; foreach (var currentCharacter in OrusTheGame.Instance.GameInformation.AllCharacters) { if(currentCharacter.IddleAnimation.Scale > 1) { character = currentCharacter; break; } } if(character != null) { character.Name = this.NameField.TextInField; character.IddleAnimation.Scale = 1; character.Position = new Point2D(Constant.StartingPlayerXPosition, Constant.StartingPlayerYPosition); OrusTheGame.Instance.GameInformation.GameMenu.CharacterSelectionInProgress = false; OrusTheGame.Instance.IsMouseVisible = false; OrusTheGame.Instance.GameInformation.Character = character; } } catch(InvalidName exception) { this.NameFieldDescription = new Text(exception.Message, false, Constant.InputBoxLeftCorner, Constant.NameFieldDescriptionPositionY, Constant.ErrorNameFieldDescriptionWidth, Constant.InputBoxHeight, Constant.NameFieldDescriptionDelay, Color.White, false, Constant.NameFontPath); } } try { this.NameField.Update(gameTime, false); } catch (InvalidName exception) { this.NameFieldDescription = new Text(exception.Message, false, Constant.InputBoxLeftCorner, Constant.NameFieldDescriptionPositionY, Constant.ErrorNameFieldDescriptionWidth, Constant.InputBoxHeight, Constant.NameFieldDescriptionDelay, Color.White, false, Constant.NameFontPath); } this.NameFieldDescription.Update(gameTime, true); }