Example #1
0
        public override void Initialize(GnomicGame game)
        {
            Hud = ParentGame.GetScreen<HudScreen>();

            int floorHeight = 60;
            Physics = new Gnomic.Physics.PhysicsSystem(this);
            Physics.CreateBorder(ParentGame.ScreenWidth * PLAY_AREA_WIDTH_IN_SCREENS,
                                 ParentGame.ScreenHeight, // * PLAY_AREA_HEIGHT_IN_SCREENS,
                                 new Vector2(0.0f, -floorHeight),
                                 /*friction*/ 0.005f);

            // Create a 2D camera
            base.Camera2D = camera = new Camera2D(ParentGame.GraphicsDevice.Viewport);

            CreateBackground();

            Vector2 vehiclePos = new Vector2(ParentGame.ScreenWidth / 5, ParentGame.ScreenHeight - floorHeight);
            Vector2 vehicleSizePhysicsCoords = new Vector2(2.7f, 4.5f);
            Vector2 vehicleOffsetPhysicsCoords = new Vector2(0.0f, -vehicleSizePhysicsCoords.Y / 2.0f);

            Vector2 princessPos = vehiclePos - ConvertUnits.ToDisplayUnits(new Vector2(0.0f, vehicleSizePhysicsCoords.Y));
            lilMissBadAss = Princess.CreatePrincess(princessPos, new Vector2(0.6f, 1.2f), new Vector2(0.0f, -0.6f));
            base.AddEntity(lilMissBadAss); // sets ParentScreen

            Vehicle = PrincessVehicle.CreateDefaultEntity(vehiclePos, vehicleSizePhysicsCoords, vehicleOffsetPhysicsCoords);
            base.AddEntity(Vehicle);

            units = new UnitManager(this);

            //float startX = 0.7f;

            //for (int i = 0; i < 20; ++i)
            //{
            //    AddUnit(UnitType.Grunt, new Vector2(startX+(i*0.05f), 0.7f));
            //}

            //startX = 0.4f;

            //for (int i = 0; i < 5; ++i)
            //{
            //    AddUnit(UnitType.Knight, new Vector2(startX + (i * 0.05f), 0.7f));
            //}

            projectiles = new ProjectileManager(this);

            this.Audio = this.ParentGame.Audio;

            base.Initialize(game);

            standingJoint = new RevoluteJoint(lilMissBadAss.Physics.Bodies[0], Vehicle.Physics.Bodies[0], Vector2.Zero, new Vector2(0.0f, -vehicleSizePhysicsCoords.Y));
            Physics.World.AddJoint(standingJoint);
        }