示例#1
0
        void Upgrade()
        {
            if (selectedConstructionPoint.Tower.NextTower != null)
            {
                if (resources.Value < selectedConstructionPoint.Tower.NextTower.Cost)
                {
                    ui.DisplayWarning = AssetLibrary.Strings.BuildNotEnoughResourcesToUpgrade;
                }
                else
                {
                    ui.DisplayMessage = AssetLibrary.Strings.BuildUpgradeSuccesful;

                    resources.Remove(selectedConstructionPoint.Tower.NextTower.Cost);

                    // Upgrade the selected construction point's associated tower.
                    selectedConstructionPoint.Tower?.Upgrade();

                    UiHud.CreateHitMarker(selectedConstructionPoint.Tower.Position, (text) =>
                    {
                        text.Label.ApplyStyle(AssetLibrary.TextStyles.HudWorldSpaceText);
                        text.Label.Color   = Color.White;
                        text.Label.Content = "UPGRADE!";
                    });
                }

                // Update the menu to reflect the values of the recently upgrade tower.
                upgradeMenuController.UpdateMenu(selectedConstructionPoint.Tower);
            }
        }
示例#2
0
        void Sell()
        {
            if (selectedConstructionPoint == null)
            {
                return;
            }

            // Tell the Construction Point to remove its associated tower.
            // The 'onRemove' callback allows access to the tower before it is removed.
            selectedConstructionPoint.RemoveTower((tower) =>
            {
                ui.DisplayMessage = string.Format("Removed object '{0}' with id {1}", tower.Name, tower.Entity.ID);

                // Refund cost
                resources.Add(tower.CurrentTower.RefundCost);

                UiHud.CreateHitMarker(tower.Position, (text) =>
                {
                    text.Label.Alignment = Alignment.Center;
                    text.Label.ApplyStyle(AssetLibrary.TextStyles.HudWorldSpaceText);
                    text.Label.Color   = Color.Green;
                    text.Label.Content = "+" + tower.CurrentTower.RefundCost;
                });
            });

            upgradeMenuController.HideMenu();

            selectedConstructionPoint = null;
        }
示例#3
0
        void Build(UnitTowerData towerData)
        {
            if (towerData.UpgradePath.Count == 0)
            {
                Log.Error("Cannot build Tower '{0}' as it has no data inside its upgrade path. It needs at least one upgrade.", towerData.Name);
                return;
            }

            if (resources.Value < towerData.UpgradePath[0].Cost)
            {
                ui.DisplayWarning = AssetLibrary.Strings.BuildNotEnoughResources;
            }
            else
            {
                ui.DisplayMessage = AssetLibrary.Strings.BuildSuccessful;

                // Tell the construction point to place a tower. This is where the tower is instantiated and initialized.
                selectedConstructionPoint.PlaceTower(towerData);

                ghost.Hide();

                resources.Remove(towerData.UpgradePath[0].Cost);

                buildMenuController.HideMenu();

                // Display a hitmarker UI showing how many resources have been deducted for building this tower.
                UiHud.CreateHitMarker(selectedConstructionPoint.Position, (text) =>
                {
                    text.Label.ApplyStyle(AssetLibrary.TextStyles.HudWorldSpaceText);
                    text.Label.Color   = Color.Red;
                    text.Label.Content = "-" + towerData.UpgradePath[0].Cost.ToString();
                });
            }
        }
示例#4
0
 private void Health_OnDamageReceived(int arg)
 {
     UiHud.CreateHitMarker(Position, (text) =>
     {
         text.Label.ApplyStyle(AssetLibrary.TextStyles.HudWorldSpaceText);
         text.Label.Color   = Color.Yellow;
         text.Label.Content = "-" + arg.ToString();
     });
 }