예제 #1
0
        public static void SwapCells(Cell origin, Cell dest)
        {
            BaseSand originSand = origin.baseSand;

            origin.BaseSand = dest.BaseSand;
            dest.BaseSand   = originSand;
        }
예제 #2
0
        public Form1()
        {
            InitializeComponent();

            for (int x = 0; x < world.TotalWorldWidthCells; x++)
            {
                Rock cell = new Rock();
                cell.Color = RandomColorOffset(cell.Color, rng, colorVariance, colorVariance, colorVariance);
                world.GetCellAtPosition(x, 0).BaseSand = cell;

                cell       = new Rock();
                cell.Color = RandomColorOffset(cell.Color, rng, colorVariance, colorVariance, colorVariance);
                world.GetCellAtPosition(x, world.TotalWorldHeightCells - 1).BaseSand = cell;

                for (int xx = 0; xx < world.TotalWorldWidthCells - 2; xx++)
                {
                    for (int y = 1; y < 5; y++)
                    {
                        BaseSand sCell = world.RNG.Next(0, 2) == 0 ? (BaseSand) new Sand() : new BlackSand();
                        sCell.Color = RandomColorOffset(sCell.Color, rng, colorVariance, colorVariance, colorVariance);
                        world.GetCellAtPosition(xx, y).BaseSand = sCell;
                    }
                }
            }

            for (int y = 0; y < world.TotalWorldHeightCells; y++)
            {
                Rock cell = new Rock();
                cell.Color = RandomColorOffset(cell.Color, rng, colorVariance, colorVariance, colorVariance);
                world.GetCellAtPosition(0, y).BaseSand = cell;

                cell       = new Rock();
                cell.Color = RandomColorOffset(cell.Color, rng, colorVariance, colorVariance, colorVariance);
                world.GetCellAtPosition(world.TotalWorldWidthCells - 1, y).BaseSand = cell;
            }

            ImageBuffer        = new Bitmap((int)(world.TotalWorldWidthCells * xResolution), (int)(world.TotalWorldHeightCells * yResolution));
            backBufferGraphics = Graphics.FromImage(ImageBuffer);
            graphics           = drawArea.CreateGraphics();

            drawArea.MouseClick += DrawArea_MouseClick;

            for (int i = 0; i < SandTypes.Count; i++)
            {
                BaseSand type = SandTypes[i];
                Button   b    = new Button();
                b.Name = "bs:" + i;
                b.Text = type.Name;
                buttonLayout.Controls.Add(b);
                b.Click += B_Click;
            }

            ActiveRegion ar = new ActiveRegion(world, 0, 0, 8, 3);

            world.ActiveRegions.Add(ar);

            drawThread = new Thread(Draw);
            drawThread.Start();
        }
예제 #3
0
        public Cell(SubChunk subChunk, int cellX, int cellY, int cellXLocal, int cellYLocal)
        {
            SubChunk   = subChunk;
            this.cellX = cellX;
            this.cellY = cellY;

            this.cellXLocal = cellXLocal;
            this.cellYLocal = cellYLocal;

            baseSand = new Sand.Air();
            BaseSand = baseSand;
        }
예제 #4
0
 private void DrawArea_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         float    x    = ((float)e.Location.X / xResolution);
         float    y    = ((float)e.Location.Y / yResolution);
         Cell     c    = world.GetCellAtPosition((int)x, (int)y);
         BaseSand sand = (BaseSand)Activator.CreateInstance(SandToPlace);
         sand.Color = RandomColorOffset(sand.Color, c.World.RNG, colorVariance, colorVariance, colorVariance);
         c.BaseSand = sand;
     }
 }
예제 #5
0
 public void Process()
 {
     BaseSand.Process();
 }