Esempio n. 1
0
        private void OnItemButtonToggled(BaseButton.ButtonToggledEventArgs args)
        {
            var item = (TileSpawnButton)args.Button.Parent;

            if (SelectedButton == item)
            {
                SelectedButton = null;
                placementManager.Clear();
                return;
            }
            else if (SelectedButton != null)
            {
                SelectedButton.ActualButton.Pressed = false;
            }

            SelectedButton = null;

            var newObjInfo = new PlacementInformation
            {
                PlacementOption = "AlignTileAny",
                TileType        = tileDefinitionManager[item.TileDef].TileId,
                Range           = 400,
                IsTile          = true
            };

            placementManager.BeginPlacing(newObjInfo);
            SelectedButton = item;
        }
Esempio n. 2
0
 private void OnPlacementCanceled(object sender, EventArgs e)
 {
     if (SelectedButton != null)
     {
         SelectedButton.ActualButton.Pressed = false;
         SelectedButton = null;
     }
 }
Esempio n. 3
0
        private void BuildTileList(string searchStr = null)
        {
            TileList.DisposeAllChildren();

            var tileDefs = tileDefinitionManager.Select(td => td.Name);

            if (!string.IsNullOrEmpty(searchStr))
            {
                tileDefs = tileDefs.Where(s => s.IndexOf(searchStr, StringComparison.InvariantCultureIgnoreCase) >= 0);
            }

            foreach (var entry in tileDefs)
            {
                var button = new TileSpawnButton()
                {
                    TileDef = entry,
                };
                button.ActualButton.Text       = entry;
                button.ActualButton.OnToggled += OnItemButtonToggled;

                TileList.AddChild(button);
            }
        }