////////////////////////////////////////////////////////////////// //Constructors public GalacticGameEngine() { ID = ""; Name = ""; Player1 = new Player(); _gameIsRunning = false; curGalacticDayMang = new GalacticDayManager(); curGameUniverse = new GameUniverse(); MainMapControl = new Controls.GameEngineControls.GalacticMapControl(); TopBarControl = new Controls.GameEngineControls.GameTopBarControl(); RightBarControl = new Controls.GameEngineControls.GameRightBarControl(); LeftPlanetMenu = new Controls.PlanetsInGalaxyMenu(); RightPlanetMenu = new Controls.PlanetsInGalaxyMenu(); LeftPlanetOrbitMenu = new Controls.PlanetOrbitControl(); InfoMenu = new Controls.GameInformationMenu(); PlanetCommandMenu = new Controls.PlanetCommandControl(); ConstructionMenu = new Controls.GameEngineControls.ConstructionMenuControl(); }
public void CreateOrbitCommandMenu(GameUpdateClassComponents curGameUpdateComponents, DataCards.Planet curPlanet) { //Create a Orbit Command Menu //Disable other controls this.disableAllControls(); Rectangle myAvgRect = new Rectangle(300, 200, 600, 400); List<GameEngine.PlayerInvObjs.InvUnit> shipInvUnits = new List<GameEngine.PlayerInvObjs.InvUnit>(); shipInvUnits = curGameUniverse.getPlanetByName(curPlanet.Name).Orbit.StarshipFleetsInOrbit; List<Controls.DataCardIconControl> dataCards = new List<GalacticConquest.Controls.DataCardIconControl>(); foreach (GameEngine.PlayerInvObjs.InvUnit curIU in shipInvUnits) { Controls.DataCardIconControl curDataCard = new GalacticConquest.Controls.DataCardIconControl(); //If Under construction@!!///// if (curIU._underConstruction) { curDataCard.imgControl = curGameUpdateComponents._staticTextureImages._underConstructionFacility; curDataCard.strControlText = curIU.iuShip.HeaderText + " (U/C " + curIU._remainingConstructionDays.ToString() + " days left)"; } else { curDataCard.imgControl = Texture2D.FromFile(curGameUpdateComponents._graphicsDevice, Model.DataUtilities._ShipsImagePath + curIU.iuShip.Name + ".jpg"); curDataCard.strControlText = curIU.iuShip.HeaderText; } Rectangle curDataCardRect = new Rectangle(myAvgRect.X + 10, myAvgRect.Y + 10, curDataCard.imgControl.Width, curDataCard.imgControl.Height); curDataCard.rectControl = curDataCardRect; curDataCard._isNull = false; dataCards.Add(curDataCard); } ///////////////////////////////// //Create Orbit Planet Menu ////////////////////////////////// Texture2D curTexture = curGameUpdateComponents._staticTextureImages._orbitCommandMenu; //Vector2 curVector = new Vector2(100, 100); //Rectangle curRect = new Rectangle(100, 100, 300, 300); Controls.PlanetOrbitControl curMenuControl = new Controls.PlanetOrbitControl(); //Start Menu Button List List<Controls.FancyButtonControl> menuButtons = new List<Controls.FancyButtonControl>(); //Get Continue Button Settings Texture2D curButtonTexture = curGameUpdateComponents._staticTextureImages._buttonTexture; Vector2 curButtonVector = new Vector2(110, 340); Rectangle curButtonRect = new Rectangle(110, 340, 130, 50); //Add the Continue Button //menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnSaveSettings", curButtonTexture, curButtonVector, curButtonRect, "Save")); //Add the Exit Button curButtonVector = new Vector2(365, 650); curButtonRect = new Rectangle(365, 650, 130, 50); menuButtons.Add(new Controls.FancyButtonControl("btnExitOrbitMenu", curButtonTexture, curButtonVector, curButtonRect, "Exit")); //Create the Menu Control curMenuControl = new Controls.PlanetOrbitControl("mnuOrbit", curPlanet.Name, curTexture, Model.OrientationType.Left, curPlanet.Name, "...Settings List Here...", menuButtons, curGameUniverse.getAllPlanetsList(), curGameUpdateComponents, this.curGameUniverse.getPlanetByName(curPlanet.Name).Orbit.StarshipFleetsInOrbit); this.LeftPlanetOrbitMenu = curMenuControl; //Add menu control to list //activeImgMenus.Add(curMenuControl); }
//////////////////////////////////////////// //Check Mouse Clicks public void checkGameRunningMouseClick(GameUpdateClassComponents curGameUpdateComponents) { if (this._gameIsRunning) { /////////////////////////////////////// //Check Orbit Planet Menus ////////////////////////////////////// //Check Orbit Menu if (!this.LeftPlanetOrbitMenu._isNull && this.LeftPlanetOrbitMenu._isEnabled) { bool blnExit = false; //foreach(Controls.FancyDropDownBoxControl curDDB in this.LeftPlanetOrbitMenu.menuDropDownBoxControls) //{ for (int i = 0; i < this.LeftPlanetOrbitMenu.menuDropDownBoxControls.Count; i++) { if (LeftPlanetOrbitMenu.menuDropDownBoxControls[i]._isEnabled) { if (LeftPlanetOrbitMenu.menuDropDownBoxControls[i].dropDownBoxArrow.mouseClicked(curGameUpdateComponents)) { if (LeftPlanetOrbitMenu.menuDropDownBoxControls[i].dropDownCollapsed) LeftPlanetOrbitMenu.menuDropDownBoxControls[i].dropDownCollapsed = false; else LeftPlanetOrbitMenu.menuDropDownBoxControls[i].dropDownCollapsed = true; } if (!LeftPlanetOrbitMenu.menuDropDownBoxControls[i].dropDownCollapsed) { LeftPlanetOrbitMenu.menuDropDownBoxControls[i].mouseClicked(curGameUpdateComponents); } } } //} bool blnOrbitLeftClose = false; int menuInc = 0; //Run through each Button foreach (Controls.FancyButtonControl curButton in this.LeftPlanetOrbitMenu.menuButtons) { if (!curButton._isNull) { if (curButton.mouseClicked(curGameUpdateComponents)) { if (curButton.ID == "btnExitOrbitMenu") {//Clicked Exit Galaxy blnOrbitLeftClose = true; } if (curButton.ID.Length > "btnSendShip".Length) { if (curButton.ID.Substring(0, "btnSendShip".Length) == "btnSendShip") { int invUnitID = Convert.ToInt32(curButton.ID.Replace("btnSendShip", "")); string originalPlanetName = LeftPlanetOrbitMenu.strPlanetName; GameEngine.PlayerInvObjs.InvUnit myInv = curGameUniverse.getInvUnitByID(invUnitID, Model.DataCardType.Ship); string desitiantionPlanetName = LeftPlanetOrbitMenu.getDestinationPlanetNameByID(invUnitID); DataCards.Planet oriPlnt = curGameUniverse.getPlanetByName(originalPlanetName); DataCards.Planet destPlnt = curGameUniverse.getPlanetByName(desitiantionPlanetName); oriPlnt.Orbit.removeShipFromOrbitByID(myInv.id); //Takes 5 days to get anywhere! myInv.transitObj.setTravelTime(5); destPlnt.Orbit.StarshipFleetsInOrbit.Add(myInv); LeftPlanetOrbitMenu.menuButtons.RemoveAt(menuInc); blnOrbitLeftClose = true; break; //myInv. } } //if (curButton.ID == "btnExitPlanetCmdMenu") //{//Clicked Exit Planet Command // exitPlntCmdMenu = true; //} //if (curButton.ID == "btnContinue") //{//Clicked Exit Faction form // _continueClicked = true; //} } } menuInc++; } if (blnOrbitLeftClose) { this.LeftPlanetOrbitMenu = new Controls.PlanetOrbitControl(); this.LeftPlanetMenu.Enable(); this.RightPlanetMenu.Enable(); } } /////////////////////////////////////// //Check Galaxy Planet Menus ////////////////////////////////////// //Check Left Menu if (!this.LeftPlanetMenu._isNull && this.LeftPlanetMenu._isEnabled) { bool exitLeftGPMenu = false; bool exitRightGPMenu = false; //Run through each Button foreach (Controls.FancyButtonControl curButton in this.LeftPlanetMenu.menuButtons) { if (!curButton._isNull) { if (curButton.mouseClicked(curGameUpdateComponents)) { if (curButton.ID == "btnExitGalaxyMenu") {//Clicked Exit Galaxy exitLeftGPMenu = true; } //if (curButton.ID == "btnContinue") //{//Clicked Exit Faction form // _continueClicked = true; //} } } } float startingPlanetY = this.LeftPlanetMenu.vectorPos.Y + 50; float infoButtonX = Model.StaticValues.xPaddingForInfoBuutton + this.LeftPlanetMenu.vectorPos.X; float commandButtonX = Model.StaticValues.xPaddingForCommandButton + this.LeftPlanetMenu.vectorPos.X; float orbitButtonX = Model.StaticValues.xPaddingForOrbitButton + this.LeftPlanetMenu.vectorPos.X; foreach (DataCards.Planet curPlanet in this.LeftPlanetMenu.menuPlanetControls) { //Check for Info Button if (curGameUpdateComponents._curMouseState.X > infoButtonX && curGameUpdateComponents._curMouseState.X < (infoButtonX + 30)) { if (curGameUpdateComponents._curMouseState.Y > startingPlanetY && curGameUpdateComponents._curMouseState.Y < (startingPlanetY + 30)) { CreatePlanetInfoMenu(curGameUpdateComponents, curPlanet); } } //Check for Command Button if (curGameUpdateComponents._curMouseState.X > commandButtonX && curGameUpdateComponents._curMouseState.X < (commandButtonX + 30)) { if (curGameUpdateComponents._curMouseState.Y > startingPlanetY && curGameUpdateComponents._curMouseState.Y < (startingPlanetY + 30)) { CreatePlanetCommandMenu(curGameUpdateComponents, curPlanet); } } //Check for Orbit Button if (curGameUpdateComponents._curMouseState.X > orbitButtonX && curGameUpdateComponents._curMouseState.X < (orbitButtonX + 30)) { if (curGameUpdateComponents._curMouseState.Y > startingPlanetY && curGameUpdateComponents._curMouseState.Y < (startingPlanetY + 30)) { //CreatePlanetCommandMenu(curGameUpdateComponents, curPlanet); CreateOrbitCommandMenu(curGameUpdateComponents, curPlanet); } } startingPlanetY += 60; } if (exitLeftGPMenu) { this.LeftPlanetMenu = new Controls.PlanetsInGalaxyMenu(); } if (exitRightGPMenu) { this.RightPlanetMenu = new Controls.PlanetsInGalaxyMenu(); } } //Check Info Menu if (!this.InfoMenu._isNull && this.InfoMenu._isEnabled) { bool exitInfoMenu = false; //Run through each Button foreach (Controls.FancyButtonControl curButton in this.InfoMenu.menuButtons) { if (!curButton._isNull) { if (curButton.mouseClicked(curGameUpdateComponents)) { if (curButton.ID == "btnExitInfoMenu") {//Clicked Exit Galaxy exitInfoMenu = true; } //if (curButton.ID == "btnExitPlanetCmdMenu") //{//Clicked Exit Planet Command // exitPlntCmdMenu = true; //} //if (curButton.ID == "btnContinue") //{//Clicked Exit Faction form // _continueClicked = true; //} } } } if (exitInfoMenu) { this.InfoMenu = new Controls.GameInformationMenu(); this.LeftPlanetMenu.Enable(); this.RightPlanetMenu.Enable(); } //if (exitPlntCmdMenu) //{ // this.PlanetCommandMenu = new Controls.PlanetCommandControl(); // this.LeftPlanetMenu.Enable(); // this.RightPlanetMenu.Enable(); //} } //Check Planet Control Menu if (!this.PlanetCommandMenu._isNull && this.PlanetCommandMenu._isEnabled) { bool exitPlntCmdMenu = false; //Run through each Button foreach (Controls.FancyButtonControl curButton in this.PlanetCommandMenu.menuButtons) { if (!curButton._isNull) { if (curButton.mouseClicked(curGameUpdateComponents)) { // if (curButton.ID == "btnExitInfoMenu") // {//Clicked Exit Galaxy // exitInfoMenu = true; // } if (curButton.ID == "btnExitPlanetCmdMenu") {//Clicked Exit Planet Command exitPlntCmdMenu = true; } //if (curButton.ID == "btnContinue") //{//Clicked Exit Faction form // _continueClicked = true; //} } } } foreach (Controls.TabPanel.TabPanel curTP in PlanetCommandMenu.tabControl.tabPanels) { Controls.PanelControl curPnl = curTP.panel; //Prolly dont need a loop here but whatevs/// if (curTP.selected) { foreach (Controls.FancyButtonControl curBtn in curPnl.menuButtons) { if (curBtn.mouseClicked(curGameUpdateComponents)) { if (curBtn.ID == "btnFacilityMFR") { buildConstructionMenu(curGameUpdateComponents, curBtn.ID); } if (curBtn.ID == "btnShipMFR") { buildConstructionMenu(curGameUpdateComponents, curBtn.ID); //buildShipMenu(curGameUpdateComponents, curBtn.ID); } if (curBtn.ID == "btnTroopsMFR") { buildConstructionMenu(curGameUpdateComponents, curBtn.ID); //buildShipMenu(curGameUpdateComponents, curBtn.ID); } if (curBtn.ID == "btnTroops") { loadAsManyTroopsOnShipsAsPossible(PlanetCommandMenu.SelectedPlanetName); } } } } } PlanetCommandMenu.CheckMouseClick(curGameUpdateComponents); if (exitPlntCmdMenu) { this.PlanetCommandMenu = new Controls.PlanetCommandControl(); this.LeftPlanetMenu.Enable(); this.RightPlanetMenu.Enable(); } } //Check Construction Menu if (!ConstructionMenu._isNull) { if (ConstructionMenu.destinationDropDown._isEnabled) { //Collapse or close menu if arrow clicked if (ConstructionMenu.destinationDropDown.dropDownBoxArrow.mouseClicked(curGameUpdateComponents)) { if (ConstructionMenu.destinationDropDown.dropDownCollapsed) ConstructionMenu.destinationDropDown.dropDownCollapsed = false; else ConstructionMenu.destinationDropDown.dropDownCollapsed = true; } //Select a new test option as "selected" if (!ConstructionMenu.destinationDropDown.dropDownCollapsed) { ConstructionMenu.destinationDropDown.mouseClicked(curGameUpdateComponents); } } if (ConstructionMenu.facilityTypeDropDown._isEnabled) { //Collapse or close menu if arrow clicked if (ConstructionMenu.facilityTypeDropDown.dropDownBoxArrow.mouseClicked(curGameUpdateComponents)) { if (ConstructionMenu.facilityTypeDropDown.dropDownCollapsed) ConstructionMenu.facilityTypeDropDown.dropDownCollapsed = false; else ConstructionMenu.facilityTypeDropDown.dropDownCollapsed = true; } //Select a new test option as "selected" if (!ConstructionMenu.facilityTypeDropDown.dropDownCollapsed) { ConstructionMenu.facilityTypeDropDown.mouseClicked(curGameUpdateComponents); } } //Check buttons foreach (Controls.FancyButtonControl curBtn in ConstructionMenu.menuButtons) { if (curBtn.mouseClicked(curGameUpdateComponents)) { //Exit if (curBtn.ID == "btnExitManuFacilityMenu") { ConstructionMenu = new Controls.GameEngineControls.ConstructionMenuControl(); } //Build new facility if (curBtn.ID == "btnContructManuFacilityMenu") {/////////Under construction is going on Type not Entity!!! string strFacilityTypeName = ConstructionMenu.facilityTypeDropDown.textOptions[ConstructionMenu.facilityTypeDropDown.selectedIndex]; string strPlanetName = ConstructionMenu.destinationDropDown.textOptions[ConstructionMenu.destinationDropDown.selectedIndex]; DataCards.Facility facilCheck = staticDataCards.getFacilityByName(strFacilityTypeName); //InvUnit will be like... An Entity. Maybe I will rename it that later when its a pain in the ass to change it :P GameEngine.PlayerInvObjs.InvUnit newUnit = new GameEngine.PlayerInvObjs.InvUnit(); newUnit._underConstruction = true; newUnit.startEntityConstruction(facilCheck, strPlanetName); newUnit.FacilityOwner = new GameEngine.GalacticComponents.Owner(Player1); //Add the Inventory Object to the GroundSpaces->Facilites array curGameUniverse.getPlanetByName(strPlanetName).GroundSpaces.Facilities.Add(newUnit); Player1.curGameResourceMang.invRawMaterials -= facilCheck.baseManufactureCost.ResourceCost; ConstructionMenu = new Controls.GameEngineControls.ConstructionMenuControl(); } //Build new Ship if (curBtn.ID == "btnContructManuShipMenu") {/////////Under construction is going on Type not Entity!!! string strFacilityTypeShipName = ConstructionMenu.facilityTypeDropDown.textOptions[ConstructionMenu.facilityTypeDropDown.selectedIndex]; string strPlanetName = ConstructionMenu.destinationDropDown.textOptions[ConstructionMenu.destinationDropDown.selectedIndex]; DataCards.Ship shipCheck = staticDataCards.getShipByName(strFacilityTypeShipName); //InvUnit will be like... An Entity. Maybe I will rename it that later when its a pain in the ass to change it :P GameEngine.PlayerInvObjs.InvUnit newUnit = new GameEngine.PlayerInvObjs.InvUnit(); newUnit._underConstruction = true; newUnit.startEntityConstruction(shipCheck, strPlanetName); newUnit.FacilityOwner = new GameEngine.GalacticComponents.Owner(Player1); //Add ship to orbit curGameUniverse.getPlanetByName(strPlanetName).Orbit.StarshipFleetsInOrbit.Add(newUnit); Player1.curGameResourceMang.invRawMaterials -= 100;//Charging 100 by default ConstructionMenu = new Controls.GameEngineControls.ConstructionMenuControl(); } //Build new Troop if (curBtn.ID == "btnContructManuTroopsMenu") {/////////Under construction is going on Type not Entity!!! string strFacilityTypeTroopsName = ConstructionMenu.facilityTypeDropDown.textOptions[ConstructionMenu.facilityTypeDropDown.selectedIndex]; string strPlanetName = ConstructionMenu.destinationDropDown.textOptions[ConstructionMenu.destinationDropDown.selectedIndex]; DataCards.Troops TroopsCheck = staticDataCards.getTroopsByName(strFacilityTypeTroopsName); //InvUnit will be like... An Entity. Maybe I will rename it that later when its a pain in the ass to change it :P GameEngine.PlayerInvObjs.InvUnit newUnit = new GameEngine.PlayerInvObjs.InvUnit(); newUnit._underConstruction = true; newUnit.startEntityConstruction(TroopsCheck, strPlanetName); newUnit.FacilityOwner = new GameEngine.GalacticComponents.Owner(Player1); //Add troops to planet curGameUniverse.getPlanetByName(strPlanetName).GroundSpaces.Troops.Add(newUnit); Player1.curGameResourceMang.invRawMaterials -= 10;//Charging 10 by default ConstructionMenu = new Controls.GameEngineControls.ConstructionMenuControl(); } } } } //Only Check if GP menus are not displayed if (this.LeftPlanetMenu._isNull && this.RightPlanetMenu._isNull) { //Check Galaxy Clicks foreach (DataCards.Galaxy curGalaxy in this.curGameUniverse.TheUniverse) { string[] strArryXYBounds = curGalaxy.MouseImageAreaCoordinates.Split(';'); Model.XYStringToInt topLeft = new Model.XYStringToInt(strArryXYBounds[0]); Model.XYStringToInt bottomRight = new Model.XYStringToInt(strArryXYBounds[1]); if (curGameUpdateComponents._curMouseState.X > topLeft.X && curGameUpdateComponents._curMouseState.X < bottomRight.X) { if (curGameUpdateComponents._curMouseState.Y > topLeft.Y && curGameUpdateComponents._curMouseState.Y < bottomRight.Y) { ///////////////////////////////// //Create Galaxy Planets Menu ////////////////////////////////// Texture2D curTexture = curGameUpdateComponents._staticTextureImages._galacticPlanetView; //Vector2 curVector = new Vector2(100, 100); //Rectangle curRect = new Rectangle(100, 100, 300, 300); Controls.PlanetsInGalaxyMenu curMenuControl = new Controls.PlanetsInGalaxyMenu(); //Start Menu Button List List<Controls.FancyButtonControl> menuButtons = new List<Controls.FancyButtonControl>(); //Get Continue Button Settings Texture2D curButtonTexture = curGameUpdateComponents._staticTextureImages._buttonTexture; Vector2 curButtonVector = new Vector2(110, 340); Rectangle curButtonRect = new Rectangle(110, 340, 130, 50); //Add the Continue Button //menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnSaveSettings", curButtonTexture, curButtonVector, curButtonRect, "Save")); //Add the Exit Button curButtonVector = new Vector2(365, 650); curButtonRect = new Rectangle(365, 650, 130, 50); menuButtons.Add(new Controls.FancyButtonControl("btnExitGalaxyMenu", curButtonTexture, curButtonVector, curButtonRect, "Exit")); //Create the Menu Control curMenuControl = new Controls.PlanetsInGalaxyMenu("mnuGalaxy", curTexture, Model.OrientationType.Left, curGalaxy.Name, "...Settings List Here...", menuButtons); curMenuControl.menuPlanetControls = this.curGameUniverse.getPlanetListByGalaxyName(curGalaxy.Name); this.LeftPlanetMenu = curMenuControl; //Add menu control to list //activeImgMenus.Add(curMenuControl); } } } } checkTopBarMouseClick(curGameUpdateComponents); } }