Beispiel #1
0
    private void showResetAverageButtonIfNecessary()
    {
        int resetsLeft = DataAndSettingsManager.getNumBoughtForStoreItem(StoreManager.ITEM_KEY_RESET_AVERAGE);

        this.resetAverageButtonLabel.text = "Reset average (" + resetsLeft + ")";
        this.resetAverageButton.SetActive(resetsLeft > 0);
    }
Beispiel #2
0
    /* * * * Buying items * * * */

    ///<summary>Updates gold amount and relevant item count as appropriate. Also updates expiration date if applicable.</summary>
    public static bool buyItem(int id)
    {
        StoreItem item      = STORE_ITEMS[id];
        string    key       = item.getKey();
        int       numBought = DataAndSettingsManager.getNumBoughtForStoreItem(key);
        int       gold      = DataAndSettingsManager.getGoldAmount();

        if (gold >= item.getCost() && (id < getNumExpendables() || numBought < 1))
        {
            DataAndSettingsManager.setNumBoughtForStoreItem(key, numBought + 1);
            DataAndSettingsManager.setGoldAmount(gold -= item.getCost());
            if (item.hasLifespan())
            {
                DateTime expiration = DataAndSettingsManager.getExpirationDateForStoreItem(key);
                DateTime now        = DateTime.Now;
                TimeSpan lifespan   = new TimeSpan(item.getLifespanHours(), 0, 0);
                if (expiration.CompareTo(now) < 0)
                {
                    // the item has already expired, so set a new expiration date
                    DataAndSettingsManager.setExpirationDateForStoreItem(key, now.Add(lifespan));
                }
                else
                {
                    // the item hasn't expired yet, so advance the expiration date further
                    DataAndSettingsManager.setExpirationDateForStoreItem(key, expiration.Add(lifespan));
                }
                //Debug.Log("expiration date was " + expiration.ToString());
            }
            return(true);
        }
        return(false);
    }
    /* * * * Lifecycle methods * * * */

    void OnEnable()
    {
        OnSelectColorScheme += this.respondToOtherItemSelected;
        if (this.isLocked)
        {
            // check whether it should still be locked
            this.isLocked = (this.colorSchemeID > 1 && DataAndSettingsManager.getNumBoughtForStoreItem(this.packName) == 0);
            if (!this.isLocked)
            {
                this.nameLabel.text = this.colorSchemeName;
            }
        }
    }
Beispiel #4
0
    /* * * * UI setup * * * */

    private void showHardModeToggleIfNecessary()
    {
        this.hardModeRect.SetActive(DataAndSettingsManager.getNumBoughtForStoreItem(StoreManager.ITEM_KEY_HARD_MODE) > 0);
        this.hardModeToggle.isOn = DataAndSettingsManager.getHardModeState();
        if (this.hardModeRect.activeSelf)   // need to adjust text position to make room for the toggle
        {
            this.helpText.anchoredPosition = new Vector2(0f, 400f);
        }
        else
        {
            this.helpText.anchoredPosition = new Vector2(0f, 300f);
        }
    }
Beispiel #5
0
    private void showReviveButtonsIfNecessary()
    {
        bool canRevive = (this.consecutiveRevivals < MAX_CONSECUTIVE_REVIVALS && GameStateManager.canRevive());

        if (canRevive)
        {
            int revivesLeft = DataAndSettingsManager.getNumBoughtForStoreItem(StoreManager.ITEM_KEY_EXTRA_LIFE);
            this.reviveButtonLabel.text = "Revive (" + revivesLeft + ")";
            this.reviveButton.SetActive(revivesLeft > 0);
        }
        else
        {
            this.reviveButton.SetActive(false);
        }
        this.reviveWithAdButton.SetActive(canRevive);
    }
    /* * * * Public methods * * * */

    public void setup(int colorSchemeID, bool selected)
    {
        this.colorSchemeID = colorSchemeID;
        this.setSelected(selected);
        ColorScheme cs = ColorSchemesManager.getColorSchemeWithID(colorSchemeID);

        this.setColors(cs);
        this.colorSchemeName = cs.getName();
        this.nameLabel.text  = this.colorSchemeName;
        this.packName        = cs.getPackName();
        this.isLocked        = (colorSchemeID > 1 && DataAndSettingsManager.getNumBoughtForStoreItem(this.packName) == 0);
        if (this.isLocked)
        {
            this.nameLabel.text += " (Locked)";
        }
    }
Beispiel #7
0
 ///<summary>Sets the counts of items with lifespans according to how many lifespans are left before their expiration dates.</summary>
 public static void updateLifespanItemCounts()
 {
     foreach (StoreItem item in STORE_ITEMS)
     {
         string key       = item.getKey();
         int    numBought = DataAndSettingsManager.getNumBoughtForStoreItem(key);
         if (numBought > 0 && item.hasLifespan())
         {
             DateTime expiration = DataAndSettingsManager.getExpirationDateForStoreItem(key);
             DateTime now        = DateTime.Now;
             int      difference = expiration.Subtract(now).Hours;
             if (difference > 0)
             {
                 DataAndSettingsManager.setNumBoughtForStoreItem(key, difference / item.getLifespanHours());
             }
             else
             {
                 DataAndSettingsManager.setNumBoughtForStoreItem(key, 0);
             }
         }
     }
 }
Beispiel #8
0
    ///<summary>Decrements the item count by 1. For now, actual item functionality should be handled where the item is expended.</summary>
    public static void expendItem(string key)   // TODO: consider handling item functionality in here
    {
        int numBought = DataAndSettingsManager.getNumBoughtForStoreItem(key);

        DataAndSettingsManager.setNumBoughtForStoreItem(key, numBought - 1);
    }
Beispiel #9
0
 ///<summary>Returns the number of this item owned by the user (not counting expended ones).</summary>
 public int getNumBought()
 {
     return(DataAndSettingsManager.getNumBoughtForStoreItem(this.key));
 }
Beispiel #10
0
 public void openMainAction()
 {
     this.deactivateAllPanels();
     this.crownImage.SetActive(DataAndSettingsManager.getNumBoughtForStoreItem(StoreManager.ITEM_KEY_BRAGGING_RIGHTS) > 0);
     this.mainPanel.SetActive(true);
 }