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; }
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 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 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; }