public void DrawMenu(SpriteBatch sb, GameTime gt, Camera cam, TypingManager typingManager) { sb.Begin(); m_backGround.DrawMe(sb); sb.End(); sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, cam.Transform); DrawConstruct(sb, gt); m_controls.DrawPart(sb, gt); sb.End(); m_dropMenu.DrawMenu(sb, gt); m_backButton.DrawMe(sb, gt); m_saveButton.DrawMe(sb, gt); m_newTowerButton.DrawMe(sb, gt); m_controls.CurrentTowerStats(sb, m_construct, m_tower, typingManager); #if DEBUG m_controls.DebugControls(sb, m_construct); sb.Begin(); sb.DrawString(Game1.debugFont, "Foundations: " + m_foundationCount + "\nRotors: " + m_rotorCount, new Vector2(100, 500), Color.White); sb.End(); #endif for (int i = 0; i < m_partMenus.Count; i++) { m_partMenus[i].DrawMenu(sb, gt); } }
private void TypingLogic(InputManager input, TypingManager typingManager, List <MessagePopup> popups, Tower tower, ContentManager content) { if (m_typingRect.Contains((int)input.Mouse.X, (int)input.Mouse.Y)) { // If the left button is pressed, enable typing if (input.LeftPressed) { m_isTyping = true; m_textColour = Color.White; } } else { // If left button is pressed disable typing if (input.LeftPressed) { m_isTyping = false; m_textColour = Color.Black; } } // If typing is toggled, then cam WASD controls switch to typing controls if (m_isTyping) { tower.TowerName = typingManager.UpdateManager(input, tower.TowerName, content, popups); } }
public void UpdateMenu(InputManager input, TypingManager typingManager, List <MessagePopup> popups, ContentManager content, Camera cam, GameTime gt, List <TowerConstruct> schematics, List <Tower> towers, PlayerStats userData) { m_dropMenu.UpdateMenu(input); // Open a tower from the menu OpenTower(schematics, towers); // Update the general buttons m_backButton.UpdateMe(input); m_saveButton.UpdateMe(input); m_newTowerButton.UpdateMe(input); // Update the controls m_controls.UpdateControls(input, typingManager, popups, m_construct, m_tower, content, cam, gt); // Create new tower CreateNewTower(content); // Update the construct m_construct.UpdateConstruct(gt); // Saving mechanics SaveTower(popups, content, schematics, towers); // Handle menus and menu options PartMenuHandler(input, userData); }
public void UpdateControls(InputManager input, TypingManager typingManager, List <MessagePopup> popups, TowerConstruct construct, Tower tower, ContentManager content, Camera cam, GameTime gt) { // Transform mouse pos to screen coordinates Vector2 mousePos = new Vector2(input.Mouse.X, input.Mouse.Y); mousePos = Vector2.Transform(mousePos, Matrix.Invert(cam.Transform)); // Toggle Typing // Checks if the typing rectangle contains non transformed mosue coordinates TypingLogic(input, typingManager, popups, tower, content); // Part creation logic PartCreation(input, construct, tower, content); // Control selected part PartDragControl(input, cam, gt, mousePos); // Mouse hover height logic MouseHoverHeight(construct, mousePos); // Iterate through the construct parts and their part slots for (int i = 0; i < construct.Parts.Count; i++) { for (int k = 0; k < construct.Parts[i].Slots.Count; k++) { // If the slot contains mouse position if (construct.Parts[i].Slots[k].DropCircle.Contains(mousePos)) { if (input.Mouse.RightButton == ButtonState.Pressed && m_hoverHeight >= construct.Parts[i].Slots[k].SlotHeight) { //BasePart part = construct.Parts[i].Slots[k].StoredPart; //TowerMasterPart tPart = tower.TowerParts[i].TowerParts[k]; //construct.Parts[i].Parts.Remove(part); //construct.Parts.Remove(part); //tower.TowerParts[i].TowerParts.Remove(tPart); //tower.TowerParts.Remove(tPart); } // Add tower part to tower and part to construct AddPartMechanics(input, construct, tower, i, k); } } } // Is the part dropped in blank space? SpaceDrop(input); }
public void CurrentTowerStats(SpriteBatch sb, TowerConstruct construct, Tower tower, TypingManager typingManager) { // Display Tower Stats tower.TowerCost = 0; tower.UpdateTowerProperties(); int[] counts = CountTowerModules(tower); string f_id; string r_id; switch (m_foundationsIndex) { case 0: f_id = "Light"; break; case 1: f_id = "Medium"; break; case 2: f_id = "Heavy"; break; default: f_id = "Null"; break; } switch (m_rotorIndex) { case 0: r_id = "Small Basic"; break; case 1: r_id = "Small Advanced"; break; case 2: r_id = "Small Prototype"; break; case 3: r_id = "Medium Basic"; break; case 4: r_id = "Medium Advanced"; break; case 5: r_id = "Medium Prototype"; break; case 6: r_id = "Large Basic"; break; case 7: r_id = "Large Advanced"; break; case 8: r_id = "Large Prototype"; break; default: r_id = "Null"; break; } sb.Begin(); sb.DrawString(Game1.gameFontNorm, "Name: " + tower.TowerName, new Vector2(800, 20), m_textColour); if (m_isTyping) { typingManager.DrawTyper(sb, "Name: " + tower.TowerName, Game1.gameFontNorm, new Vector2(800, 30), Game1.gameFontNorm.MeasureString("Name: " + tower.TowerName).Y, false); } sb.End(); sb.Begin(); sb.DrawString(Game1.debugFont, "Health: " + tower.Health + "\nCost: " + tower.TowerCost + "\n\n Foundations\n" + "\n Tower Base: " + f_id + "\n\n Rotors\n" + "\n Rotor: " + r_id + "\n\nConstruct Parts: " + construct.Parts.Count + " / " + tower.MaxComponents + "\nHover Height: " + m_hoverHeight, new Vector2(1200, 1), Color.White); sb.End(); }