Exemplo n.º 1
0
 public void ApplyUpgrade(UpgradeBase upgrade)
 {
     this.Update(() =>
     {
         _topology.ApplyUpgrade(upgrade);
     });
 }
Exemplo n.º 2
0
        public void TryUpgrade()
        {
            var upgrades = new UpgradeBase[]
            {
                new Upgrade0To1(),
                new Upgrade1To2(),
                new Upgrade2To3(),
                new Upgrade3To4(),
                new Upgrade4To5(),
                new Upgrade5To6(AVATAR_COUNT),
                new Upgrade6To7(),
                new Upgrade7To8()
            };
            var sortedUpgrades = upgrades.OrderBy(i => i.ToVersion);

            foreach (var upgrade in sortedUpgrades)
            {
                if (Version == upgrade.FromVersion)
                {
                    upgrade.Upgrade(this);
                    Version = upgrade.ToVersion;
                    Save();
                }
            }
        }
Exemplo n.º 3
0
 private void HandleUpgradeMouseExit(object sender, EventArgs e)
 {
     _current = null;
     _levelIndicator.UpdateColor();
     GameState.Instance.UpdateCost(null);
     UpgradeDetails.UpdateTarget(null);
 }
Exemplo n.º 4
0
 private void OnSelect(UpgradeBase upgrade)
 {
     if (Ship.UpgradeSlotFree())
     {
         Ship.ApplyUpgrade(upgrade);
     }
     Ended = true;
 }
Exemplo n.º 5
0
    //Add A Purchasable Upgrades
    public void AddUpgradable(UpgradeBase item)
    {
        //Create button prefab and attach it to the content panel
        GameObject       buttonCreation = Instantiate(upgradeButton, contentPanel);
        UpgradeBuyButton buttonScript   = buttonCreation.GetComponent <UpgradeBuyButton>();

        buttonScript.Setup(item);         //pass upgrade object into the button

        upgradeList.Add(item);
    }
Exemplo n.º 6
0
        public void SetUpgrades(UpgradeBase[] upgrades)
        {
            _upgrades.ForEach(Destroy);
            _upgrades.Clear();
            UpgradeDetails.UpdateTarget(null);

            if (upgrades == null)
            {
                return;
            }

            foreach (var upgrade in upgrades)
            {
                var upgradeObject = Instantiate(upgrade.Icon, Vector2.zero, Quaternion.identity, UpgradesParent);
                upgradeObject.transform.localPosition = new Vector2(_upgrades.Count % 6 * _positionOffset, 0f);
                upgradeObject.transform.localScale    = _scale;
                foreach (var spriteRenderer in upgradeObject.GetComponentsInChildren <SpriteRenderer>())
                {
                    spriteRenderer.sortingOrder = _sortingOrder;
                }
                upgradeObject.GetComponentInChildren <LevelIndicator>().Upgrade = upgrade;

                var interaction = upgradeObject.GetComponentInChildren <Interaction>();
                interaction.OnClick += HandleUpgradeClick;
                interaction.OnEnter += (sender, o) =>
                {
                    _current        = upgrade;
                    _spriteRenderer = o.GetComponentInChildren <SpriteRenderer>();
                    _levelIndicator = o.GetComponentInChildren <LevelIndicator>();
                    GameState.Instance.UpdateCost(upgrade.NextCost);
                    UpgradeDetails.UpdateTarget(upgradeObject, true, upgrade);
                };
                interaction.OnExit += HandleUpgradeMouseExit;

                _upgrades.Add(upgradeObject.gameObject);
            }
        }
Exemplo n.º 7
0
    public void Select(UpgradeBase upgrade)
    {
        Unselect();

        upgrade.Image.color = selectedColor;

        title.text       = $"{upgrade.upgradeTitle} {upgrade.level}";
        description.text = upgrade.upgradeDescription;

        if (upgrade.IsBought)
        {
            button.sprite = boughtImage;
            cost.text     = "Bought";
        }
        else
        {
            button.sprite = buyImage;
            cost.text     = upgrade.cost.ToString();
        }

        currentUpgrade = upgrade;

        upgradeUI.SetActive(true);
    }
 //Setup on instantiate
 public void Setup(UpgradeBase item)
 {
     buttonText.text = item.name + ": " + item.description + " | Cost: " + item.cost.ToAbbreviatedString();
     upgradeItem     = item;
     Debug.Log(item.name + " is available to purchase!");
 }
Exemplo n.º 9
0
 public void ApplyUpgrade(UpgradeBase upgrade)
 {
     Upgrades = Upgrades.Concat(new[] { upgrade }).ToArray();
 }
Exemplo n.º 10
0
 public UpgradeMenuOption(UpgradeBase upgrade, Action <UpgradeBase> onSelect)
 {
     _upgrade  = upgrade;
     _onSelect = onSelect;
 }