public static Ship CreateShipForBattleMode(string key, Empire Owner, Vector2 p) { Ship newShip = new Ship() { Role = Ship_Game.ResourceManager.ShipsDict[key].Role, Name = Ship_Game.ResourceManager.ShipsDict[key].Name, BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength, BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp }; newShip.LoadContent(GetContentManager()); SceneObject newSO = new SceneObject(); if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated) { newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0]) { ObjectType = ObjectType.Dynamic }; newShip.SetSO(newSO); } else { SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath); newSO = new SceneObject(model.Model); newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model); } foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList()) { Thruster thr = new Thruster() { Parent = newShip, tscale = t.tscale, XMLPos = t.XMLPos }; newShip.GetTList().Add(thr); } foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList) { ModuleSlot newSlot = new ModuleSlot(); newSlot.SetParent(newShip); newSlot.SlotOptions = slot.SlotOptions; newSlot.Restrictions = slot.Restrictions; newSlot.Position = slot.Position; newSlot.facing = slot.facing; newSlot.state = slot.state; newSlot.InstalledModuleUID = slot.InstalledModuleUID; newShip.ModuleSlotList.AddLast(newSlot); } newShip.Position = p; newShip.loyalty = Owner; newShip.Initialize(); newShip.GetSO().World = Matrix.CreateTranslation(new Vector3(newShip.Center, 0f)); newShip.isInDeepSpace = true; Owner.AddShip(newShip); return newShip; }
public static Ship CreateTroopShipAtPoint(string key, Empire Owner, Vector2 point, Troop troop) { Ship newShip = new Ship() { Role = "troop", Name = key, VanityName = troop.Name }; newShip.LoadContent(GetContentManager()); SceneObject newSO = new SceneObject(); if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated) { newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0]) { ObjectType = ObjectType.Dynamic }; } else { SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath); newSO = new SceneObject(model.Model); newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model); } newSO.ObjectType = ObjectType.Dynamic; newShip.SetSO(newSO); newShip.Position = point; foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList()) { Thruster thr = new Thruster() { Parent = newShip, tscale = t.tscale, XMLPos = t.XMLPos }; newShip.GetTList().Add(thr); } foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList) { ModuleSlot newSlot = new ModuleSlot(); newSlot.SetParent(newShip); newSlot.SlotOptions = slot.SlotOptions; newSlot.Restrictions = slot.Restrictions; newSlot.Position = slot.Position; newSlot.facing = slot.facing; newSlot.InstalledModuleUID = slot.InstalledModuleUID; newShip.ModuleSlotList.AddLast(newSlot); } newShip.loyalty = Owner; newShip.Initialize(); newShip.GetSO().World = Matrix.CreateTranslation(new Vector3(newShip.Center, 0f)); newShip.VanityName = troop.Name; lock (GlobalStats.ObjectManagerLocker) { Ship_Game.ResourceManager.universeScreen.ScreenManager.inter.ObjectManager.Submit(newShip.GetSO()); } foreach (Thruster t in newShip.GetTList()) { t.load_and_assign_effects(Ship_Game.ResourceManager.universeScreen.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", Ship_Game.ResourceManager.universeScreen.ThrusterEffect); t.InitializeForViewing(); } newShip.TroopList.Add(Ship_Game.ResourceManager.CopyTroop(troop)); Owner.AddShip(newShip); return newShip; }
public static Ship CreateShipAtPointNow(string key, Empire Owner, Vector2 p) { Ship newShip = new Ship(); if (!Ship_Game.ResourceManager.ShipsDict.ContainsKey(key)) { return null; } newShip.Role = Ship_Game.ResourceManager.ShipsDict[key].Role; newShip.Name = Ship_Game.ResourceManager.ShipsDict[key].Name; newShip.BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength; newShip.BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp; newShip.LoadContent(GetContentManager()); SceneObject newSO = new SceneObject(); if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated) { newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0]) { ObjectType = ObjectType.Dynamic }; newShip.SetSO(newSO); } else { SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath); newSO = new SceneObject(model.Model); newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model); } newSO.ObjectType = ObjectType.Dynamic; newShip.SetSO(newSO); if (newShip.Role == "fighter" && Owner.data != null) { Ship level = newShip; level.Level = level.Level + Owner.data.BonusFighterLevels; } foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList()) { Thruster thr = new Thruster() { Parent = newShip, tscale = t.tscale, XMLPos = t.XMLPos }; newShip.GetTList().Add(thr); } foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList) { ModuleSlot newSlot = new ModuleSlot(); newSlot.SetParent(newShip); newSlot.SlotOptions = slot.SlotOptions; newSlot.Restrictions = slot.Restrictions; newSlot.Position = slot.Position; newSlot.facing = slot.facing; newSlot.state = slot.state; newSlot.InstalledModuleUID = slot.InstalledModuleUID; newShip.ModuleSlotList.AddLast(newSlot); } newShip.Position = p; newShip.loyalty = Owner; newShip.Initialize(); //Added by McShooterz: add automatic ship naming if (GlobalStats.ActiveMod != null && Ship_Game.ResourceManager.ShipNames.CheckForName(Owner.data.Traits.ShipType, newShip.Role)) newShip.VanityName = Ship_Game.ResourceManager.ShipNames.GetName(Owner.data.Traits.ShipType, newShip.Role); newShip.GetSO().World = Matrix.CreateTranslation(new Vector3(newShip.Center, 0f)); lock (GlobalStats.ObjectManagerLocker) { Ship_Game.ResourceManager.universeScreen.ScreenManager.inter.ObjectManager.Submit(newShip.GetSO()); } newShip.isInDeepSpace = true; foreach (Thruster t in newShip.GetTList()) { t.load_and_assign_effects(Ship_Game.ResourceManager.universeScreen.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", Ship_Game.ResourceManager.universeScreen.ThrusterEffect); t.InitializeForViewing(); } Owner.AddShip(newShip); return newShip; }
//Added by McShooterz: for refit to keep name public static Ship CreateShipAt(string key, Empire Owner, Planet p, bool DoOrbit, string RefitName, byte RefitLevel) { Ship newShip; //if (universeScreen.MasterShipList.pendingRemovals.TryPop(out newShip)) //{ // newShip.ShipRecreate(); // newShip.Role = Ship_Game.ResourceManager.ShipsDict[key].Role; // newShip.Name = Ship_Game.ResourceManager.ShipsDict[key].Name; // newShip.BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength; // newShip.BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp; //} //else newShip = new Ship() { Role = Ship_Game.ResourceManager.ShipsDict[key].Role, Name = Ship_Game.ResourceManager.ShipsDict[key].Name, BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength, BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp }; newShip.LoadContent(GetContentManager()); SceneObject newSO = new SceneObject(); if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated) { newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0]) { ObjectType = ObjectType.Dynamic }; newShip.SetSO(newSO); } else { SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath); newSO = new SceneObject(model.Model); newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model); } newSO.ObjectType = ObjectType.Dynamic; newShip.SetSO(newSO); foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList()) { Thruster thr = new Thruster() { Parent = newShip, tscale = t.tscale, XMLPos = t.XMLPos }; newShip.GetTList().Add(thr); } foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList) { ModuleSlot newSlot = new ModuleSlot(); newSlot.SetParent(newShip); newSlot.SlotOptions = slot.SlotOptions; newSlot.Restrictions = slot.Restrictions; newSlot.Position = slot.Position; newSlot.facing = slot.facing; newSlot.state = slot.state; newSlot.InstalledModuleUID = slot.InstalledModuleUID; newShip.ModuleSlotList.AddLast(newSlot); } newShip.Position = p.Position; newShip.loyalty = Owner; newShip.Initialize(); //Added by McShooterz: add automatic ship naming newShip.VanityName = RefitName; newShip.Level = RefitLevel; newShip.GetSO().World = Matrix.CreateTranslation(new Vector3(newShip.Center, 0f)); lock (GlobalStats.ObjectManagerLocker) { Ship_Game.ResourceManager.universeScreen.ScreenManager.inter.ObjectManager.Submit(newShip.GetSO()); } foreach (Thruster t in newShip.GetTList()) { t.load_and_assign_effects(Ship_Game.ResourceManager.universeScreen.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", Ship_Game.ResourceManager.universeScreen.ThrusterEffect); t.InitializeForViewing(); } if (newShip.Role == "fighter") { Ship level = newShip; level.Level += Owner.data.BonusFighterLevels; } Owner.AddShip(newShip); newShip.GetAI().State = AIState.AwaitingOrders; return newShip; }
public static Ship GetShip(string key) { Ship newShip = new Ship() { Role = Ship_Game.ResourceManager.ShipsDict[key].Role, BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength, BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp }; newShip.LoadContent(GetContentManager()); newShip.Name = Ship_Game.ResourceManager.ShipsDict[key].Name; SceneObject newSO = new SceneObject(); if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated) { newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0]) { ObjectType = ObjectType.Dynamic }; newShip.SetSO(newSO); } else { SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath); newSO = new SceneObject(model.Model); newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model); } newSO.ObjectType = ObjectType.Dynamic; newShip.SetSO(newSO); foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList()) { Thruster thr = new Thruster() { Parent = newShip, tscale = t.tscale, XMLPos = t.XMLPos }; newShip.GetTList().Add(thr); } foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList) { ModuleSlot newSlot = new ModuleSlot(); newSlot.SetParent(newShip); newSlot.SlotOptions = slot.SlotOptions; newSlot.Restrictions = slot.Restrictions; newSlot.Position = slot.Position; newSlot.facing = slot.facing; newSlot.state = slot.state; newSlot.InstalledModuleUID = slot.InstalledModuleUID; newShip.ModuleSlotList.AddLast(newSlot); } return newShip; }
public static Ship GetPlayerShip(string key) { Ship newShip = new Ship() { PlayerShip = true, Role = Ship_Game.ResourceManager.ShipsDict[key].Role }; newShip.LoadContent(GetContentManager()); SceneObject newSO = new SceneObject(); if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated) { newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0]) { ObjectType = ObjectType.Dynamic }; newShip.SetSO(newSO); } else { SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath); newSO = new SceneObject(model.Model); newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model); } newSO.ObjectType = ObjectType.Dynamic; newShip.SetSO(newSO); foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList()) { Thruster thr = new Thruster() { Parent = newShip, XMLPos = t.XMLPos, tscale = t.tscale }; newShip.GetTList().Add(thr); } if (newShip.FirstNode == null) { (new ShipModuleNode()).Next = new ShipModuleNode(); } foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList) { ModuleSlot newSlot = new ModuleSlot() { Restrictions = slot.Restrictions, Position = slot.Position, facing = slot.facing, InstalledModuleUID = slot.InstalledModuleUID }; newShip.ModuleSlotList.AddLast(newSlot); } return newShip; }
public override void LoadContent() { base.ScreenManager.inter.ObjectManager.Clear(); PrimitiveQuad.graphicsDevice = base.ScreenManager.GraphicsDevice; this.aspect = new Vector2((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight); this.border = new PrimitiveQuad(this.aspect.X / 2f - 512f, this.aspect.Y / 2f - 512f, 1024f, 1024f); this.what = this.border.enclosingRect; ToggleButton Internal = new ToggleButton(new Rectangle(this.what.X - 32, this.what.Y + 5, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "I"); this.DesignStateButtons.Add(Internal); Internal.Action = "I"; ToggleButton InternalO = new ToggleButton(new Rectangle(this.what.X - 32, this.what.Y + 5 + 29, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "IO"); this.DesignStateButtons.Add(InternalO); InternalO.Action = "IO"; ToggleButton External = new ToggleButton(new Rectangle(this.what.X - 32, this.what.Y + 5 + 58, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "O"); this.DesignStateButtons.Add(External); External.Action = "O"; ToggleButton Engines = new ToggleButton(new Rectangle(this.what.X - 32, this.what.Y + 5 + 87, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "E"); this.DesignStateButtons.Add(Engines); Engines.Action = "E"; this.ModuleSlotTexture = base.ScreenManager.Content.Load<Texture2D>("Textures/Ships/singlebox"); this.LoadModelButton = new DanButton(new Vector2(20f, (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 50)), "Load Model"); this.SaveHullButton = new DanButton(new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 200), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 50)), "Save Hull"); this.ShipNameBox = new UITextEntry() { ClickableArea = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 200, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 115, 180, 20), Text = this.HullName }; LightRig rig = base.ScreenManager.Content.Load<LightRig>("example/ShipyardLightrig"); base.ScreenManager.inter.LightManager.Clear(); base.ScreenManager.inter.LightManager.Submit(rig); base.ScreenManager.environment = base.ScreenManager.Content.Load<SceneEnvironment>("example/scene_environment"); float width = (float)base.ScreenManager.GraphicsDevice.Viewport.Width; Viewport viewport = base.ScreenManager.GraphicsDevice.Viewport; float aspectRatio = width / (float)viewport.Height; Vector3 camPos = this.cameraPosition * new Vector3(-1f, 1f, 1f); this.view = ((Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f))) * Matrix.CreateRotationX(MathHelper.ToRadians(0f))) * Matrix.CreateLookAt(camPos, new Vector3(camPos.X, camPos.Y, 0f), new Vector3(0f, -1f, 0f)); this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, aspectRatio, 1f, 10000f); this.moduleSlot = base.ScreenManager.Content.Load<Texture2D>("Textures/Ships/singlebox"); this.DottedLine = base.ScreenManager.Content.Load<Texture2D>("Textures/UI/DottedLine"); this.Center = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2)); this.ConfigureSlots(); this.ThrusterEffect = base.ScreenManager.Content.Load<Effect>("Effects/Thrust"); this.thruster = new Thruster(); this.ScreenRect = new Rectangle(0, 0, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight); this.thruster.load_and_assign_effects(base.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", this.ThrusterEffect); base.LoadContent(); }