public static IHelm Load(HelmDefinition that) { var shipClass = Catalog.Instance.GetShipClass(that.ClassName); if (shipClass == null) { throw new NullReferenceException("Undefined ship class " + that.ClassName); } MissileClass missileClass = null; if (!string.IsNullOrEmpty(that.MissileName)) { missileClass = Catalog.Instance.GetMissileClass(that.MissileName); if (missileClass == null) { throw new NullReferenceException("Undefined Missile class " + that.MissileName); } } var shipDynamics = new Dynamics(shipClass, that, TimeSpan.Zero); return(new Helm { Id = that.Id == Guid.Empty ? Guid.NewGuid() : that.Id, Class = shipClass, Name = that.Name, Nation = that.Nation, Dynamics = shipDynamics, Missile = missileClass, Missiles = that.Missiles, State = that.State, Health = that.Health, }); }
public static IHelm Load(HelmDefinition that) { var shipClass = Catalog.Instance.GetShipClass(that.ClassName); if (shipClass == null) { throw new NullReferenceException("Undefined ship class " + that.ClassName); } MissileClass missileClass = null; if (!string.IsNullOrEmpty(that.MissileName)) { missileClass = Catalog.Instance.GetMissileClass(that.MissileName); if (missileClass == null) { throw new NullReferenceException("Undefined Missile class " + that.MissileName); } } var shipDynamics = new Dynamics(shipClass, that, TimeSpan.Zero); return(new Helm { Ship = new Ship { Name = that.ShipName, Class = shipClass, Nation = that.Nation, Dynamics = shipDynamics, Missile = missileClass, Missiles = that.MissileNumber, }, }); }
protected void CreateMissiles(GameTime gameTime) { // Key space fires missiles if last shot time is greater than cool down time if (Keyboard.GetState().IsKeyDown(Keys.Space)) { TimeSpan TimeSinceLastShot = gameTime.TotalGameTime - LastShot; if (TimeSinceLastShot > ShotCoolDown) { MissileClass Missile = new MissileClass(); Missile.Positon = Ship.Position; Missile.Rotation = Ship.Rotation; Matrix MissileRotationMatrix = Matrix.CreateRotationZ(Missile.Rotation); Missile.Velocity = new Vector2(0, -10); Missile.Velocity = Vector2.Transform(Missile.Velocity, MissileRotationMatrix); Missile.Velocity = Missile.Velocity + Ship.Velocity; Missile.Size = new Vector2(16, 16); Missile.MaxLimit = new Vector2(graphics.PreferredBackBufferWidth + 500, graphics.PreferredBackBufferHeight + 500); Missile.MinLimit = new Vector2(-500, -500); MyMissiles.Add(Missile); LastShot = gameTime.TotalGameTime; } } }
void Awake() { missileClass = otherGameObject.GetComponent <MissileClass>(); }