public void OnActivate(params object[] args) { if (args.Length >= 1 && args[0] is Sector) { Sector = (Sector)args[0]; } else { Sector = new Sector(); } if (args.Length >= 2 && args[1] is PlayerShip) { PlayerShip = (PlayerShip)args[1]; } else { PlayerShip = new PlayerShip(); } // Store window window = Root.Singleton.Window; rctScreen = Util.ScreenRect(window.Size.X, window.Size.Y, 1.7778f); // Add background var texBackground = Root.Singleton.Material("img/stars/bg_blueStarcluster.png"); sprBackground = new Sprite(texBackground); sprBackground.Position = new Vector2f(rctScreen.Left, rctScreen.Top); sprBackground.Scale = Util.Scale(sprBackground, new Vector2f(rctScreen.Width, rctScreen.Height)); // Init ship renderer playerShipRenderer.ShowRooms = true; playerShipRenderer.Ship = PlayerShip; Util.LayoutControl(playerShipRenderer, 310, 100, 660, 450, rctScreen); playerShipRenderer.Parent = Root.Singleton.Canvas; playerShipRenderer.Init(); // Init HUD UpdateHullMeter(); UpdateScrapMeter(); UpdateShields(); UpdateItems(); UpdateJumpButton(); }
public void SetShipGenerator(Library.ShipGenerator gen, int layout = 0) { if (lstSystems != null) { foreach (var system in lstSystems) system.Remove(); lstSystems.Clear(); lstSystems = null; } // Set current ship currentShipGen = gen; currentShip = (PlayerShip)gen.Generate(layout); // Update ship renderer shipRenderer.Ship = currentShip; // Update layout buttons btnLayoutA.Enabled = (currentShipGen.NumberOfLayouts >= 1); btnLayoutA.Toggled = (layout == 0); btnLayoutA.UpdateImage(); btnLayoutB.Enabled = (currentShipGen.NumberOfLayouts >= 2); btnLayoutB.Toggled = (layout == 1); btnLayoutB.UpdateImage(); // Create new UI tbShipName.Text = currentShip.Name; lstSystems = new List<ImageButton>(); var systems = currentShip.Systems; for (int i = 0; i < systems.Count; i++) { var system = systems[i]; var btnSystem = new ImageButton(); btnSystem.Image = Root.Singleton.Material("img/customizeUI/box_system_on.png"); btnSystem.HoveredImage = Root.Singleton.Material("img/customizeUI/box_system_select2.png"); btnSystem.DisabledImage = Root.Singleton.Material("img/customizeUI/box_system_off.png"); btnSystem.Enabled = true; //btnSystem.HoverSound = Root.Singleton.Sound("audio/waves/ui/select_light1.wav"); Util.LayoutControl(btnSystem, 370 + (i * 38), 380, 38, 96, rctScreen); btnSystem.Parent = Root.Singleton.Canvas; btnSystem.Init(); var systembox = new SystemBox(); systembox.SystemIcon = Root.Singleton.Material(system.IconGraphics["green"]); systembox.PowerLevel = system.MinPower; systembox.Width = btnSystem.Width - 2; systembox.Height = btnSystem.Height - 2; systembox.Parent = btnSystem; systembox.Init(); lstSystems.Add(btnSystem); } }