Ejemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <PlayerController> () != null)
        {
            if (!isEquipment && !isHpRegen)
            {
                ScoreManager.AddPoints(pointsToAdd);
            }

            if (isEquipment)
            {
                eq.AddItem();
                door.isOpened = true;
                door.Open();
            }

            if (isHpRegen)
            {
                HealthManager.playerHp++;
            }

            if (isLifeUp)
            {
                life.GiveLife();
            }

            pickedItemSoundEffect.Play();
            Destroy(gameObject);
        }
    }
Ejemplo n.º 2
0
    public void LoadSaveState(SaveState saveState)
    {
        if (File.Exists(Application.persistentDataPath + saveState.fileName))
        {
            BinaryFormatter bf            = new BinaryFormatter();
            FileStream      file          = File.Open(Application.persistentDataPath + saveState.fileName, FileMode.Open);
            InventoryData   inventoryData = (InventoryData)bf.Deserialize(file);
            file.Close();

            InventoryMenu inventory = InventoryMenu.inventoryMenu;
            inventory.weapon1 = RestoreItem(inventoryData.quickslot1) as Weapon;
            inventory.weapon2 = RestoreItem(inventoryData.quickslot2) as Weapon;
            //Debug.Log("Restored " + inventory.weapon1 + " in weapon1");
            //Debug.Log("Restored " + inventory.weapon2 + " in weapon2");
            //inventory.weapon3 = RestoreItem(inventoryData.quickslot3) as Weapon;

            for (int i = 0; i < inventoryData.items.Length; i++)
            {
                ItemData iData = inventoryData.items[i];
                Item     item  = RestoreItem(iData);
                if (item == null)
                {
                    continue;
                }
                inventory.AddItem(item, i);
                //sDebug.Log("Restored '" + item.itemName + "' item in inventory slot " + i);
            }
        }
        else
        {
            //InventoryMenu.inventoryMenu.weapon1 = WeaponFactory.weaponFactory.GetSword(Player.player, 5, 1f);
            Debug.LogWarning("SaveState doesn't exist! Values were set to default.");
        }

        Debug.Log("Loaded SaveState '" + currentSaveState.name + "'.");
    }