コード例 #1
0
        public Level(GameContent gameContent)
        {
            world = new World(atomGravity, false);
            this.gameContent = gameContent;

            if (gameContent.levelIndex == -1) this.isLAB = true;

            camera = new Camera2D(gameContent.viewportSize, false);

            if (!isLAB) LoadLevelComponent();
            else
            {
                labComponent = new LabComponent(gameContent, world);
                editMode = true;
                world.Gravity = equipGravity;
                camera.Scale = targetScale = scale = labComponent.EqScale;
                camera.Position = new Vector2(labComponent.Width, labComponent.Height) / 2;
                camera.Speed = 15;
                camera.ScrollBar = new Vector2(100, 50);
                camera.ScrollWidth = labComponent.Width;
                camera.ScrollHeight = labComponent.Height;
            }

            mouseGroundBody = world.CreateBody(new BodyDef());
        }
        public override void LoadContent()
        {
            GameContent gameContent = ScreenManager.GameContent;
            camera = new Camera2D(gameContent.viewportSize, false);
            camera.ScrollWidth = 1600;
            camera.ScrollBar = new Vector2(225, 0);
            camera.Speed = 5;

            titleTexture = gameContent.levelMenuTitle;

            MenuEntry backMenuEntry = new MenuEntry("Back to Main Menu", new Vector2(400, 50), this);
            backMenuEntry.Selected += OnCancel;
            //MenuEntries.Add(backMenuEntry);

            List<Vector2> v = gameContent.content.Load<List<Vector2>>("Graphics/levelButton");

            for (int i = 0; i < gameContent.storage.saveData.LevelData.Count; i++)
            {
                MenuEntry me = new MenuEntry(gameContent.levelButton[i], v[i], this);

                me.UserData = i;
                if (gameContent.storage.saveData.LevelData[i] > 0)
                    me.footers = "Atoomic Value " + gameContent.storage.saveData.LevelData[i].ToString();

                me.Selected += LoadLevelMenuEntrySelected;
                MenuEntries.Add(me);
            }
        }
コード例 #3
0
        public Level(GameContent gameContent, int levelIndex)
        {
            this.gameContent = gameContent;
            this.levelIndex = levelIndex;

            LoadTiles(levelIndex);
            //LoadGround();

            car = new Car(new Vector2(-200), gameContent, world);

            camera = new Camera2D(gameContent.viewportSize, false);
            camera.Position = gameContent.viewportSize / 2;
            camera.Origin = new Vector2(400, 550);
            camera.Scale = .6f;
        }
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            GameContent gameContent = ScreenManager.GameContent;

            Camera2D camera2 = new Camera2D();
            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera2.Transform);

            Vector2 ori = new Vector2(gameContent.labNextButton.Width, gameContent.labNextButton.Height) / 2;
            spriteBatch.Draw(gameContent.labNextButton, new Vector2(775, 200) - ori, Color.White * TransitionAlpha);
            spriteBatch.Draw(gameContent.labPrevButton, new Vector2(25, 200) - ori, Color.White * TransitionAlpha);

            spriteBatch.End();
        }
コード例 #5
0
        public Level(ScreenManager screenManager, int levelIndex)
        {
            this.gameContent = screenManager.GameContent;
            this.levelIndex = levelIndex;

            camera = new Camera2D();

            groundBody = world.CreateBody(new BodyDef());
            LoadTiles(levelIndex);

            UpdateCameraChaseTarget(new GameTime());

            Vector2[] v = {Vector2.Zero, new Vector2(tiles.GetLength(0), 0),
                              new Vector2(tiles.GetLength(0), tiles.GetLength(1)),
                              new Vector2(0, tiles.GetLength(1)), Vector2.Zero};

            for (int i = 0; i < v.Length - 1; i++)
            {
                PolygonShape ps = new PolygonShape();
                ps.SetAsEdge(v[i] * Tile.Width / gameContent.b2Scale, v[i + 1] * Tile.Width / gameContent.b2Scale);

                groundBody.CreateFixture(ps, 0);
            }
        }
コード例 #6
0
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.Transform);

            level.Draw(gameTime, ScreenManager.SpriteBatch);

            //Hud back
            //if (editMode)
            //    spriteBatch.Draw(gameContent.blank, new Rectangle(150, 50, 530, 80), new Color(Color.Black, 0.2f));

            spriteBatch.End();

            #if WINDOWS_PHONE
            Camera2D camera2 = new Camera2D();
            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera2.Transform);

            Vector2 ori = new Vector2(gameContent.labNextButton.Width, gameContent.labNextButton.Height) / 2;
            spriteBatch.Draw(gameContent.labNextButton, new Vector2(775, 300) - ori, Color.White * TransitionAlpha);
            spriteBatch.Draw(gameContent.labPrevButton, new Vector2(25, 300) - ori, Color.White * TransitionAlpha);

            if (!editMode)
            {
                spriteBatch.Draw(gameContent.labNextButton, new Vector2(400, 25), null,
                    Color.White * TransitionAlpha, -90f / 180 * (float)Math.PI, ori, 1, SpriteEffects.None, 1);

                spriteBatch.Draw(gameContent.labNextButton, new Vector2(400, 585), null,
                    Color.White * TransitionAlpha, 90f / 180 * (float)Math.PI, ori, 1, SpriteEffects.None, 1);
            }

            spriteBatch.End();
            #endif

            base.Draw(gameTime);
        }
コード例 #7
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.End();

            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.Transform);

            for (int x = 0; x < tiles.GetLength(0); x++) for (int y = 0; y < tiles.GetLength(1); y++)
                {
                    Vector2 v = new Vector2(x * Tile.Width, y * Tile.Height);
                    if (tiles[x, y].tileType == TileType.sea) spriteBatch.Draw(tiles[x, y].texture, v, Color.White);
                }

            for (int x = 0; x < tiles.GetLength(0); x++) for (int y = 0; y < tiles.GetLength(1); y++)
                {
                    Vector2 v = new Vector2(x * Tile.Width, y * Tile.Height);
                    if (tiles[x, y].tileType == TileType.land)
                        spriteBatch.Draw(gameContent.sandBed,
                            v + new Vector2(Tile.Width - gameContent.sandBed.Width) / 2, Color.Gainsboro);
                }

            for (int x = 0; x < tiles.GetLength(0); x++) for (int y = 0; y < tiles.GetLength(1); y++)
                {
                    Vector2 v = new Vector2(x * Tile.Width, y * Tile.Height);
                    if (tiles[x, y].tileType == TileType.land) spriteBatch.Draw(tiles[x, y].texture, v, Color.White);
                }

            spriteBatch.Draw(gameContent.crossMark, exit - new Vector2(gameContent.crossMark.Width) / 2,
                Color.White);

            for (int i = 0; i < hearts.Count; i++)
                spriteBatch.Draw(gameContent.heart, hearts[i] - new Vector2(gameContent.heart.Width) / 2,
                    Color.White);

            for (int i = 0; i < collets.Count; i++)
                spriteBatch.Draw(gameContent.collect, collets[i] - new Vector2(gameContent.collect.Width) / 2,
                    Color.White);

            player.Draw(gameTime, spriteBatch);

            ship.Draw(gameTime, spriteBatch);

            for (int i = 0; i < enemies.Count; i++) enemies[i].Draw(gameTime, spriteBatch);

            spriteBatch.End();

            Camera2D tempCam = new Camera2D();
            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, tempCam.Transform);

            player.DrawHealthBar(spriteBatch);

            spriteBatch.Draw(gameContent.collect, new Vector2(100, 32), null, Color.White, 0,
                new Vector2(gameContent.collect.Width) / 2, 0.5f, SpriteEffects.None, 1);

            spriteBatch.DrawString(gameContent.gameFont, "x " + Score, new Vector2(120, 25), Color.White, 0,
                Vector2.Zero, 32.0f / gameContent.gameFontSize, SpriteEffects.None, 1);
        }