private UIElement GetWorldObjView(IWorldMapObject cell)
        {
            UIElement objView = new Border
            {
                BorderBrush     = Brushes.Gray,
                BorderThickness = new Thickness(1)
            };

            switch (cell.Type)
            {
            case WorldObjectType.Poison:
                ((Border)objView).Background = Brushes.DarkRed;
                break;

            case WorldObjectType.Wall:
                ((Border)objView).Background = Brushes.DarkGray;
                break;

            case WorldObjectType.Bot:
                var bot    = (Bot)cell;
                var button = new Button();
                button.Background = Brushes.BlueViolet;
                button.Content    = bot.Health;
                button.Click     += (sender, _) =>
                {
                    if (!paused)
                    {
                        return;
                    }
                    var btn = (Button)sender;
                    MessageBox.Show($"Bot at {Grid.GetColumn(btn)};{Grid.GetRow(btn)}");
                };
                objView = button;
                break;

            case WorldObjectType.Food:
                ((Border)objView).Background = Brushes.Green;
                break;

            case WorldObjectType.Empty:
                ((Border)objView).Background = Brushes.Black;
                break;
            }

            return(objView);
        }
Пример #2
0
 public WorldMapCellChangedEventArgs(Point coordinates, IWorldMapObject previousObj)
 {
     Coordinates = coordinates;
     PreviousObj = previousObj;
 }