public override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.F)) { gameManager.ChangeState(new ForceOrganizerState(gameManager, GraphicsDevice, gameManager.Content)); return; } ChapterMaster.ViewController.UpdateMouse(); ChapterMaster.ViewController.UpdateKeyboard(); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Q)) { GameManager.Quit(); } if (Keyboard.GetState().IsKeyUp(Keys.E)) { buttonDown = false; } if (Keyboard.GetState().IsKeyDown(Keys.E) && !buttonDown) { //ChapterMaster.Sector.GridGenerate(50, 100, Constants.SystemSize, Constants.WorldWidth, Constants.WorldHeight); ChapterMaster.Sector.clusterGenerate(); ChapterMaster.Sector.WarpLaneGenerate(); ChapterMaster.Sector.GenerateSystemNames(); ChapterMaster.Sector.GeneratePlanets(); buttonDown = true; } if (Keyboard.GetState().IsKeyDown(Keys.Home)) { if (ChapterMaster.Sector.GetHomeSystem() != null) { World.System system = ChapterMaster.Sector.GetHomeSystem(); ChapterMaster.ViewController.camX = system.x; ChapterMaster.ViewController.camY = system.y; // TODO: Select home system? } } ChapterMaster.ViewController.MouseSelection(ChapterMaster.Sector); ChapterMaster.DebugString += "\n" + ChapterMaster.Sector.GetImperialDate(); ChapterMaster.MainScreen.Update(ChapterMaster.ViewController); ChapterMaster.ViewController.Update(); }
public void DrawStar(SpriteBatch spriteBatch, World.System system, Color color, ViewController view) { Rectangle rect = view.TransformedOriginRect(system.x, system.y, Constants.SystemSize, true); spriteBatch.Draw(Assets.SystemTextures[system.color], rect, Color.White); Rectangle rectLabel = view.TransformedOriginRect(system.x + Constants.SystemSize / 4, system.y - Constants.SystemSize / 4, Constants.SystemSize, true); Vector2 position = new Vector2(rectLabel.Left, rectLabel.Bottom); string name = system.name.Replace("’", "'"); Vector2 nameSize = Assets.CourierNew.MeasureString(name); // TODO: scale system name better. spriteBatch.DrawString(Assets.CourierNew, name, position, Color.White, 0, new Vector2(0, 0), view.zoom + 0.3f, SpriteEffects.None, 0); string owners = ""; foreach (KeyValuePair <string, float> control in system.FindOwners()) { owners += control.Key.Substring(0, 1) + $": {(control.Value * 100).ToString("G3")}%,"; } spriteBatch.DrawString(Assets.CourierNew, owners, new Vector2(rectLabel.Left, rectLabel.Bottom + nameSize.Y * view.zoom + 1), Color.White, 0, new Vector2(0, 0), view.zoom + 0.3f, SpriteEffects.None, 0); }