//! Initializes variables when the world is loaded. private void Init() { ; if (FileBasedPrefs.GetInt(stateManager.worldName + "payloadRequired") != 0) { payloadRequired = FileBasedPrefs.GetInt(stateManager.worldName + "payloadRequired"); } if (FileBasedPrefs.GetInt(stateManager.worldName + "day") != 0) { day = FileBasedPrefs.GetInt(stateManager.worldName + "day"); } gameTime = FileBasedPrefs.GetFloat(stateManager.worldName + "gameTime"); initialized = true; }
public void LoadGame() //30 переменных { // SteamAchiments.main.LockAchiv("ACH_TRAVEL_FAR_ACCUM"); MatchThree.main.LifeDays = FileBasedPrefs.GetInt("LifeDays"); MatchThree.main.TimeHour = FileBasedPrefs.GetInt("TimeHour"); MatchThree.main.TimeMinute = FileBasedPrefs.GetInt("TimeMinute"); LastNalogDay = FileBasedPrefs.GetInt("LastNalogDay"); MatchThree.main.eat = FileBasedPrefs.GetInt("eat"); MatchThree.main.energy = FileBasedPrefs.GetInt("energy"); MatchThree.main.coffee = FileBasedPrefs.GetInt("coffee"); MatchThree.main.hygiene = FileBasedPrefs.GetInt("hygiene"); MatchThree.main.money = FileBasedPrefs.GetInt("money"); MatchThree.main.coffeevarka = FileBasedPrefs.GetBool("coffeevarka"); MatchThree.main.multvarka = FileBasedPrefs.GetBool("multvarka"); MatchThree.main.icebox = FileBasedPrefs.GetBool("icebox"); MatchThree.main.shower = FileBasedPrefs.GetBool("shower"); MatchThree.main.bed = FileBasedPrefs.GetBool("bed"); MatchThree.main.computer = FileBasedPrefs.GetBool("computer"); flowchart.SetBooleanVariable("FirstKitchen", FileBasedPrefs.GetBool("FirstKitchen")); flowchart.SetBooleanVariable("FirstShower", FileBasedPrefs.GetBool("FirstShower")); flowchart.SetBooleanVariable("FirstBed", FileBasedPrefs.GetBool("FirstBed")); flowchart.SetBooleanVariable("Firstcabinet", FileBasedPrefs.GetBool("Firstcabinet")); flowchart.SetBooleanVariable("HaveCompDialog", FileBasedPrefs.GetBool("HaveCompDialog")); // Показывался ли диалог со сломаным пк IncriseMoney = FileBasedPrefs.GetFloat("IncriseMoney"); // общее увеличение доходв от компа // Налоги Nalogi = FileBasedPrefs.GetFloat("Nalogi"); NDS = FileBasedPrefs.GetFloat("NDS"); Priceincrease = FileBasedPrefs.GetFloat("Priceincrease"); Rentincrease = FileBasedPrefs.GetFloat("Rentincrease"); //продукты numproducts = FileBasedPrefs.GetInt("numproducts"); // число продуктов в холодильнике numcoffee = FileBasedPrefs.GetInt("numcoffee"); // число кофе в холодильнике //Statistic MovesinGame = FileBasedPrefs.GetInt("MovesinGame"); // ходов стелано в последней игре GameWins = FileBasedPrefs.GetInt("GameWins"); // игр выйграно MoneyProfit = FileBasedPrefs.GetInt("MoneyProfit"); // денег заработано MoneyOutgo = FileBasedPrefs.GetInt("MoneyOutgo"); // денег потрачено ChangeBG.main.UpdateStatusDevice(); }
void FloatTests() { FileBasedPrefs.SetFloat("test", 1); if (!FileBasedPrefs.GetFloat("test").Equals(1)) { Debug.LogException(new System.Exception("SetFloatFailed")); return; } FileBasedPrefs.SetFloat("test", 2); if (!FileBasedPrefs.GetFloat("test").Equals(2)) { Debug.LogException(new System.Exception("ReplaceFloatFailed")); return; } if (!FileBasedPrefs.HasKeyForFloat("test")) { Debug.LogException(new System.Exception("HasKeyForFloatFailed")); return; } FileBasedPrefs.DeleteFloat("test"); if (!FileBasedPrefs.GetFloat("test").Equals(0)) { Debug.LogException(new System.Exception("DeleteFloatFailed")); return; } FileBasedPrefs.SetFloat("test", 333.333f); if (!FileBasedPrefs.GetFloat("test").Equals(333.333f)) { Debug.LogException(new System.Exception("ReplaceFloatFailed")); return; } Debug.Log("Float Tests Passed"); }
//! Called once per frame by unity engine. public void Update() { if (FileBasedPrefs.initialized == true) { if (FileBasedPrefs.GetBool(GetComponent <StateManager>().worldName + "Initialized") == false) { if (lander.GetComponent <InventoryManager>().initialized == true) { lander.GetComponent <InventoryManager>().AddItem("Solar Panel", 9); lander.GetComponent <InventoryManager>().AddItem("Universal Conduit", 8); lander.GetComponent <InventoryManager>().AddItem("Storage Container", 4); lander.GetComponent <InventoryManager>().AddItem("Smelter", 3); lander.GetComponent <InventoryManager>().AddItem("Universal Extractor", 2); lander.GetComponent <InventoryManager>().AddItem("Dark Matter Conduit", 1); lander.GetComponent <InventoryManager>().AddItem("Dark Matter Collector", 1); FileBasedPrefs.SetBool(GetComponent <StateManager>().worldName + "Initialized", true); } } else { if (loadedBlockPhysics == false) { if (PlayerPrefsX.GetPersistentBool("multiplayer") == false) { blockPhysics = PlayerPrefsX.GetPersistentBool("blockPhysics"); } else { blockPhysics = false; } loadedBlockPhysics = true; } if (loadedHazardsEnabled == false) { hazardsEnabled = PlayerPrefsX.GetPersistentBool("hazardsEnabled"); loadedHazardsEnabled = true; } if (loadedMeteorTimer == false) { meteorShowerTimer = FileBasedPrefs.GetFloat(GetComponent <StateManager>().worldName + "meteorShowerTimer"); loadedMeteorTimer = true; } if (loadedPirateTimer == false) { pirateAttackTimer = FileBasedPrefs.GetFloat(GetComponent <StateManager>().worldName + "pirateAttackTimer"); loadedPirateTimer = true; } } // A save game request is pending. if (dataSaveRequested == true) { if (GetComponent <StateManager>().saving == false && GetComponent <StateManager>().AddressManagerBusy() == false) { UnityEngine.Debug.Log("Saving world..."); GetComponent <StateManager>().SaveData(); dataSaveRequested = false; } else if (GetComponent <StateManager>().AddressManagerBusy() == true) { if (GetComponent <GameManager>().simulationSpeed < 0.1f) { userSimSpeed = GetComponent <GameManager>().simulationSpeed; resetSimSpeed = true; } GetComponent <GameManager>().simulationSpeed = 0.1f; } } else if (resetSimSpeed == true) { GetComponent <GameManager>().simulationSpeed = userSimSpeed; resetSimSpeed = false; } // Used to ensure components are removed before combining meshes. if (replacingMeshFilters == true) { mfDelay += 1 * Time.deltaTime; if (mfDelay > 1) { meshManager.CombineMeshes(); mfDelay = 0; replacingMeshFilters = false; } } if (GetComponent <StateManager>().worldLoaded == true) { hazardManager.UpdateHazards(); } if (memoryCoroutineBusy == false) { memoryCoroutine = StartCoroutine(ManageMemory()); } } }
//! Called by unity engine on start up to initialize variables. public void Start() { string worldName = FindObjectOfType <StateManager>().worldName; bool paintedIron = false; bool paintedGlass = false; bool paintedBrick = false; bool paintedSteel = false; if (gameObject.name.Equals("ironHolder(Clone)")) { if (FileBasedPrefs.GetBool(worldName + "ironHolder" + ID + "painted") == true) { float r = FileBasedPrefs.GetFloat(worldName + "ironHolder" + ID + "Red"); float g = FileBasedPrefs.GetFloat(worldName + "ironHolder" + ID + "Green"); float b = FileBasedPrefs.GetFloat(worldName + "ironHolder" + ID + "Blue"); GetComponent <Renderer>().material.color = new Color(r, g, b); if (paintedIron == false) { Transform[] allBuiltObjects = FindObjectOfType <GameManager>().builtObjects.GetComponentsInChildren <Transform>(true); foreach (Transform block in allBuiltObjects) { if (block.GetComponent <IronBlock>() != null) { block.GetComponent <Renderer>().material.color = new Color(r, g, b); } } } } } if (gameObject.name.Equals("steelHolder(Clone)")) { if (FileBasedPrefs.GetBool(worldName + "steelHolder" + ID + "painted") == true) { float r = FileBasedPrefs.GetFloat(worldName + "steelHolder" + ID + "Red"); float g = FileBasedPrefs.GetFloat(worldName + "steelHolder" + ID + "Green"); float b = FileBasedPrefs.GetFloat(worldName + "steelHolder" + ID + "Blue"); GetComponent <Renderer>().material.color = new Color(r, g, b); if (paintedSteel == false) { Transform[] allBuiltObjects = FindObjectOfType <GameManager>().builtObjects.GetComponentsInChildren <Transform>(true); foreach (Transform block in allBuiltObjects) { if (block.GetComponent <Steel>() != null) { block.GetComponent <Renderer>().material.color = new Color(r, g, b); } } } } } if (gameObject.name.Equals("brickHolder(Clone)")) { if (FileBasedPrefs.GetBool(worldName + "brickHolder" + ID + "painted") == true) { float r = FileBasedPrefs.GetFloat(worldName + "brickHolder" + ID + "Red"); float g = FileBasedPrefs.GetFloat(worldName + "brickHolder" + ID + "Green"); float b = FileBasedPrefs.GetFloat(worldName + "brickHolder" + ID + "Blue"); GetComponent <Renderer>().material.color = new Color(r, g, b); if (paintedBrick == false) { Transform[] allBuiltObjects = FindObjectOfType <GameManager>().builtObjects.GetComponentsInChildren <Transform>(true); foreach (Transform block in allBuiltObjects) { if (block.GetComponent <Brick>() != null) { block.GetComponent <Renderer>().material.color = new Color(r, g, b); } } } } } if (gameObject.name.Equals("glassHolder(Clone)")) { if (FileBasedPrefs.GetBool(worldName + "glassHolder" + ID + "painted") == true) { float r = FileBasedPrefs.GetFloat(worldName + "glassHolder" + ID + "Red"); float g = FileBasedPrefs.GetFloat(worldName + "glassHolder" + ID + "Green"); float b = FileBasedPrefs.GetFloat(worldName + "glassHolder" + ID + "Blue"); GetComponent <Renderer>().material.color = new Color(r, g, b); if (paintedGlass == false) { Transform[] allBuiltObjects = FindObjectOfType <GameManager>().builtObjects.GetComponentsInChildren <Transform>(true); foreach (Transform block in allBuiltObjects) { if (block.GetComponent <Glass>() != null) { block.GetComponent <Renderer>().material.color = new Color(r, g, b); } } } } } }