/// <summary> /// Default constructor /// </summary> /// <param name="x">X position on screen</param> /// <param name="y">Y position on screen</param> /// <param name="zIndex">Z index of tower location and tower on it</param> public TowerLocation(int x, int y, int zIndex) { // Assign coordinates this.x = x; this.y = y; // Set layer index this.layerIndex = zIndex; // No tower on it at creation this.tower = null; // Prepare visual control String image = TowerLocation.baseFolder + "location.png"; // Add visual control to UI Application.Current.Dispatcher.BeginInvoke((Action)delegate() { this.control = new View.Control.TowerLocationControl(this, image, 35, 17); this.control.move(x, y); this.control.changeZIndex(zIndex); }); }
/// <summary> /// Modify the tower occupying the location /// </summary> /// <param name="tower">Tower to place, or null</param> private void setTower(Entity.Tower tower) { if (this.tower != null) { this.tower.dispose(); } this.tower = tower; if (this.tower != null) { this.tower.place(this); } }