public Player() { Ship = new Ship(Renderer.Singleton.Game); ComponentsInventory = new List<Component>(); MaterialsInventory = new List<RawMaterial>(); PlayerController = new PlayerController(Renderer.Singleton.Game); PlayerController.Initialize(Ship); }
public NPC(Game game, Ship Ship, VertexScreen Vertex) : base(game) { this.Ship = Ship; this.Ship.CurrentVertex = Vertex; Ship.CurrentVertex.Ships.Add(Ship); GeneralManager.NPCs.Add(this); }
public void DetectCollisions(VertexScreen V, Ship Owner) { foreach (Bullet B in Bullets) { foreach (Ship S in V.Ships) { if (S.Hull.Mask.CheckCollision(B.Position + Owner.Position - S.Position + S.OutsideView.FrameSize/2) && Owner != S) { B.CurrentLife = B.LifeTime; S.HitPoints -= Damage; S.CurrentVertex.Effect.Parameters["BloomIntensity"].SetValue(1.5f); } } } }
public override void Update(GameTime gameTime) { if (AttackTarget != null) { Ship.FlyTo(AttackTarget.Position); } if (true) { AttackTarget = GeneralManager.Singleton.CurrentPlayer.Ship; } else { AttackTarget = null; } if ((AttackTarget.Position - Ship.Position).Length() < 1000) { foreach (Slot S in Ship.Hull.Slots) { if (S.Component is Weapon) { Weapon Weapon = S.Component as Weapon; if (Weapon is Weapon_GaussCannonB50) { if (BulletsShoot < 10) { Ship.Shoot(Weapon, AttackTarget.Position - Ship.Position); BulletsShoot++; } if (Weapon.Heat < Weapon.MaxHeat / 2) { BulletsShoot = 0; } } } } } base.Update(gameTime); }
public void Initialize(Ship Ship) { this.Ship = Ship; base.Initialize(); }
public override void Draw(GameTime gameTime) { if (Visible) { foreach (Background B in Backgrounds) { Renderer.Singleton.batch.Draw(B.Tex, new Rectangle(0, 0, Camera.Width, Camera.Height), new Rectangle((int)(Camera.X / 10), (int)(Camera.Y / 10), (int)(B.Tex.Width / B.Scale.X), (int)(B.Tex.Height / B.Scale.Y)), B.Color); } bool IsCurrentPlayerOnVertex = false; foreach (VertexComponent C in Components) { C.Draw(gameTime); } foreach (Ship S in Ships) { if (S.Equals(GeneralManager.Singleton.CurrentPlayer.Ship) && S.State == Ship.ShipState.InVertex) { IsCurrentPlayerOnVertex = true; } if (S.State == Ship.ShipState.InVertex) { if (S.Equals(SelectedShip)) { Renderer.Animations["ShipSelector"].Position = S.DrawPosition - Renderer.Animations["ShipSelector"].FrameSize / 2; Renderer.Animations["ShipSelector"].Draw(gameTime); } if (S.ShipView) { S.DrawOutside(gameTime); } else { S.DrawInside(gameTime); } if (S.Equals(SelectedShip)) { Renderer.Singleton.batch.Draw(Renderer.Textures["ShipInfo"], new Rectangle((int)(S.DrawPosition.X), (int)(S.DrawPosition.Y - Renderer.Height * 0.1f), (int)(Renderer.Width * 0.1f), (int)(Renderer.Height * 0.1f)), Color.White); Text Text = new Text(Game); Text.Font = Renderer.Fonts["Visitor"]; Text.Name = S.HitPoints.ToString() + " / " + S.Hull.BasicHull.ToString(); Text.Rect = new Rectangle((int)(S.DrawPosition.X) + 10, (int)(S.DrawPosition.Y - Renderer.Height * 0.1f + 10), 100, 12); Text.Draw(gameTime); } } if (S.Hull.Mask.CheckCollision(GeneralManager.Singleton.MousePos - S.DrawPosition + S.OutsideView.FrameSize/2) && GeneralManager.Singleton.CheckLMB()) { SelectedShip = S; } } if (IsCurrentPlayerOnVertex) { if (!Camera.Intersects(new Rectangle((int)GeneralManager.Singleton.CurrentPlayer.Ship.Position.X, (int)GeneralManager.Singleton.CurrentPlayer.Ship.Position.Y, (int)GeneralManager.Singleton.CurrentPlayer.Ship.OutsideView.FrameSize.X, (int)GeneralManager.Singleton.CurrentPlayer.Ship.OutsideView.FrameSize.Y))) { ShipIndicatorPosition = GeneralManager.Singleton.CurrentPlayer.Ship.Position - new Vector2(Camera.X, Camera.Y); short Direction = 0; // 0 - top, 1 - right, 2 - bottom, 3- left if (ShipIndicatorPosition.X < 100) { Direction = 3; ShipIndicatorPosition.X = 100; } else if (ShipIndicatorPosition.X > Camera.Width - 100) { Direction = 1; ShipIndicatorPosition.X = Camera.Width - 100; } if (ShipIndicatorPosition.Y < 100) { Direction = 0; ShipIndicatorPosition.Y = 100; } else if (ShipIndicatorPosition.Y > Camera.Height - 100) { Direction = 2; ShipIndicatorPosition.Y = Camera.Height - 100; } switch (Direction) { case 0: Renderer.Singleton.batch.Draw(Renderer.Singleton.ShipIndicator, ShipIndicatorPosition - new Vector2(Renderer.Singleton.ShipIndicator.Width / 2, Renderer.Singleton.ShipIndicator.Height / 2), Color.White); break; case 1: Renderer.Singleton.batch.Draw(Renderer.Singleton.ShipIndicator, new Vector2((ShipIndicatorPosition.X - (Renderer.Singleton.ShipIndicator.Width / 2)), (ShipIndicatorPosition.Y - Renderer.Singleton.ShipIndicator.Height / 2)), null, Color.White, (float)(0.5f * Math.PI), new Vector2(50, 50), Vector2.One, SpriteEffects.None, 0.0f); break; case 2: Renderer.Singleton.batch.Draw(Renderer.Singleton.ShipIndicator, new Vector2((ShipIndicatorPosition.X - (Renderer.Singleton.ShipIndicator.Width / 2)), (ShipIndicatorPosition.Y - Renderer.Singleton.ShipIndicator.Height / 2)), null, Color.White, (float)(1.0f * Math.PI), new Vector2(50, 50), Vector2.One, SpriteEffects.None, 0.0f); break; case 3: Renderer.Singleton.batch.Draw(Renderer.Singleton.ShipIndicator, new Vector2((ShipIndicatorPosition.X - (Renderer.Singleton.ShipIndicator.Width / 2)), (ShipIndicatorPosition.Y - Renderer.Singleton.ShipIndicator.Height / 2)), null, Color.White, (float)(1.5f * Math.PI), new Vector2(50, 50), Vector2.One, SpriteEffects.None, 0.0f); break; } } } Renderer.Singleton.batch.Draw(Renderer.Singleton.FromVertexToLevelGUI, Vector2.Zero, Color.White); DrawMinimap(); DrawWeaponsMenu(); Renderer.Singleton.DrawMoney(); } }
public NPC_Pirate1(Game game, Ship Ship, VertexScreen Vertex) : base(game, Ship, Vertex) { this.AI = new AgresiveAI(game); this.AI.Initialize(Ship); }
public static void GenerateNPC(Game Game) { Ship TmpShip = new Ship(Game); TmpShip.Hull = new Hull_Cerberus_B24(); TmpShip.Position = Vector2.One * 1000; TmpShip.State = Ship.ShipState.InVertex; TmpShip.ShipView = true; TmpShip.ShipColor = Color.Red; TmpShip.Hull.Slots[0].Component = new Weapon_GaussCannonB50(Game); //TmpShip.Hull.Slots[1].Component = new Weapon_GaussCannonB50(Game); TmpShip.CurrentVertex = GeneratingLevel.Components[0] as VertexScreen; TmpShip.Initialize(); //(GeneratingLevel.Components[0] as Vertex).Parent.Ships.Add(TmpShip); NPC TmpNPC = new NPC_Pirate1(Game, TmpShip, (GeneratingLevel.Components[0] as Vertex).Parent); }