private void OnApplicationPause(bool pause) { if (pause) { SaveLoadSystem.SaveStash(); SaveLoadSystem.SaveGame(); } }
private void Awake() { GetComponent <GUIButton>().onClick.AddListener(() => { SaveLoadSystem.SaveStash(); SaveLoadSystem.SaveGame(); LevelLoader.DestroyLevel(); SceneManager.LoadScene(SceneToLoad); }); }
private void CompareWithPasswordList() { //try to get mapname based on the password key input string getableMapName = mapDict.GetMapName(inputPassword); Debug.Log("getableMapName " + getableMapName); //if the input is correct, or the mapname exists in the dictionary if (getableMapName != MapDictionary.WRONGINPUT) { //and if the map had been acquired before if (mapDict.CheckAlreadyAcquired(getableMapName)) { inputField.text = ""; delayForRetry = maxDelayForRetry; flagToStartDelay = true; inputField.interactable = false; delayFromAlreadyInput = true; SetSttText(alreadyExistText, Color.yellow); } else { acquireMapName = getableMapName; //Change status text SetSttText(correctPassText, Color.yellow); //Hide Image and Input field component to gain space for secret map tile TurnOnOffInputFieldContent(false); //turn on found secret map tile display TurnOnOffMaptileDisplay(true); //turn on corresponding dot on world map newlyAdded = true; //Add the corresponding map to the bottom end of Campaign list mapDict.SetMapDictValue(getableMapName); //if this is the last secret of the current world, disable input //EXTENDABLE #1 optionally disable input or just keep player able to input /*if(mapDict.IsAllSecretMapRevealed()){ * print("inputSucceeded " + inputSucceeded + "all map ok"); * inputSucceeded = true; * inputField.interactable = false; * }*/ // Saving the input map SaveLoadSystem.SaveGame(PlayerProgress.playerData); } //if the input is not correct } else { inputField.text = ""; print("Incorrect Password"); delayForRetry = maxDelayForRetry; flagToStartDelay = true; inputField.interactable = false; } }
//--------------------------------------------------------------- public void WaveChangeHandling() { if (currentWaveChild) { if (currentWaveChild.childCount <= 0) { isWaveCleared = true; currentWaveChild.gameObject.SetActive(false); //clear the enemy paddle if all the enemy objects are removed /*if(enemyPaddleSpawner && enemyPaddleSpawner.transform.childCount>0){ * Destroy(enemyPaddleSpawner.transform.GetChild(0).gameObject); * }*/ if (currentWaveIndex + 1 < waveLength) { currentWaveIndex++; PlayerPrefManager.SetUITextStatus(PlayerPrefManager.GUITEXT_STATUS_CHANGING); UITextController.SetUITextStatusType(UITextController.DISPLAY_TEXT.WAVE, ""); currentWaveChild = enemyWaveSpawner.transform.GetChild(currentWaveIndex); } else if (currentWaveIndex + 1 >= waveLength && !saved) { waveHasStarted = false; WinLoseCondition wlCondition = GameObject.FindGameObjectWithTag("Win Lose Condition").GetComponent <WinLoseCondition>(); wlCondition.Win(); //Saving data when the stage was cleared //store collected gold to player data Inventory inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent <Inventory>(); PlayerProgress.playerData.gold += inventory.GetCollectedCoin(); //if the first time completing map if (!PlayerProgress.playerData.completedMaps.Contains(mapName)) { //store in to completed map list PlayerProgress.playerData.completedMaps.Add(mapName); if (!MapDictionary.CheckIsSecretMap(mapName)) { CheckForTheNextMap(); } } else // this map had been cleared before { RewardLoot.GetComponent <Reward>().SetHadLooted(); } SaveLoadSystem.SaveGame(PlayerProgress.playerData); saved = true; } } } }
private void Awake() { GetComponent <GUIButton>().onClick.AddListener(() => { if (SaveGameOnQuit) { SaveLoadSystem.SaveStash(); SaveLoadSystem.SaveGame(); } Application.Quit(); }); }
private void OnDeath() { Messaging.Player.Health.Invoke(0, 1); //Messaging.Player.Charge.Invoke(0, 1); //Messaging.Player.SoftDamage.Invoke(0); Messaging.CameraControl.RemoveShake.Invoke(); Messaging.System.SetTimeScale.Invoke(TimeScale.SuperSlowmo); Messaging.CameraControl.TargetRotation.Invoke(Random.value > .5f ? 90 : -90); //handle player info change instantly to make sure designator won't go ape shit SaveLoadSystem.SaveStash(); PlayerInfo.CurrentLocal.PlayerHasBeenInitialized = false; if (Difficulty.PermanentDeath) { SaveLoadSystem.DeletePlayerInfo(); } else { PlayerInfo.CurrentLocal.CurrentMap = SoftcoreDeathScene; SaveLoadSystem.SaveGame(); } float deathTimer = 0f; GameObject deadwaker = new GameObject("Dead Waker"); UpdateCallHook u = deadwaker.AddComponent <UpdateCallHook>(); u.OnUpdateCall.AddListener(() => { deathTimer += Time.unscaledDeltaTime; Messaging.GUI.Painflash.Invoke(1f); Messaging.GUI.Blackout.Invoke(deathTimer / 7f); if (deathTimer > 7f) { Destroy(deadwaker.gameObject); if (Difficulty.PermanentDeath) { UnityEngine.SceneManagement.SceneManager.LoadScene(HardcoreDeathScene); } else { Messaging.System.ChangeLevel.Invoke(SoftcoreDeathScene, 0); } } }); Messaging.Player.Death.Invoke(); }
void SaveAsLatestUsedSkill(string skillNameToSave) { string charName = skillPanel.GetSkillUsingCharName(); switch (charName) { case CommonData.char_pippo: PlayerProgress.playerData.latestUsedSkill_Pippo = skillNameToSave; break; case CommonData.char_johnny: PlayerProgress.playerData.latestUsedSkill_Johnny = skillNameToSave; break; case CommonData.char_mathial: PlayerProgress.playerData.latestUsedSkill_Mathial = skillNameToSave; break; case CommonData.char_kolav: PlayerProgress.playerData.latestUsedSkill_Kolav = skillNameToSave; break; case CommonData.char_maja: PlayerProgress.playerData.latestUsedSkill_Maja = skillNameToSave; break; case CommonData.char_bape: PlayerProgress.playerData.latestUsedSkill_Bape = skillNameToSave; break; case CommonData.char_vie: PlayerProgress.playerData.latestUsedSkill_Vie = skillNameToSave; break; case CommonData.char_lynu: PlayerProgress.playerData.latestUsedSkill_Lynu = skillNameToSave; break; default: break; } SaveLoadSystem.SaveGame(PlayerProgress.playerData); }
//--------------------------------------------------------------- private void CheckForTheNextMap() { string nextMapName = GetNextMapName(); //If there is still a normal map at current world if (nextMapName != "") { PlayerProgress.playerData.availableMaps.Add(nextMapName); } else //this is the last normal map //open the next world, make the first map of the next world available to play { PlayerProgress.playerData.maxReachableWorld++; int newestWorldIndex = PlayerProgress.playerData.maxReachableWorld - 1; print("newestWorldIndex " + newestWorldIndex); string firstMapOfNextWorld = MapDictionary.wholeGameMaps[newestWorldIndex][0]; PlayerProgress.playerData.availableMaps.Add(firstMapOfNextWorld); SaveLoadSystem.SaveGame(PlayerProgress.playerData); } }
void AcceptPurchase() { if (PlayerProgress.playerData.gold < price) { purchaseNotif.text = "Not enough Gold."; mainBox.gameObject.SetActive(false); subBox.gameObject.SetActive(true); return; } PlayerProgress.playerData.gold -= price; GoldObject.GetComponentInChildren <Text>().text = PlayerProgress.playerData.gold.ToString(); switch (itemTypeToConfirm) { case Item.TYPE.CHARACTER: PlayerProgress.playerData.availableCharacters.Add(itemNameToConfirm); break; case Item.TYPE.MAP: PlayerProgress.playerData.availableMaps.Add(itemNameToConfirm); break; case Item.TYPE.SHOT: CheckShotPurchased(); break; case Item.TYPE.VEHICLE: PlayerProgress.playerData.availableVehicles.Add(itemNameToConfirm); break; default: break; } SaveLoadSystem.SaveGame(PlayerProgress.playerData); purchaseNotif.text = "Item purchase successful!"; selectedItem.SetIsPurchased(); subBox.gameObject.SetActive(true); mainBox.gameObject.SetActive(false); }
// Use this for initialization void Start() { items = new List <Item>(); newItems = new List <Item>(); alreadyExistItems = new List <Item>(); WinLoseCondition.SetIsWinner(isWinnerForTest); //Check whether the reward loot exists or not reward = FindObjectOfType <Reward>(); if (!reward) { Debug.LogError("Cannot find reward Object to loot"); return; } //If there is , then check if game won or lost if (!WinLoseCondition.GetIsWinner()) { Debug.Log("Well. Look like you lost. you cannot loot the reward"); return; } //if you won, then check whether it has been looted or not /*if(reward.GetHadLooted()){ * Debug.LogError("You completed this map before. Only gold could be collected"); * acquiredGold = reward.GetRewardGold(); * PlayerProgress.playerData.gold += acquiredGold; * return; * }*/ //If has ever not been looted acquiredGold = reward.GetRewardGold(); PlayerProgress.playerData.gold += reward.GetRewardGold(); List <Item> itemsInRewardLoot = reward.GetItemsInReward(); if (itemsInRewardLoot != null) { for (int i = 0; i < itemsInRewardLoot.Count; i++) { if (reward.GetHadLooted() && itemsInRewardLoot[i].isStageItem) { Debug.LogError("this item is stage item. As you completed this map before, Only gold could be collected"); acquiredGold = reward.GetRewardGold(); PlayerProgress.playerData.gold += acquiredGold; continue; } switch (itemsInRewardLoot[i].itemType) { case Item.TYPE.CHARACTER: if (PlayerProgress.playerData.availableCharacters.Contains(itemsInRewardLoot[i].itemName)) { Debug.Log("This character is already in your group. You will receive gold instead."); itemsInRewardLoot[i].isAlreadyInStock = true; PlayerProgress.playerData.gold += itemsInRewardLoot[i].itemValue; alreadyExistItems.Add(itemsInRewardLoot[i]); items.Add(itemsInRewardLoot[i]); } else if (CommonData.charNameList.Contains(itemsInRewardLoot[i].itemName)) { Debug.Log(itemsInRewardLoot[i].itemName + " is found in datatabase"); newItems.Add(itemsInRewardLoot[i]); items.Add(itemsInRewardLoot[i]); PlayerProgress.playerData.availableCharacters.Add(itemsInRewardLoot[i].itemName); //Do stuff here } else { Debug.Log("this prisoner name :" + itemsInRewardLoot[i].itemName + " is not existing in the database"); } break; case Item.TYPE.VEHICLE: if (PlayerProgress.playerData.availableVehicles.Contains(itemsInRewardLoot[i].itemName)) { Debug.Log("This vehicle is already in your group. You will receive gold instead."); itemsInRewardLoot[i].isAlreadyInStock = true; PlayerProgress.playerData.gold += itemsInRewardLoot[i].itemValue; alreadyExistItems.Add(itemsInRewardLoot[i]); items.Add(itemsInRewardLoot[i]); } else if (CommonData.vehicleList.Contains(itemsInRewardLoot[i].itemName)) { Debug.Log(itemsInRewardLoot[i].itemName + " is found in datatabase"); PlayerProgress.playerData.availableVehicles.Add(itemsInRewardLoot[i].itemName); newItems.Add(itemsInRewardLoot[i]); items.Add(itemsInRewardLoot[i]); //Do stuff here } else { Debug.Log("this vehicle name :" + itemsInRewardLoot[i].itemName + " is not existing in the database"); } break; case Item.TYPE.SHOT: break; case Item.TYPE.MAP: break; case Item.TYPE.GOLD: Debug.Log("this item is gold."); PlayerProgress.playerData.gold += itemsInRewardLoot[i].itemValue; items.Add(itemsInRewardLoot[i]); Debug.Log("there are" + items.Count + "items in total"); break; default: break; } } } SaveLoadSystem.SaveGame(PlayerProgress.playerData); }
private void OnApplicationQuit() { SaveLoadSystem.SaveStash(); SaveLoadSystem.SaveGame(); }