void OnApplicationQuit() { //When we quit the application we want to save our position and rotation PlayerPrefsX.SetVector3(this.name + "_Position", transform.localPosition); PlayerPrefsX.SetQuaternion(this.name + "_Rotation", transform.localRotation); PlayerPrefsX.SetVector3(this.name + "_Scale", transform.localScale); }
void Update() { #region Debug if (Input.GetKey(KeyCode.G) && Input.GetKeyDown(KeyCode.Z)) //Save { PlayerPrefsX.SetVector3("pos", player.transform.position); print("Save"); } if (Input.GetKey(KeyCode.G) && Input.GetKeyDown(KeyCode.X)) //Load { charCtrl.enabled = false; player.transform.position = PlayerPrefsX.GetVector3("pos"); charCtrl.enabled = true; print("Load"); } if (Input.GetKey(KeyCode.G) && Input.GetKeyDown(KeyCode.P)) //Delete { PlayerPrefs.DeleteAll(); print("Delete"); } if (Input.GetKey(KeyCode.G) && Input.GetKeyDown(KeyCode.R)) //Reset { Resetar(); print("Reset"); } #endregion }
public void SaveGame() { PlayerPrefsX.SetVector3("PlayerPosition", player.transform.position); PlayerPrefsX.SetVector3("PlayerVelocity", player.GetComponent <Rigidbody2D>().velocity); PlayerPrefsX.SetVector3("LastCheckpoint", player.GetComponent <Player>().getLastCheckpoint()); PlayerPrefs.SetInt("PlayerHealth", player.GetComponent <Player>().getHitPoints()); PlayerPrefs.SetInt("PlayerLives", player.GetComponent <Player>().getRemainingLives()); player.GetComponent <Player>().capturePowerUpInfo(); PlayerPrefs.SetString("CurrentLevel", Application.loadedLevelName); if (Application.loadedLevelName == "Level2" || Application.loadedLevelName == "Level4" || Application.loadedLevelName == "Level6") { PlayerPrefsX.SetVector3("BossPosition", boss.transform.position); PlayerPrefsX.SetVector3("BossVelocity", boss.GetComponent <Rigidbody2D>().velocity); PlayerPrefs.SetInt("BossHealth", boss.GetComponent <Agent>().getHitPoints()); if (Application.loadedLevelName == "Level2") { boss.GetComponent <Boss>().capturePhaseInformation(); } if (Application.loadedLevelName == "Level4") { boss.GetComponent <BossTwo>().capturePowerUpInformation(); } if (Application.loadedLevelName == "Level6") { boss.GetComponent <BossThree>().capturePowerUpInformation(); } } else { PlayerPrefsX.SetBool("LeftLeverPulled", LeftLever.GetComponent <Animator>().GetBool("Pulled")); PlayerPrefsX.SetBool("RightLeverPulled", RightLever.GetComponent <Animator>().GetBool("Pulled")); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { PlayerPrefsX.SetVector3("OldPlayerPosition", other.transform.position - other.transform.forward * 2); SceneManager.LoadScene(ShrineName); } }
void OnDestroy() { PlayerPrefsX.SetVector3("CubePosition" + cubeID.ToString(), transform.position); PlayerPrefsX.SetQuaternion("CubeRotation" + cubeID.ToString(), transform.rotation); PlayerPrefsX.SetVector3("CubeRigidbodyVelocity" + cubeID.ToString(), GetComponent <Rigidbody>().velocity); PlayerPrefsX.SetVector3("CubeRigidbodyAngularVelocity" + cubeID.ToString(), GetComponent <Rigidbody>().angularVelocity); }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("DeleteSave")) { PlayerPrefsX.SetVector3("TucaCompleRBFinal", transform.position); PlayerPrefs.DeleteAll(); } }
private IEnumerator Save(Vector3[] data) { for (int i = 0; i < data.Length; i++) { PlayerPrefsX.SetVector3(KEY + i.ToString(), data[i]); yield return(new WaitForEndOfFrame()); } yield break; }
public override void OnEnter() { for (int i = 0; i < keys.Length; i++) { if (!keys[i].IsNone || !keys[i].Value.Equals("")) { string key = keys[i].Value; FsmVar fsmVar = values[i]; switch (fsmVar.Type) { case VariableType.Int: PlayerPrefs.SetInt(key, fsmVar.IsNone ? 0 : (int)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Float: PlayerPrefs.SetFloat(key, fsmVar.IsNone ? 0f : (float)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Bool: PlayerPrefsX.SetBool(key, fsmVar.IsNone ? false : (bool)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Color: PlayerPrefsX.SetColor(key, fsmVar.IsNone ? Color.black : (Color)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Quaternion: PlayerPrefsX.SetQuaternion(key, fsmVar.IsNone ? Quaternion.identity : (Quaternion)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Rect: PlayerPrefsX.SetRect(key, fsmVar.IsNone ? new Rect(0f, 0f, 0f, 0f) : (Rect)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Vector2: PlayerPrefsX.SetVector2(key, fsmVar.IsNone ? Vector2.zero : (Vector2)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.Vector3: PlayerPrefsX.SetVector3(key, fsmVar.IsNone ? Vector3.zero : (Vector3)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; case VariableType.String: PlayerPrefs.SetString(key, fsmVar.IsNone ? "" : (string)PlayMakerUtils.GetValueFromFsmVar(this.Fsm, fsmVar)); break; default: LogError("PlayerPrefsx does not support saving " + fsmVar.Type); break; } } } Finish(); }
public void Save() { PlayerPrefs.SetString("Players Name", playersName); PlayerPrefs.SetInt("Players Gender", (int)gender); PlayerPrefs.SetInt("Players Funds", funds); PlayerPrefs.SetString("Last Zone", lastZone); PlayerPrefsX.SetVector3("Last Position", lastPosition); PlayerPrefsX.SetBool("Can Battle", canBattle); pokemonRoster.Save(Path.Combine(Application.persistentDataPath, "roster.xml")); pokemonInventory.Save(Path.Combine(Application.persistentDataPath, "pinventory.xml")); }
public void Save() { PlayerPrefsX.SetVector3("playerPosition", transform.position); string [] strAllowedTiles = new string[allowedTiles.Count]; for (int i = 0; i < allowedTiles.Count; i++) { strAllowedTiles[i] = allowedTiles[i].ToString(); } PlayerPrefsX.SetStringArray("playerTiles", strAllowedTiles); }
public void CheckPoint() { PlayerPrefsX.SetVector3("pos", player.transform.position); for (int i = 0; i < parede.Length; i++) { PlayerPrefsX.SetVector3("posParede", parede[i].transform.position); } print("Save"); }
public void saveLocation() { SetHorizontalPivot(AnchorModes.min); SetVerticalPivot(AnchorModes.max); PlayerPrefsX.SetVector3(name + "position", rect.position); PlayerPrefsX.SetVector3(name + "size", rect.sizeDelta); PlayerPrefsX.SetBool(name + "horiz", (anchorHorizontal == AnchorModes.max)); PlayerPrefsX.SetBool(name + "vert", (anchorVertical == AnchorModes.max)); PlayerPrefsX.SetVector3(name + "scale", rect.localScale); PlayerPrefsX.SetBool(name + "saved", true); Debug.Log(name + " saved ", gameObject); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Player")) { GameInformation.LastScene = SceneManager.GetActiveScene().name; PlayerPrefsX.SetVector3("OldPlayerPosition", collision.transform.position - collision.transform.forward * 2); GameInformation.LastPos = PlayerPrefsX.GetVector3("OldPlayerPosition"); GameInformation.LastEnemy = this.gameObject.name; SceneManager.LoadScene(EnemyType); } }
/// <summary> /// WTF? Are you kidding with me? What the hell is this? /// </summary> public static void CreateNewSaveData() { PlayerPrefsX.SetVector3(SaveVarName.PlayerPosition, Constant.PlayerPosition[0]); PlayerPrefsX.SetIntArray(SaveVarName.BackPackArray, null); PlayerPrefsX.SetIntArray(SaveVarName.ReminderArray, null); PlayerPrefsX.SetIntArray(SaveVarName.ConclusionArray, null); PlayerPrefsX.SetIntArray(SaveVarName.TruthArray, null); PlayerPrefsX.SetIntArray(SaveVarName.ClueArray, null); PlayerPrefsX.SetIntArray(SaveVarName.PermanentItemArray, null); PlayerPrefsX.SetIntArray(SaveVarName.UsableItemArray, null); PlayerPrefsX.SetIntArray(SaveVarName.ReminderItemArray, null); }
//reset button public void InstanceFlag() { //count times instaniate this one if ==1 is instantiate else more than 1 no instance CountFlag++; if (isInstancePosFlag && CountFlag == 1) { PlayerPrefsX.SetVector3("PosFlag", posSaveDiamond); Instantiate(FlagDead, PlayerPrefsX.GetVector3("PosFlag"), Quaternion.identity); } else if (CountFlag > 1) { isInstancePosFlag = false; } }
public void CheckPoint(Vector3 pos) { // Som de save FMODUnity.RuntimeManager.PlayOneShot(saveSound); // Salva posição de player PlayerPrefsX.SetVector3("pos", pos); // Salva o indice da última cena acessada PlayerPrefs.SetInt("lastSceneIndex", SceneManager.GetActiveScene().buildIndex); // Salva os pontos totais no momento do checkpoint PlayerPrefs.SetInt("pecasTotais", pontos.pontos); // Salva a vida total no momento do checkpoint PlayerPrefs.SetFloat("vida", vida.vida); #region Paredes // Pra cada objeto da lista... for (int i = 0; i < paredes.Length; i++) { PlayerPrefsX.SetVector3("posParede_" + SceneManager.GetActiveScene().buildIndex + "_" + i, paredes[i].transform.position); //Salva posição dos objetos } #endregion #region Itens for (int i = 0; i < items.Length; i++) { string key = "item_" + SceneManager.GetActiveScene().buildIndex + "_" + i; PlayerPrefsX.SetBool(key, items[i].activeSelf); // Carrega a atividade de objetos } #endregion #region Botões for (int i = 0; i < alavancas.Length; i++) { string key = "alavancaAperto_" + SceneManager.GetActiveScene().buildIndex + "_" + i; PlayerPrefsX.SetBool(key, alavancas[i].apertado); // Carrega o aperto de botões string key2 = "alavancaTrava_" + SceneManager.GetActiveScene().buildIndex + "_" + i; PlayerPrefsX.SetBool(key2, alavancas[i].travado); // Carrega a trava de botões } #endregion print("Save"); }
//! Saves the player's location and money. public void SavePlayerData() { playerInventory.SaveData(); GameObject.Find("LanderCargo").GetComponent <InventoryManager>().SaveData(); FileBasedPrefs.SetBool(stateManager.worldName + "oldWorld", true); if (PlayerPrefsX.GetPersistentBool("multiplayer") == true) { PlayerPrefsX.SetPersistentVector3(stateManager.worldName + "playerPosition", transform.position); PlayerPrefs.SetInt(stateManager.worldName + "money", money); } else { PlayerPrefsX.SetVector3(stateManager.worldName + "playerPosition", transform.position); FileBasedPrefs.SetInt(stateManager.worldName + "money", money); } }
public void Save() { if (!Directory.Exists(Application.persistentDataPath + "/Saves")) { Directory.CreateDirectory(Application.persistentDataPath + "/Saves"); } /* Player */ PlayerPrefsX.SetVector3("PlayerPosition", transform.position); //PlayerPrefsX.SetVector3("PlayerRotation", transform.eulerAngles); /* Items */ foreach (Inventory.ItemsClass item in invScript.items) { PlayerPrefs.SetInt("Item-" + item.name, item.item); } StartCoroutine(Notifications.Call("Saved.")); }
public static void SaveAll() { PlayerPrefs.SetInt("PLAYERLEVEL", GameInformation.Aila.PlayerLevel); PlayerPrefs.SetString("PLAYERNAME", GameInformation.Aila.PlayerName); PlayerPrefs.SetInt("IMAGINACAO", GameInformation.Aila.Imaginacao); PlayerPrefs.SetInt("DETERMINACAO", GameInformation.Aila.Determinacao); PlayerPrefs.SetInt("ARMADURA", GameInformation.Aila.Armadura); PlayerPrefs.SetInt("SORTE", GameInformation.Aila.Sorte); PlayerPrefs.SetInt("PVTOTAL", GameInformation.AilaPV); PlayerPrefs.SetInt("PVATUAL", GameInformation.AilaPVatual); PlayerPrefs.SetInt("PFTOTAL", GameInformation.AilaPF); PlayerPrefs.SetInt("PFATUAL", GameInformation.AilaPFatual); PlayerPrefs.SetInt("FRAGMENTOSDEMEMORIA", GameInformation.FragmentosDeMemoria); PlayerPrefs.SetString("LASTSCENE", GameInformation.LastScene); PlayerPrefsX.SetVector3("SavePlayerPos", GameInformation.LastPos); PlayerPrefsX.SetBool("COXINHABOSSDEFEATED", GameInformation.coxinhabossWon); Debug.Log("Saved All Information!"); }
public static void SaveTheGame(int saveSlot) //should be 1-4 { loadedSlot = saveSlot; //KEEP PLANTS IN THE SAME ORDER FOR INSTANTIATION IN PLAYERGRIDOBJECT? PlayerPrefsX.SetVector3("respawn" + saveSlot, new Vector3(player.transform.position.x, player.transform.position.y, player.transform.position.z)); PlayerPrefs.SetString("activeScene" + saveSlot, SceneManager.GetActiveScene().name); PlayerPrefs.SetInt("playerHealth" + saveSlot, player.health); PlayerPrefsX.SetBool("lavaBossBeaten" + saveSlot, lavaBossBeaten); PlayerPrefsX.SetBool("windBossBeaten" + saveSlot, windBossBeaten); PlayerPrefsX.SetBool("caveBossBeaten" + saveSlot, caveBossBeaten); //Debug.Log("SAVING HEALTH AS " + player.health); PlayerPrefsX.SetIntArray("playerInventory" + saveSlot, inventory); Vector3[] tempPlantPositions = new Vector3[plants.Count]; int[] tempPlantTypes = new int[plants.Count]; //need plant type String[] tempPlantScenes = new String[plants.Count]; int[] tempPlantDirections = new int[plants.Count]; //need plant object or direction int i = 0; foreach (KeyValuePair <PlantData, int> plantInfo in plants) { tempPlantPositions[i] = plantInfo.Key.PlantLocation; tempPlantScenes[i] = plantInfo.Key.PlantScene; tempPlantTypes[i] = plantInfo.Value; tempPlantDirections[i] = (int)plantInfo.Key.PlantDirection; i++; } PlayerPrefsX.SetVector3Array("PlantPositions" + saveSlot, tempPlantPositions); PlayerPrefsX.SetIntArray("PlantTypes" + saveSlot, tempPlantTypes); PlayerPrefsX.SetStringArray("PlantScenes" + saveSlot, tempPlantScenes); PlayerPrefsX.SetIntArray("PlantDirections" + saveSlot, tempPlantDirections); foreach (DialogueNPCTrigger n in npcs) { n.saveRead(); } }
public void SaveGame() { PlayerPrefs.SetString("Date" + index, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString()); var currentRT = RenderTexture.active; Camera camera = Camera.main.transform.GetChild(0).GetComponent <Camera>(); RenderTexture.active = camera.targetTexture; camera.Render(); Texture2D image = new Texture2D(camera.targetTexture.width, camera.targetTexture.height); image.ReadPixels(new Rect(0, 0, camera.targetTexture.width, camera.targetTexture.height), 0, 0); image.Apply(); RenderTexture.active = currentRT; PlayerPrefsX.WriteTextureToPlayerPrefs("Image" + index, image); PlayerPrefs.SetString("Level" + index, SceneManager.GetActiveScene().name); PlayerPrefsX.SetVector3("Position" + index, CharacterController.Player.transform.position); PlayerPrefsX.SetQuaternion("Rotation" + index, CharacterController.Player.transform.rotation); PlayerPrefs.SetFloat("Health" + index, CharacterController.Player.Health.CurrentHealth); PlayerPrefs.SetFloat("Energy" + index, CharacterController.Player.Energy.CurrentEnergy); PlayerPrefsX.SetStringArray("ITriggers" + index, PlayerPrefsX.GetStringArray("ITriggers" + PlayerPrefs.GetInt("Slot")).Concat(Loader.FindObjectsOfTypeAll <MonoBehaviour>().OfType <ITrigger>().Where(e => e.Complete).Select(f => f.GameObject.name).ToArray()).ToArray()); }
public void save() { enemylist = GameObject.Find("Enemies"); if (!PlayerPrefs.HasKey("PlayerPos")) { foreach (Transform t in enemylist.transform) { Debug.Log(t.name); PlayerPrefs.SetString(t.name, t.name); } } player = GameObject.Find("QuinSpriteFinal_1"); PlayerPrefsX.SetVector3("PlayerPos", new Vector3(player.GetComponent <Pibble>().spawnpoint.x, player.GetComponent <Pibble>().spawnpoint.y, player.GetComponent <Pibble>().spawnpoint.z)); if (player.GetComponent <Pibble>().introRunning) { PlayerPrefsX.SetBool("IntroPlayed", true); } else { PlayerPrefsX.SetBool("IntroPlayed", false); } PlayerPrefsX.SetBool("HintDC", player.GetComponent <Pibble>().firstPatrol); PlayerPrefsX.SetBool("HintDCJ", player.GetComponent <Pibble>().firstDCJ); PlayerPrefsX.SetBool("HintNC", player.GetComponent <Pibble>().firstNinCat); PlayerPrefsX.SetBool("HintDoom", player.GetComponent <Pibble>().firstDoomba); PlayerPrefsX.SetBool("HintRov", player.GetComponent <Pibble>().firstRover); PlayerPrefsX.SetBool("HintKid", player.GetComponent <Pibble>().firstKid); PlayerPrefsX.SetBool("HintBirb", player.GetComponent <Pibble>().firstBirb); PlayerPrefsX.SetBool("HintUFO", player.GetComponent <Pibble>().firstUFO); PlayerPrefsX.SetBool("HintLas", player.GetComponent <Pibble>().firstLaser); PlayerPrefsX.SetBool("HintAst", player.GetComponent <Pibble>().firstAsteroid); PlayerPrefsX.SetBool("HintWorm", player.GetComponent <Pibble>().firstWormhole); PlayerPrefsX.SetBool("cityBG", bgcontroller.GetComponent <BGController>().cityActive); PlayerPrefsX.SetBool("carnivalBG", bgcontroller.GetComponent <BGController>().carnivalActive); PlayerPrefsX.SetBool("nosoBG", bgcontroller.GetComponent <BGController>().nosoActive); PlayerPrefsX.SetBool("moonBG", bgcontroller.GetComponent <BGController>().moonActive); }
// Update is called once per frame void Update() { //Detecting if LevelObject sprite contains touch position and if so, load it if unlocked; if (Input.GetMouseButton(0)) { touchPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); touchTime += Time.deltaTime; } if (Input.GetMouseButtonUp(0)) { for (int i = 0; i < levelList.Count; i++) { if (levelList[i].unlocked && levelList[i].LevelObject.bounds.Contains(touchPos) && touchTime < reactTime) { Application.LoadLevel(levelList[i].LevelIndex); PlayerPrefsX.SetVector3("currentCamPos", cam.transform.position); } } touchTime = 0; } }
// map public void LoadMapLevel() { //set the first check instance flag PlayerPrefs.SetInt("First", 10); DestroyFlagOutMap(); PlayerPrefs.SetInt("CheckFlag", 1); ScrollSnapRect._instance.Setpage(); //UIManager._instance.CountFlag++; //banner destroy //Demo._instance.hideBanner(); // UIManager._instance.CountBigBannerShow = 0; //// if (Saving) { PlayerPrefsX.SetVector3("PosFlag", UIManager._instance.posSaveDiamond); // Debug.Log(UIManager._instance.CountFlag); Saving = false; } MenuScripts._instance.levelTextToPlay.text = "Play level: " + PlayerPrefs.GetInt("ValueMaxLevel"); //SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name); ScrollSnapRect._instance.CheckScroll = true; GetLevel(); diamondText.text = "" + PlayerPrefs.GetInt("DiamondTotal"); ChangeColorCamera._instance.SwitchColor(9); ChangeColorCamera._instance.zoomIn = true; UIManager._instance.GameOverShownPanel.SetActive(false); GameManager._instance.DesTroyer = true; GameManager._instance.DestroyerLevel(); Canvas1.SetActive(false); Canvas2.SetActive(true); DisableEverything(); }
// Ontrigger private void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.name == "Dead") { // check if many check is random if (PlayerPrefs.GetInt("Check") > 1) { CharacterManager._instance.CheckRandom = true; CharacterManager._instance.RandomChar(); } // CharacterManager._instance.RandomChar(); ChangeColorCamera._instance.SnailColor = false; // reset score is 0 ScoreManager._instance._score = 0; // save pos when dead to instance xDead posSaveLevel = transform.position; // _anim.SetTrigger("Dead"); _rb.isKinematic = true; //speedUp = 0f; CountItemsEated = 0; //disable everything from cameara RotationCamera._instance.isZoomin = false; RotationCamera._instance.isZoomOut = false; RotationCamera._instance.rayShoot = false; RotationCamera._instance.rayShootNguoc = false; RotationCamera._instance.state = 0; GameManager._instance.isDead = true; ChangeColorCamera._instance.zoomIn = false; //gan ten tu game manager equar this name level; // position instance Xdead IsUp = false; IsLeft = false; IsRight = false; // gameObject.SetActive(false); UIManager._instance.GameOverShow(); // CharacterManager._instance.RandomChar(); soundManager.playPlayerSound(DeadSound[Random.Range(0, DeadSound.Length)], 1f); // Dead(); // check flag avata // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (UIManager._instance.posSaveDiamond == null) { // ReSharper disable once HeuristicUnreachableCode UIManager._instance.isCheckGetPositionFlag = true; } // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (UIManager._instance.posSaveDiamond != null) { UIManager._instance.isCheckGetPositionFlag = false; UIManager._instance.isInstancePosFlag = true; } // // Get the first in stance flag and then never instantiale any more // set firs 0 and load map set is 10 and over if (!PlayerPrefs.HasKey("First")) { PlayerPrefs.SetInt("First", 0); } if (PlayerPrefs.GetInt("First") == 0) { PlayerPrefsX.SetVector3("PosFlag", UIManager._instance.posSaveDiamond); } Destroy(gameObject); } else if (col.gameObject.name == "Diamond") { // check flag avata if (UIManager._instance.isCheckGetPositionFlag) { UIManager._instance.posSaveDiamond = col.bounds.center; } // getPosDiamond = false; // getPosDiamond = false; // CountItemsEated++; soundManager.DiamondSound(); ScoreManager._instance.AddScore(10); // ScoreManager._instance.AddDiamond(); col.gameObject.SetActive(false); //if (CountItemsEated > PlayerPrefs.GetInt("ItemsCountLevel" + ValuePlayLevel)) //{ ScoreManager._instance.diamondText.text = CountItemsEated + "/" + CountItems; } else { if (col.gameObject.tag == "LevelUp") { // Debug.Log(PlayerPrefs.GetInt("ValuePlayLevel")); if (RotationCamera._instance._animCam.GetCurrentAnimatorStateInfo(0).IsName("Rotation")) { RotationCamera._instance._animCam.SetBool("Right", false); } if (RotationCamera._instance._animCam.GetCurrentAnimatorStateInfo(0).IsName("Left")) { RotationCamera._instance._animCam.SetBool("Left", false); } // if (PlayerPrefs.GetInt("ValueMaxLevel") < ValuePlayLevel + 1) { // source.PlayOneShot(levelFinish, 1f); PlayerPrefs.SetInt("ValueMaxLevel", ValuePlayLevel + 1); PlayerPrefs.Save(); } //Update Text Facebook img // GameManager._instance.UpdateText(); // ScoreManager._instance.diamondText.text = PlayerPrefs.GetInt("ItemsCountLevel" + ValuePlayLevel) + "/" + CountItems; // //checkRay = true; GameManager._instance.levelToLoadAgain = col.transform.parent.parent.name; //check if level max less than value level+1 and save valueplay...... RotationCamera._instance.mainCamera.transform.rotation = Quaternion.Euler(0f, 0f, 0f); //Kiểm tra số item ăn được có bằng item đếm được trong màn CountItems = GameObject.Find(col.transform.parent.parent.name).transform.Find("Diamond").childCount; CharacterManager._instance.unlock = true; CharacterManager._instance.LockCharacter(); // Debug.Log(CountItems); } if (col.gameObject.tag == "Hard") { col.gameObject.SetActive(false); if (UIManager._instance.isCheckGetPositionFlag) { UIManager._instance.posSaveDiamond = col.bounds.center; } } else if (col.gameObject.name == "VeDich") { LevelManager._instance.Level[PlayerPrefs.GetInt("ValueMaxLevel") - 1].transform.Find("Avata") .gameObject.SetActive(false); //defauc camera state UIManager._instance.UpdateText(PlayerPrefs.GetInt("ValuePlayLevel") + 2); ChangeColorCamera._instance.SwitchColor(7); //speed violet ChangeColorCamera._instance.mauTimSpeed = false; // speedUp = 2.6f; // _anim.speed = 1; // ChangeColorCamera._instance.zoomIn = true; RotationCamera._instance.isZoomOut = true; ChangeColorCamera._instance.SnailColor = false; RotationCamera._instance._animCam.speed = 1; Anim.SetBool("Change", false); Anim.speed = 1; //speedUp = 2.6f; // Debug.Log(gameObject.name); CheckPlayerSound = true; isMoveCenter = true; FollowCamera._instance.Setup(); //get level text // int a = PlayerPrefs.GetInt("ValuePlayLevel" + 1); // UIManager._instance.UpdateText(a); // CharacterManager._instance.unlock = true; // check false default RotationCamera._instance.rayShoot = false; RotationCamera._instance.rayShootNguoc = false; if (RotationCamera._instance.isZoomin) { RotationCamera._instance.isZoomin = false; RotationCamera._instance.isZoomOut = true; } RotationCamera._instance.state = 0; // RotationCamera._instance.vedich = true; // tang level moi khi cham dich ValuePlayLevel++; //gan so level //reset camera if (RotationCamera._instance._animCam.GetCurrentAnimatorStateInfo(0).IsName("Rotation")) { RotationCamera._instance._animCam.SetBool("Right", false); } if (RotationCamera._instance._animCam.GetCurrentAnimatorStateInfo(0).IsName("Left")) { RotationCamera._instance._animCam.SetBool("Left", false); } PlayerPrefs.SetInt("ValuePlayLevel", ValuePlayLevel); PlayerPrefs.Save(); // Kiểm tra số item ăn được có bằng item đếm được trong màn if (!PlayerPrefs.HasKey("ItemsLevel" + ValuePlayLevel)) { PlayerPrefs.SetString("ItemsLevel" + ValuePlayLevel, "False"); } if (PlayerPrefs.GetString("ItemsLevel" + ValuePlayLevel) == "False") { if ((CountItemsEated == CountItems) || (PlayerPrefs.GetInt("Diamond") > CountItems)) { PlayerPrefs.SetString("ItemsLevel" + ValuePlayLevel, "True"); } else { PlayerPrefs.SetString("ItemsLevel" + ValuePlayLevel, "False"); } PlayerPrefs.Save(); } if (!PlayerPrefs.HasKey("ItemsCountLevel" + ValuePlayLevel)) // max diamond value each level { PlayerPrefs.SetInt("ItemsCountLevel" + ValuePlayLevel, CountItemsEated); PlayerPrefs.SetInt("DiamondTotal", PlayerPrefs.GetInt("DiamondTotal") + CountItemsEated); // total diamond } // check cup va sound if (ValuePlayLevel < PlayerPrefs.GetInt("ValueMaxLevel")) { soundManager.LevelUp(1f); //soundManager.LevelUp(1f); LevelManager._instance.cupGot.SetActive(false); } else if (PlayerPrefs.GetInt("ValueMaxLevel") >= ValuePlayLevel) { LevelManager._instance.cupGot.SetActive(true); _audioSource.clip = FinishWin; _audioSource.Play(); } if (PlayerPrefs.GetInt("ItemsCountLevel" + ValuePlayLevel) < CountItemsEated) { PlayerPrefs.SetInt("ItemsCountLevel" + ValuePlayLevel, PlayerPrefs.GetInt("ItemsCountLevel" + ValuePlayLevel) + (CountItemsEated - PlayerPrefs.GetInt("ItemsCountLevel" + ValuePlayLevel))); PlayerPrefs.SetInt("DiamondTotal", PlayerPrefs.GetInt("DiamondTotal") + (CountItemsEated - PlayerPrefs.GetInt("ItemsCountLevel" + ValuePlayLevel))); //Tổng số kc kiếm được } CountItemsEated = 0; _boxMoveMid = col; } else if (col.gameObject.tag == "Stop") { SpeedUp = 2.6f; Destroy(gameObject); LevelManager._instance.LevelComplete.SetActive(true); } else if (col.gameObject.tag == "Green") { if (CheckColor) { //RotationCamera._instance.state = 3; //ChangeColorCamera._instance.SwitchColor(0); StartCoroutine(ChangeColor(3, 0)); } else { RotationCamera._instance.state = 3; SpeedUp = 2.6f; ChangeColorCamera._instance.SwitchColor(8); } } else if (col.gameObject.tag == "Orange") { if (CheckColor) { //RotationCamera._instance.state = 2; //ChangeColorCamera._instance.SwitchColor(1); StartCoroutine(ChangeColor(2, 1)); } else { RotationCamera._instance.state = 2; SpeedUp = 2.6f; ChangeColorCamera._instance.SwitchColor(8); } } else if (col.gameObject.tag == "Pink") { if (CheckColor) { //RotationCamera._instance.state = 1; //ChangeColorCamera._instance.SwitchColor(7); StartCoroutine(ChangeColor(1, 7)); } else { RotationCamera._instance.state = 1; SpeedUp = 2.6f; ChangeColorCamera._instance.SwitchColor(8); } } else if (col.gameObject.tag == "Violet") { if (CheckColor) { //RotationCamera._instance.state = 1; ////RotationCamera._instance.rayShoot = true; //ChangeColorCamera._instance.SwitchColor(4); StartCoroutine(ChangeColor(1, 4)); } else { RotationCamera._instance.state = 1; SpeedUp = 2.6f; ChangeColorCamera._instance.SwitchColor(8); } } else if (col.gameObject.tag == "BlueBlur") { if (CheckColor) { // isActiveCameraRotation = true; // camerahehe = 1; // Debug.Log(camerahehe); //RotationCamera._instance.state = 1; //ChangeColorCamera._instance.SwitchColor(5); StartCoroutine(ChangeColor(2, 5)); } else { RotationCamera._instance.state = 1; SpeedUp = 2.6f; ChangeColorCamera._instance.SwitchColor(8); } } else if (col.gameObject.tag == "CamSam") { if (CheckColor) { //RotationCamera._instance.state = 1; //ChangeColorCamera._instance.SwitchColor(2); StartCoroutine(ChangeColor(1, 2)); } else { RotationCamera._instance.state = 1; SpeedUp = 2.6f; ChangeColorCamera._instance.SwitchColor(8); } } else if (col.gameObject.tag == "Blue") { ChangeColorCamera._instance.SwitchColor(6); if (CheckColor && (ValuePlayLevel > 2)) { StartCoroutine(ChangeColor(2, 6)); } else if (ValuePlayLevel > 2) { RotationCamera._instance.state = 2; SpeedUp = 2.6f; ChangeColorCamera._instance.SwitchColor(8); } } else if (col.gameObject.tag == "PinkBlur") { if (CheckColor) { StartCoroutine(ChangeColor(1, 3)); } else { RotationCamera._instance.state = 2; SpeedUp = 2.6f; ChangeColorCamera._instance.SwitchColor(8); } } else if (col.gameObject.tag == "Right") { if (UIManager._instance.isCheckGetPositionFlag) { // isJump = false; UIManager._instance.posSaveDiamond = col.bounds.center; } } else if (col.gameObject.tag == "Left") { if (UIManager._instance.isCheckGetPositionFlag) { // isJump = false; UIManager._instance.posSaveDiamond = col.bounds.center; } } else if (col.gameObject.tag == "Up") { if (UIManager._instance.isCheckGetPositionFlag) { // isJump = false; UIManager._instance.posSaveDiamond = col.bounds.center; } } else if (col.gameObject.tag == "Jump") { if (UIManager._instance.isCheckGetPositionFlag) { UIManager._instance.posSaveDiamond = col.bounds.center; } } } }
private void OnApplicationQuit() { //save date PlayerPrefsX.SetVector3("position", transform.position); Vector3[] anArray = target.ToArray(); PlayerPrefsX.SetVector3Array("VectorsArray", anArray); }
//! Saves the world. public IEnumerator SaveDataCoroutine() { stateManager.dataSaved = false; stateManager.saving = true; currentObject = 0; int saveInterval = 0; int objectID = 0; string worldID = ""; string objectName = ""; List <int> machineIdList = new List <int>(); List <int> blockIdList = new List <int>(); GameObject[] machines = GameObject.FindGameObjectsWithTag("Machine"); Transform[] blocks = stateManager.builtObjects.GetComponentsInChildren <Transform>(true); MeshPainter[] meshPainters = Object.FindObjectsOfType <MeshPainter>(); if (totalObjects == 0) { totalObjects = machines.Length + blocks.Length + meshPainters.Length; } foreach (GameObject go in machines) { if (go != null) { if (go.transform.parent != stateManager.builtObjects.transform) { Vector3 objectPosition = go.transform.position; Quaternion objectRotation = go.transform.rotation; if (go.GetComponent <Auger>() != null) { objectName = stateManager.worldName + "Auger"; worldID = go.GetComponent <Auger>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); int speed = go.GetComponent <Auger>().speed; float amount = go.GetComponent <Auger>().amount; FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <ElectricLight>() != null) { objectName = stateManager.worldName + "ElectricLight"; worldID = go.GetComponent <ElectricLight>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <DarkMatterCollector>() != null) { objectName = stateManager.worldName + "DarkMatterCollector"; worldID = go.GetComponent <DarkMatterCollector>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); int speed = go.GetComponent <DarkMatterCollector>().speed; float darkMatterAmount = go.GetComponent <DarkMatterCollector>().darkMatterAmount; FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "darkMatterAmount", darkMatterAmount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <DarkMatterConduit>() != null) { objectName = stateManager.worldName + "DarkMatterConduit"; worldID = go.GetComponent <DarkMatterConduit>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <DarkMatterConduit>().inputID; string outputID = go.GetComponent <DarkMatterConduit>().outputID; int speed = go.GetComponent <DarkMatterConduit>().speed; float darkMatterAmount = go.GetComponent <DarkMatterConduit>().darkMatterAmount; int range = go.GetComponent <DarkMatterConduit>().range; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetInt(worldID + "range", range); FileBasedPrefs.SetFloat(worldID + "darkMatterAmount", darkMatterAmount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <RailCart>() != null) { objectName = stateManager.worldName + "RailCart"; worldID = go.GetComponent <RailCart>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string targetID = go.GetComponent <RailCart>().targetID; Vector3 startPosition = go.GetComponent <RailCart>().startPosition; if (go.GetComponent <InventoryManager>() != null) { go.GetComponent <InventoryManager>().SaveData(); } FileBasedPrefs.SetString(worldID + "targetID", targetID); PlayerPrefsX.SetVector3(worldID + "startPosition", startPosition); } } if (go.GetComponent <RailCartHub>() != null) { objectName = stateManager.worldName + "RailCartHub"; worldID = go.GetComponent <RailCartHub>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <RailCartHub>().inputID; string outputID = go.GetComponent <RailCartHub>().outputID; int range = go.GetComponent <RailCartHub>().range; bool centralHub = go.GetComponent <RailCartHub>().centralHub; bool stop = go.GetComponent <RailCartHub>().stop; int circuit = go.GetComponent <RailCartHub>().circuit; float stopTime = go.GetComponent <RailCartHub>().stopTime; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetInt(worldID + "range", range); FileBasedPrefs.SetInt(worldID + "circuit", circuit); FileBasedPrefs.SetBool(worldID + "centralHub", centralHub); FileBasedPrefs.SetBool(worldID + "stop", stop); FileBasedPrefs.SetFloat(worldID + "stopTime", stopTime); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <UniversalConduit>() != null) { objectName = stateManager.worldName + "UniversalConduit"; worldID = go.GetComponent <UniversalConduit>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <UniversalConduit>().inputID; string outputID = go.GetComponent <UniversalConduit>().outputID; string type = go.GetComponent <UniversalConduit>().type; int speed = go.GetComponent <UniversalConduit>().speed; int range = go.GetComponent <UniversalConduit>().range; float amount = go.GetComponent <UniversalConduit>().amount; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetString(worldID + "type", type); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetInt(worldID + "range", range); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <HeatExchanger>() != null) { objectName = stateManager.worldName + "HeatExchanger"; worldID = go.GetComponent <HeatExchanger>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <HeatExchanger>().inputID; string outputID = go.GetComponent <HeatExchanger>().outputID; string inputType = go.GetComponent <HeatExchanger>().inputType; int speed = go.GetComponent <HeatExchanger>().speed; float amount = go.GetComponent <HeatExchanger>().amount; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetString(worldID + "inputType", inputType); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <Retriever>() != null) { objectName = stateManager.worldName + "Retriever"; worldID = go.GetComponent <Retriever>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <Retriever>().inputID; string outputID = go.GetComponent <Retriever>().outputID; int speed = go.GetComponent <Retriever>().speed; float amount = go.GetComponent <Retriever>().amount; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); if (go.GetComponent <InventoryManager>() != null) { go.GetComponent <InventoryManager>().SaveData(); } } } if (go.GetComponent <AutoCrafter>() != null) { objectName = stateManager.worldName + "AutoCrafter"; worldID = go.GetComponent <AutoCrafter>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <AutoCrafter>().inputID; int speed = go.GetComponent <AutoCrafter>().speed; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); if (go.GetComponent <InventoryManager>() != null) { go.GetComponent <InventoryManager>().SaveData(); } } } if (go.GetComponent <Smelter>() != null) { objectName = stateManager.worldName + "Smelter"; worldID = go.GetComponent <Smelter>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <Smelter>().inputID; string outputID = go.GetComponent <Smelter>().outputID; string inputType = go.GetComponent <Smelter>().inputType; string outputType = go.GetComponent <Smelter>().outputType; int speed = go.GetComponent <Smelter>().speed; float amount = go.GetComponent <Smelter>().amount; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetString(worldID + "inputType", inputType); FileBasedPrefs.SetString(worldID + "outputType", outputType); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <Turret>() != null) { objectName = stateManager.worldName + "Turret"; worldID = go.GetComponent <Turret>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); int speed = go.GetComponent <Turret>().speed; FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <MissileTurret>() != null) { objectName = stateManager.worldName + "MissileTurret"; worldID = go.GetComponent <MissileTurret>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); int speed = go.GetComponent <MissileTurret>().speed; string ammoType = go.GetComponent <MissileTurret>().ammoType; int ammoAmount = go.GetComponent <MissileTurret>().ammoAmount; FileBasedPrefs.SetString(worldID + "ammoType", ammoType); FileBasedPrefs.SetInt(worldID + "ammoAmount", ammoAmount); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <PowerSource>() != null) { if (go.GetComponent <PowerSource>().type == "Solar Panel") { objectName = stateManager.worldName + "SolarPanel"; } else if (go.GetComponent <PowerSource>().type == "Generator") { objectName = stateManager.worldName + "Generator"; } else if (go.GetComponent <PowerSource>().type == "Reactor Turbine") { objectName = stateManager.worldName + "ReactorTurbine"; } worldID = go.GetComponent <PowerSource>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string outputID = go.GetComponent <PowerSource>().outputID; string fuelType = go.GetComponent <PowerSource>().fuelType; int fuelAmount = go.GetComponent <PowerSource>().fuelAmount; FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetString(worldID + "fuelType", fuelType); FileBasedPrefs.SetInt(worldID + "fuelAmount", fuelAmount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <NuclearReactor>() != null) { objectName = stateManager.worldName + "NuclearReactor"; worldID = go.GetComponent <NuclearReactor>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <PowerConduit>() != null) { objectName = stateManager.worldName + "PowerConduit"; worldID = go.GetComponent <PowerConduit>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <PowerConduit>().inputID; string outputID1 = go.GetComponent <PowerConduit>().outputID1; string outputID2 = go.GetComponent <PowerConduit>().outputID2; bool dualOutput = go.GetComponent <PowerConduit>().dualOutput; int range = go.GetComponent <PowerConduit>().range; int powerAmount = go.GetComponent <PowerConduit>().powerAmount; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "outputID1", outputID1); FileBasedPrefs.SetString(worldID + "outputID2", outputID2); FileBasedPrefs.SetBool(worldID + "dualOutput", dualOutput); FileBasedPrefs.SetInt(worldID + "range", range); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <AlloySmelter>() != null) { objectName = stateManager.worldName + "AlloySmelter"; worldID = go.GetComponent <AlloySmelter>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID1 = go.GetComponent <AlloySmelter>().inputID1; string inputID2 = go.GetComponent <AlloySmelter>().inputID2; string inputType1 = go.GetComponent <AlloySmelter>().inputType1; string inputType2 = go.GetComponent <AlloySmelter>().inputType2; string outputType = go.GetComponent <AlloySmelter>().outputType; string outputID = go.GetComponent <AlloySmelter>().outputID; int speed = go.GetComponent <AlloySmelter>().speed; float amount = go.GetComponent <AlloySmelter>().amount; float amount2 = go.GetComponent <AlloySmelter>().amount2; float outputAmount = go.GetComponent <AlloySmelter>().outputAmount; FileBasedPrefs.SetString(worldID + "inputID1", inputID1); FileBasedPrefs.SetString(worldID + "inputID2", inputID2); FileBasedPrefs.SetString(worldID + "inputType1", inputType1); FileBasedPrefs.SetString(worldID + "inputType2", inputType2); FileBasedPrefs.SetString(worldID + "outputType", outputType); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetFloat(worldID + "amount2", amount2); FileBasedPrefs.SetFloat(worldID + "amount", outputAmount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <Press>() != null) { objectName = stateManager.worldName + "Press"; worldID = go.GetComponent <Press>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <Press>().inputID; string inputType = go.GetComponent <Press>().inputType; string outputType = go.GetComponent <Press>().outputType; string outputID = go.GetComponent <Press>().outputID; int speed = go.GetComponent <Press>().speed; float amount = go.GetComponent <Press>().amount; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "inputType", inputType); FileBasedPrefs.SetString(worldID + "outputType", outputType); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <Extruder>() != null) { objectName = stateManager.worldName + "Extruder"; worldID = go.GetComponent <Extruder>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <Extruder>().inputID; string inputType = go.GetComponent <Extruder>().inputType; string outputType = go.GetComponent <Extruder>().outputType; string outputID = go.GetComponent <Extruder>().outputID; int speed = go.GetComponent <Extruder>().speed; float amount = go.GetComponent <Extruder>().amount; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "inputType", inputType); FileBasedPrefs.SetString(worldID + "outputType", outputType); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <GearCutter>() != null) { objectName = stateManager.worldName + "GearCutter"; worldID = go.GetComponent <GearCutter>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); string inputID = go.GetComponent <GearCutter>().inputID; string inputType = go.GetComponent <GearCutter>().inputType; string outputType = go.GetComponent <GearCutter>().outputType; string outputID = go.GetComponent <GearCutter>().outputID; int speed = go.GetComponent <GearCutter>().speed; float amount = go.GetComponent <GearCutter>().amount; FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "inputType", inputType); FileBasedPrefs.SetString(worldID + "outputType", outputType); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <UniversalExtractor>() != null) { objectName = stateManager.worldName + "UniversalExtractor"; worldID = go.GetComponent <UniversalExtractor>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); int speed = go.GetComponent <UniversalExtractor>().speed; float amount = go.GetComponent <UniversalExtractor>().amount; string type = go.GetComponent <UniversalExtractor>().type; FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetString(worldID + "type", type); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (stateManager.IsStorageContainer(go)) { objectName = stateManager.worldName + "StorageContainer"; worldID = go.GetComponent <InventoryManager>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); go.GetComponent <InventoryManager>().SaveData(); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <StorageComputer>() != null) { objectName = stateManager.worldName + "StorageComputer"; worldID = go.GetComponent <StorageComputer>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <Door>() != null) { if (go.GetComponent <Door>().type == "Door") { objectName = stateManager.worldName + "Door"; } else if (go.GetComponent <Door>().type == "Quantum Hatchway") { Debug.Log("Saving hatch"); objectName = stateManager.worldName + "QuantumHatchway"; } worldID = go.GetComponent <Door>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); int audioClip = go.GetComponent <Door>().audioClip; int texture = go.GetComponent <Door>().textureIndex; string material = go.GetComponent <Door>().material; bool edited = go.GetComponent <Door>().edited; FileBasedPrefs.SetInt(worldID + "audioClip", audioClip); FileBasedPrefs.SetInt(worldID + "texture", texture); FileBasedPrefs.SetString(worldID + "material", material); FileBasedPrefs.SetBool(worldID + "edited", edited); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <ModMachine>() != null) { objectName = stateManager.worldName + "ModMachine"; worldID = go.GetComponent <ModMachine>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); int speed = go.GetComponent <ModMachine>().speed; float amount = go.GetComponent <ModMachine>().amount; string machineName = go.GetComponent <ModMachine>().machineName; string inputID = go.GetComponent <ModMachine>().inputID; string outputID = go.GetComponent <ModMachine>().outputID; string inputType = go.GetComponent <ModMachine>().inputType; string outputType = go.GetComponent <ModMachine>().outputType; FileBasedPrefs.SetString(worldID + "machineName", machineName); FileBasedPrefs.SetString(worldID + "inputID", inputID); FileBasedPrefs.SetString(worldID + "outputID", outputID); FileBasedPrefs.SetString(worldID + "inputType", inputType); FileBasedPrefs.SetString(worldID + "outputType", outputType); FileBasedPrefs.SetInt(worldID + "speed", speed); FileBasedPrefs.SetFloat(worldID + "amount", amount); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); } } if (go.GetComponent <ProtectionBlock>() != null) { worldID = go.GetComponent <ProtectionBlock>().ID; List <string> userNames = go.GetComponent <ProtectionBlock>().GetUserNames(); if (worldID != "unassigned" && worldID != "" && userNames != null) { PlayerPrefsX.SetStringArray(worldID + "userNames", userNames.ToArray()); FileBasedPrefs.SetBool(worldID + "falling", go.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", go.GetComponent <PhysicsHandler>().fallingStack); objectName = stateManager.worldName + "ProtectionBlock"; objectID = int.Parse(worldID.Substring(objectName.Length)); machineIdList.Add(objectID); } } FileBasedPrefs.SetString(stateManager.worldName + "machine" + objectID + "Name", objectName); PlayerPrefsX.SetVector3(stateManager.worldName + "machine" + objectID + "Position", objectPosition); PlayerPrefsX.SetQuaternion(stateManager.worldName + "machine" + objectID + "Rotation", objectRotation); currentObject++; saveInterval++; if (saveInterval >= totalObjects * 0.05f) { yield return(null); saveInterval = 0; } } } } foreach (Transform T in blocks) { if (T != null) { Vector3 objectPosition = T.position; Quaternion objectRotation = T.rotation; if (T.gameObject.GetComponent <IronBlock>() != null) { if (T.gameObject.name.Equals("IronRamp(Clone)")) { objectName = stateManager.worldName + "IronRamp"; } else { objectName = stateManager.worldName + "IronBlock"; } worldID = T.gameObject.GetComponent <IronBlock>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); blockIdList.Add(objectID); FileBasedPrefs.SetString(stateManager.worldName + "block" + objectID + "Name", objectName); PlayerPrefsX.SetVector3(stateManager.worldName + "block" + objectID + "Position", objectPosition); PlayerPrefsX.SetQuaternion(stateManager.worldName + "block" + objectID + "Rotation", objectRotation); FileBasedPrefs.SetBool(worldID + "falling", T.gameObject.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent <PhysicsHandler>().fallingStack); } } if (T.gameObject.GetComponent <Steel>() != null) { if (T.gameObject.name.Equals("SteelRamp(Clone)")) { objectName = stateManager.worldName + "SteelRamp"; } else { objectName = stateManager.worldName + "Steel"; } worldID = T.gameObject.GetComponent <Steel>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); blockIdList.Add(objectID); FileBasedPrefs.SetString(stateManager.worldName + "block" + objectID + "Name", objectName); PlayerPrefsX.SetVector3(stateManager.worldName + "block" + objectID + "Position", objectPosition); PlayerPrefsX.SetQuaternion(stateManager.worldName + "block" + objectID + "Rotation", objectRotation); FileBasedPrefs.SetBool(worldID + "falling", T.gameObject.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent <PhysicsHandler>().fallingStack); } } if (T.gameObject.GetComponent <Brick>() != null) { objectName = stateManager.worldName + "Brick"; worldID = T.gameObject.GetComponent <Brick>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); blockIdList.Add(objectID); FileBasedPrefs.SetString(stateManager.worldName + "block" + objectID + "Name", objectName); PlayerPrefsX.SetVector3(stateManager.worldName + "block" + objectID + "Position", objectPosition); PlayerPrefsX.SetQuaternion(stateManager.worldName + "block" + objectID + "Rotation", objectRotation); FileBasedPrefs.SetBool(worldID + "falling", T.gameObject.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent <PhysicsHandler>().fallingStack); } } if (T.gameObject.GetComponent <Glass>() != null) { objectName = stateManager.worldName + "Glass"; worldID = T.gameObject.GetComponent <Glass>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); blockIdList.Add(objectID); FileBasedPrefs.SetString(stateManager.worldName + "block" + objectID + "Name", objectName); PlayerPrefsX.SetVector3(stateManager.worldName + "block" + objectID + "Position", objectPosition); PlayerPrefsX.SetQuaternion(stateManager.worldName + "block" + objectID + "Rotation", objectRotation); FileBasedPrefs.SetBool(worldID + "falling", T.gameObject.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent <PhysicsHandler>().fallingStack); } } if (T.gameObject.GetComponent <ModBlock>() != null) { objectName = stateManager.worldName + "ModBlock"; worldID = T.gameObject.GetComponent <ModBlock>().ID; if (worldID != "unassigned" && worldID != "") { objectID = int.Parse(worldID.Substring(objectName.Length)); blockIdList.Add(objectID); string blockName = T.gameObject.GetComponent <ModBlock>().blockName; FileBasedPrefs.SetString(worldID + "blockName", blockName); FileBasedPrefs.SetString(stateManager.worldName + "block" + objectID + "Name", objectName); PlayerPrefsX.SetVector3(stateManager.worldName + "block" + objectID + "Position", objectPosition); PlayerPrefsX.SetQuaternion(stateManager.worldName + "block" + objectID + "Rotation", objectRotation); FileBasedPrefs.SetBool(worldID + "falling", T.gameObject.GetComponent <PhysicsHandler>().falling); FileBasedPrefs.SetBool(worldID + "fallingStack", T.gameObject.GetComponent <PhysicsHandler>().fallingStack); } } currentObject++; saveInterval++; if (saveInterval >= totalObjects * 0.05f) { yield return(null); saveInterval = 0; } } } foreach (MeshPainter painter in meshPainters) { painter.SaveData(); currentObject++; saveInterval++; if (saveInterval >= totalObjects * 0.05f) { yield return(null); saveInterval = 0; } } if (machineIdList.Count > 0) { PlayerPrefsX.SetIntArray(stateManager.worldName + "machineIdList", machineIdList.ToArray()); } if (blockIdList.Count > 0) { PlayerPrefsX.SetIntArray(stateManager.worldName + "blockIdList", blockIdList.ToArray()); } FileBasedPrefs.ManuallySave(); stateManager.dataSaved = true; stateManager.saving = false; currentObject = 0; totalObjects = 0; }