Beispiel #1
0
        private void UpdateConfiguration()
        {
            string        exePath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), APP_CONFIGFILE);
            Configuration conf    = ConfigurationManager.OpenExeConfiguration(exePath);

            LiveUpgradeConfigurationSection newCS = new LiveUpgradeConfigurationSection();
            LiveUpgradeConfigurationSection cs    = conf.GetSection(UPGRADE_SECTION) as LiveUpgradeConfigurationSection;

            if (cs != null)
            {
                foreach (UpgradeElement element in cs.UpgradeProducts)
                {
                    if (element.Product != project.Product)
                    {
                        newCS.UpgradeProducts.AddElement(element);
                    }
                }
            }

            UpgradeElement ele = new UpgradeElement();

            ele.Product      = project.Product;
            ele.UpgradeDate  = DateTime.Now.ToLocalTime();
            ele.LocalVersion = project.Version;
            newCS.UpgradeProducts.AddElement(ele);

            conf.Sections.Remove(UPGRADE_SECTION);
            conf.Sections.Add(UPGRADE_SECTION, newCS);
            conf.Save();
        }
Beispiel #2
0
    protected void ConfigureUpgrade <T>(UpgradeElement element, UpgradeHelper <T> upgradeManager, Action <T> successAction) where T : Upgrade
    {
        element.CostButton.onClick.RemoveAllListeners();

        bool hasNextUpgrade = upgradeManager.Next != null;

        element.CostButton.enabled = hasNextUpgrade;

        for (int i = 0; i < element.Levels.Length; i++)
        {
            element.Levels[i].color = (i < upgradeManager.Current.Level) ? new Color(186f / 255f, 0, 0, 1f) : Color.white;
        }

        if (hasNextUpgrade)
        {
            element.CostButton.onClick.AddListener(() => UpgradeStat(upgradeManager, successAction));
            element.Name.text     = upgradeManager.Next.Title;
            element.CostText.text = "£" + upgradeManager.Next.Cost.ToString();
        }
    }