/// <summary> /// Draws the menu to the screen. /// </summary> /// <param name="sprite_batch"></param> public static void Draw(SpriteBatch sprite_batch) { Texture2D menu_texture = null; if (menu_state == MenuStates.Open) { float backdrop_layer = (((int)H_Drawing.DrawLayers.UI) / 100.0f) - 0.0001f; H_Drawing.DrawSprite(sprite_batch, menu_fade, Vector2.Zero, backdrop_layer, default(Rectangle), new Color(255, 255, 255, 100)); switch (menu_tab_state) { case MenuTabStates.Stats: menu_texture = stats_menu; break; case MenuTabStates.Inventory: menu_texture = inventory_menu; break; case MenuTabStates.Options: menu_texture = options_menu; break; } Vector2 new_menu_position = H_Math.VectorLevel(menu_position); float ui_layer = ((int)H_Drawing.DrawLayers.UI) / 100.0f; H_Drawing.DrawSprite(sprite_batch, menu_texture, new_menu_position, ui_layer); float overlay_layer = ((int)H_Drawing.DrawLayers.UIOverlay) / 100.0f; switch (menu_tab_state) { case MenuTabStates.Stats: for (uint i = 0; i < M_PartyManager.MembersCount; i++) { Vector2 position = menu_position + member_positions[i]; H_Drawing.DrawSprite(sprite_batch, M_PartyManager.Members[i].Portrait, position, overlay_layer); M_TextManager.DrawText(sprite_batch, M_PartyManager.Members[i].Name, position + new Vector2(36, -2), overlay_layer); M_TextManager.DrawText(sprite_batch, "HP: " + M_PartyManager.Members[i].Health + "/" + M_PartyManager.Members[i].HealthMax, position + new Vector2(36, 10), overlay_layer); M_TextManager.DrawText(sprite_batch, "MP: " + M_PartyManager.Members[i].Mana + "/" + M_PartyManager.Members[i].ManaMax, position + new Vector2(36, 22), overlay_layer); } break; case MenuTabStates.Inventory: int slot = 0; for (int i = 0; i < inventory_rows; i++) { for (int j = 0; j < inventory_columns; j++) { Vector2 slot_position = menu_position + inventory_position + new Vector2(j * inventory_column_spacing, i * inventory_row_spacing); if (slot < I_Inventory.InventoryItems) { M_TextManager.DrawText(sprite_batch, I_Inventory.Inventory[slot].Name, slot_position, overlay_layer, Color.White); } else { M_TextManager.DrawText(sprite_batch, "-----", slot_position, overlay_layer, Color.Gray); } slot++; } } break; case MenuTabStates.Options: break; } } }
/// <summary> /// Generates a random key for the item, to be used in inventory clearing. /// </summary> public void GenerateKey() { this.key = this.name + ":" + H_Math.RandomInt(1000, 9999); }