public AI(Vector2 position, GraphicsDeviceManager graphics, Texture2D ShipTexture, Texture2D BulletTexture, SpriteBatch Sprite, Ship player, float hardness) : base(position,graphics,ShipTexture,BulletTexture, Sprite) { this.player = player; next.position = 4; color = Color.Red; rayCenter = Math.Min(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight) / 2; //Standard bulletSpeed = 7.5f; bullets = 15; speed = 2.5f; cooldown = 1f; Random a = new Random(); float newBulletSpeed = 5f + 5f*(float)a.NextDouble(); //5 10 float newSpeed = 1.5f + 2f * (float)a.NextDouble(); //1.5 3.5 float newCooldown = .7f + .5f * (float)a.NextDouble(); //.7 1.2 float r = (bulletSpeed + speed - cooldown) / (newBulletSpeed + newSpeed - newCooldown) + hardness/10; bulletSpeed = newBulletSpeed * r; speed = newSpeed * r; cooldown = newCooldown / r; bullets = (int)(15f * Math.Pow(cooldown, -0.5f)); }
public Bullet(Vector2 shipPosition, float shipRotation,Texture2D bulletTexture, SpriteBatch sprite, GraphicsDeviceManager graphics, bool isPLayer, List<Bullet> shotsFired, Ship owner) : base(shipPosition, bulletTexture, sprite, graphics) { this.shotsFired = shotsFired; this.owner = owner; this.scale = new Vector2(.6f,.5f); this.velocity = Vector2.UnitX; this.velocity = Vector2.Transform(velocity, Matrix.CreateRotationZ(shipRotation)); this.rotation = shipRotation +(float)(Math.PI/2); this.outOfBounds = false; if (!isPLayer) this.color = Color.Red; }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); ShipTexture = Content.Load<Texture2D>("Ship"); BulletTexture = Content.Load<Texture2D>("Bullet"); //Initialize ships here, for loading less resources if (TwoAI) { mainShip = new AI(new Vector2(graphics.PreferredBackBufferWidth / 4, graphics.PreferredBackBufferHeight / 2), graphics, ShipTexture, BulletTexture, spriteBatch, null, hardness); } else { mainShip = new Player(new Vector2(graphics.PreferredBackBufferWidth / 4, graphics.PreferredBackBufferHeight / 2), graphics, ShipTexture, BulletTexture, spriteBatch); } dummy = new AI(new Vector2((graphics.PreferredBackBufferWidth / 4) * 3, graphics.PreferredBackBufferHeight / 2), graphics, ShipTexture, BulletTexture, spriteBatch, mainShip, hardness); if (TwoAI) ((AI)(mainShip)).player = dummy; }
protected override void UnloadContent() { mainShip.Dispose(); mainShip = null; dummy.Dispose(); dummy = null; ShipTexture.Dispose(); ShipTexture = null; BulletTexture.Dispose(); BulletTexture = null; }