Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        HealthManager h = collision.GetComponent <HealthManager>();

        if (h != null)
        {
            h.ChangeHealth(Damage);
        }

        Destroy(gameObject);
    }
Beispiel #2
0
    public void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/slot1.dat"))
        {
            thePlayer.isTalking = false;
            thePlayer.canMove   = true;
            PlayerPrefs.DeleteAll();
            SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.UI_START_MENU_SELECT);

            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/slot1.dat", FileMode.Open);

            PlayerData data = (PlayerData)bf.Deserialize(file);
            file.Close();

            thePlayer.nextUuid = data.savePointId;
            stats.level        = data.level;
            moneyManager.AddMoney(data.gold);
            healthManager.UpdateMaxHealth(stats.hpLevels[data.level]);
            mpManager.UpdateMaxMP(stats.mpLevels[data.level]);
            uiManager.LevelChanged(stats.level, stats.expToLevelUp.Length,
                                   stats.expToLevelUp[stats.level],
                                   stats.expToLevelUp[stats.level - 1]);
            stats.exp = data.exp;
            uiManager.ExpChanged(data.exp);

            stats.newstrengthLevels = data.str;
            stats.newdefenseLevels  = data.def;
            stats.newmagicAttLevels = data.mat;
            stats.newmagicDefLevels = data.mdf;
            stats.newspeedLevels    = data.spd;
            stats.newluckLevels     = data.lck;
            stats.newaccuracyLevels = data.acc;


            //stats.AddStatsAtLevelUP(0);
            mpManager.ChangeMP(data.mp);
            healthManager.ChangeHealth(data.health);
            itemsManager.currentPotions     = data.potions;
            itemsManager.currentEthers      = data.ethers;
            itemsManager.currentPhoenixDown = data.pd;

            //Recupera weapons
            for (int i = 0; i < data.weaponsInInventory.Count; i++)
            {
                weaponManager.SearchWeaponByName(data.weaponsInInventory[i]);
            }
            //Activa el arma que tenia activa
            //weaponManager.ChangeWeapon(data.activeWeapon);
            weaponManager.activeWeapon = data.activeWeapon;
            weaponManager.DeactivateWeapon(true);
            uiManager.WeaponEq();
            //Recupera Armors
            for (int i = 0; i < data.armorsInInventory.Count; i++)
            {
                armorManager.SearchArmorByName(data.armorsInInventory[i]);
            }
            //armorManager.ChangeArmor(data.activeArmor);
            armorManager.activeArmor = data.activeArmor;
            armorManager.ActivateArmor(true);
            uiManager.ArmorEq();
            //Recupera Accesorios
            for (int i = 0; i < data.accesoriesInInventory.Count; i++)
            {
                accesoryManager.SearchAccByName(data.accesoriesInInventory[i]);
            }
            //accesoryManager.ChangeAccesory(data.activeAccesory);
            accesoryManager.activeAccesory = data.activeAccesory;
            accesoryManager.ActivateAcc(true);
            uiManager.AccesoryEq();

            //Recupera quests terminadas
            for (int i = 0; i < data.questsCompleted.Count; i++)
            {
                questManager.SearchQuestByIDSetCompleted(data.questsCompleted[i]);
            }

            //Recupera quests arrancadas
            for (int i = 0; i < data.questsStarted.Count; i++)
            {
                questManager.SearchQuestByIDSetStarted(data.questsStarted[i]);
            }

            //Recupera Items Quest

            for (int i = 0; i < data.questItems.Count; i++)
            {
                //Debug.Log(data.questItems[i]);
                itemsManager.AddQuestItemByName(data.questItems[i]);
            }

            //Recupera skills activas
            for (int i = 0; i < data.activeSkills.Count; i++)
            {
                uiManager.ActivateSkill(data.activeSkills[i]);
            }

            itemsManager.chestsDict = data.chests;
            // Recupera los chests
            foreach (KeyValuePair <string, string> entry in data.chests)
            {
                PlayerPrefs.SetString(entry.Key, entry.Value);
            }

            sceneTransition.Transition(data.sceneName);
            //SceneManager.LoadScene(data.sceneName)
        }
        else
        {
            SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.UI_MENU_ERROR);
        }
    }