Exemple #1
0
        public virtual void Magnetize(Ship ship, float distance, float angle)
        {
            Magnetizing = true;
            Polarity polarity = ship.CurrentPolarity;

            if (polarity != CurrentPolarity)
            {
                Attract(angle);
            }
            else
            {
                Repel(distance, angle);
            }
        }
Exemple #2
0
        public static StandardShip CreateCruiser(Ship.Polarity polarity, Vector2 position)
        {
            StandardShip ship = new StandardShip(Game);
            Texture2D texture;

            if (polarity == Ship.Polarity.Positive)
            {
                texture = Game.Content.Load<Texture2D>("Graphics\\positive-cruiser");
            }
            else if (polarity == Ship.Polarity.Negative)
            {
                texture = Game.Content.Load<Texture2D>("Graphics\\negative-cruiser");
            }
            else
            {
                texture = Game.Content.Load<Texture2D>("Graphics\\neutral-cruiser");
            }

            ship.BoxDimensions.X = 40;
            ship.BoxDimensions.Y = 40;
            ship.BoxDimensions.W = 40;
            ship.BoxDimensions.Z = 40;

            ship.Initialize(texture, position);
            ship.MagneticRadius = 1000;
            ship.RepelRadius = 200;
            ship.MaxVelocity = 0.5f;
            ship.FleeVelocity = 5;
            ship.ChargeVelocity = 1;
            ship.Value = 10;
            ship.HP = 29;
            ship.SetPolarity(polarity);

            ActorManager.CheckIn(ship);

            return ship;
        }
Exemple #3
0
        public static StandardShip CreateScout(Ship.Polarity polarity, Vector2 position)
        {
            StandardShip ship = new StandardShip(Game);
            Texture2D texture;

            if (polarity == Ship.Polarity.Positive)
            {
                texture = Game.Content.Load<Texture2D>("Graphics\\positive-scout");
            }
            else if (polarity == Ship.Polarity.Negative)
            {
                texture = Game.Content.Load<Texture2D>("Graphics\\negative-scout");
            }
            else
            {
                texture = Game.Content.Load<Texture2D>("Graphics\\neutral-scout");
            }

            ship.BoxDimensions.X = 10;
            ship.BoxDimensions.Y = 10;
            ship.BoxDimensions.W = 10;
            ship.BoxDimensions.Z = 10;

            ship.Initialize(texture, position);
            ship.MaxVelocity = 5.2f;
            ship.FleeVelocity = 6.5f;
            ship.ChargeVelocity = 5.5f;
            ship.Value = 3;
            ship.HP = 0;
            ship.AngleChangeProbability = 20;
            ship.SetPolarity(polarity);

            ActorManager.CheckIn(ship);

            return ship;
        }
Exemple #4
0
        public static StandardShip CreateShip(Ship.Polarity polarity, Vector2 position)
        {
            StandardShip ship = new StandardShip(Game);
            Texture2D texture;

            if (polarity == Ship.Polarity.Positive)
            {
                texture = Game.Content.Load<Texture2D>("Graphics\\positive-ship");
            }
            else if (polarity == Ship.Polarity.Negative)
            {
                texture = Game.Content.Load<Texture2D>("Graphics\\negative-ship");
            }
            else
            {
                texture = Game.Content.Load<Texture2D>("Graphics\\neutral-ship");
            }

            ship.Initialize(texture, position);
            ship.SetPolarity(polarity);

            ActorManager.CheckIn(ship);

            return ship;
        }
Exemple #5
0
        static void CheckMagnetism(Ship actor, Ship other)
        {
            if (actor.CurrentPolarity != Ship.Polarity.Neutral && other.CurrentPolarity != Ship.Polarity.Neutral)
            {
                var dy = other.Position.Y - actor.Position.Y;
                var dx = other.Position.X - actor.Position.X;
                var linearDistance = Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2));
                var angle = (float) Math.Atan2(dy, dx);
                var otherAngle = (float)Math.Atan2(-dy, -dx);

                if (linearDistance < actor.MagneticRadius || linearDistance < other.MagneticRadius)
                {
                    actor.Magnetize(other, (float)linearDistance, angle);
                    other.Magnetize(actor, (float)linearDistance, otherAngle);
                }
            }
        }
Exemple #6
0
 public override void Magnetize(Ship ship, float distance, float angle)
 {
 }
Exemple #7
0
 public override void Magnetize(Ship ship, float distance, float angle)
 {
     if (ship.GetType() == typeof(MainShip)) {
         base.Magnetize(ship, distance, angle);
     }
 }