//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public Menu(GameManager gameManager) { this.gameManager = gameManager; this.backgroundSprite = null; this.currentSlotGroup = null; this.slotGroups = new List<SlotGroup>(); this.drawHUD = false; }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public Slot(SlotGroup group, Point2I position, int width) { this.group = group; this.position = position; this.width = width; this.connections = new ISlotConnection[4]; this.item = null; this.disabled = false; }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public MenuEssences(GameManager gameManager) : base(gameManager) { this.backgroundSprite = Resources.GetImage("UI/menu_essences_a"); SlotGroup group1 = new SlotGroup(); SlotGroup group2 = new SlotGroup(); currentSlotGroup = group1; this.slotGroups.Add(group1); this.slotGroups.Add(group2); Point2I[] essencePoints = new Point2I[] { new Point2I(32, 16), new Point2I(56, 16), new Point2I(72, 32), new Point2I(72, 56), new Point2I(56, 72), new Point2I(32, 72), new Point2I(16, 56), new Point2I(16, 32) }; for (int i = 0; i < 8; i++) { group1.AddSlot(essencePoints[i], 16); } for (int i = 0; i < 8; i++) { group1.GetSlotAt(i).SetConnection(Directions.Up, group1.GetSlotAt((i + 7) % 8)); group1.GetSlotAt(i).SetConnection(Directions.Down, group1.GetSlotAt((i + 1) % 8)); group1.GetSlotAt(i).SetConnection(Directions.Left, group2); group1.GetSlotAt(i).SetConnection(Directions.Right, group2); } //group2.AddSlot(new Point2I(112, 8), 32); //group2.AddSlot(new Point2I(112, 56), 32); group2.AddSlot(new Point2I(112, 32), 32); group2.GetSlotAt(0).SlotItem = new CustomSlotItem("Pieces of Heart", "4 more makes a Heart Container.", null); group2.AddSlot(new Point2I(112, 80), 32); group2.GetSlotAt(1).SlotItem = new CustomSlotItem("Save Screen", "Go to the Save Screen.", GameData.SPR_HUD_SAVE_BUTTON); for (int i = 0; i < 2; i++) { group2.GetSlotAt(i).SetConnection(Directions.Up, group2.GetSlotAt((i + 1) % 2)); group2.GetSlotAt(i).SetConnection(Directions.Down, group2.GetSlotAt((i + 1) % 2)); group2.GetSlotAt(i).SetConnection(Directions.Left, group1); group2.GetSlotAt(i).SetConnection(Directions.Right, group1); } }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public MenuSecondaryItems(GameManager gameManager) : base(gameManager) { this.backgroundSprite = Resources.GetImage("UI/menu_key_items_a"); SlotGroup group = new SlotGroup(); currentSlotGroup = group; this.slotGroups.Add(group); Slot[,] slots = new Slot[5, 4]; Slot ringBagSlot = null; Point2I gridSize = new Point2I(5, 4); for (int y = 0; y < gridSize.Y; y++) { for (int x = 0; x < gridSize.X; x++) { if (y == gridSize.Y - 1) { if (x == 0) ringBagSlot = group.AddSlot(new Point2I(12, 80), 16); slots[x, y] = group.AddSlot(new Point2I(32 + 24 * x, 80), 16); } else { slots[x, y] = group.AddSlot(new Point2I(24 + 24 * x, 8 + 24 * y), (x == (gridSize.X - 1) ? 24 : 16)); group.GetSlotAt(group.NumSlots - 1); } } } for (int y = 0; y < gridSize.Y; y++) { for (int x = 0; x < gridSize.X; x++) { if (x == 0 && y == gridSize.Y - 1) slots[x, y].SetConnection(Directions.Left, ringBagSlot); else if (x == 0) slots[x, y].SetConnection(Directions.Left, slots[gridSize.X - 1, (y + gridSize.Y - 1) % gridSize.Y]); else slots[x, y].SetConnection(Directions.Left, slots[x - 1, y]); if (x == gridSize.X - 1 && y == gridSize.Y - 2) slots[x, y].SetConnection(Directions.Right, ringBagSlot); else if (x == gridSize.X - 1) slots[x, y].SetConnection(Directions.Right, slots[0, (y + 1) % gridSize.Y]); else slots[x, y].SetConnection(Directions.Right, slots[x + 1, y]); slots[x, y].SetConnection(Directions.Up, slots[x, (y + gridSize.Y - 1) % gridSize.Y]); slots[x, y].SetConnection(Directions.Down, slots[x, (y + 1) % gridSize.Y]); } } ringBagSlot.SetConnection(Directions.Left, slots[gridSize.X - 1, gridSize.Y - 2]); ringBagSlot.SetConnection(Directions.Right, slots[0, gridSize.Y - 1]); ringBagSlot.SetConnection(Directions.Up, slots[0, gridSize.Y - 2]); ringBagSlot.SetConnection(Directions.Down, slots[0, 0]); }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public MenuWeapons(GameManager gameManager) : base(gameManager) { this.backgroundSprite = Resources.GetImage("UI/menu_weapons_a"); this.ammoSlot = 0; this.ammoMenuSize = new Point2I(16, 8); this.ammoSlotGroup = null; this.oldEquippedWeapons = new ItemWeapon[2]; SlotGroup group = new SlotGroup(); currentSlotGroup = group; this.slotGroups.Add(group); Slot[,] slots = new Slot[4, 4]; Point2I gridSize = new Point2I(4, 4); for (int y = 0; y < gridSize.Y; y++) { for (int x = 0; x < gridSize.X; x++) { slots[x, y] = group.AddSlot(new Point2I(24 + 32 * x, 8 + 24 * y), 24); } } for (int y = 0; y < gridSize.Y; y++) { for (int x = 0; x < gridSize.X; x++) { if (x == 0) { slots[x, y].SetConnection(Directions.Left, slots[gridSize.X - 1, (y + gridSize.Y - 1) % gridSize.Y]); } else { slots[x, y].SetConnection(Directions.Left, slots[x - 1, y]); } if (x == gridSize.X - 1) { slots[x, y].SetConnection(Directions.Right, slots[0, (y + 1) % gridSize.Y]); } else { slots[x, y].SetConnection(Directions.Right, slots[x + 1, y]); } slots[x, y].SetConnection(Directions.Up, slots[x, (y + gridSize.Y - 1) % gridSize.Y]); slots[x, y].SetConnection(Directions.Down, slots[x, (y + 1) % gridSize.Y]); } } }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public MenuEssences(GameManager gameManager) : base(gameManager) { this.backgroundSprite = Resources.GetImage("UI/menu_essences_a"); SlotGroup group1 = new SlotGroup(); SlotGroup group2 = new SlotGroup(); currentSlotGroup = group1; this.slotGroups.Add(group1); this.slotGroups.Add(group2); Point2I[] essencePoints = new Point2I[]{ new Point2I(32, 16), new Point2I(56, 16), new Point2I(72, 32), new Point2I(72, 56), new Point2I(56, 72), new Point2I(32, 72), new Point2I(16, 56), new Point2I(16, 32) }; for (int i = 0; i < 8; i++) { group1.AddSlot(essencePoints[i], 16); } for (int i = 0; i < 8; i++) { group1.GetSlotAt(i).SetConnection(Directions.Up, group1.GetSlotAt((i + 7) % 8)); group1.GetSlotAt(i).SetConnection(Directions.Down, group1.GetSlotAt((i + 1) % 8)); group1.GetSlotAt(i).SetConnection(Directions.Left, group2); group1.GetSlotAt(i).SetConnection(Directions.Right, group2); } //group2.AddSlot(new Point2I(112, 8), 32); //group2.AddSlot(new Point2I(112, 56), 32); group2.AddSlot(new Point2I(112, 32), 32); group2.GetSlotAt(0).SlotItem = new CustomSlotItem("Pieces of Heart", "4 more makes a Heart Container.", null); group2.AddSlot(new Point2I(112, 80), 32); group2.GetSlotAt(1).SlotItem = new CustomSlotItem("Save Screen", "Go to the Save Screen.", GameData.SPR_HUD_SAVE_BUTTON); for (int i = 0; i < 2; i++) { group2.GetSlotAt(i).SetConnection(Directions.Up, group2.GetSlotAt((i + 1) % 2)); group2.GetSlotAt(i).SetConnection(Directions.Down, group2.GetSlotAt((i + 1) % 2)); group2.GetSlotAt(i).SetConnection(Directions.Left, group1); group2.GetSlotAt(i).SetConnection(Directions.Right, group1); } }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public MenuWeapons(GameManager gameManager) : base(gameManager) { this.backgroundSprite = Resources.GetImage("UI/menu_weapons_a"); this.ammoSlot = 0; this.ammoMenuSize = new Point2I(16, 8); this.ammoSlotGroup = null; this.oldEquippedWeapons = new ItemWeapon[2]; SlotGroup group = new SlotGroup(); currentSlotGroup = group; this.slotGroups.Add(group); Slot[,] slots = new Slot[4, 4]; Point2I gridSize = new Point2I(4, 4); for (int y = 0; y < gridSize.Y; y++) { for (int x = 0; x < gridSize.X; x++) { slots[x, y] = group.AddSlot(new Point2I(24 + 32 * x, 8 + 24 * y), 24); } } for (int y = 0; y < gridSize.Y; y++) { for (int x = 0; x < gridSize.X; x++) { if (x == 0) slots[x, y].SetConnection(Directions.Left, slots[gridSize.X - 1, (y + gridSize.Y - 1) % gridSize.Y]); else slots[x, y].SetConnection(Directions.Left, slots[x - 1, y]); if (x == gridSize.X - 1) slots[x, y].SetConnection(Directions.Right, slots[0, (y + 1) % gridSize.Y]); else slots[x, y].SetConnection(Directions.Right, slots[x + 1, y]); slots[x, y].SetConnection(Directions.Up, slots[x, (y + gridSize.Y - 1) % gridSize.Y]); slots[x, y].SetConnection(Directions.Down, slots[x, (y + 1) % gridSize.Y]); } } }
public void NextSlot(int direction) { ISlotConnection connection = currentSlotGroup.CurrentSlot.GetConnectionAt(direction); if (connection != null) { if (connection is Slot) { Slot slot = connection as Slot; slot.Select(); if (slot.Disabled) { NextSlot(direction); return; } AudioSystem.PlaySound(GameData.SOUND_MENU_CURSOR_MOVE); } else if (connection is SlotGroup) { currentSlotGroup = (connection as SlotGroup); AudioSystem.PlaySound(GameData.SOUND_MENU_CURSOR_MOVE); } } }
public void NextSlot(int direction) { ISlotConnection connection = currentSlotGroup.CurrentSlot.GetConnectionAt(direction); if (connection != null) { if (connection is Slot) { Slot slot = connection as Slot; slot.Select(); if (slot.Disabled) { NextSlot(direction); return; } AudioSystem.PlaySound("UI/menu_cursor_move"); } else if (connection is SlotGroup) { currentSlotGroup = (connection as SlotGroup); AudioSystem.PlaySound("UI/menu_cursor_move"); } } }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public MenuSecondaryItems(GameManager gameManager) : base(gameManager) { this.backgroundSprite = Resources.GetImage("UI/menu_key_items_a"); SlotGroup group = new SlotGroup(); currentSlotGroup = group; this.slotGroups.Add(group); Slot[,] slots = new Slot[5, 4]; Slot ringBagSlot = null; Point2I gridSize = new Point2I(5, 4); for (int y = 0; y < gridSize.Y; y++) { for (int x = 0; x < gridSize.X; x++) { if (y == gridSize.Y - 1) { if (x == 0) { ringBagSlot = group.AddSlot(new Point2I(12, 80), 16); } slots[x, y] = group.AddSlot(new Point2I(32 + 24 * x, 80), 16); } else { slots[x, y] = group.AddSlot(new Point2I(24 + 24 * x, 8 + 24 * y), (x == (gridSize.X - 1) ? 24 : 16)); group.GetSlotAt(group.NumSlots - 1); } } } for (int y = 0; y < gridSize.Y; y++) { for (int x = 0; x < gridSize.X; x++) { if (x == 0 && y == gridSize.Y - 1) { slots[x, y].SetConnection(Directions.Left, ringBagSlot); } else if (x == 0) { slots[x, y].SetConnection(Directions.Left, slots[gridSize.X - 1, (y + gridSize.Y - 1) % gridSize.Y]); } else { slots[x, y].SetConnection(Directions.Left, slots[x - 1, y]); } if (x == gridSize.X - 1 && y == gridSize.Y - 2) { slots[x, y].SetConnection(Directions.Right, ringBagSlot); } else if (x == gridSize.X - 1) { slots[x, y].SetConnection(Directions.Right, slots[0, (y + 1) % gridSize.Y]); } else { slots[x, y].SetConnection(Directions.Right, slots[x + 1, y]); } slots[x, y].SetConnection(Directions.Up, slots[x, (y + gridSize.Y - 1) % gridSize.Y]); slots[x, y].SetConnection(Directions.Down, slots[x, (y + 1) % gridSize.Y]); } } ringBagSlot.SetConnection(Directions.Left, slots[gridSize.X - 1, gridSize.Y - 2]); ringBagSlot.SetConnection(Directions.Right, slots[0, gridSize.Y - 1]); ringBagSlot.SetConnection(Directions.Up, slots[0, gridSize.Y - 2]); ringBagSlot.SetConnection(Directions.Down, slots[0, 0]); }
//----------------------------------------------------------------------------- // Overridden methods //----------------------------------------------------------------------------- public override void Update() { base.Update(); if (!inSubMenu) { // Equip weapons. if (Controls.A.IsPressed() || Controls.B.IsPressed()) { int slot = (Controls.A.IsPressed() ? 0 : 1); ItemWeapon selectedItem = slotGroups[0].CurrentSlot.SlotItem as ItemWeapon; if (selectedItem != null && selectedItem.NumAmmos > 1) { ammoMenuSize = new Point2I(16, 8); ammoSlot = slot; inSubMenu = true; currentSlotGroup = null; ammoSlotGroup = new SlotGroup(); List<Ammo> ammo = new List<Ammo>(); int currentAmmoIndex = 0; for (int i = 0; i < selectedItem.NumAmmos; i++) { if (selectedItem.GetAmmoAt(i).IsObtained) { if (selectedItem.CurrentAmmo == i) currentAmmoIndex = ammo.Count; ammo.Add(selectedItem.GetAmmoAt(i)); } } int start = (160 - (ammo.Count * 24 + 8)) / 2 + 8; int y = (DrawAmmoMenuAtTop ? 20 : 60); for (int i = 0; i < ammo.Count; i++) { ammoSlotGroup.AddSlot(new Point2I(start + 24 * i, y), 16); ammoSlotGroup.GetSlotAt(i).SlotItem = ammo[i]; } for (int i = 0; i < ammo.Count; i++) { ammoSlotGroup.GetSlotAt(i).SetConnection(Directions.Left, ammoSlotGroup.GetSlotAt((i + ammo.Count - 1) % ammo.Count)); ammoSlotGroup.GetSlotAt(i).SetConnection(Directions.Right, ammoSlotGroup.GetSlotAt((i + 1) % ammo.Count)); } ammoSlotGroup.SetCurrentSlot(ammoSlotGroup.GetSlotAt(currentAmmoIndex)); } else { EquipWeapon(slot); } } } else { Point2I maxSize = new Point2I(ammoSlotGroup.NumSlots * 24 + 8, 32); if (ammoMenuSize.X < maxSize.X) { ammoMenuSize.X += 8; } else if (ammoMenuSize.Y < maxSize.Y) { ammoMenuSize.Y += 4; if (ammoMenuSize.Y == maxSize.Y) { currentSlotGroup = ammoSlotGroup; ResetDescription(); } } else if (Controls.A.IsPressed() || Controls.B.IsPressed() || Controls.Start.IsPressed()) { Ammo selectedAmmo = ammoSlotGroup.CurrentSlot.SlotItem as Ammo; ItemWeapon weapon = slotGroups[0].CurrentSlot.SlotItem as ItemWeapon; for (int i = 0; i < weapon.NumAmmos; i++) { if (weapon.GetAmmoAt(i) == selectedAmmo) weapon.CurrentAmmo = i; } EquipWeapon(ammoSlot); inSubMenu = false; ammoSlotGroup = null; currentSlotGroup = slotGroups[0]; } } }
public override void Update() { base.Update(); if (!inSubMenu) { // Equip weapons. if (Controls.A.IsPressed() || Controls.B.IsPressed()) { int slot = (Controls.A.IsPressed() ? 0 : 1); ItemWeapon selectedItem = slotGroups[0].CurrentSlot.SlotItem as ItemWeapon; if (selectedItem != null && selectedItem.NumAmmos > 1) { ammoMenuSize = new Point2I(16, 8); ammoSlot = slot; inSubMenu = true; currentSlotGroup = null; ammoSlotGroup = new SlotGroup(); List <Ammo> ammo = new List <Ammo>(); int currentAmmoIndex = 0; for (int i = 0; i < selectedItem.NumAmmos; i++) { if (selectedItem.GetAmmoAt(i).IsObtained) { if (selectedItem.CurrentAmmo == i) { currentAmmoIndex = ammo.Count; } ammo.Add(selectedItem.GetAmmoAt(i)); } } int start = (160 - (ammo.Count * 24 + 8)) / 2 + 8; int y = (DrawAmmoMenuAtTop ? 20 : 60); for (int i = 0; i < ammo.Count; i++) { ammoSlotGroup.AddSlot(new Point2I(start + 24 * i, y), 16); ammoSlotGroup.GetSlotAt(i).SlotItem = ammo[i]; } for (int i = 0; i < ammo.Count; i++) { ammoSlotGroup.GetSlotAt(i).SetConnection(Directions.Left, ammoSlotGroup.GetSlotAt((i + ammo.Count - 1) % ammo.Count)); ammoSlotGroup.GetSlotAt(i).SetConnection(Directions.Right, ammoSlotGroup.GetSlotAt((i + 1) % ammo.Count)); } ammoSlotGroup.SetCurrentSlot(ammoSlotGroup.GetSlotAt(currentAmmoIndex)); } else { EquipWeapon(slot); } } } else { Point2I maxSize = new Point2I(ammoSlotGroup.NumSlots * 24 + 8, 32); if (ammoMenuSize.X < maxSize.X) { ammoMenuSize.X += 8; } else if (ammoMenuSize.Y < maxSize.Y) { ammoMenuSize.Y += 4; if (ammoMenuSize.Y == maxSize.Y) { currentSlotGroup = ammoSlotGroup; ResetDescription(); } } else if (Controls.A.IsPressed() || Controls.B.IsPressed() || Controls.Start.IsPressed()) { Ammo selectedAmmo = ammoSlotGroup.CurrentSlot.SlotItem as Ammo; ItemWeapon weapon = slotGroups[0].CurrentSlot.SlotItem as ItemWeapon; for (int i = 0; i < weapon.NumAmmos; i++) { if (weapon.GetAmmoAt(i) == selectedAmmo) { weapon.CurrentAmmo = i; } } EquipWeapon(ammoSlot); inSubMenu = false; ammoSlotGroup = null; currentSlotGroup = slotGroups[0]; } } }