public BuildingSpawnShieldAdorner(Building adornedBuilding)
     : base(adornedBuilding)
 {
     this.adornedBuilding = adornedBuilding;
     this.InitializeSpawnShieldVisual();
     this.InitializeSpawnShieldVisualEffects();
 }
Пример #2
0
        void RemoveBuilding(Building targetBuilding)
        {
            if (targetBuilding != this.townHall &&
                targetBuilding != this.clanCastle)
            {
                if (targetBuilding == this.selectedBuilding)
                {
                    this.selectedBuilding = null;
                }

                this.buildingCounts[targetBuilding.BuildingID]--;
                this.villageLayoutGrid.Children.Remove(targetBuilding);
            }

            this.RefreshVillageDetails();
        }
Пример #3
0
        void MoveBuilding(Building building, int xOffset, int yOffset)
        {
            int currentColumn = Grid.GetColumn(building);
            int currentRow = Grid.GetRow(building);

            int newColumn = currentColumn + xOffset;
            int newRow = currentRow + yOffset;

            if (-1 < newColumn &&
                -1 < newRow &&
                Village.VillageGridSize >= newColumn + building.GridWidth &&
                Village.VillageGridSize >= newRow + building.GridHeight)
            {
                Grid.SetColumn(building, newColumn);
                Grid.SetRow(building, newRow);
            }
        }
Пример #4
0
        public void CreateNewVillage()
        {
            this.RefreshVillageDetails();
            this.buildingCounts = new Dictionary<string, int>();
            this.selectedBuilding = null;

            this.villageLayoutGrid.Children.Clear();
            this.villageLayoutGrid.ColumnDefinitions.Clear();
            this.villageLayoutGrid.RowDefinitions.Clear();

            for (int i = 0; i < Village.VillageGridSize; i++)
            {
                ColumnDefinition columnDefinition = new ColumnDefinition();
                this.villageLayoutGrid.ColumnDefinitions.Add(columnDefinition);

                RowDefinition rowDefinition = new RowDefinition();
                this.villageLayoutGrid.RowDefinitions.Add(rowDefinition);
            }

            this.villageGridSquares = new List<Border>(Village.VillageGridSize * Village.VillageGridSize);
            for (int x = 0; x < Village.VillageGridSize; x++)
            {
                for (int y = 0; y < Village.VillageGridSize; y++)
                {
                    BitmapImage bitmapImage = new BitmapImage(new Uri("Images\\VillageBackground.png", UriKind.RelativeOrAbsolute));

                    Image cellImage = new Image();
                    cellImage.Source = bitmapImage;
                    cellImage.Stretch = Stretch.Uniform;
                    
                    Border villageGridSquare = new Border();
                    villageGridSquare.Child = cellImage;

                    if (this.ShowVillageGridLines)
                    {
                        villageGridSquare.BorderBrush = new SolidColorBrush(Colors.Black);
                        villageGridSquare.BorderThickness = new Thickness(1.0);
                    }
                    
                    this.villageGridSquares.Add(villageGridSquare);

                    this.villageLayoutGrid.Children.Add(villageGridSquare);
                    Grid.SetColumn(villageGridSquare, x);
                    Grid.SetRow(villageGridSquare, y);
                }
            }

            this.UpdateGridSize();

            this.townHall = new TownHall();
            this.townHall.TownHallLevelChanged += new RoutedEventHandler(this.TownHallLevelChanged);
            this.townHall.IsDraggingChanged += new RoutedEventHandler(this.Building_IsDraggingChanged);
            this.townHall.IsSelectedChanged += new RoutedEventHandler(this.Building_IsSelectedChanged);

            this.townHall.SetBinding(Building.ShowSpawnShieldLayerProperty, this.SpawnShieldLayerBinding);

            this.villageLayoutGrid.Children.Add(this.townHall);

            Grid.SetColumn(this.townHall, (Village.VillageGridSize / 2) - (this.townHall.GridWidth / 2));
            Grid.SetRow(this.townHall, (Village.VillageGridSize / 2) - (this.townHall.GridHeight / 2));

            this.clanCastle = new ClanCastle();
            this.clanCastle.IsDraggingChanged += new RoutedEventHandler(this.Building_IsDraggingChanged);
            this.clanCastle.IsSelectedChanged += new RoutedEventHandler(this.Building_IsSelectedChanged);

            this.clanCastle.SetBinding(DefensiveBuilding.ShowAttackRangeLayerProperty, this.AttackRangeLayerBinding);
            this.clanCastle.SetBinding(Building.ShowSpawnShieldLayerProperty, this.SpawnShieldLayerBinding);

            this.villageLayoutGrid.Children.Add(this.clanCastle);

            Grid.SetColumn(this.clanCastle, Grid.GetColumn(this.townHall) + 5);
            Grid.SetRow(this.clanCastle, Grid.GetRow(this.townHall) + 5);

            this.RefreshVillageDetails();
        }
Пример #5
0
        void Building_IsSelectedChanged(object sender, RoutedEventArgs e)
        {
            Building building = sender as Building;
            if (null != building)
            {
                if (building.IsSelected)
                {
                    if (null != this.selectedBuilding)
                    {
                        this.selectedBuilding.IsSelected = false;
                    }

                    this.selectedBuilding = building;
                    Panel.SetZIndex(this.selectedBuilding, ++this.selectedBuildingZOrder);
                }
                else
                {
                    if (building == this.selectedBuilding)
                    {
                        this.selectedBuilding = null;
                    }
                }
            }
        }
Пример #6
0
 void Building_IsDraggingChanged(object sender, RoutedEventArgs e)
 {
     Building targetBuilding = sender as Building;
     if (targetBuilding.IsDragging)
     {
         this.draggingBuilding = targetBuilding;
         this.draggingBuilding.IsSelected = true;
         this.draggingBuildingInitialColumn = Grid.GetColumn(this.draggingBuilding);
         this.draggingBuildingInitialRow = Grid.GetRow(this.draggingBuilding);
     }
     else
     {
         this.draggingBuilding = null;
     }
 }