예제 #1
0
        public ThrongGameScreen(Game1 game)
            : base(game, game.Camera.Clone())
        {
            ConvertUnits.SetDisplayUnitToSimUnitRatio(64f);

            _eggtastic = game;

            Clips = new Dictionary<string, Clip>();
            Enemies = new List<EnemyEntity>();
            Eggs = new List<EggEntity>();
            QueuedForDisposal = new List<CharacterEntity>();
            QueuedForCreation = new List<CharacterEntity>();

            ScreenSizeDefault = new Vector2(1280, 720);

            GraphicsDevice = game.GraphicsDevice;
            Viewport = GraphicsDevice.Viewport;
            ScreenCenter = new Vector2(ScreenSizeDefault.X / 2f, ScreenSizeDefault.Y / 2f);
            Content = game.Content;

            gameFont = Content.Load<SpriteFont>("GameFont");

            #if !ANDROID
            //BackgroundMusic =
            //    Content.Load<Song>("background-music");
            //MediaPlayer.Play(BackgroundMusic);
            //MediaPlayer.Volume = 0.5f;
            #endif

            Corners = new Vertices(4);
            Corners.Add(new Vector2(0f));                                           // top-left
            Corners.Add(new Vector2(ScreenSizeDefault.X, 0f));                     // top-right
            Corners.Add(new Vector2(ScreenSizeDefault.X, ScreenSizeDefault.Y));   // bottom-right
            Corners.Add(new Vector2(0f, ScreenSizeDefault.Y));                     // bottom-left

            projection =
                Matrix.CreateOrthographicOffCenter(0f, ConvertUnits.ToSimUnits(ScreenSizeDefault.X),
                                                   ConvertUnits.ToSimUnits(ScreenSizeDefault.Y), 0f, 0f, 1f);

            World = new World(new Vector2(0, 0));
            DebugView = new DebugViewXNA(World);
            DebugView.RemoveFlags(DebugViewFlags.Shape);
            DebugView.DefaultShapeColor = Color.White;
            DebugView.SleepingShapeColor = Color.LightGray;
            DebugView.LoadContent(GraphicsDevice, Content, "GameFont");

            if (Tweak.SHOW_PHYSICS_ON_START)
                EnableOrDisableFlag(DebugViewFlags.Shape);
            Tweak.Init();

            InitialiseClips();

            _enemySpawner = new EnemySpawner(this, Clips["enemy"]);

            // World is 1 screen high, N screens wide
            _border = new Border(World, new Vector2(ScreenSizeDefault.X * PLAY_AREA_WIDTH_IN_SCREENS, ScreenSizeDefault.Y - BUILDINGS_BOUNDARY - BOTTOM_BOUNDARY), new Vector2(.0f, BUILDINGS_BOUNDARY));

            InitialiseLevel();
        }
예제 #2
0
        public ThrongGameScreen(Game1 game)
            : base(game, game.Camera.Clone())
        {
            ConvertUnits.SetDisplayUnitToSimUnitRatio(64f);

            _eggtastic = game;

            Clips             = new Dictionary <string, Clip>();
            Enemies           = new List <EnemyEntity>();
            Eggs              = new List <EggEntity>();
            QueuedForDisposal = new List <CharacterEntity>();
            QueuedForCreation = new List <CharacterEntity>();

            ScreenSizeDefault = new Vector2(1280, 720);

            GraphicsDevice = game.GraphicsDevice;
            Viewport       = GraphicsDevice.Viewport;
            ScreenCenter   = new Vector2(ScreenSizeDefault.X / 2f, ScreenSizeDefault.Y / 2f);
            Content        = game.Content;

            gameFont = Content.Load <SpriteFont>("GameFont");

#if !ANDROID
            //BackgroundMusic =
            //    Content.Load<Song>("background-music");
            //MediaPlayer.Play(BackgroundMusic);
            //MediaPlayer.Volume = 0.5f;
#endif

            Corners = new Vertices(4);
            Corners.Add(new Vector2(0f));                                         // top-left
            Corners.Add(new Vector2(ScreenSizeDefault.X, 0f));                    // top-right
            Corners.Add(new Vector2(ScreenSizeDefault.X, ScreenSizeDefault.Y));   // bottom-right
            Corners.Add(new Vector2(0f, ScreenSizeDefault.Y));                    // bottom-left

            projection =
                Matrix.CreateOrthographicOffCenter(0f, ConvertUnits.ToSimUnits(ScreenSizeDefault.X),
                                                   ConvertUnits.ToSimUnits(ScreenSizeDefault.Y), 0f, 0f, 1f);

            World     = new World(new Vector2(0, 0));
            DebugView = new DebugViewXNA(World);
            DebugView.RemoveFlags(DebugViewFlags.Shape);
            DebugView.DefaultShapeColor  = Color.White;
            DebugView.SleepingShapeColor = Color.LightGray;
            DebugView.LoadContent(GraphicsDevice, Content, "GameFont");

            if (Tweak.SHOW_PHYSICS_ON_START)
            {
                EnableOrDisableFlag(DebugViewFlags.Shape);
            }
            Tweak.Init();

            InitialiseClips();

            _enemySpawner = new EnemySpawner(this, Clips["enemy"]);

            // World is 1 screen high, N screens wide
            _border = new Border(World, new Vector2(ScreenSizeDefault.X * PLAY_AREA_WIDTH_IN_SCREENS, ScreenSizeDefault.Y - BUILDINGS_BOUNDARY - BOTTOM_BOUNDARY), new Vector2(.0f, BUILDINGS_BOUNDARY));

            InitialiseLevel();
        }