private static void OverideSave() { SaveDebugScriptable debugSave = (SaveDebugScriptable)Selection.activeObject; FileSaveLoad.Save(debugSave.data); Debug.Log("----- SAVED ------- "); }
// Use this for initialization void Start() { SaveData data = FileSaveLoad.Load(); data.currentScene = sceneIndex; FileSaveLoad.Save(data); }
public void BuyItem(BaseUpgrade upgrade) { if (!upgrade.canBuy) { EventDispatcher.DispatchEvent(Events.UI_ERROR, null); return; } SaveData data = FileSaveLoad.Load(); UpgradeInfo upgradeInfo = data.upgradesInfo[upgrade.saveDataIndex]; data.money -= upgrade.currentPrice; data.shipWeight += upgrade.wheight; upgradeInfo.currentUpgradeNb++; upgradeInfo.boughtUpgradeNb = Mathf.Max(upgradeInfo.currentUpgradeNb, upgradeInfo.boughtUpgradeNb); upgrade.Equip(data); // specialized save data modification. different for each Upgrade type. FileSaveLoad.Save(data); wheightUI.UpdateWheight(); moneyUI.UpdateMoney(); shopUI.UpdateAllItems(); shopDetailsPane.UpdateDetails(upgrade); EventDispatcher.DispatchEvent(Events.UI_SUCCESS, null); if (isOverWheight && !CheckIfOverwheight(data)) { overloadErrorUIAnimator.SetTrigger("Close"); } }
public void UnEquip(BaseUpgrade upgrade) { SaveData data = FileSaveLoad.Load(); UpgradeInfo upgradeInfo = data.upgradesInfo[upgrade.saveDataIndex]; if (!upgrade.canUnEquip || upgradeInfo.currentUpgradeNb <= 0) { EventDispatcher.DispatchEvent(Events.UI_ERROR, null); return; } data.shipWeight -= upgrade.wheight; upgradeInfo.currentUpgradeNb--; upgrade.UnEquip(data); FileSaveLoad.Save(data); wheightUI.UpdateWheight(); shopUI.UpdateAllItems(); shopDetailsPane.UpdateDetails(upgrade); EventDispatcher.DispatchEvent(Events.UI_SUCCESS, null); if (isOverWheight && !CheckIfOverwheight(data)) { overloadErrorUIAnimator.SetTrigger("Close"); } }
private void OnPlayerDeath(object useless) { SaveData data = FileSaveLoad.Load(); data.money += score; data.highScore = Mathf.Max(data.highScore, score); data.bestTime = Mathf.Max(data.bestTime, Time.time - timeStart); data.bestEnemiesKilled = Mathf.Max(data.bestEnemiesKilled, enemiesKilled); FileSaveLoad.Save(data); }
private void BossDied() { bossBeatenObjects.SetActive(true); SaveData data = FileSaveLoad.Load(); data.bossesBeaten.Add(bossIndex); FileSaveLoad.Save(data); EventDispatcher.DispatchEvent(Events.BOSS_BEATEN, bossIndex); }
//called from shipDetails pane (weird, I know) public void SelectShip(int shipIndex) { SaveData data = FileSaveLoad.Load(); if (data.shipsInfo[shipIndex].stock >= 1 && data.shipsInfo[shipIndex].isUnlocked) { data.selectedShip = shipIndex; data.shipsInfo[shipIndex].stock -= 1; FileSaveLoad.Save(data); transitor.Transition(); } }
void Start() { SaveData data = FileSaveLoad.Load(); List <ShipConfig> ships = GlobalData.instance.gameData.ships; for (int i = 0; i < ships.Count; i++) { if (data.selectedShip != i) { data.shipsInfo[i].stock = Mathf.Min(ships[i].maxStock, data.shipsInfo[i].stock + ships[i].stockGainByRun); } } FileSaveLoad.Save(data); }
protected virtual void Unlock() { SaveData data = FileSaveLoad.Load(); data.achievementsUnlocked.Add(achievementIndex); if (shipToUnlock != -1) { data.shipsInfo[shipToUnlock].isUnlocked = true; } FileSaveLoad.Save(data); EventDispatcher.DispatchEvent(Events.ACHIEVMENT_UNLOCKED, achievementIndex); Destroy(this); }
void Start() { if (!FileSaveLoad.DoesSaveExists()) { SaveData data = FileSaveLoad.Load(); List <ShipConfig> ships = GlobalData.instance.gameData.ships; List <UpgradeCategory> upgradesCategories = GlobalData.instance.gameData.upgradesCategories; data.shipsInfo = new List <ShipInfo>(); for (int i = 0; i < ships.Count; i++) { ShipInfo info = new ShipInfo(); info.stock = ships[i].maxStock; data.shipsInfo.Add(info); } for (int i = 0; i < GlobalData.instance.gameData.shipsUnlockedAtStart.Count; i++) { data.shipsInfo[GlobalData.instance.gameData.shipsUnlockedAtStart[i]].isUnlocked = true; } int upgradesNb = 0; for (int i = 0; i < upgradesCategories.Count; i++) { upgradesNb += upgradesCategories[i].upgrades.Count; } data.upgradesInfo = new UpgradeInfo[upgradesNb]; for (int i = 0; i < upgradesCategories.Count; i++) { for (int j = 0; j < upgradesCategories[i].upgrades.Count; j++) { UpgradeInfo info = new UpgradeInfo(); info.isUnlocked = upgradesCategories[i].upgrades[j].unlockedAtStart; data.upgradesInfo[upgradesCategories[i].upgrades[j].saveDataIndex] = info; } } data.selectedWeapons = new List <int>(); data.selectedWeapons.Add(firstWeapon.weaponIndex); data.shipWeight += firstWeapon.wheight; data.upgradesInfo[firstWeapon.saveDataIndex].boughtUpgradeNb = 1; data.upgradesInfo[firstWeapon.saveDataIndex].currentUpgradeNb = 1; FileSaveLoad.Save(data); } }