Example #1
0
    private static void LoadDebugSave()
    {
        SaveDebugScriptable debugSave = (SaveDebugScriptable)Selection.activeObject;

        debugSave.data = FileSaveLoad.Load();
        Debug.Log(" ----- LOADED ------ ");
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        SaveData data = FileSaveLoad.Load();

        data.currentScene = sceneIndex;
        FileSaveLoad.Save(data);
    }
Example #3
0
    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");
        }
    }
Example #4
0
    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");
        }
    }
Example #5
0
    // Use this for initialization
    void Awake()
    {
        instance = this;
        gameData = _gameData;
        saveData = FileSaveLoad.Load();

        EventDispatcher.AddEventListener(Events.FILE_SAVED, OnFileSaved);
    }
Example #6
0
    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);
    }
Example #7
0
    private void BossDied()
    {
        bossBeatenObjects.SetActive(true);

        SaveData data = FileSaveLoad.Load();

        data.bossesBeaten.Add(bossIndex);
        FileSaveLoad.Save(data);

        EventDispatcher.DispatchEvent(Events.BOSS_BEATEN, bossIndex);
    }
Example #8
0
    // Use this for initialization
    void Start()
    {
        gameData           = GlobalData.instance.gameData;
        upgradesCategories = gameData.upgradesCategories;
        shopUI.InitItems(upgradesCategories);

        if (CheckIfOverwheight(FileSaveLoad.Load()))
        {
            overloadErrorUIAnimator.SetTrigger("Open");
        }
    }
Example #9
0
    //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();
        }
    }
Example #10
0
    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);
    }
Example #11
0
    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);
    }
Example #12
0
    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);
        }
    }
Example #13
0
 private void OnFileSaved(object useless)
 {
     saveData = FileSaveLoad.Load();
 }
 // Use this for initialization
 void Start()
 {
     loader.sceneIndex = FileSaveLoad.Load().currentScene;
     loader.Load();
 }