private void BlackHoleSystemControls(Screen blackHoleSystem, BlackHoleSystem bhs) { KeyboardState state = Keyboard.GetState(); if ((state.IsKeyDown(Keys.Right) || state.IsKeyDown(Keys.D)) && Math.Abs(((BackGround)blackHoleSystem.Objects["Back"]).X) < ((BackGround)blackHoleSystem.Objects["Back"]).Width - graphics.PreferredBackBufferWidth) { ((IMoveble)blackHoleSystem.Objects["Back"]).X -= MOVEMENT; foreach (IDraw obj in bhs.Objects) { ((IMoveble)obj).X -= MOVEMENT; if (obj is StationOnBuilding) { obj.ToStationOnBuilding().Progress.X -= MOVEMENT; } } } if ((state.IsKeyDown(Keys.Left) || state.IsKeyDown(Keys.A)) && ((BackGround)blackHoleSystem.Objects["Back"]).X < 0) { ((IMoveble)blackHoleSystem.Objects["Back"]).X += MOVEMENT; foreach (IDraw obj in bhs.Objects) { ((IMoveble)obj).X += MOVEMENT; if (obj is StationOnBuilding) { obj.ToStationOnBuilding().Progress.X += MOVEMENT; } } } if ((state.IsKeyDown(Keys.Up) || state.IsKeyDown(Keys.W)) && ((BackGround)blackHoleSystem.Objects["Back"]).Y < 0) { ((IMoveble)blackHoleSystem.Objects["Back"]).Y += 6; foreach (IDraw obj in bhs.Objects) { ((IMoveble)obj).Y += MOVEMENT; if (obj is StationOnBuilding) { obj.ToStationOnBuilding().Progress.Y += MOVEMENT; } } } if ((state.IsKeyDown(Keys.Down) || state.IsKeyDown(Keys.S)) && Math.Abs(((BackGround)blackHoleSystem.Objects["Back"]).Y) < ((BackGround)blackHoleSystem.Objects["Back"]).Height - graphics.PreferredBackBufferHeight) { ((IMoveble)blackHoleSystem.Objects["Back"]).Y -= MOVEMENT; foreach (IDraw obj in bhs.Objects) { ((IMoveble)obj).Y -= MOVEMENT; if (obj is StationOnBuilding) { obj.ToStationOnBuilding().Progress.Y -= MOVEMENT; } } } if (state.IsKeyDown(Keys.M)) { UnloadEvents("BlackHoleSystem"); GalaxyMapOpen(screens["GalaxyMap"].Objects["Map"].ToMap()); ((Popup)screens["BlackHoleSystem"].Objects["MoreInfoPopup"]).IsVisible = false; ((BackGround)blackHoleSystem.Objects["Back"]).X = 0; ((BackGround)blackHoleSystem.Objects["Back"]).Y = 0; foreach (IDraw obj in bhs.Objects) { if (obj is BlackHole) { ((BlackHole)obj).X = 1000; ((BlackHole)obj).Y = 1000; } } } if (state.IsKeyDown(Keys.Escape) && !isEscDown) { isEscDown = true; EscEvents(blackHoleSystem); } if (state.IsKeyUp(Keys.Escape)) { isEscDown = false; } }
//------------------------------------------------------------ //BLACKHOLE SYSTEM CREATE //------------------------------------------------------------ private void CreateBlackHoleSystem(BlackHoleSystem bhs) { if (!screens.ContainsKey("BlackHoleSystem")) { Screen BlackHoleSystemScreen = new Screen(); BackGround BlackHoleSystemBack = CreateBackground("Temp/SolarBackTest", Scales.None, 255f, false); BlackHoleSystemScreen.Objects.Add("Back", BlackHoleSystemBack); //info popup BackGround infoPopupBack = CreateBackground("UI/SoftPopup", Scales.Quarter, 255f); Popup infoPopup = CreatePopup(infoPopupBack, Scales.None, 400, 400); GameString infoString = CreateGameString("SpriteFont1", "", 30, 20, Color.Azure); infoPopup.Objects.Add("InfoString", infoString); //end info popup //more info popup TextBox nameTextBox = CreateTextBox("Square", "SpriteFont1", 332, 40, Scales.ThreeWithHalfTenth); Popup moreInfoPopup = CreateInfoPopup(); //for buttons position BackGround moreInfoPopupBack = (BackGround)moreInfoPopup.Objects["Back"]; GameString name = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Name", Shift(30, 20), Color.Azure); ((GameString)nameTextBox.ContentSource).Position = new Vector2(moreInfoPopup.Position.X + nameTextBox.Position.X + 10, moreInfoPopup.Position.Y + nameTextBox.Position.Y + 5); GameString PlanetSizeString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Size", Shift(30, 50), Color.Azure); GameString MinTemperatureString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Minimum Temperature", Shift(30, 80), Color.Azure); GameString MaxTemperatureString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Maximum Temperature", Shift(30, 110), Color.Azure); GameString IsAborigensString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Life", Shift(30, 140), Color.Azure); GameString MassString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Mass", Shift(30, 170), Color.Azure); GameString OwnerString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Owner", Shift(30, 200), Color.Azure); GameString RaceString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Race", Shift(30, 230), Color.Azure); GameString GravityString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Gravity", Shift(30, 260), Color.Azure); GameString ClimatString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Climat", Shift(30, 290), Color.Azure); GameString StabilityString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Stability", Shift(30, 320), Color.Azure); GameString FertilityString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Fertility", Shift(30, 350), Color.Azure); GameString RadioactivityString = new GameString(Content.Load<SpriteFont>("Fonts/SpriteFont1"), "Radioactivity", Shift(30, 380), Color.Azure); moreInfoPopup.Objects.Add("NameString", name); moreInfoPopup.Objects.Add("PlanetSizeString", PlanetSizeString); moreInfoPopup.Objects.Add("MinTemperatureString", MinTemperatureString); moreInfoPopup.Objects.Add("MaxTemperatureString", MaxTemperatureString); moreInfoPopup.Objects.Add("IsAborigensString", IsAborigensString); moreInfoPopup.Objects.Add("MassString", MassString); moreInfoPopup.Objects.Add("OwnerString", OwnerString); moreInfoPopup.Objects.Add("RaceString", RaceString); moreInfoPopup.Objects.Add("GravityString", GravityString); moreInfoPopup.Objects.Add("ClimatString", ClimatString); moreInfoPopup.Objects.Add("StabilityString", StabilityString); moreInfoPopup.Objects.Add("FertilityString", FertilityString); moreInfoPopup.Objects.Add("RadioactivityString", RadioactivityString); moreInfoPopup.Objects.Add("NameTextBox", nameTextBox); //end more info popup BlackHoleSystemScreen.Objects.Add("BlackHoleSystem", bhs); BlackHoleSystemScreen.Objects.Add("InfoPopup", infoPopup); BlackHoleSystemScreen.Objects.Add("MoreInfoPopup", moreInfoPopup); BlackHoleSystemScreen.Objects.Add("EscPopup", CreateEscMenu()); CreateHUD(BlackHoleSystemScreen); screens.Add("BlackHoleSystem", BlackHoleSystemScreen); } else { screens["BlackHoleSystem"].Objects["BlackHoleSystem"] = bhs; } }
//-------------------------------------------------------------- //GENERATE BLACKHOLE SYSTEM //-------------------------------------------------------------- private void GenerateBlackHoleSystem(BlackHoleOnMap hole) { //Construct black hole name string tempName = ConstructName(); hole.Name = tempName; //End name construction //Generationg BlackHole System //Generating black hole BlackHole bh = new BlackHole(Content.Load<Texture2D>("BlackHoles/"+ blackHolesTextures[new Random().Next(0, blackHolesTextures.Length)]), CenterPoint, new Vector2(Scales.TwoTenth)); bh.Name = tempName; //End generating black hole BlackHoleSystem bhs = new BlackHoleSystem(bh); bhs.BackGround = CreateBackground("SystemBacks/" + systemBackTextures[new Random().Next(0, systemBackTextures.Length)], Scales.None, 255f); //End generating GeneratingAsteroids(bhs); hole.System = bhs; }