public void AddCannonTurret(CannonTurret turret) { if (!Turrets.Contains(turret)) { Turrets.Add(turret); } }
/// <summary> /// /// </summary> /// <param name="textureDictionary">all the different textures the ship uses, most used are Default, Left and Right</param> /// <param name="position">position of the ship</param> /// <param name="turrets">turrets on the ship</param> /// <param name="healthMax">max health</param> /// <param name="energyMax">max energy</param> /// <param name="energyRegen">energy regen per frame</param> /// <param name="turnRate">how fast the ship turns</param> public Ship(IReadOnlyDictionary <string, Texture2D> textureDictionary, Vector2 position, Dictionary <string, List <ITurret> > turrets, float healthMax, float energyMax, float energyRegen, float turnRate, float speed, TractorBeam tractorBeam, int upgradeCount) : base(textureDictionary["Default"], position) { foreach (var t in turrets) { Turrets.Add(t.Key, t.Value); } foreach (var entry in textureDictionary) { TextureDictionary.Add(entry.Key, entry.Value); } Upgrades = new Upgrade[upgradeCount]; TractorBeam = tractorBeam; HealthMax = healthMax; BaseHealth = healthMax; Health = healthMax; BaseEnergy = energyMax; EnergyMax = energyMax; Energy = energyMax; BaseEnergyRegen = energyRegen; EnergyRegen = energyRegen; TurnRate = turnRate; Speed = speed; BackwardsSpeed = 1 / 5f * speed; StrafeSpeed = 3 / 5f * speed; }
public void CreateTurret(Vector2 location, int owner) { Turret t = new Turret(location, owner); Turrets.Add(t); if (AddTurret != null) { AddTurret(this, new TurretArgs(t)); } }
public void FirstUpdate(GameTime gameTime) { Music.Beat += new EventHandler(OnBeat); Music.Start(gameTime.TotalRealTime); spawner = new Spawner(); for (int i = 0; i < 4; i++) { Players[i].IsActive = true; Turrets.Add(new Turret(new Vector2((i % 2 + 1) * 250, (float)Math.Ceiling((double)i / 2) * 250), i)); } }
public override void CreateStructure( float xPos, float yPos, StructureTypes structureType, float health, float constructionPoints, int ID, HashSet <int> teams) { Structure structure; switch (structureType) { case (StructureTypes.LaserTurret): /*Turret t = new PlanetTurret(_projectileManager, _textureManager, _shipManager, new Vector2(xPos, yPos), buildingType, _bus, _physicsManager, health, ID, 666); * structures.Add(ID, t); * t.potentialTargets = _potentialTargets; * t.isLocalSim = localSim; */ Turret t = new Turret(_projectileManager, _textureManager, _shipManager, _bus, _physicsManager.World, new Vector2(xPos, yPos), structureType, health, ID, 666, TurretTypes.Planet, teams); _teamManager.RegisterObject(t); _structures.Add(t); Turrets.Add(t); t.IsAlliedWithPlanetOwner = true; //True by default, may change later structure = t; break; case (StructureTypes.CommandCenter): { structure = new CommandCenter(_bus, _messageManager.SendEnterColonyRequest, _shipManager.IsEnterModeOn, _physicsManager.World, _textureManager, new Vector2(xPos, yPos), structureType, health, ID, teams); _teamManager.RegisterObject(structure); _structures.Add(structure); break; } default: structure = new Structure(_bus, _textureManager, xPos, yPos, structureType, health, ID, teams); // Need to move this _structures.Add(structure); structure.Body = BodyFactory.CreateCircle(_physicsManager.World, 1, 1, new StructureBodyDataObject(BodyTypes.Structure, ID, structure)); break; } _targetManager.RegisterObject(structure); }
public Ship(Ship ship) { TextureDictionary = ship.TextureDictionary; //Sprite Rotation = ship.Rotation; Position = ship.Position; Rectangle = ship.Rectangle; Origin = ship.Origin; Texture = ship.Texture; //End TextureIndexCounter = ship.TextureIndexCounter; ShipCurrentIndex = ship.ShipCurrentIndex; ShipPreviousIndex = ship.ShipPreviousIndex; Description = ship.Description; Name = ship.Name; Cost = ship.Cost; TurnRate = ship.TurnRate; Speed = ship.Speed; BackwardsSpeed = ship.BackwardsSpeed; StrafeSpeed = ship.StrafeSpeed; Boost = ship.Boost; Moving = ship.Moving; BaseHealth = ship.BaseHealth; Health = ship.Health; HealthMax = ship.HealthMax; BaseEnergy = ship.BaseEnergy; Energy = ship.Energy; EnergyMax = ship.EnergyMax; BaseEnergyRegen = ship.BaseEnergyRegen; EnergyRegen = ship.EnergyRegen; Upgrades = new Upgrade[ship.Upgrades.Length]; for (int i = 0; i < ship.Upgrades.Length; i++) { if (ship.Upgrades[i] == null) { continue; } Upgrades[i] = new Upgrade(ship.Upgrades[i]); } if (ship.TractorBeam != null) { TractorBeam = new TractorBeam(ship.TractorBeam); } foreach (var turretGroup in ship.Turrets) { Turrets.Add(turretGroup.Key, new List <ITurret>()); } foreach (var turretList in Turrets.Values) { foreach (var turretGroup in ship.Turrets) { foreach (var turret in turretGroup.Value) { turretList.Add(turret.CloneTurret(turret)); //TODO see if this can be don easier instead of implementing CloneTurret in every turret } } } }