Ejemplo n.º 1
0
 public LevelInfo(int width, int height, Color topLeft, Color topRight, Color bottomRight, Color bottomLeft, TileLock tileLock)
 {
     TopLeft     = topLeft;
     TopRight    = topRight;
     BottomRight = bottomRight;
     BottomLeft  = bottomLeft;
     Width       = width;
     Height      = height;
     TileLock    = tileLock;
 }
Ejemplo n.º 2
0
        public Level(int width, int height, Color topLeft, Color topRight, Color bottomRight, Color bottomLeft, TileLock tileLock) : base(width, height, topLeft, topRight, bottomRight, bottomLeft, tileLock)
        {
            solution = new Color[Width, Height];
            tiles    = new Color[Width, Height];
            locked   = new bool[Width, Height];
            for (int x = 0; x < Width; ++x)
            {
                for (int y = 0; y < Height; ++y)
                {
                    solution[x, y] = Blerp(topLeft, topRight, bottomRight, bottomLeft, (double)x / (Width - 1), (double)y / (Height - 1));
                    tiles[x, y]    = solution[x, y];

                    // mirror
                    int ax = x < Width / 2 ? x : Width - x - 1;
                    int ay = y < Height / 2 ? y : Height - y - 1;

                    switch (tileLock)
                    {
                    case TileLock.None: locked[x, y] = false; break;

                    case TileLock.Borders: locked[x, y] = ax == 0 || ay == 0; break;

                    case TileLock.Checkered: locked[x, y] = (ax + ay) % 2 == 0; break;

                    default: throw new Exception();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static LevelInfo GetRandom(int width, int height, TileLock tl)
        {
            var colors = GetRandomColors(4);

            return(new LevelInfo(width, height, colors[0], colors[1], colors[2], colors[3], tl));
        }