public void Control(GameWorld gameWorld, Spacecraft me) { Infinity.debugString += " " + targetId; var aiIdentifiableObjectInfos = gameWorld.GetIdentifiableObjects(); var target = FindTarget(aiIdentifiableObjectInfos, me); if (target == null) return; targetId = target.GameObjectId; facingOpponent = facingOpponent = MyMath.MovingTowards(target.Position, me.GamePosition, oldVelocity, 0.6f); ; //if (me.Energy < 20) plan = 2; turnVelocityLimit = 10f; moveVelocityLimit = 60f; if (plan == 1) { MoveTowardsAndAttack(me, target, aiIdentifiableObjectInfos); if (facingOpponent && MyMath.Distance(target.Position, me.GamePosition) < 600 && MyMath.Random.NextDouble() < .4f ) me.FireBullet(); if (MyMath.Distance(me.GamePosition, target.Position) < 50 + MyMath.Random.Next(50)) plan = 2; } else { MoveAwayFrom(me, target); if (MyMath.Distance(me.GamePosition, target.Position) > 200 && MyMath.Random.NextDouble() < .1f) plan = 1; } //if (MyMath.Random.NextDouble() < .01f) plan = plan%2 +1; }
private Spacecraft(GameWorld gameWorld, Vector2 gamePosition) : base(gameWorld, gamePosition) { energy = 100; dead = false; myCount = ++count; switch (MyMath.Random.Next(4)) { case 0: myTexture = new MyTexture(MyContentManager.Spacecraft0); myTextureOverlay = new MyTexture(MyContentManager.Spacecraft0_Overlay); break; case 1: myTexture = new MyTexture(MyContentManager.Spacecraft1); myTextureOverlay = new MyTexture(MyContentManager.Spacecraft1_Overlay); break; case 2: myTexture = new MyTexture(MyContentManager.Spacecraft2); myTextureOverlay = new MyTexture(MyContentManager.Spacecraft2_Overlay); break; case 3: myTexture = new MyTexture(MyContentManager.Spacecraft3); myTextureOverlay = new MyTexture(MyContentManager.Spacecraft3_Overlay); break; default: throw new Exception(); } color = new Color(Color1(), Color1(), Color1()); colorOverlay = new Color(Color1(), Color1(), Color1()); }
public void Control(GameWorld gameWorld, Spacecraft me) { float x = 100 * (Mouse.GetState().X - gameWorld.ScreenCenter.X) / gameWorld.ScreenCenter.X; float y = 100 * (Mouse.GetState().Y - gameWorld.ScreenCenter.Y) / gameWorld.ScreenCenter.Y; me.RotataeAndMove(new Vector2(x, y)); if (Mouse.GetState().LeftButton == ButtonState.Pressed) me.FireBullet(); }
public Bullet(GameWorld gameWorld, Vector2 gamePosition, Vector2 velocity, int ownerId) : base(gameWorld, gamePosition) { this.ownerId = ownerId; myTexture = new MyTexture(MyContentManager.Bullet); myCount = count++; CreateBullet(gamePosition, velocity); }
public BulletExplosion(GameWorld gameWorld, Vector2 gamePosition, float energy) : base(gameWorld, gamePosition) { this.energy = energy; smoke = new MyTexture(MyContentManager.Smoke); explosion = new MyTexture(MyContentManager.Explosion); explosionFrame = 0; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here MyContentManager.LoadContent(Content); var playerPosition = new Vector2(0, 0); var screenCenter = new Vector2(graphics.GraphicsDevice.Viewport.Width/2f, graphics.GraphicsDevice.Viewport.Height/2f); gameWorld = new GameWorld(playerPosition, screenCenter); player = Spacecraft.CreatePlayer(gameWorld, playerPosition); background = new Background(gameWorld); gameWorld.Add(player); for (int i = 0; i < 20; i++) { gameWorld.Add(Spacecraft.CreateEnemy(gameWorld, new Vector2(MyMath.Random.Next(1000), MyMath.Random.Next(1000)))); } base.Initialize(); }
public Background(GameWorld gameWorld) : base(gameWorld,new Vector2()) { myTexture = new MyTexture(MyContentManager.Background, 2); }
protected GameObject(GameWorld gameWorld, Vector2 gamePosition) { this.gameWorld = gameWorld; this.gamePosition = gamePosition; GameObjectId = gameObjectIdCount++; }
public static Spacecraft CreatePlayer(GameWorld gameWorld, Vector2 gamePosition) { var spacecraft = new Spacecraft(gameWorld, gamePosition); spacecraft.spacecraftController = new PlayerSpacecraftController(); // spacecraft.myTexture = new MyTexture(MyContentManager.Spacecraft1); // spacecraft.myTextureOverlay = new MyTexture(MyContentManager.Spacecraft1_Overlay); // spacecraft.color = Color.Wheat; // spacecraft.colorOverlay = Color.Snow; return spacecraft; }
public static Spacecraft CreateEnemy(GameWorld gameWorld, Vector2 gamePosition) { var spacecraft = new Spacecraft(gameWorld, gamePosition); // spacecraft.myTexture = new MyTexture(MyContentManager.Spacecraft2); // spacecraft.myTextureOverlay = new MyTexture(MyContentManager.Spacecraft2_Overlay); // spacecraft.color = Color.Pink; // spacecraft.colorOverlay = Color.LightPink; spacecraft.spacecraftController = new SpacecraftControllerAI(); return spacecraft; }
protected GameObject(GameWorld gameWorld, Vector2 gamePosition) { this.gameWorld = gameWorld; this.gamePosition = gamePosition; GameObjectId = gameObjectIdCount++; }
public Background(GameWorld gameWorld) : base(gameWorld, new Vector2()) { myTexture = new MyTexture(MyContentManager.Background, 2); }