Example #1
0
 /// <summary>
 /// main constructor
 /// </summary>
 /// <param name="font">SpriteFont for the Messages to use</param>
 /// <param name="inventory">inventory to be drawn</param>
 /// <param name="scoreXY">scoreDisplay position vector</param>
 /// <param name="screenSize">current screen size vector</param>
 /// <param name="timerXY">timerDisplay position vector</param>
 private HUD(Vector2 timerXY, Vector2 scoreXY, SpriteFont font, Inventory inventory, Vector2 screenSize)
 {
     this.inventory = inventory;
     this.font = font;
     this.screenSize = screenSize;
     timerDisplay = new Message("Current Time: ", timerXY, font);
     scoreDisplay = new Message("Score: ", scoreXY, font);
 }
Example #2
0
 /// <summary>
 /// Constructor for a new menu
 /// </summary>
 /// <param name="background">Background image to use</param>
 /// <param name="screenSize">Size of the screen</param>
 /// <param name="font">SpriteFont to use</param>
 /// <param name="title">Title of the menu</param>
 /// <param name="menuItems">Items to populate the menu with</param>
 /// <param name="selected">Color of the selected item</param>
 /// <param name="unselected">Color of an unselected item</param>
 public Menu(Texture2D background, Vector2 screenSize, SpriteFont font, string title, string message, List<MenuItem> menuItems,
     Color selected, Color unselected)
     : base(background, screenSize / 2)
 {
     this.screenSize = screenSize;
     this.font = font;
     this.title = title;
     this.message = message;
     this.menuItems = menuItems;
     this.selected = selected;
     this.unselected = unselected;
     decimal scaleX = ((decimal)(screenSize.X / background.Width));
     decimal scaleY = ((decimal)(screenSize.Y / background.Height));
     scale.setValue(Math.Max(scaleX, scaleY));
     currentItemMenu = 0;
     menuItemStartPosition = new Vector2(screenSize.X/2, screenSize.Y/2);
     displayMessage = new Message(title, menuItemStartPosition,font,Color.White);
 }
Example #3
0
 public void setTimerData(Vector2 position, SpriteFont font)
 {
     timerDisplay = new Message("Current Time: ", position, font);
 }
Example #4
0
 public void setScoreData(Vector2 position, SpriteFont font)
 {
     scoreDisplay = new Message("Score: ", position, font);
 }
Example #5
0
        /// <summary>
        /// draws the inventory to the screen
        /// </summary>
        /// <param name="batch">spriteBatch that should be drawn to</param>
        /// <param name="font">SpriteFont that should be used when message is created</param>
        /// <param name="screenSize">current size of the screen</param>
        public void Draw(SpriteBatch batch, Vector2 location, SpriteFont font)
        {
            //starts the toolbar off in the lower left hand corner and it will grow across the screen in positive X direction
            for (int i = 0; i < NUM_SLOTS; i++)
            {
                Texture2D slotFrame;
                if (i == selected)
                {
                    slotFrame = selectedImage;
                }
                else
                {
                    slotFrame = unselectedImage;
                }

                batch.Draw(slotFrame, new Vector2(location.X + i * Block.WIDTH, location.Y), Color.White);

                if (inventory[i].Count() > 0)
                {
                    //grab the first item from stack
                    Item item = inventory[i].Peek();
                    //get its sprite used
                    Texture2D sprite = item.getSpriteSheet();

                    //over lap the sprite image with the number of those items in inventory
                    // this needs to be fixed to remove the literals
                    Message myMessage = new Message("" + inventory[i].Count(), new Vector2(location.X + i * Block.WIDTH + 5, location.Y + 5), font);
                    //draw it to the screen
                    // this needs to be fixed to remove the literals
                    batch.Draw(sprite, new Vector2(location.X + i * Block.WIDTH + 4, location.Y + 4), Color.White);
                    myMessage.Draw(batch);
                }
            }
        }
Example #6
0
 /// <summary>
 /// Sets the message
 /// </summary>
 /// <param name="position">position of the message</param>
 /// <param name="font">font of the message</param>
 /// <param name="selected">color of the selected item</param>
 public void setMessage(Vector2 position, SpriteFont font, Color selected)
 {
     displayMessage = new Message(message, position, font, selected);
 }
Example #7
0
 public void setMessage(String message)
 {
     this.message = new Message(message,
         new Vector2(screenSize.X / 2 - font.MeasureString(message).X/2, 0), font, Color.White);
 }