Esempio n. 1
0
 public void Draw(Graphics g, View view, float delta)
 {
     int sy = view.GetY() / (Chunk.size * Tile.size) - 2;
     int my = sy + (int) Math.Ceiling(g.VisibleClipBounds.Height / (Chunk.size * Tile.size)) + 2;
     int sx = view.GetX() / (Chunk.size * Tile.size) - 2;
     int mx = sx + (int)Math.Ceiling(g.VisibleClipBounds.Width / (Chunk.size * Tile.size)) + 2;
     for (int y = sy; y <= my; y++)
     {
         for (int x = sx; x <= mx; x++)
         {
             Chunk chunk = this.chunkManager.GetChunk(x, y);
             if (chunk == null)
             {
                 this.chunkManager.Load(x, y, this.seed);
             }
             else
             {
                 chunk.Draw(g, view, this, delta);
             }
         }
     }
     for (int y = sy; y <= my; y++)
     {
         for (int x = sx; x < mx; x++)
         {
             Chunk chunk = this.chunkManager.GetChunk(x, y);
             if (chunk != null)
             {
                 chunk.DrawEntities(g, view, this, delta);
             }
         }
     }
 }
Esempio n. 2
0
 public Game(int seed, Form window, Options options)
 {
     this.window = window;
     this.world = new World(seed, @"saves/save.csf");
     this.view = new View(window, this.world.GetPlayer());
     this.ui = new UI(this.world.GetPlayer());
     this.running = false;
     this.options = options;
 }
Esempio n. 3
0
 public virtual void Draw(Graphics g, View view, World world, int x, int y, int up, int down, int left, int right)
 {
     g.DrawImage(ImageManager.GetImage(this.image), x * Tile.size - view.GetX(), y * Tile.size - view.GetY(), 32, 32);
 }
Esempio n. 4
0
 public void DrawEntities(Graphics g, View view, World world, float delta)
 {
     List<Entity>[] entities = new List<Entity>[size];
     for (int y = 0; y < size; y++)
     {
         entities[y] = new List<Entity>(5);
     }
     foreach (Entity entity in this.entities)
     {
         entities[(entity.Y % Chunk.size + Chunk.size) % Chunk.size].Add(entity);
     }
     for (int y = 0; y < size; y++)
     {
         foreach (Entity entity in entities[y])
         {
             entity.Draw(g, view, world, delta);
         }
     }
 }
Esempio n. 5
0
 public void Draw(Graphics g, View view, World world, float delta)
 {
     Chunk cUp = world.GetChunk(this.x, this.y - 1);
     Chunk cDown = world.GetChunk(this.x, this.y + 1);
     Chunk cLeft = world.GetChunk(this.x - 1, this.y);
     Chunk cRight = world.GetChunk(this.x + 1, this.y);
     int X = this.x * Chunk.size;
     int Y = this.y * Chunk.size;
     for (int y = 0; y < Chunk.size; y++)
     {
         for (int x = 0; x < Chunk.size; x++)
         {
             int up = (y > 0 ? this.tiles[this.ToIndex(x, y - 1)] : (cUp == null ? 0 : cUp.GetTile(x, y - 1)));
             int down = (y < Chunk.size - 1 ? this.tiles[this.ToIndex(x, y + 1)] : (cDown == null ? 0 : cDown.GetTile(x, y + 1)));
             int left = (x > 0 ? this.tiles[this.ToIndex(x - 1, y)] : (cLeft == null ? 0 : cLeft.GetTile(x - 1, y)));
             int right = (x < Chunk.size - 1 ? this.tiles[this.ToIndex(x + 1, y)] : (cRight == null ? 0 : cRight.GetTile(x + 1, y)));
             Tile.GetTile(this.tiles[this.ToIndex(x, y)]).Draw(g, view, world, X + x, Y + y, up, down, left, right);
         }
     }
 }
Esempio n. 6
0
 public virtual void Draw(Graphics g, View view, World world, float delta, int offX, int offY)
 {
     this.Draw(g, view, world, delta, image, offX, offY);
 }
Esempio n. 7
0
 public virtual void Draw(Graphics g, View view, World world, float delta)
 {
     this.Draw(g, view, world, delta, image);
 }
Esempio n. 8
0
 protected virtual void Draw(Graphics g, View view, World world, float delta, int image, int offsetX, int offsetY)
 {
     g.DrawImage(ImageManager.GetImage(image), this.x * Tile.size - view.GetX() + offsetX, this.y * Tile.size - Tile.size / 4 - view.GetY() + offsetY);
 }
Esempio n. 9
0
 protected override void Draw(Graphics g, View view, World world, float delta, int image)
 {
     g.DrawImage(ImageManager.GetImage(image), this.GetVisualX() - view.GetX(), this.GetVisualY() - Tile.size / 4 - view.GetY());
 }