Example #1
0
        public override void Reload()
        {
            winSize        = DefaultSettings.Settings["WindowSize"];
            PhysicsManager = new PhysicsEngine(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10);

            PhysicsManager.AddUniversalForce(DefaultForces.LinearDrag);
            //PhysicsManager.AddUniversalForce(DefaultForces.Gravity);


            var    world = new List <WorldObject>();
            Random rand  = new Random();


            ActiveMap = new Map(world);  // Create map from world

            // Walls -- invisible
            var w0 = new ROIDS.Sandbox.VertWallBody(new Vector2(0, winSize.Height / 2), winSize.Height);
            var w1 = new ROIDS.Sandbox.VertWallBody(new Vector2(winSize.Width, winSize.Height / 2), winSize.Height);

            var w2 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, 0), winSize.Width);
            var w3 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, winSize.Height), winSize.Width);

            PhysicsManager.MapBodies.Add(w0);
            PhysicsManager.MapBodies.Add(w1);
            PhysicsManager.MapBodies.Add(w2);
            PhysicsManager.MapBodies.Add(w3);

            //
            Console.WriteLine("HIT PERIOD TO DISABLE GRFX");
        }
Example #2
0
        // Load new Map + init
        public void Reload()
        {
            _world = new List <WorldObject>();
            Size winSize = (Size)DefaultSettings.Settings["WindowSize"];

            PhysicsManager = new PhysicsEngine(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10);

            _player      = new MovingBoxDemoPlayer("Player", Vector2.Zero, 0f);
            _player.Mass = 10;
            _world.Add(_player);
            PhysicsManager.ActiveBodies.Add(_player);

            // Fill Map
            int maxEnts = 50;

            Random rand = new Random();

            for (int i = 0; i < maxEnts; i++)
            {
                var obs = new MovingBoxDemoObstacle(i.ToString(),
                                                    new Vector2((float)rand.NextDouble() * winSize.Width, (float)rand.NextDouble() * winSize.Height));
                obs.HasInfiniteMass = (rand.Next(2) == 1) ? true : false;
                obs.Destroyed      += new WorldObjectEventHandler(obs_Destroyed);
                _world.Add(obs);
                PhysicsManager.ActiveBodies.Add(obs);
            }


            int nx  = 15;
            int ny  = 15;
            var rad = 4f;
            var buf = 0f;
            var pos = new Vector2(winSize.Width / 2 - nx * (2f * rad + buf) / 2f, winSize.Height / 2 - ny * (2f * rad + buf) / 2f);

            for (int xi = 0; xi < nx; xi++)
            {
                for (int yi = 0; yi < ny; yi++)
                {
                    var cent = pos + new Vector2((2f * rad + buf) * xi, (2f * rad + buf) * yi);
                    var ball = new MovingBoxDemoObstacle("lolwtf", cent);
                    ball.Radius          = rad;
                    ball.HasInfiniteMass = false;
                    ball.Destroyed      += new WorldObjectEventHandler(obs_Destroyed);
                    _world.Add(ball);
                    PhysicsManager.ActiveBodies.Add(ball);
                }
            }

            var w0 = new ROIDS.Sandbox.VertWallBody(new Vector2(0, winSize.Height / 2), winSize.Height);
            var w1 = new ROIDS.Sandbox.VertWallBody(new Vector2(winSize.Width, winSize.Height / 2), winSize.Height);

            var w2 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, 0), winSize.Width);
            var w3 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, winSize.Height), winSize.Width);

            PhysicsManager.MapBodies.Add(w0);
            PhysicsManager.MapBodies.Add(w1);
            PhysicsManager.MapBodies.Add(w2);
            PhysicsManager.MapBodies.Add(w3);
        }
Example #3
0
        public override void Reload()
        {
            winSize = DefaultSettings.Settings["WindowSize"];
            PhysicsManager = new PhysicsEngine(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10);

            PhysicsManager.AddUniversalForce(DefaultForces.LinearDrag);
            //PhysicsManager.AddUniversalForce(DefaultForces.Gravity);

            int maxAstroids = 10;

            var world = new List<WorldObject>();
            Random rand = new Random();

            var player = new Player(
                new Vector2((float)rand.NextDouble() * (winSize.Width - 50), (float)rand.NextDouble() * (winSize.Height - 50)),
                0f);

            world.Add(player);
            PhysicsManager.ActiveBodies.Add(player);

            int nx = 30;
            int ny = 30;
            var rad = 4f;
            var buf = 2f;
            var pos = new Vector2(winSize.Width / 2 - nx * (2f * rad + buf) / 2f, winSize.Height / 2 - ny * (2f * rad + buf) / 2f);
            for (int xi = 0; xi < nx; xi++)
            {
                for (int yi = 0; yi < ny; yi++)
                {
                    var pert = 0.1f * buf * (float)MathUtils.Rand.NextDouble() * MathUtils.RandDirection(); //minor perturbation from perfect grid.
                    var cent = pos + new Vector2((2f * rad + buf) * xi, (2f * rad + buf) * yi) + pert;
                    var obs = new InertRoid(cent, rad);

                    world.Add(obs);
                    PhysicsManager.ActiveBodies.Add(obs);
                }
            }

            ActiveMap = new Map(world);  // Create map from world

            // Walls -- invisible
            var w0 = new ROIDS.Sandbox.VertWallBody(new Vector2(0, winSize.Height / 2), winSize.Height);
            var w1 = new ROIDS.Sandbox.VertWallBody(new Vector2(winSize.Width, winSize.Height / 2), winSize.Height);

            var w2 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, 0), winSize.Width);
            var w3 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, winSize.Height), winSize.Width);

            PhysicsManager.MapBodies.Add(w0);
            PhysicsManager.MapBodies.Add(w1);
            PhysicsManager.MapBodies.Add(w2);
            PhysicsManager.MapBodies.Add(w3);

            //
            Console.WriteLine("CONTROLS:");
            Console.WriteLine("[LCLICK] - trigger explosion");
            Console.WriteLine("[RCLICK] - infect area");
        }
Example #4
0
        public override void Reload()
        {
            winSize = DefaultSettings.Settings["WindowSize"];
            PhysicsManager = new PhysicsEngine(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10);

            PhysicsManager.AddUniversalForce(DefaultForces.LinearDrag);
            //PhysicsManager.AddUniversalForce(DefaultForces.Gravity);

            var world = new List<WorldObject>();
            ActiveMap = new Map(world);
            Random rand = new Random();

            var player = new Player(
                new Vector2((float)rand.NextDouble() * (winSize.Width - 50), (float)rand.NextDouble() * (winSize.Height - 50)),
                0f);

            SpawnObject<Actor>(player);

            //
            //
            //

            int goodRoidNumber = 10;
            int BadRoidNumber = 5;

            for (int i = 0; i < goodRoidNumber; i++)
            {
                var pos = new Vector2((float)MathUtils.Rand.Next(50, (int)winSize.Width - 50), (float)MathUtils.Rand.Next(50, (int)winSize.Height - 50));
                var rad = 15f + (float)MathUtils.Rand.NextDouble() * 20;
                var gr = new GoodRoid(pos, rad, 50f, .1f, Vector2.Zero);
                SpawnObject<Actor>(gr);
            }

            for (int i = 0; i < BadRoidNumber; i++)
            {
                var pos = new Vector2((float)MathUtils.Rand.Next(50, (int)winSize.Width - 50), (float)MathUtils.Rand.Next(50, (int)winSize.Height - 50));
                var rad = 15f + (float)MathUtils.Rand.NextDouble() * 20;
                var br = new BadRoid(pos, rad, 50f, .1f, Vector2.Zero);
                SpawnObject<Actor>(br);
            }

            //
            //
            //

            // Walls -- invisible
            var w0 = new ROIDS.Sandbox.VertWallBody(new Vector2(0, winSize.Height / 2), winSize.Height);
            var w1 = new ROIDS.Sandbox.VertWallBody(new Vector2(winSize.Width, winSize.Height / 2), winSize.Height);

            var w2 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, 0), winSize.Width);
            var w3 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, winSize.Height), winSize.Width);

            PhysicsManager.MapBodies.Add(w0);
            PhysicsManager.MapBodies.Add(w1);
            PhysicsManager.MapBodies.Add(w2);
            PhysicsManager.MapBodies.Add(w3);

            //
            Console.WriteLine("CONTROLS:");
            Console.WriteLine("[LCLICK] - launch charge");
            Console.WriteLine("[RCLICK] - launch sensor");
            Console.WriteLine("[SPACE] - detonate all charges");
        }
Example #5
0
        public override void Reload()
        {
            var winSize = DefaultSettings.Settings["WindowSize"];

            PhysicsManager = new PhysicsEngine(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10);

            PhysicsManager.AddUniversalForce(DefaultForces.LinearDrag);


            var world = new List <WorldObject>();

            ActiveMap = new Map(world);



            /*
             * Setup Map
             */

            int goodRoidNumber = 10;
            int badRoidNumber  = 5;
            int bombRoidNumber = 5;

            int chargesAllowed = 5;
            int sensorsAllowed = 5;


            PlayerProfile = new PlayerProfile(1000,                           // Health
                                              badRoidNumber, goodRoidNumber); // Roids

            Random rand = new Random();

            var player = new Player(
                new Vector2((float)rand.NextDouble() * (winSize.Width - 50), (float)rand.NextDouble() * (winSize.Height - 50)),
                0f);

            player.GotHurt += new PlayerEventHandler(player_GotHurt);
            SpawnObject <Actor>(player);

            for (int i = 0; i < chargesAllowed; i++)
            {
                PlayerProfile.AddCharge(new Charge(50, 15));
            }

            for (int i = 0; i < sensorsAllowed; i++)
            {
                PlayerProfile.AddSensor(new Sensor(60f));
            }

            for (int i = 0; i < goodRoidNumber; i++)
            {
                var pos = new Vector2((float)MathUtils.Rand.Next(50, (int)winSize.Width - 50), (float)MathUtils.Rand.Next(50, (int)winSize.Height - 50));
                var rad = 15f + (float)MathUtils.Rand.NextDouble() * Asteroid.MaxRadius;
                var gr  = new GoodRoid(pos, rad, 1000f, .1f, new Vector2((float)MathUtils.Rand.NextDouble() * 300, (float)MathUtils.Rand.NextDouble() * 300));
                gr.Destroyed += new WorldObjectEventHandler(goodRoid_Destroyed);
                SpawnObject <Actor>(gr);
            }

            for (int i = 0; i < badRoidNumber; i++)
            {
                var pos = new Vector2((float)MathUtils.Rand.Next(50, (int)winSize.Width - 50), (float)MathUtils.Rand.Next(50, (int)winSize.Height - 50));
                var rad = 15f + (float)MathUtils.Rand.NextDouble() * Asteroid.MaxRadius;
                var br  = new BadRoid(pos, rad, 1000f, .1f, new Vector2((float)MathUtils.Rand.NextDouble() * 300, (float)MathUtils.Rand.NextDouble() * 300));
                br.Destroyed += new WorldObjectEventHandler(badRoid_Destroyed);
                SpawnObject <Actor>(br);
            }
            for (int i = 0; i < bombRoidNumber; i++)
            {
                var pos = new Vector2((float)MathUtils.Rand.Next(50, (int)winSize.Width - 50), (float)MathUtils.Rand.Next(50, (int)winSize.Height - 50));
                var rad = 15f + (float)MathUtils.Rand.NextDouble() * Asteroid.MaxRadius;
                var br  = new BombRoid(pos, rad);
                SpawnObject <Actor>(br);
            }



            //
            //
            //


            // Walls -- invisible
            var w0 = new ROIDS.Sandbox.VertWallBody(new Vector2(0, winSize.Height / 2), winSize.Height);
            var w1 = new ROIDS.Sandbox.VertWallBody(new Vector2(winSize.Width, winSize.Height / 2), winSize.Height);

            var w2 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, 0), winSize.Width);
            var w3 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, winSize.Height), winSize.Width);

            PhysicsManager.MapBodies.Add(w0);
            PhysicsManager.MapBodies.Add(w1);
            PhysicsManager.MapBodies.Add(w2);
            PhysicsManager.MapBodies.Add(w3);

            this.Write("Health: {0}\nCharges: {1}\nSensors: {2}\nRoids to Blast: {3}",
                       PlayerProfile.Health,
                       PlayerProfile.ChargesLeft,
                       PlayerProfile.SensorsLeft,
                       PlayerProfile.RoidsToBlast);
        }
Example #6
0
        /*
         * IPlayable Reqs
         */
        public override void Reload()
        {
            Size winSize = (Size)DefaultSettings.Settings["WindowSize"];

            //CollisionEngine.Init(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10, 0.3f);
            PhysicsManager = new PhysicsEngine(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10);

            // Fill Map
            int maxDroids      = 100;
            int maxTreasures   = 20;
            int test           = 2;
            int degreeOfLaxity = 5;
            var world          = new WorldObject[maxDroids + maxTreasures + 1];


            Random rand = new Random();

            // Add Player
            var player = new Player(
                new Vector2((float)rand.NextDouble() * (winSize.Width - 50), (float)rand.NextDouble() * (winSize.Height - 50)),
                0f);

            world[0] = player;
            PhysicsManager.ActiveBodies.Add(player);

            // Randomly add Treasures
            for (int i = 1; i < maxTreasures; i++)
            {
                var obs = new Treasure(
                    new Vector2((float)rand.NextDouble() * winSize.Width, (float)rand.NextDouble() * winSize.Height),
                    0f);

                // obs.Destroyed += new WorldObjectEventHandler(TreasureTaken);
                world[i] = obs;
                PhysicsManager.ActiveBodies.Add(obs);
            }

            /*for (int i = 1; i < test; i++)
             * {
             *  var obs = new ROIDS.GameObjects.Devices.Sensor(
             *      new Vector2((float)rand.NextDouble() * winSize.Width, (float)rand.NextDouble() * winSize.Height),
             *      0f);
             *
             *  // obs.Destroyed += new WorldObjectEventHandler(TreasureTaken);
             *  world[i] = obs;
             *  PhysicsManager.ActiveBodies.Add(obs);
             * }*/


            // Randomly add droids
            for (int i = 1; i <= maxDroids; i++)
            {
                var obs = new Droid(
                    new Vector2((float)rand.NextDouble() * winSize.Width, (float)rand.NextDouble() * winSize.Height),
                    0f, (rand.Next(degreeOfLaxity) == 2) ? 1:0);

                // if necessary: obs.Destroyed += new WorldObjectEventHandler(obs_Destroyed);
                world[maxTreasures + i] = obs;
                PhysicsManager.ActiveBodies.Add(obs);
            }


            ActiveMap = new Map(world);  // Create map from world

            // Walls -- invisible
            var w0 = new ROIDS.Sandbox.VertWallBody(new Vector2(0, winSize.Height / 2), winSize.Height);
            var w1 = new ROIDS.Sandbox.VertWallBody(new Vector2(winSize.Width, winSize.Height / 2), winSize.Height);

            var w2 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, 0), winSize.Width);
            var w3 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, winSize.Height), winSize.Width);

            PhysicsManager.MapBodies.Add(w0);
            PhysicsManager.MapBodies.Add(w1);
            PhysicsManager.MapBodies.Add(w2);
            PhysicsManager.MapBodies.Add(w3);

            // Game Logic Setup
            PlayerManger = new PointsEtc(0, 100);
        }
Example #7
0
        public override void Reload()
        {
            winSize = DefaultSettings.Settings["WindowSize"];
            PhysicsManager = new PhysicsEngine(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10);

            PhysicsManager.AddUniversalForce(DefaultForces.LinearDrag);
            //PhysicsManager.AddUniversalForce(DefaultForces.Gravity);

            var world = new List<WorldObject>();
            Random rand = new Random();

            ActiveMap = new Map(world);  // Create map from world

            // Walls -- invisible
            var w0 = new ROIDS.Sandbox.VertWallBody(new Vector2(0, winSize.Height / 2), winSize.Height);
            var w1 = new ROIDS.Sandbox.VertWallBody(new Vector2(winSize.Width, winSize.Height / 2), winSize.Height);

            var w2 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, 0), winSize.Width);
            var w3 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, winSize.Height), winSize.Width);

            PhysicsManager.MapBodies.Add(w0);
            PhysicsManager.MapBodies.Add(w1);
            PhysicsManager.MapBodies.Add(w2);
            PhysicsManager.MapBodies.Add(w3);

            //
            Console.WriteLine("HIT PERIOD TO DISABLE GRFX");
        }
Example #8
0
        public override void Reload()
        {
            var winSize = DefaultSettings.Settings["WindowSize"];
            PhysicsManager = new PhysicsEngine(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10);

            PhysicsManager.AddUniversalForce(DefaultForces.LinearDrag);

            var world = new List<WorldObject>();
            ActiveMap = new Map(world);

            /*
             * Setup Map
             */

            int goodRoidNumber = 10;
            int badRoidNumber = 5;
            int bombRoidNumber = 5;

            int chargesAllowed = 5;
            int sensorsAllowed = 5;

            PlayerProfile = new PlayerProfile(1000, // Health
                badRoidNumber, goodRoidNumber); // Roids

            Random rand = new Random();

            var player = new Player(
                new Vector2((float)rand.NextDouble() * (winSize.Width - 50), (float)rand.NextDouble() * (winSize.Height - 50)),
                0f);
            player.GotHurt += new PlayerEventHandler(player_GotHurt);
            SpawnObject<Actor>(player);

            for (int i = 0; i < chargesAllowed; i++)
                PlayerProfile.AddCharge(new Charge(50, 15));

            for (int i = 0; i < sensorsAllowed; i++)
                PlayerProfile.AddSensor(new Sensor(60f));

            for (int i = 0; i < goodRoidNumber; i++)
            {
                var pos = new Vector2((float)MathUtils.Rand.Next(50, (int)winSize.Width - 50), (float)MathUtils.Rand.Next(50, (int)winSize.Height - 50));
                var rad = 15f + (float)MathUtils.Rand.NextDouble() * Asteroid.MaxRadius;
                var gr = new GoodRoid(pos, rad, 1000f, .1f, new Vector2((float)MathUtils.Rand.NextDouble() * 300, (float)MathUtils.Rand.NextDouble() * 300));
                gr.Destroyed += new WorldObjectEventHandler(goodRoid_Destroyed);
                SpawnObject<Actor>(gr);
            }

            for (int i = 0; i < badRoidNumber; i++)
            {
                var pos = new Vector2((float)MathUtils.Rand.Next(50, (int)winSize.Width - 50), (float)MathUtils.Rand.Next(50, (int)winSize.Height - 50));
                var rad = 15f + (float)MathUtils.Rand.NextDouble() * Asteroid.MaxRadius;
                var br = new BadRoid(pos, rad, 1000f, .1f, new Vector2((float)MathUtils.Rand.NextDouble()*300,(float)MathUtils.Rand.NextDouble()*300));
                br.Destroyed += new WorldObjectEventHandler(badRoid_Destroyed);
                SpawnObject<Actor>(br);
            }
            for (int i = 0; i < bombRoidNumber; i++)
            {
                var pos = new Vector2((float)MathUtils.Rand.Next(50, (int)winSize.Width - 50), (float)MathUtils.Rand.Next(50, (int)winSize.Height - 50));
                var rad = 15f + (float)MathUtils.Rand.NextDouble() * Asteroid.MaxRadius;
                var br = new BombRoid(pos, rad);
                SpawnObject<Actor>(br);

            }

            //
            //
            //

            // Walls -- invisible
            var w0 = new ROIDS.Sandbox.VertWallBody(new Vector2(0, winSize.Height / 2), winSize.Height);
            var w1 = new ROIDS.Sandbox.VertWallBody(new Vector2(winSize.Width, winSize.Height / 2), winSize.Height);

            var w2 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, 0), winSize.Width);
            var w3 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, winSize.Height), winSize.Width);

            PhysicsManager.MapBodies.Add(w0);
            PhysicsManager.MapBodies.Add(w1);
            PhysicsManager.MapBodies.Add(w2);
            PhysicsManager.MapBodies.Add(w3);

            this.Write("Health: {0}\nCharges: {1}\nSensors: {2}\nRoids to Blast: {3}",
                PlayerProfile.Health,
                PlayerProfile.ChargesLeft,
                PlayerProfile.SensorsLeft,
                PlayerProfile.RoidsToBlast);
        }
Example #9
0
        public override void Reload()
        {
            winSize        = DefaultSettings.Settings["WindowSize"];
            PhysicsManager = new PhysicsEngine(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10);

            PhysicsManager.AddUniversalForce(DefaultForces.LinearDrag);
            //PhysicsManager.AddUniversalForce(DefaultForces.Gravity);


            var world = new List <WorldObject>();

            ActiveMap = new Map(world);
            Random rand = new Random();

            var player = new Player(
                new Vector2((float)rand.NextDouble() * (winSize.Width - 50), (float)rand.NextDouble() * (winSize.Height - 50)),
                0f);

            SpawnObject <Actor>(player);

            //
            //
            //


            int goodRoidNumber = 10;
            int BadRoidNumber  = 5;

            for (int i = 0; i < goodRoidNumber; i++)
            {
                var pos = new Vector2((float)MathUtils.Rand.Next(50, (int)winSize.Width - 50), (float)MathUtils.Rand.Next(50, (int)winSize.Height - 50));
                var rad = 15f + (float)MathUtils.Rand.NextDouble() * 20;
                var gr  = new GoodRoid(pos, rad, 50f, .1f, Vector2.Zero);
                SpawnObject <Actor>(gr);
            }

            for (int i = 0; i < BadRoidNumber; i++)
            {
                var pos = new Vector2((float)MathUtils.Rand.Next(50, (int)winSize.Width - 50), (float)MathUtils.Rand.Next(50, (int)winSize.Height - 50));
                var rad = 15f + (float)MathUtils.Rand.NextDouble() * 20;
                var br  = new BadRoid(pos, rad, 50f, .1f, Vector2.Zero);
                SpawnObject <Actor>(br);
            }



            //
            //
            //


            // Walls -- invisible
            var w0 = new ROIDS.Sandbox.VertWallBody(new Vector2(0, winSize.Height / 2), winSize.Height);
            var w1 = new ROIDS.Sandbox.VertWallBody(new Vector2(winSize.Width, winSize.Height / 2), winSize.Height);

            var w2 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, 0), winSize.Width);
            var w3 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, winSize.Height), winSize.Width);

            PhysicsManager.MapBodies.Add(w0);
            PhysicsManager.MapBodies.Add(w1);
            PhysicsManager.MapBodies.Add(w2);
            PhysicsManager.MapBodies.Add(w3);

            //
            Console.WriteLine("CONTROLS:");
            Console.WriteLine("[LCLICK] - launch charge");
            Console.WriteLine("[RCLICK] - launch sensor");
            Console.WriteLine("[SPACE] - detonate all charges");
        }
Example #10
0
        public override void Reload()
        {
            winSize        = DefaultSettings.Settings["WindowSize"];
            PhysicsManager = new PhysicsEngine(new Region(0, (float)winSize.Width, 0, (float)winSize.Height), 10);

            PhysicsManager.AddUniversalForce(DefaultForces.LinearDrag);
            //PhysicsManager.AddUniversalForce(DefaultForces.Gravity);

            int maxAstroids = 10;


            var    world = new List <WorldObject>();
            Random rand  = new Random();

            var player = new Player(
                new Vector2((float)rand.NextDouble() * (winSize.Width - 50), (float)rand.NextDouble() * (winSize.Height - 50)),
                0f);

            world.Add(player);
            PhysicsManager.ActiveBodies.Add(player);



            int nx  = 30;
            int ny  = 30;
            var rad = 4f;
            var buf = 2f;
            var pos = new Vector2(winSize.Width / 2 - nx * (2f * rad + buf) / 2f, winSize.Height / 2 - ny * (2f * rad + buf) / 2f);

            for (int xi = 0; xi < nx; xi++)
            {
                for (int yi = 0; yi < ny; yi++)
                {
                    var pert = 0.1f * buf * (float)MathUtils.Rand.NextDouble() * MathUtils.RandDirection(); //minor perturbation from perfect grid.
                    var cent = pos + new Vector2((2f * rad + buf) * xi, (2f * rad + buf) * yi) + pert;
                    var obs  = new InertRoid(cent, rad);

                    world.Add(obs);
                    PhysicsManager.ActiveBodies.Add(obs);
                }
            }



            ActiveMap = new Map(world);  // Create map from world

            // Walls -- invisible
            var w0 = new ROIDS.Sandbox.VertWallBody(new Vector2(0, winSize.Height / 2), winSize.Height);
            var w1 = new ROIDS.Sandbox.VertWallBody(new Vector2(winSize.Width, winSize.Height / 2), winSize.Height);

            var w2 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, 0), winSize.Width);
            var w3 = new ROIDS.Sandbox.HorizWallBody(new Vector2(winSize.Width / 2, winSize.Height), winSize.Width);

            PhysicsManager.MapBodies.Add(w0);
            PhysicsManager.MapBodies.Add(w1);
            PhysicsManager.MapBodies.Add(w2);
            PhysicsManager.MapBodies.Add(w3);

            //
            Console.WriteLine("CONTROLS:");
            Console.WriteLine("[LCLICK] - trigger explosion");
            Console.WriteLine("[RCLICK] - infect area");
        }