Example #1
0
        public MainWindow()
        {
            ResizeMode    = ResizeMode.NoResize;
            SizeToContent = SizeToContent.WidthAndHeight;
            // Initialize data structure
            ColorsData.LoadData();

            InitializeComponent();
            // set text and button
            MyText.TextWrapping    = TextWrapping.Wrap;
            MyText.IsReadOnly      = true;
            MyText.BorderThickness = new Thickness(0);
            MyText.FontSize        = 15;
            MyText.TextAlignment   = TextAlignment.Center;
            // set button click listener
            TopButton.Click += SetTopmost;
            // set getting color of pixel, calculate closest color and set text every 100ms
            var timer = new Timer(100)
            {
                AutoReset = true,
                Enabled   = true
            };

            timer.Elapsed += ColorGetHandler;
        }
Example #2
0
    private List <Tile> GetTilesWithColors(ColorsData colorInfo, List <Tile> variants)
    {
        IEnumerable <Tile> result = variants;

        if (colorInfo.RightColor0 != Color.clear)
        {
            result = result.Where(t => t.RightColor0 == colorInfo.RightColor0 && t.RightColor1 == colorInfo.RightColor1);
        }

        if (colorInfo.LeftColor0 != Color.clear)
        {
            result = result.Where(t => t.LeftColor0 == colorInfo.LeftColor0 && t.LeftColor1 == colorInfo.LeftColor1);
        }

        if (colorInfo.ForwardColor0 != Color.clear)
        {
            result = result.Where(t => t.ForwardColor0 == colorInfo.ForwardColor0 && t.ForwardColor1 == colorInfo.ForwardColor1);
        }

        if (colorInfo.BackColor0 != Color.clear)
        {
            result = result.Where(t => t.BackColor0 == colorInfo.BackColor0 && t.BackColor1 == colorInfo.BackColor1);
        }

        return(result.ToList());
    }
Example #3
0
    private ColorsData GetColorsInfo(int x, int y)
    {
        // определяем какие цвета должны быть у тайла
        // смотрим вокруг себя во всех направлениях
        // цвет сзади тайла должен быть равен цвету спереди у сзади стоящего тайла

        var result = new ColorsData();

        if (y - 1 >= 0 && spawnedTiles[x, y - 1] != null)
        {
            result.BackColor0 = spawnedTiles[x, y - 1].ForwardColor0;
            result.BackColor1 = spawnedTiles[x, y - 1].ForwardColor1;
        }

        if (y + 1 < MapSize.y && spawnedTiles[x, y + 1] != null)
        {
            result.ForwardColor0 = spawnedTiles[x, y + 1].BackColor0;
            result.ForwardColor1 = spawnedTiles[x, y + 1].BackColor1;
        }

        if (x - 1 >= 0 && spawnedTiles[x - 1, y] != null)
        {
            result.LeftColor0 = spawnedTiles[x - 1, y].RightColor0;
            result.LeftColor1 = spawnedTiles[x - 1, y].RightColor1;
        }

        if (x + 1 < MapSize.x && spawnedTiles[x + 1, y] != null)
        {
            result.RightColor0 = spawnedTiles[x + 1, y].LeftColor0;
            result.RightColor1 = spawnedTiles[x + 1, y].LeftColor1;
        }

        return(result);
    }
Example #4
0
 public void Rotate(RotationType rotation)
 {
     transform.Rotate(Vector3.up, ((int)rotation) * 90);
     ColorsData = ColorsData.Rotate(rotation);
 }