Ejemplo n.º 1
0
    public void LoadGame()
    {
        DestroyOnLoad.box  = this.boxDestroy;
        DestroyOnLoad.boss = this.bossDestroy;

        /*Load player stats*/
        PlayerUnit.expForLvlUp   = this.playerData.expForLvlUp;
        PlayerUnit.pickUpClass   = this.playerData.pickUpClass;
        PlayerUnit.unitName      = this.playerData.unitName;
        PlayerUnit.unitLvl       = this.playerData.unitLvl;
        PlayerUnit.damage        = this.playerData.damage;
        PlayerUnit.maxHP         = this.playerData.maxHP;
        PlayerUnit.currentHP     = this.playerData.currentHP;
        PlayerUnit.exp           = this.playerData.exp;
        PlayerUnit.manaAmount    = this.playerData.manaAmount;
        PlayerUnit.maxMana       = this.playerData.maxMana;
        PlayerUnit.enemiesKilled = this.playerData.enemiesKilled;
        PlayerUnit.time          = this.playerData.time;
        PlayerUnit.bossFight     = this.playerData.bossFight;


        /*Load inventory*/

        Inventory.goldAmount   = this.playerInventory.gold;
        Inventory.itemQuantity = this.playerInventory.itemQuantity;

        foreach (var item in this.playerInventory.playerItems)
        {
            Inventory.AddItem(Resources.Load <ItemObject>("Items/" + item));
        }

        foreach (var skill in this.playerInventory.playerSkills)
        {
            Inventory.AddSkill(Resources.Load <SkillObject>("Skills/" + skill));
        }

        Inventory.AddClass(Resources.Load <ClassObject>("Classes/" + this.playerInventory.playerClass));

        foreach (var equip in this.playerInventory.playerEquip)
        {
            Inventory.Equip(Resources.Load <EquipmentItem>("Items/" + equip));
        }



        PlayerPrefs.SetFloat("x", this.playerData.playerPositionX);
        PlayerPrefs.SetFloat("y", this.playerData.playerPositionY);
        Time.timeScale = 1;
        PlayerPrefs.DeleteKey("_last_scene_");
        SceneManager.LoadScene(this.playerData.sceneName, LoadSceneMode.Single);
    }
 public void ChooseClass(ClassObject classObject)
 {
     Inventory.AddClass(classObject);
 }