Ejemplo n.º 1
0
    public void save()
    {
        FinanceManager _totalMoney = _managers.GetComponent <FinanceManager>();

        ShaftManager gett = _managers.GetComponent <ShaftManager>();

        Inventory _elevator_amount = _elevatorDropOff_Amount.GetComponent <Inventory>();

        UpgradeActorUI _elevatorUpgradeAmount   = _elevatorUpgrade.GetComponent <UpgradeActorUI>();
        Actor          _elevatorSkillMultiplier = _elevator.GetComponent <Actor>();

        UpgradeActorUI _wareHouseAmount          = _warehouseUpgrade.GetComponent <UpgradeActorUI>();
        Actor          _wareHouseSkillMultiplier = _wareHouse.GetComponent <Actor>();

        // we add the _textSplit[0] to the name of the saved value to ensure
        // that the script can be used for saving a lot of mines.
        // Encrypt & Save the total number of current shafts.
        EncryptedPlayerPrefs.SetInt(_textSplit[0] + "NumberOfShafts", +gett.Shafts.Count);

        // Encrypt & Save the totalMoney value.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "TotalMoney", +(float)_totalMoney.totalMoney);

        // Encrypt & Save the Elevator Drop Off Amount.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "ElevatorDropOff_Amount", +_elevator_amount.money);

        // Encrypt & Save the Elevator Upgrade Amount.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "ElevatorUpgradeAmount", +_elevatorUpgradeAmount._price);

        // Encrypt & Save the Elevator Skill Multiplier value.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "ElevatorSkillMultiplier", +_elevatorSkillMultiplier.SkillMultiplier);

        // Encrypt & Save the WareHouse Amount.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "WareHouseAmount", +_wareHouseAmount._price);

        // Encrypt & Save the WareHouse Skill Multiplier value.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "WareHouseSkillMultiplier", +_wareHouseSkillMultiplier.SkillMultiplier);

        // Encrypt & Save the Upgrade Amout, Skill Multiplier & Drop Off Amount
        // for every shaft.
        for (int i = 0; i < gett.Shafts.Count; i++)
        {
            float UpgradeAmount   = gett.Shafts[i].transform.GetChild(3).GetChild(1).GetComponent <UpgradeActorUI>()._price;
            float SkillMultiplier = gett.Shafts[i].transform.GetChild(1).GetComponent <Actor>().SkillMultiplier;
            float DropOff_Amount  = gett.Shafts[i].transform.GetChild(2).GetChild(1).GetComponent <Inventory>().money;

            EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "UpgradeAmount" + i, UpgradeAmount);
            EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "SkillMultiplier" + i, SkillMultiplier);
            EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "DropOff_Amount" + i, DropOff_Amount);
        }

        // When the game is saved, hide the menu & return to game.
        _menuBackground.SetActive(false);
        Time.timeScale = 1.0f;
    }