Exemplo n.º 1
0
 public Form1()
 {
     InitializeComponent();
     currentChunk  = new Sean.Shared.ChunkCoords(64, 28);
     textBox1.Text = "Keys: W,A,S,D";
     WorldInstance = new World();
 }
Exemplo n.º 2
0
        private void OnKeyPress(object sender, KeyPressEventArgs e)
        {
            bool update = false;

            switch (e.KeyChar)
            {
            case 'w':
                currentChunk = new Sean.Shared.ChunkCoords(currentChunk.X, currentChunk.Z - 1);
                update       = true;
                break;

            case 's':
                currentChunk = new Sean.Shared.ChunkCoords(currentChunk.X, currentChunk.Z + 1);
                update       = true;
                break;

            case 'a':
                currentChunk = new Sean.Shared.ChunkCoords(currentChunk.X - 1, currentChunk.Z);
                update       = true;
                break;

            case 'd':
                currentChunk = new Sean.Shared.ChunkCoords(currentChunk.X + 1, currentChunk.Z);
                update       = true;
                break;
            }
            if (update)
            {
                DrawMaps();
            }
        }
Exemplo n.º 3
0
        public Bitmap DrawAllChunks(int width, int height)
        {
            var bitmap   = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            var graphics = Graphics.FromImage(bitmap);

            graphics.SmoothingMode = SmoothingMode.AntiAlias;

            int xOri = 0;

            for (int x = WorldInstance.MinXChunk; x <= WorldInstance.MaxXChunk; x++)
            {
                int zOri = 0;
                for (int z = WorldInstance.MinZChunk; z <= WorldInstance.MaxZChunk; z++)
                {
                    var coords = new Sean.Shared.ChunkCoords(x, z);
                    if (WorldInstance.IsChunkLoaded(coords))
                    {
                        var chunk = WorldInstance.GetChunk(coords);
                        DrawChunk(graphics, chunk, xOri, zOri);
                    }
                    if (coords == currentChunk)
                    {
                        graphics.DrawRectangle(new Pen(Color.FromArgb(255, 255, 0, 0)), xOri, zOri, Global.CHUNK_SIZE - 1, Global.CHUNK_SIZE - 1);
                    }
                    zOri = zOri + Global.CHUNK_SIZE;
                }
                xOri = xOri + Global.CHUNK_SIZE;
            }
            return(bitmap);
        }
Exemplo n.º 4
0
        private void OnGlobalMapMouseDoubleClick(object sender, MouseEventArgs e)
        {
            var map = WorldInstance.GlobalMap;

            currentChunk = new Sean.Shared.ChunkCoords(
                Settings.globalChunkCount * e.X / this.pictureBox1.Width,
                Settings.globalChunkCount * e.Y / this.pictureBox1.Height);
            DrawMaps();
        }
Exemplo n.º 5
0
 public Chunk(ChunkCoords chunkCoords)
 {
     ChunkCoords = chunkCoords;
     Blocks      = new Blocks();
     //HeightMap = new Array<int>(CHUNK_SIZE, CHUNK_SIZE);
     //Clutters = new HashSet<Clutter>();
     //LightSources = new ConcurrentDictionary<int, LightSource>();
     //Mobs = new HashSet<Mob>();
     //GameItems = new ConcurrentDictionary<int, GameItemDynamic>();
 }
 private Chunk GetOrCreate(ChunkCoords chunkCoords)
 {
     long chunkHash = ((long)chunkCoords.X << 32) + (long)chunkCoords.Z;
     Chunk chunk = _chunks [chunkHash];
     if (chunk == null) {
         chunk = new Chunk (chunkCoords);
         _chunks[chunkHash] = chunk;
     }
     return chunk;
 }
 public void Add(ChunkCoords chunkCoords, Chunk chunk)
 {
     long chunkHash = ((long)chunkCoords.X << 32) + (long)chunkCoords.Z;
     _chunks [chunkHash] = chunk;
 }