示例#1
0
    public SaveData(CoolerCookieClicker resources, List <PassiveUnit> passiveUnitList, List <PassiveUpgrade> passiveUpgradeList)
    {
        // Serialize each PassiveUnit's data
        foreach (PassiveUnit passiveUnit in passiveUnitList)
        {
            passiveUnitDataList.Add(new PassiveUnitData(passiveUnit.getDataToSave()));
        }

        // Serialize each PassiveUpgrade's data
        foreach (PassiveUpgrade passiveUpgrade in passiveUpgradeList)
        {
            passiveUpgradeDataList.Add(new PassiveUpgradeData(passiveUpgrade.getDataToSave()));
        }

        // Serialize game resources data
        this.currency          = resources.currency;
        this.currencyPerPower  = resources.currencyPerPower;
        this.currencyPerSecond = resources.currencyPerSecond;
        this.powerPerSecond    = resources.powerPerSecond;
        this.totalPowerRate    = resources.totalPowerRate;
        this.purchasepool      = resources.purchasepool;
        this.treadmillSpeed    = resources.treadmillSpeed;
    }
示例#2
0
    /***************************************************************************
     * PassiveUnit state changes
     **************************************************************************/
    /// <summary>
    /// Buys one more of this unit type
    /// </summary>
    public void PurchaseUnit()
    {
        CoolerCookieClicker resourceManager = CoolerCookieClicker.Instance;

        if (resourceManager.currency >= priceToPurchase)
        {
            // buy unit
            resourceManager.purchasepool += priceToPurchase;
            resourceManager.AddToPassive(powerRatePerQuantity);
            quantity++;
            // increase price
            priceToPurchase *= priceGrowthRate;
            // update the power gen rate
            TotalPowerRate = powerRatePerQuantity * quantity;
            // if there isn't a reference to that unit yet, add it
            //if (!resourceManager.unitList.ContainsKey(unitType))
            //{
            //    resourceManager.unitList.Add(unitType, this);
            //}
            // update the UI
            UpdateUI();
        }
    }