如何使我的当前EXP整数在重装后不重置为0
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何使我的当前EXP整数在重装后不重置为0相关的知识,希望对你有一定的参考价值。
UPDATE这是显示错误的视频。https://youtu.be/R3r-Y2jsxps
我正在尝试开发大亨风格的游戏,但是我有一些错误。我刚完成自动保存的编码,遇到了2个问题。自动将整数提高,停止和重置的脚本。而我目前的经验值保持不变,但目前的经验值没有保存。
代码(expScipt)
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class expScript : MonoBehaviour
{
//Current level
public static int vLevel = 1;
//Current exp amount
public static int vCurrExp = 0;
//Exp amount needed for lvl 1
public static int vExpBase = 25;
//Exp amount left to next levelup
public static int vExpLeft = 25;
//Modifier that increases needed exp each level
public float vExpMod = 1.15f;
public Slider ExpBar;
public Text displayText;
public Text LevelDisplayText;
public static int currentValue = 0;
public int CurrentValuee
{
get { return currentValue; }
set
{
currentValue = value;
ExpBar.value = currentValue;
ExpBar.maxValue = vExpLeft;
}
}
public void Update()
{
displayText.GetComponent<Text>().text = (ExpBar.value) + " EXP";
LevelDisplayText.GetComponent<Text>().text = "Level : " + vLevel;
currentValue = vCurrExp;
if (vCurrExp == vExpLeft)
{
ExpBar.value = 0;
displayText.GetComponent<Text>().text = (ExpBar.value) + " EXP";
}
}
public void ExpPlusOne()
{
CurrentValuee += 1;
}
//Leveling methods
public void GainExp(int e)
{
vCurrExp += e;
if(vCurrExp >= vExpLeft)
{
LvlUp();
}
}
void LvlUp()
{
vCurrExp -= vExpLeft;
vLevel++;
float t = Mathf.Pow(vExpMod, vLevel);
vExpLeft = (int)Mathf.Floor(vExpBase * t);
}
}
和下面的保存脚本,>>
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GlobalGameMechanics : MonoBehaviour { public Audiosource muffinSound; public static double GlobalPlayerDiamonds; public static double InternalPlayerDiamonds = 1500000; public GameObject PlayerDiamondDisplay; public static double InternalPlayerMuffins = 0; public static double TotalMPSint = 0; public double Test = 0; public static double currentMuffins; public GameObject ShopPanel; public GameObject DiamondShop; public Text MuffinText; public Text TotalMPS; public void Start() { Load(); } void Update() { GlobalPlayerDiamonds = InternalPlayerDiamonds; PlayerDiamondDisplay.GetComponent<Text>().text = "" + InternalPlayerDiamonds; MuffinText.GetComponent<Text>().text = "Muffins " + InternalPlayerMuffins; TotalMPS.GetComponent<Text>().text = "MPS: " + TotalMPSint; TotalMPSint = (GlobalBakery.BakeryMPSint + GlobalFactory.FactoryMPSint + GlobalRoboMuffin.RoboMuffinMPSint + GlobalMuffinLand.MuffinLandMPSint + GlobalSmartFactory.SmartFactoryMPSint + GlobalMuffinFarm.MuffinFarmMPSint + GlobalMuffinCity.MuffinCityMPSint + GlobalMuffinLabs.MuffinLabsMPSint + GlobalMuffinLabsv2.MuffinLabsv2MPSint + GlobalBioMuffin.BioMuffinMPSint + GlobalNuclearMuffin.NuclearMuffinMPSint + GlobalPlanetMuffin.PlanetMuffinMPSint + GlobalUniverseMuffin.UniverseMuffinMPSint + GlobalGalacticMuffin.GalacticMuffinMPSint + GlobalMuffinLabsv2.MuffinLabsv2Levelint); GlobalMuffins.MuffinCount = InternalPlayerMuffins; currentMuffins = InternalPlayerMuffins; if (InternalPlayerMuffins > 10000) { MuffinText.GetComponent<Text>().text = "Muffins " + (InternalPlayerMuffins / 1000).ToString("0.00") + "k"; } if (TotalMPSint >= 10000) { TotalMPS.GetComponent<Text>().text = "/Sec " + (TotalMPSint / 1000).ToString("0.00") + "k"; } if (InternalPlayerMuffins >= 1000000) { MuffinText.GetComponent<Text>().text = "Muffins " + (InternalPlayerMuffins / 1000000).ToString("0.00") + "M"; } if (TotalMPSint >= 1000000) { TotalMPS.GetComponent<Text>().text = "/Sec " + (TotalMPSint / 1000000).ToString("0.00") + "M"; } if (InternalPlayerMuffins >= 1000000000) { MuffinText.GetComponent<Text>().text = "Muffins " + (InternalPlayerMuffins / 1000000000).ToString("0.00") + "B"; } if (TotalMPSint >= 1000000000) { TotalMPS.GetComponent<Text>().text = "/Sec " + (TotalMPSint / 1000000000).ToString("0.00") + "B"; } if (InternalPlayerMuffins >= 1000000000000) { MuffinText.GetComponent<Text>().text = "Muffins " + (InternalPlayerMuffins / 1000000000000).ToString("0.00") + "T"; } if (TotalMPSint >= 1000000000000) { TotalMPS.GetComponent<Text>().text = "/Sec " + (TotalMPSint / 1000000000000).ToString("0.00") + "T"; } if (InternalPlayerMuffins >= 1000000000000000) { MuffinText.GetComponent<Text>().text = "Muffins " + (InternalPlayerMuffins / 1000000000000000).ToString("0.00") + "Qa"; } if (TotalMPSint >= 1000000000000000) { TotalMPS.GetComponent<Text>().text = "/Sec " + (TotalMPSint / 1000000000000000).ToString("0.00") + "Qa"; } if (InternalPlayerMuffins >= 1000000000000000000) { MuffinText.GetComponent<Text>().text = "Muffins " + (InternalPlayerMuffins / 1000000000000000000).ToString("0.00") + "Qi"; } if (TotalMPSint >= 1000000000000000000) { TotalMPS.GetComponent<Text>().text = "/Sec " + (TotalMPSint / 1000000000000000000).ToString("0.00") + "Qi"; } Save(); } public void muffinonClick() { muffinSound.Play(); InternalPlayerMuffins += (1 + GlobalPowerClick.PowerClickInt ); } public void OpenShop() { if(ShopPanel != null){ ShopPanel.GetComponent<Animation>().Play("PanelAnimFadeOpen"); Debug.Log("playing anim"); ShopPanel.SetActive(true);} } public void OpenDiamondShop() { if(DiamondShop != null){ DiamondShop.GetComponent<Animation>().Play("PanelAnimFadeOpen"); Debug.Log("playing anim"); DiamondShop.SetActive(true);} } public void Load() { GlobalPlayerDiamonds = double.Parse(PlayerPrefs.GetString("GlobalPlayerDiamonds","0")); InternalPlayerDiamonds = double.Parse(PlayerPrefs.GetString("InternalPlayerDiamonds","150000")); InternalPlayerMuffins = double.Parse(PlayerPrefs.GetString("InternalPlayerMuffins","0")); TotalMPSint = double.Parse(PlayerPrefs.GetString("TotalMPSint","0")); currentMuffins = double.Parse(PlayerPrefs.GetString("currentMuffins","0")); GlobalBakery.BakeryCostint = double.Parse(PlayerPrefs.GetString("GlobalBakery.BakeryCostint","25")); GlobalBakery.BakeryDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalBakery.BakeryDiamondCostint","1")); GlobalBakery.BakeryLevelint = double.Parse(PlayerPrefs.GetString("GlobalBakery.BakeryLevelint","0")); GlobalBakery.BakeryMPSint = double.Parse(PlayerPrefs.GetString("GlobalBakery.BakeryMPSint","0")); GlobalBioMuffin.BioMuffinCostint = double.Parse(PlayerPrefs.GetString("GlobalBioMuffin.BioMuffinCostint","500000000")); GlobalBioMuffin.BioMuffinDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalBioMuffin.BioMuffinDiamondCostint","10")); GlobalBioMuffin.BioMuffinLevelint = double.Parse(PlayerPrefs.GetString("GlobalBioMuffin.BioMuffinLevelint","0")); GlobalBioMuffin.BioMuffinMPSint = double.Parse(PlayerPrefs.GetString("GlobalBioMuffin.BioMuffinMPSint","0")); GlobalFactory.FactoryCostint = double.Parse(PlayerPrefs.GetString("GlobalFactory.FactoryCostint","125")); GlobalFactory.FactoryDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalFactory.FactoryDiamondCostint","2")); GlobalFactory.FactoryLevelint = double.Parse(PlayerPrefs.GetString("GlobalFactory.FactoryLevelint","0")); GlobalFactory.FactoryMPSint = double.Parse(PlayerPrefs.GetString("GlobalFactory.FactoryMPSint","0")); GlobalGalacticMuffin.GalacticMuffinCostint = double.Parse(PlayerPrefs.GetString("GlobalGalacticMuffin.GalacticMuffinCostint","2500000000000")); GlobalGalacticMuffin.GalacticMuffinDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalGalacticMuffin.GalacticMuffinDiamondCostint","14")); GlobalGalacticMuffin.GalacticMuffinLevelint = double.Parse(PlayerPrefs.GetString("GlobalGalacticMuffin.GalacticMuffinLevelint","0")); GlobalGalacticMuffin.GalacticMuffinMPSint = double.Parse(PlayerPrefs.GetString("GlobalGalacticMuffin.GalacticMuffinMPSint","0")); GlobalMuffinCity.MuffinCityCostint = double.Parse(PlayerPrefs.GetString("GlobalMuffinCity.MuffinCityCostint","12500")); GlobalMuffinCity.MuffinCityDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalMuffinCity.MuffinCityDiamondCostint","7")); GlobalMuffinCity.MuffinCityLevelint = double.Parse(PlayerPrefs.GetString("GlobalMuffinCity.MuffinCityLevelint","0")); GlobalMuffinCity.MuffinCityMPSint = double.Parse(PlayerPrefs.GetString("GlobalMuffinCity.MuffinCityMPSint","0")); GlobalMuffinFarm.MuffinFarmCostint = double.Parse(PlayerPrefs.GetString("GlobalMuffinFarm.MuffinFarmCostint","2500")); GlobalMuffinFarm.MuffinFarmDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalMuffinFarm.MuffinFarmDiamondCostint","6")); GlobalMuffinFarm.MuffinFarmLevelint = double.Parse(PlayerPrefs.GetString("GlobalMuffinFarm.MuffinFarmLevelint","0")); GlobalMuffinFarm.MuffinFarmMPSint = double.Parse(PlayerPrefs.GetString("GlobalMuffinFarm.MuffinFarmMPSint","0")); GlobalMuffinLabs.MuffinLabsCostint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLabs.MuffinLabsCostint","25000")); GlobalMuffinLabs.MuffinLabsDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLabs.MuffinLabsDiamondCostint","8")); GlobalMuffinLabs.MuffinLabsLevelint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLabs.MuffinLabsLevelint","0")); GlobalMuffinLabs.MuffinLabsMPSint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLabs.MuffinLabsMPSint","0")); GlobalMuffinLabsv2.MuffinLabsv2Costint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLabsv2.MuffinLabsv2Costint","25000000")); GlobalMuffinLabsv2.MuffinLabsv2DiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLabsv2.MuffinLabsv2DiamondCostint","9")); GlobalMuffinLabsv2.MuffinLabsv2Levelint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLabsv2.MuffinLabsv2Levelint","0")); GlobalMuffinLabsv2.MuffinLabsv2MPSint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLabsv2.MuffinLabsv2MPSint","0")); GlobalMuffinLand.MuffinLandCostint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLand.MuffinLandCostint","750")); GlobalMuffinLand.MuffinLandDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLand.MuffinLandDiamondCostint","4")); GlobalMuffinLand.MuffinLandLevelint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLand.MuffinLandLevelint","0")); GlobalMuffinLand.MuffinLandMPSint = double.Parse(PlayerPrefs.GetString("GlobalMuffinLand.MuffinLandMPSint","0")); GlobalNuclearMuffin.NuclearMuffinCostint = double.Parse(PlayerPrefs.GetString("GlobalNuclearMuffin.NuclearMuffinCostint","75000000000")); GlobalNuclearMuffin.NuclearMuffinDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalNuclearMuffin.NuclearMuffinDiamondCostint","11")); GlobalNuclearMuffin.NuclearMuffinLevelint = double.Parse(PlayerPrefs.GetString("GlobalNuclearMuffin.NuclearMuffinLevelint","0")); GlobalNuclearMuffin.NuclearMuffinMPSint = double.Parse(PlayerPrefs.GetString("GlobalNuclearMuffin.NuclearMuffinMPSint","0")); GlobalPlanetMuffin.PlanetMuffinCostint = double.Parse(PlayerPrefs.GetString("GlobalPlanetMuffin.PlanetMuffinCostint","150000000000")); GlobalPlanetMuffin.PlanetMuffinDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalPlanetMuffin.PlanetMuffinDiamondCostint","12")); GlobalPlanetMuffin.PlanetMuffinLevelint = double.Parse(PlayerPrefs.GetString("GlobalPlanetMuffin.PlanetMuffinLevelint","0")); GlobalPlanetMuffin.PlanetMuffinMPSint = double.Parse(PlayerPrefs.GetString("GlobalPlanetMuffin.PlanetMuffinMPSint","0")); GlobalPowerClick.PowerClickInt = double.Parse(PlayerPrefs.GetString("GlobalPowerClick.PowerClickInt","2")); GlobalPowerClick.PowerClickCostint = double.Parse(PlayerPrefs.GetString("GlobalPowerClick.PowerClickCostint","5000")); GlobalPowerClick.PowerClickDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalPowerClick.PowerClickDiamondCostint","5")); GlobalPowerClick.PowerClickLevelint = double.Parse(PlayerPrefs.GetString("GlobalPowerClick.PowerClickLevelint","1")); GlobalPowerClick.PowerClickMultiplierint = double.Parse(PlayerPrefs.GetString("GlobalPowerClick.PowerClickMultiplierint","2")); GlobalRoboMuffin.RoboMuffinCostint = double.Parse(PlayerPrefs.GetString("GlobalRoboMuffin.RoboMuffinCostint","250")); GlobalRoboMuffin.RoboMuffinDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalRoboMuffin.RoboMuffinDiamondCostint","3")); GlobalRoboMuffin.RoboMuffinLevelint = double.Parse(PlayerPrefs.GetString("GlobalRoboMuffin.RoboMuffinLevelint","0")); GlobalRoboMuffin.RoboMuffinMPSint = double.Parse(PlayerPrefs.GetString("GlobalRoboMuffin.RoboMuffinMPSint","0")); GlobalSmartFactory.SmartFactoryCostint = double.Parse(PlayerPrefs.GetString("GlobalSmartFactory.SmartFactoryCostint","1500")); GlobalSmartFactory.SmartFactoryDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalSmartFactory.SmartFactoryDiamondCostint","5")); GlobalSmartFactory.SmartFactoryLevelint = double.Parse(PlayerPrefs.GetString("GlobalSmartFactory.SmartFactoryLevelint","0")); GlobalSmartFactory.SmartFactoryMPSint = double.Parse(PlayerPrefs.GetString("GlobalSmartFactory.SmartFactoryMPSint","0")); GlobalUniverseMuffin.UniverseMuffinCostint = double.Parse(PlayerPrefs.GetString("GlobalUniverseMuffin.UniverseMuffinCostint","500000000000")); GlobalUniverseMuffin.UniverseMuffinDiamondCostint = double.Parse(PlayerPrefs.GetString("GlobalUniverseMuffin.UniverseMuffinDiamondCostint","13")); GlobalUniverseMuffin.UniverseMuffinLevelint = double.Parse(PlayerPrefs.GetString("GlobalUniverseMuffin.UniverseMuffinLevelint","0")); GlobalUniverseMuffin.UniverseMuffinMPSint = double.Parse(PlayerPrefs.GetString("GlobalUniverseMuffin.UniverseMuffinMPSint","0")); expScript.vLevel = PlayerPrefs.GetInt("expScript.vLevel", 1); expScript.vCurrExp = PlayerPrefs.GetInt("expScript.vCurrExp", 0); expScript.vExpBase = PlayerPrefs.GetInt("expScript.vExpBase", 10); expScript.vExpLeft = PlayerPrefs.GetInt("expScript.vExpLeft", 25); expScript.currentValue = PlayerPrefs.GetInt("expScript.currentValue", 0); }
自动MPS脚本
面包店
using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GlobalBakery : MonoBehaviour { public static bool turnOffButton = false; public AudioSource playSound; public GameObject BakeryCost; public GameObject BakeryLevel; public GameObject BakeryMPS; public GameObject BakeryButton; public GameObject FakeBakeryButton; public static double BakeryCostint = 25; public static double BakeryDiamondCostint = 1; public static double BakeryLevelint = 0; public static double BakeryMPSint; public GameObject FakeBakeryCost; public GameObject FakeBakeryLevel; public GameObject FakeBakeryMPS; public GameObject BakeryDiamondCost; public GameObject FakeBakeryDiamondCost; public GameObject MaxLevelDiamondButton; public GameObject MaxLevelBakeryCost; public GameObject MaxLevelBakeryLevel; public GameObject MaxLevelFakeBakeryMPS; public GameObject MaxLevelBakeryButtom; void Update() { BakeryCost.GetComponent<Text>().text = "Cost: " + BakeryCostint; BakeryLevel.GetComponent<Text>().text = "Level: " + BakeryLevelint; BakeryMPS.GetComponent<Text>().text = "MPS: " + BakeryMPSint; BakeryDiamondCost.GetComponent<Text>().text = BakeryDiamondCostint + " Diamond"; FakeBakeryCost.GetComponent<Text>().text = "Cost: " + BakeryCostint; FakeBakeryLevel.GetComponent<Text>().text = "Level: " + BakeryLevelint; FakeBakeryMPS.GetComponent<Text>().text = "MPS: " + BakeryMPSint; FakeBakeryDiamondCost.GetComponent<Text>().text = BakeryDiamondCostint + " Diamond"; MaxLevelBakeryLevel.GetComponent<Text>().text = "Level: " + BakeryLevelint; MaxLevelFakeBakeryMPS.GetComponent<Text>().text = "MPS: " + BakeryMPSint; if(GlobalGameMechanics.currentMuffins >= BakeryCostint) { FakeBakeryButton.SetActive(false); BakeryButton.SetActive(true); } if(turnOffButton == true) { Debug.Log("Turning off"); FakeBakeryButton.SetActive(true); BakeryButton.SetActive(false); turnOffButton = false; } if(GlobalGameMechanics.currentMuffins <= BakeryCostint) { FakeBakeryButton.SetActive(true); BakeryButton.SetActive(false); } if (BakeryCostint >= 10000) { BakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000).ToString("0.0") + "k"; FakeBakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000).ToString("0.0") + "k"; } if (BakeryCostint > 1000000) { BakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000000).ToString("0.0") + "M"; FakeBakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000000).ToString("0.0") + "M"; } if (BakeryCostint > 1000000000) { BakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000000000).ToString("0.0") + "B"; FakeBakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000000000).ToString("0.0") + "B"; } if (BakeryCostint > 1000000000000) { BakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000000000000).ToString("0.0") + "T"; FakeBakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000000000000).ToString("0.0") + "T"; } if (BakeryCostint > 1000000000000000) { BakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000000000000000).ToString("0.0") + "Qa"; FakeBakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000000000000000).ToString("0.0") + "Qa"; } if (BakeryCostint > 1000000000000000000) { BakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 1000000000000000000).ToString("0.0") + "Qi"; FakeBakeryCost.GetComponent<Text>().text = "Cost " + (BakeryCostint / 10000000000000000).ToString("0.0") + "Qi"; } if (BakeryLevelint >= 9999) { BakeryCost.GetComponent<Text>().text = "MAX LEVEL"; BakeryButton.SetActive(false); FakeBakeryButton.SetActive(false); BakeryDiamondCost.SetActive(false); FakeBakeryDiamondCost.SetActive(false); MaxLevelDiamondButton.SetActive(false); MaxLevelBakeryButtom.SetActive(true); } } public void StartAutoBakery() { if (GlobalGameMechanics.InternalPlayerMuffins >=BakeryCostint){ playSound.Play(); InvokeRepeating("muffinonClick", 0f, 1.0f); GlobalGameMechanics.InternalPlayerMuffins -= BakeryCostint; BakeryCostint += 5; turnOffButton = true; Debug.Log("Button Turned Off"); BakeryMPSint += 1; BakeryLevelint += 1; }else{ Debug.Log("Cant do anything"); } } public void PurchaseBakeryWithDiamonds() { if (GlobalGameMechanics.InternalPlayerDiamonds >=BakeryDiamondCostint){ playSound.Play(); InvokeRepeating("muffinonClick", 0f, 1.0f); GlobalGameMechanics.InternalPlayerDiamonds -= BakeryDiamondCostint; BakeryCostint += 5; turnOffButton = true; BakeryMPSint += 1; BakeryLevelint += 1; }else{ Debug.Log("You Dont Have Enough Diamonds"); } } public void muffinonClick() { GlobalGameMechanics.InternalPlayerMuffins += 1; } }
Power Click脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GlobalPowerClick : MonoBehaviour
{
public static bool turnOffButton = false;
public AudioSource playSound;
public GameObject PowerClickCost;
public GameObject PowerClickLevel;
public GameObject PowerClickMultiplier;
public GameObject PowerClickButton;
public GameObject FakePowerClickButton;
public static double PowerClickInt = 2;
public static double PowerClickCostint = 5000;
public static double PowerClickDiamondCostint = 5;
public static double PowerClickLevelint = 1;
public static double PowerClickMultiplierint = 2;
public GameObject FakePowerClickCost;
public GameObject FakePowerClickLevel;
public GameObject FakePowerClickMultiplier;
public GameObject PowerClickDiamondCost;
public GameObject FakePowerClickDiamondCost;
public GameObject MaxLevelDiamondButton;
public GameObject MaxLevelPowerClickCost;
public GameObject MaxLevelPowerClickLevel;
public GameObject MaxLevelFakePowerClickMultiplier;
public GameObject MaxLevelPowerClickButtom;
void Update()
{
PowerClickCost.GetComponent<Text>().text = "Cost: " + PowerClickCostint;
PowerClickLevel.GetComponent<Text>().text = "Level: " + PowerClickLevelint;
PowerClickMultiplier.GetComponent<Text>().text = "x" + PowerClickMultiplierint + " Multiplier";
PowerClickDiamondCost.GetComponent<Text>().text = PowerClickDiamondCostint + " Diamonds";
FakePowerClickCost.GetComponent<Text>().text = "Cost: " + PowerClickCostint;
FakePowerClickLevel.GetComponent<Text>().text = "Level: " + PowerClickLevelint;
FakePowerClickMultiplier.GetComponent<Text>().text = "x" + PowerClickMultiplierint + " Multiplier";
FakePowerClickDiamondCost.GetComponent<Text>().text = PowerClickDiamondCostint + " Diamonds";
MaxLevelPowerClickLevel.GetComponent<Text>().text = "Level: " + PowerClickLevelint;
MaxLevelFakePowerClickMultiplier.GetComponent<Text>().text = "x" + PowerClickMultiplierint + " Multiplier";
if(GlobalGameMechanics.currentMuffins >= PowerClickCostint)
{
FakePowerClickButton.SetActive(false);
PowerClickButton.SetActive(true);
}
if(turnOffButton == true)
{
Debug.Log("Turning off");
FakePowerClickButton.SetActive(true);
PowerClickButton.SetActive(false);
turnOffButton = false;
}
if(GlobalGameMechanics.currentMuffins <= PowerClickCostint)
{
FakePowerClickButton.SetActive(true);
PowerClickButton.SetActive(false);
}
if (PowerClickCostint >= 10000)
{
PowerClickCost.GetComponent<Text>().text = "Cost " + (PowerClickCostint / 1000).ToString("0.0") + "k";
FakePowerClickCost.GetComponent<Text>().text = "Cost " + (PowerClickCostint / 1000).ToString("0.0") + "k";
}
if (PowerClickMultiplierint >= 10000)
{
PowerClickMultiplier.GetComponent<Text>().text = " Multiplier " + (PowerClickMultiplierint / 1000).ToString("0.0") + "k";
FakePowerClickMultiplier.GetComponent<Text>().text = " Multiplier " + (PowerClickMultiplierint / 1000).ToString("0.0") + "k";
}
if (PowerClickCostint > 1000000)
{
PowerClickCost.GetComponent<Text>().text = "Cost " + (PowerClickCostint / 1000000).ToString("0.0") + "M";
FakePowerClickCost.GetComponent<Text>().text = "Cost " + (PowerClickCostint / 1000000).ToString("0.0") + "M";
}
if (PowerClickMultiplierint > 1000000)
{
PowerClickMultiplier.GetComponent<Text>().text = " Multiplier " + (PowerClickMultiplierint / 1000000).ToString("0.0") + "M";
FakePowerClickMultiplier.GetComponent<Text>().text = " Multiplier " + (PowerClickMultiplierint / 1000000).ToString("0.0") + "M";
MaxLevelFakePowerClickMultiplier.GetComponent<Text>().text = " Multiplier " + (PowerClickMultiplierint / 1000000).ToString("0.0") + "M";
}
if (PowerClickCostint > 1000000000)
{
PowerClickCost.GetComponent<Text>().text = "Cost " + (PowerClickCostint / 1000000000).ToString("0.0") + "B";
FakePowerClickCost.GetComponent<Text>().text = "Cost " + (PowerClickCostint / 1000000000).ToString("0.0") + "B";
MaxLevelFakePowerClickMultiplier.GetComponent<Text>().text = "Multiplier " + (PowerClickCostint / 1000000000).ToString("0.0") + "B";
}
if (PowerClickMultiplierint > 1000000000)
{
PowerClickMultiplier.GetComponent<Text>().text = " Multiplier " + (PowerClickMultiplierint / 1000000000).ToString("0.0") + "B";
FakePowerClickMultiplier.GetComponent<Text>().text = " Multiplier " + (PowerClickMultiplierint / 1000000000).ToString("0.0") + "B";
MaxLevelFakePowerClickMultiplier.GetComponent<Text>().text = " Multiplier " + (PowerClickMultiplierint / 1000000000).ToString("0.0") + "B";
}
if (PowerClickCostint > 1000000000000)
{
PowerClickCost.GetComponent<Text>().text = "Cost " + (PowerClickCostint / 1000000000000).ToString("0.0") + "T";
FakePowerClickCost.GetComponent<Text>().text = "Cost " + (PowerClickCostint / 1000000000000).ToString("0.0") + "T";
MaxLevelFakePowerClickMultiplier.GetComponent<Text>().text = "Multiplier " + (PowerClickCostint / 1000000000000).ToString("0.0") + "T";
}
if (PowerClickMultiplierint > 1000000000000)
{
PowerClickMultiplier.GetComponent<Text>().text = " Multiplier " + (PowerClickMultiplierint / 1000000000000).ToString("0.0") + "T";
FakePowerClickMultiplier.GetComponent<Text>().text = " Multiplier " + (PowerClickMultiplierint / 1000000000000).ToString("0.0") + "T";
}
if (PowerClickLevelint >= 40)
{
PowerClickCost.GetComponent<Text>().text = "MAX LEVEL";
PowerClickButton.SetActive(false);
FakePowerClickButton.SetActive(false);
PowerClickDiamondCost.SetActive(false);
FakePowerClickDiamondCost.SetActive(false);
MaxLevelDiamondButton.SetActive(false);
MaxLevelPowerClickButtom.SetActive(true);
}
}
public void StartAutoPowerClick()
{
if (GlobalGameMechanics.InternalPlayerMuffins >=PowerClickCostint){
playSound.Play();
GlobalGameMechanics.InternalPlayerMuffins -= PowerClickCostint;
PowerClickInt *=1*2;
PowerClickCostint *=1*2;
turnOffButton = true;
Debug.Log("Button Turned Off");
PowerClickLevelint += 1;
PowerClickMultiplierint *=1*2;
}else{
Debug.Log("Cant do anything");
}
}
public void PurchaseAutoPowerClickWithDiamonds()
{
if (GlobalGameMechanics.InternalPlayerDiamonds >=PowerClickDiamondCostint){
playSound.Play();
GlobalGameMechanics.InternalPlayerDiamonds -= PowerClickDiamondCostint;
PowerClickInt *=1*2;
PowerClickCostint *=1*2;
PowerClickDiamondCostint +=5;
turnOffButton = true;
Debug.Log("Button Turned Off");
PowerClickLevelint += 1;
PowerClickMultiplierint *=1*2;
}else{
Debug.Log("Cant do anything");
}
}
}
UPDATE这是显示错误的视频。 https://youtu.be/R3r-Y2jsxps我正在尝试开发一个大亨风格的游戏,但是我有一些错误。我刚刚完成了自动保存的编码,现在有2个...
答案
加载时,您没有任何设置expbar的最大值或当前值的东西。您的CurrentValuee
设置器已经执行了此操作,因此您只需在CurrentValuee
中将Load
设置为其自身即可。为此,您需要引用expScript
的实例:
以上是关于如何使我的当前EXP整数在重装后不重置为0的主要内容,如果未能解决你的问题,请参考以下文章
拯救者,下载inventor之后卸载过一次,安装不上了,需要重置电脑或重装,重装后还是正版Win吗?