예제 #1
0
 public Player(GraphicsDevice GraphicsDevice)
 {
     this.GraphicsDevice = GraphicsDevice;
     conMan = new ConnectionManager();
     VecUnits = new List<BaseUnit>();
     sprite = new SpriteBatch(GraphicsDevice);
     map = new Map();
     Inter = new Interface(GraphicsDevice, 0, map);
     sw = new Stopwatch();
 }
예제 #2
0
        public int DrawMap(Texture2D[] wallTexture, Interface inter, Camera2D camera)
        {
            sprite.Begin(SpriteSortMode.BackToFront,
                                   BlendState.AlphaBlend,
                                   null,
                                   null,
                                   null,
                                   null,
                                   inter.camera.GetTransformation(sprite.GraphicsDevice));

            for (int i = Math.Max(((int)camera._pos.X - camera.width) / tileWidth - safezone, 0); i < Math.Min(((int)camera._pos.X + camera.width) / tileWidth + safezone, width); i++)
            {
                for (int j = Math.Max(((int)camera._pos.Y - camera.height) / tileHeight - safezone, 0); j < Math.Min(((int)camera._pos.Y + camera.height) / tileHeight + safezone, height); j++)
                {
                    if (map[i, j] == 0)
                    {
                        Rectangle tmp = new Rectangle(i * tileWidth, j * tileHeight, tileWidth, tileHeight);
                        sprite.Draw(wallTexture[0], tmp, Color.White);
                    }
                    else if (map[i, j] == 1)
                    {
                        Rectangle tmp = new Rectangle(i * tileWidth, j * tileHeight, tileWidth, tileHeight);
                        sprite.Draw(wallTexture[1], tmp, Color.White);
                    }
                    else if (map[i, j] == 2)
                    {
                        Rectangle tmp = new Rectangle(i * tileWidth, j * tileHeight, tileWidth, tileHeight);
                        sprite.Draw(wallTexture[2], tmp, Color.White);
                    }
                    else if (map[i, j] == 3)
                    {
                        Rectangle tmp = new Rectangle(i * tileWidth, j * tileHeight, tileWidth, tileHeight);
                        sprite.Draw(wallTexture[3], tmp, Color.White);
                    }
                    else if (map[i, j] == 4)
                    {
                        Rectangle tmp = new Rectangle(i * tileWidth, j * tileHeight, tileWidth, tileHeight);
                        sprite.Draw(wallTexture[4], tmp, Color.White);
                    }
                }
            }
            sprite.End();
            return 0;
        }