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 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 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; }
private void DrawTacticalIcons(Ship ship) { if (this.LookingAtPlanet || (!this.showingFTLOverlay && ship.IsPlatform && this.viewState == UniverseScreen.UnivScreenState.GalaxyView)) return; if (this.showingFTLOverlay && ship.IsPlatform && ship.Name != "Subspace Projector") { return; } if (this.viewState == UniverseScreen.UnivScreenState.GalaxyView) { float num1 = ship.GetSO().WorldBoundingSphere.Radius; Vector3 vector3_1 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(ship.Position, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 position = new Vector2(vector3_1.X, vector3_1.Y); Vector3 vector3_2 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(new Vector2(ship.Center.X + num1, ship.Center.Y), 0.0f), this.projection, this.view, Matrix.Identity); float num2 = Vector2.Distance(new Vector2(vector3_2.X, vector3_2.Y), position); if ((double)num2 < 5.0) num2 = 5f; float scale = num2 / (float)(45 - GlobalStats.IconSize); Vector2 origin = new Vector2((float)(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"].Width / 2), (float)(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"].Width / 2)); bool flag = true; foreach (UniverseScreen.ClickableFleet clickableFleet in this.ClickableFleetsList) { if (clickableFleet.fleet == ship.fleet && (double)Vector2.Distance(position, clickableFleet.ScreenPos) < 20.0) { flag = false; break; } } if (!ship.Active || !flag) return; this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["TacticalIcons/symbol_" + ship.Role], position, new Rectangle?(), ship.loyalty.EmpireColor, ship.Rotation, origin, scale, SpriteEffects.None, 1f); } else if ((this.ShowTacticalCloseup || this.viewState > UniverseScreen.UnivScreenState.ShipView) && !this.LookingAtPlanet) { float num1 = ship.GetSO().WorldBoundingSphere.Radius; Vector3 vector3_1 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(ship.Position, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 position = new Vector2(vector3_1.X, vector3_1.Y); Vector3 vector3_2 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(new Vector2(ship.Center.X + num1, ship.Center.Y), 0.0f), this.projection, this.view, Matrix.Identity); float num2 = Vector2.Distance(new Vector2(vector3_2.X, vector3_2.Y), position); if ((double)num2 < 5.0) num2 = 5f; float scale = num2 / (float)(45- GlobalStats.IconSize); //45 Vector2 origin = new Vector2((float)(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"].Width / 2), (float)(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"].Width / 2)); bool flag = true; foreach (UniverseScreen.ClickableFleet clickableFleet in this.ClickableFleetsList) { if (clickableFleet.fleet == ship.fleet && (double)Vector2.Distance(position, clickableFleet.ScreenPos) < (double)num2 + 3.0) { flag = false; break; } } if (!ship.Active || !flag) return; if (ship.isColonyShip) this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["UI/flagicon"], position + new Vector2(-7f, -17f), ship.loyalty.EmpireColor); //Added by McShooterz: Make Fighter tactical symbol default if not found if(ResourceManager.TextureDict.ContainsKey("TacticalIcons/symbol_" + ship.Role)) this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["TacticalIcons/symbol_" + ship.Role], position, new Rectangle?(), ship.loyalty.EmpireColor, ship.Rotation, origin, scale, SpriteEffects.None, 1f); else this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"], position, new Rectangle?(), ship.loyalty.EmpireColor, ship.Rotation, origin, scale, SpriteEffects.None, 1f); } //else if (this.viewState == UniverseScreen.UnivScreenState.ShipView) //{ // float num1 = ship.GetSO().WorldBoundingSphere.Radius; // Vector3 vector3_1 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(ship.Position, 0.0f), this.projection, this.view, Matrix.Identity); // Vector2 position = new Vector2(vector3_1.X, vector3_1.Y); // Vector3 vector3_2 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(new Vector2(ship.Center.X + num1, ship.Center.Y), 0.0f), this.projection, this.view, Matrix.Identity); // float num2 = Vector2.Distance(new Vector2(vector3_2.X, vector3_2.Y), position); // if ((double)num2 < 5.0) // num2 = 5f; // float scale = num2 / (float)(45 - GlobalStats.IconSize); //45 // scale *= .2f; // Vector2 origin = new Vector2((float)(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"].Width / 2), (float)(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"].Width / 2)); // bool flag = true; // foreach (UniverseScreen.ClickableFleet clickableFleet in this.ClickableFleetsList) // { // if (clickableFleet.fleet == ship.fleet && (double)Vector2.Distance(position, clickableFleet.ScreenPos) < (double)num2 + 3.0) // { // flag = false; // break; // } // } // if (!ship.Active || !flag) // return; // if (ship.isColonyShip) // this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["UI/flagicon"], position + new Vector2(-7f, -17f), ship.loyalty.EmpireColor); // //Added by McShooterz: Make Fighter tactical symbol default if not found // if (ResourceManager.TextureDict.ContainsKey("TacticalIcons/symbol_" + ship.Role)) // this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["TacticalIcons/symbol_" + ship.Role], position, new Rectangle?(), ship.loyalty.EmpireColor, ship.Rotation, origin, scale, SpriteEffects.None, 1f); // else // this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"], position, new Rectangle?(), ship.loyalty.EmpireColor, ship.Rotation, origin, scale, SpriteEffects.None, 1f); //} else { if (this.viewState != UniverseScreen.UnivScreenState.ShipView || this.LookingAtPlanet) return; float num1 = ship.GetSO().WorldBoundingSphere.Radius; Vector3 vector3_1 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(ship.Position, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 vector2_1 = new Vector2(vector3_1.X, vector3_1.Y); Vector3 vector3_2 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(new Vector2(ship.Center.X + num1, ship.Center.Y), 0.0f), this.projection, this.view, Matrix.Identity); float num2 = Vector2.Distance(new Vector2(vector3_2.X, vector3_2.Y), vector2_1); float scale2 = num2 / (float)(45 - GlobalStats.IconSize); if ((double)num2 < 5.0) num2 = 5f; float scale = num2 / (float)(45 - GlobalStats.IconSize); //45 float check = this.GetZfromScreenState(UniverseScreen.UnivScreenState.ShipView); if (ship.Role != "fighter" && ship.Role != "scout") { scale2 *= (this.camHeight / (check + (check*2 -camHeight*2))); } else { // scale2 *= this.camHeight * 2 > this.GetZfromScreenState(UniverseScreen.UnivScreenState.ShipView) ? 1 : this.camHeight * 2 / this.GetZfromScreenState(UniverseScreen.UnivScreenState.ShipView); scale2 *= (this.camHeight * 3 / this.GetZfromScreenState(UniverseScreen.UnivScreenState.ShipView)); } //scale *= .5f; Vector2 vector2_2 = new Vector2((float)(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"].Width / 2), (float)(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"].Width / 2)); if (!ship.Active ) return; Vector2 position = new Vector2(vector2_1.X + 15f * scale2, vector2_1.Y + 15f * scale); if (ship.isColonyShip) this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["UI/flagicon"], position + new Vector2(-7f, -17f), ship.loyalty.EmpireColor); position = new Vector2(vector3_1.X, vector3_1.Y); //Added by McShooterz: Make Fighter tactical symbol default if not found position = new Vector2(vector3_1.X, vector3_1.Y); if (ResourceManager.TextureDict.ContainsKey("TacticalIcons/symbol_" + ship.Role)) { float width = (float)(ResourceManager.TextureDict["TacticalIcons/symbol_" + ship.Role].Width / 2); //width = width * scale2 < 20? width / scale2 : width; Vector2 origin = new Vector2(width, width); this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["TacticalIcons/symbol_" + ship.Role], position, new Rectangle?(), ship.loyalty.EmpireColor, ship.Rotation, origin, scale2, SpriteEffects.None, 1f); } else { float width = (float)(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"].Width / 2); //width = width * scale2 < 20 ? width / scale2 : width; Vector2 origin = new Vector2(width, width); this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["TacticalIcons/symbol_fighter"], position, new Rectangle?(), ship.loyalty.EmpireColor, ship.Rotation, origin, scale2, SpriteEffects.None, 1f); } if ((double)ship.OrdinanceMax <= 0.0) return; if ((double)ship.Ordinance < 0.200000002980232 * (double)ship.OrdinanceMax) { position = new Vector2(vector2_1.X + 15f * scale, vector2_1.Y + 15f * scale); this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["NewUI/icon_ammo"], position, new Rectangle?(), Color.Red, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 1f); } else { if ((double)ship.Ordinance >= 0.5 * (double)ship.OrdinanceMax) return; position = new Vector2(vector2_1.X + 15f * scale, vector2_1.Y + 15f * scale); this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["NewUI/icon_ammo"], position, new Rectangle?(), Color.Yellow, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 1f); } } }
private Circle DrawSelectionCirclesAroundShip(Ship ship) { if (this.SelectedShip != null && this.SelectedShip == ship || this.SelectedShipList.Contains(ship)) { float num = ship.GetSO().WorldBoundingSphere.Radius; Vector3 vector3_1 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(ship.Position, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 Center = new Vector2(vector3_1.X, vector3_1.Y); Vector3 vector3_2 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(new Vector2(ship.Center.X + num, ship.Center.Y), 0.0f), this.projection, this.view, Matrix.Identity); float Radius = Vector2.Distance(new Vector2(vector3_2.X, vector3_2.Y), Center); if ((double)Radius < 5.0) Radius = 5f; if (this.viewState < UniverseScreen.UnivScreenState.SectorView) return new Circle(Center, Radius); } return (Circle)null; }