Ejemplo n.º 1
0
        public void Draw(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice, GameTime gameTime, ScreenInfo screenInfo)
        {
            //Prepare IRR call
            irr.Draw();

            graphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, DepthStencilState.Default, RasterizerState.CullNone, null, camera.GetViewTransformationMatrix());
            //IRR only - mBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, DepthStencilState.Default, RasterizerState.CullNone, null, renderer.GetTransformationMatrix());
            // If we're in a level draw that level
            if (curLevel != null && curLevel.IsLevelLoaded())
            {
                curLevel.DrawLevel(spriteBatch, camera, screenInfo);
            }

            if (playerShip != null)
                playerShip.Draw(spriteBatch, curLevel.GetLevelWidth(), curLevel.GetLevelHeight());

            foreach (Ship enemy in enemyShips)
            {
                enemy.Draw(spriteBatch, curLevel.GetLevelWidth(), curLevel.GetLevelHeight());
            }

            Globals.gPrimitives.DrawAllPrimitives(spriteBatch);
            spriteBatch.End();
        }
Ejemplo n.º 2
0
        public void Draw(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice, GameTime gameTime, ScreenInfo screenInfo)
        {
            graphicsDevice.Clear(Color.Black);

            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            Vector2 firstSquare = new Vector2(Isometric.IsoCamera.Location.X / Isometric.Tile.TileStepX, Isometric.IsoCamera.Location.Y / Isometric.Tile.TileStepY);
            int firstX = (int)firstSquare.X;
            int firstY = (int)firstSquare.Y;

            Vector2 squareOffset = new Vector2(Isometric.IsoCamera.Location.X % Isometric.Tile.TileStepX, Isometric.IsoCamera.Location.Y % Isometric.Tile.TileStepY);
            int offsetX = (int)squareOffset.X;
            int offsetY = (int)squareOffset.Y;

            float maxdepth = ((curLevel.Tiles.MapWidth + 1) + ((curLevel.Tiles.MapHeight + 1) * Isometric.Tile.TileWidth)) * 10;
            float depthOffset;

            for (int y = 0; y < curLevel.TilesHigh; y++)
            {
                int rowOffset = 0;
                if ((firstY + y) % 2 == 1)
                    rowOffset = Isometric.Tile.OddRowXOffset;

                for (int x = 0; x < curLevel.TilesWide; x++)
                {
                    int mapx = (firstX + x);
                    int mapy = (firstY + y);
                    depthOffset = 0.7f - ((mapx + (mapy * Isometric.Tile.TileWidth)) / maxdepth);

                    if ((mapx >= curLevel.Tiles.MapWidth) || (mapy >= curLevel.Tiles.MapHeight))
                        continue;
                    /*foreach (int tileID in curLevel.Tiles.Rows[mapy].Columns[mapx].BaseTiles)
                    {
                        spriteBatch.Draw(Isometric.Tile.TileSetTexture, Isometric.IsoCamera.WorldToScreen(new Vector2((mapx * Isometric.Tile.TileStepX) + rowOffset,
                            mapy * Isometric.Tile.TileStepY)), Isometric.Tile.GetSourceRectangle(tileID), Color.White,
                            0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 1.0f);
                    }*/
                    spriteBatch.Draw(Isometric.Tile.TileSetTexture, Isometric.IsoCamera.WorldToScreen(new Vector2((mapx * Isometric.Tile.TileStepX) + rowOffset,
                        mapy * Isometric.Tile.TileStepY)), Isometric.Tile.GetSourceRectangle(curLevel.Tiles.Rows[mapy].Columns[mapx].BaseTile), Color.White,
                        0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 1.0f);
                    int heightRow = 0;

                    foreach (int tileID in curLevel.Tiles.Rows[mapy].Columns[mapx].HeightTiles)
                    {
                        spriteBatch.Draw(Isometric.Tile.TileSetTexture, Isometric.IsoCamera.WorldToScreen(new Vector2((mapx * Isometric.Tile.TileStepX) + rowOffset,
                                    mapy * Isometric.Tile.TileStepY - (heightRow * Isometric.Tile.HeightTileOffset))), Isometric.Tile.GetSourceRectangle(tileID),
                            Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, depthOffset - ((float)heightRow * curLevel.HeightRowDepthMod));
                        heightRow++;
                    }

                    foreach (int tileID in curLevel.Tiles.Rows[mapy].Columns[mapx].Props)
                    {
                        spriteBatch.Draw(Isometric.Tile.TileSetTexture, Isometric.IsoCamera.WorldToScreen(new Vector2((mapx * Isometric.Tile.TileStepX) + rowOffset,
                                    mapy * Isometric.Tile.TileStepY - (heightRow * Isometric.Tile.HeightTileOffset))), Isometric.Tile.GetSourceRectangle(tileID),
                            Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, depthOffset - ((float)heightRow * curLevel.HeightRowDepthMod));
                        heightRow++;
                    }

                    /*
                    // Draws the coordinates for each tile
                    spriteBatch.DrawString(Globals.gFonts["Miramonte"], (x + firstX).ToString() + "," + (y + firstY).ToString(),
                        new Vector2((x * Tile.TileStepX) - offsetX + rowOffset + baseOffsetX + 20,
                        (y * Tile.TileStepY) - offsetY + baseOffsetY + 38), Color.White, 0f, Vector2.Zero,
                        1.0f, SpriteEffects.None, 0.0f);
                    */
                }
            }

            // Characters
            /*Vector2 vladStandingOn = myMap.WorldToMapCell(vlad.Position, out tempOut);
            int vladHeight = myMap.Rows[(int)vladStandingOn.Y].Columns[(int)vladStandingOn.X].HeightTiles.Count * Tile.HeightTileOffset;
            vlad.Draw(spriteBatch, 0, -vladHeight);
            */

            int hilightrowOffset = 0;
            if ((hilightPoint.Y) % 2 == 1)
                hilightrowOffset = Isometric.Tile.OddRowXOffset;

            spriteBatch.Draw(hilight, Isometric.IsoCamera.WorldToScreen(new Vector2((hilightPoint.X * Isometric.Tile.TileStepX) + hilightrowOffset,
                                    (hilightPoint.Y + 2) * Isometric.Tile.TileStepY)),
                            new Rectangle(0, 0, 64, 32), Color.White * 0.3f, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.0f);

            spriteBatch.End();
        }
Ejemplo n.º 3
0
        public void SetupNewLevel(ContentManager cm, ScreenInfo screenInfo)
        {
            if (playerShip == null)
                playerShip = new Ship();
            playerShip.Load(cm, "Art\\Vehicles\\SampleShip", true);

            Vector2 newShipPos = screenInfo.curScreenCenter;
            // Go from the center of the screen to the ship position, top left of it.
            newShipPos.X -= playerShip.GetSize().X / 2;
            newShipPos.Y -= playerShip.GetSize().Y / 2;
            playerShip.Reset(newShipPos);
            camera.StartFollow(playerShip);

            // Load enemies
            Ship tempShip = new Ship();
            tempShip.Load(cm, "Art\\Vehicles\\2dAlienUfo", false);
            tempShip.SetPosition(new Vector2(3000, 2500));
            enemyShips.Add(tempShip);
            /*
            tempShip = new Ship();
            tempShip.Load(Content, "Art\\Vehicles\\2dAlienUfo", false);
            tempShip.SetPosition(new Vector2(3050, 2200));
            enemyShips.Add(tempShip);
            */
            #if DEBUG
            //playerShip.DebugSetup(new Vector2(2890.771f, 2477.647f), new Vector2(0.8470135f, -0.5315714f), Vector2.Zero, -5.27282f, 0.002f);
            #endif
        }