Example #1
0
        private void Generate_btn_Click(object sender, EventArgs e)
        {
            int size = ToTexture2D.Convert(Int32.Parse(WorldGrad.Text));
            int seed = Int32.Parse(Seed_Box.Text);

            if (isGenerated && !Controller.isNewMap(seed, size))
            {
                Controller.LoadFullMap();
                WorldPicture.Image = Controller.ControlImage;
                return;
            }
            isGenerated = true;
            int x, y;

            if (!(Int32.TryParse(PosX.Text, out x) && Int32.TryParse(PosY.Text, out y)))
            {
                return;
            }
            WorldPicture.Size        = new System.Drawing.Size(size, size);
            WorldPicture.BorderStyle = BorderStyle.Fixed3D;
            Controller.StartWork(x, y, size, seed, MiniMapMode.Checked);
            WorldPicture.Image = Controller.ControlImage;

            ChunkX.Text = String.Format("{0}", Controller.player.ChunkX);
            ChunkY.Text = String.Format("{0}", Controller.player.ChunkY);
            PosX.Text   = String.Format("{0}", Controller.player.x);
            PosY.Text   = String.Format("{0}", Controller.player.y);
        }
Example #2
0
 public static void ChangedMode()
 {
     if (MiniMapMode)
     {
         ControlImage = ToTexture2D.IncreaseScale(MakeMiniMap(Map, player.ChunkX, player.ChunkY), 3);
     }
     else
     {
         ControlImage = Map;
     }
 }
Example #3
0
        public static void PlayerMoved(int SomeX, int SomeY, bool tp)
        {
            int OldX = player.x, OldY = player.y, OldChunkX = player.ChunkX, OldChunkY = player.ChunkY;

            if (tp)
            {
                player.ChangeCoords(SomeX, SomeY, size);
            }
            else
            {
                player.ChangeCoords(player.x + SomeX, player.y + SomeY, size);
            }

            player.SetRightChunks();

            if (OldChunkX == player.ChunkX && OldChunkY == player.ChunkY)
            {
                Map.SetPixel(OldX, OldY, GameMap.GetColorInPos(OldX, OldY));
                Map.SetPixel(player.x, player.y, Color.FromArgb(255, 255, 0, 0));
                if (MiniMapMode)
                {
                    ControlImage = ToTexture2D.IncreaseScale(MakeMiniMap(Map, player.ChunkX, player.ChunkY), 3);
                }
                else
                {
                    ControlImage = Map;
                }
            }
            else
            {
                GameMap.LoadChunk(player.ChunkX, player.ChunkY);
                Map = GameMap.CreateBitmap();
                Map.SetPixel(player.x, player.y, Color.FromArgb(255, 255, 0, 0));
                PaintChunk(ref Map, player.ChunkX, player.ChunkY);
                if (MiniMapMode)
                {
                    ControlImage = ToTexture2D.IncreaseScale(MakeMiniMap(Map, player.ChunkX, player.ChunkY), 3);
                }
                else
                {
                    ControlImage = Map;
                }
            }
        }
Example #4
0
 public static void StartWork(int _x, int _y, int _size, int _seed, bool _minimap)
 {
     size        = _size;
     seed        = _seed;
     MiniMapMode = _minimap;
     GameMap     = new CombinedMap(size, seed, chunksize);
     player      = new Player(_x, _y, size);
     GameMap.LoadChunk(player.ChunkX, player.ChunkY);
     Map = GameMap.CreateBitmap();
     Map.SetPixel(player.x, player.y, Color.FromArgb(255, 255, 0, 0));
     PaintChunk(ref Map, player.ChunkX, player.ChunkY);
     if (MiniMapMode)
     {
         ControlImage = ToTexture2D.IncreaseScale(MakeMiniMap(Map, player.ChunkX, player.ChunkY), 3);
     }
     else
     {
         ControlImage = Map;
     }
 }
Example #5
0
 public static void LoadFullMap()
 {
     for (int i = 0; i < size; i++)
     {
         for (int j = 0; j < size; j++)
         {
             GameMap.LoadPoint(i, j);
         }
     }
     Map = GameMap.CreateBitmap();
     Map.Save(String.Format("{0}.png", seed), ImageFormat.Png);
     Map.SetPixel(player.x, player.y, Color.FromArgb(255, 255, 0, 0));
     PaintChunk(ref Map, player.ChunkX, player.ChunkY);
     if (MiniMapMode)
     {
         ControlImage = ToTexture2D.IncreaseScale(MakeMiniMap(Map, player.ChunkX, player.ChunkY), 3);
     }
     else
     {
         ControlImage = Map;
     }
 }
Example #6
0
 private static void PaintChunk(ref Bitmap Img, int ChunkX, int ChunkY)
 {
     ToTexture2D.PaintSquare(ref Img, ChunkX * chunksize - 1, ChunkY * chunksize - 1, (ChunkX + 1) * chunksize, (ChunkY + 1) * chunksize, Color.Red);
 }