Ejemplo n.º 1
0
    public void Start()
    {
        if (s != null && s != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            s = this;
        }

        bool isThere = false;

        if (SaveMaster.toSave != null)
        {
            foreach (SaveMaster.SaveDelegate del in SaveMaster.toSave.GetInvocationList())
            {
                if (del == Save)
                {
                    isThere = true;
                    break;
                }
            }
        }

        if (!isThere)
        {
            SaveMaster.toSave += Save;
        }

        if (SaveMaster.s.mySave.activeEquipment != "none")
        {
            activeEquipment = myEquipments.Find(x => x.item.name == SaveMaster.s.mySave.activeEquipment);
        }
        else
        {
            activeEquipment = null;
        }

        selectedElement = SaveMaster.s.mySave.selectedElement;
        elementLevel    = SaveMaster.s.mySave.elementLevel;

        LoadInventory();

#if UNITY_EDITOR
        if (cheatInventory)
        {
            CheatInventory();
        }
#endif

        /*if (SceneMaster.s.curScene == 0) {
         *      MenuSwitchController.s.GetComponent<CharacterMenuController> ().SetEquipped ();
         *      ElementSelector.s.UpdateElementSliders ();
         * }*/
    }
Ejemplo n.º 2
0
    public void Add(ItemBase toAdd, int amount)
    {
        DataLogger.LogMessage("Item added: " + toAdd.name);
        InventoryItem myInvItem;

        if (toAdd is Equipment)
        {
            InventoryEquipment myEq = myEquipments.Find(x => x.item.name == toAdd.name);
            myInvItem = new InventoryEquipment((Equipment)toAdd, amount);
            if (myEq != null)
            {
                myEq.chargesLeft += amount;
            }
            else
            {
                myEquipments.Add((InventoryEquipment)myInvItem);
            }

            if (activeEquipment == null)
            {
                EquipItem((InventoryEquipment)myInvItem);
            }
        }
        else if (toAdd is Ingredient)
        {
            InventoryIngredient myIng = myIngredients.Find(x => x.item.name == toAdd.name);
            myInvItem = new InventoryIngredient((Ingredient)toAdd, amount);
            if (myIng != null)
            {
                myIng.chargesLeft += amount;
            }
            else
            {
                myIngredients.Add((InventoryIngredient)myInvItem);
            }
        }
        else
        {
            InventoryPotion myPot = myPotions.Find(x => x.item.name == toAdd.name);
            myInvItem = new InventoryPotion((Potion)toAdd, amount);
            if (myPot != null)
            {
                myPot.chargesLeft += amount;
            }
            else
            {
                myPotions.Add((InventoryPotion)myInvItem);
            }
        }

        if (ItemGainedScreen.s != null)
        {
            ItemGainedScreen.s.ShowGainedItem(myInvItem);
        }

        SaveMaster.s.Save();
    }
Ejemplo n.º 3
0
    private void Awake()
    {
        icoImage          = transform.Find("Image").GetComponent <Image>();
        nameText          = transform.Find("NameText").GetComponent <Text>();
        qualityText       = transform.Find("QualityText/Text").GetComponent <Text>();
        damageText        = transform.Find("DamageText/Text").GetComponent <Text>();
        hpText            = transform.Find("HpText/Text").GetComponent <Text>();
        contentText       = transform.Find("Text").GetComponent <Text>();
        effectivenessText = transform.Find("EffectivenessText/Text").GetComponent <Text>();

        //roleImage = transform.parent.Find("RoleImage").GetComponent<RoleImage>();
        inventoryEquipment = transform.parent.GetComponent <InventoryEquipment>();
    }
Ejemplo n.º 4
0
        public void Menu_007_Inventory()
        {
            var _menu = new MainMenuPage(_driver);

            Assert.IsTrue(_menu.MenuContainer.Displayed);

            _menu.OpenEquipmentPage();
            SwitchToContent();
            var _inventoryEquipmentPage = new InventoryEquipment(_driver);

            _inventoryEquipmentPage.WaitElementIsShown(_inventoryEquipmentPage.Form);
            Assert.IsTrue(_inventoryEquipmentPage.IsDisplayed());
        }
Ejemplo n.º 5
0
    //----------------- helpers

    public void EquipItem(InventoryEquipment toEquip)
    {
        if (toEquip == null)
        {
            return;
        }
        activeEquipment = toEquip;
        SaveMaster.s.Save();

        if (SceneMaster.s.curScene == 0)
        {
            if (VC_CharacterMenuController.s != null)
            {
                VC_CharacterMenuController.s.SetEquipped();
            }
        }
        else
        {
            CharacterStuffController.s.SetUpButtons();
        }
    }
Ejemplo n.º 6
0
    public void ClearInventory()
    {
        DataLogger.LogError("Inventory Cleared");
        myEquipments    = new List <InventoryEquipment> ();
        myIngredients   = new List <InventoryIngredient> ();
        myPotions       = new List <InventoryPotion> ();
        activeEquipment = null;

        if (SceneMaster.s.curScene == 0)
        {
            if (VC_CharacterMenuController.s != null)
            {
                VC_CharacterMenuController.s.SetEquipped();
            }
        }
        else
        {
            CharacterStuffController.s.SetUpButtons();
        }

        Save();
    }
Ejemplo n.º 7
0
    public SavedData(AllCharacterStats characterStats, Inventory inventory)
    {
        // player position/rotation
        position    = new float[3];
        position[0] = characterStats.transform.position.x;
        position[1] = characterStats.transform.position.y;
        position[2] = characterStats.transform.position.z;

        rotation    = new float[4];
        rotation[0] = characterStats.transform.rotation.x;
        rotation[1] = characterStats.transform.rotation.y;
        rotation[2] = characterStats.transform.rotation.z;
        rotation[3] = characterStats.transform.rotation.w;

        // player stats
        balance    = characterStats.Balance;
        health     = characterStats.Health;
        protection = characterStats.Protection;
        speed      = characterStats.Speed;
        damage     = characterStats.Damage;

        // player inventory
        inventorySlots     = inventory.InventoryItems.Count;
        inventoryItems     = new List <InventoryItem>();
        inventoryEquipment = new List <InventoryEquipment>();
        for (int i = 0; i < inventorySlots; i++)
        {
            Debug.Log("checking inventory slot at index" + i);

            if (inventory.GetInventory()[i] != null)
            {
                Debug.Log("found item at index " + i);


                if (inventory.GetInventory()[i].item is EquipmentBlueprint)
                {
                    InventoryEquipment item    = new InventoryEquipment();
                    EquipmentBlueprint equipBP = inventory.GetInventory()[i].item.equipBP;

                    EquipmentSlots equipmentSlots = equipBP.EquipSlot;
                    item.EquipSlot = equipmentSlots;

                    List <Positives> positives = new List <Positives>();
                    for (int j = 0; j < equipBP.PositiveTraits.Count; j++)
                    {
                        Positives posTrait = new Positives();
                        posTrait.traitLevel = equipBP.PositiveTraits[j].traitLevel;
                        posTrait.traits     = equipBP.PositiveTraits[j].traits;

                        positives.Add(posTrait);
                    }

                    List <Negatives> negatives = new List <Negatives>();
                    for (int j = 0; j < equipBP.NegativeTraits.Count; j++)
                    {
                        Negatives negTrait = new Negatives();
                        negTrait.traitLevel = equipBP.NegativeTraits[j].traitLevel;
                        negTrait.traits     = equipBP.NegativeTraits[j].traits;

                        negatives.Add(negTrait);
                    }

                    item.ItemName = equipBP.ItemName;

                    Texture2D tex = equipBP.ItemIcon.texture;
                    exportObj.x     = tex.width;
                    exportObj.y     = tex.height;
                    exportObj.bytes = ImageConversion.EncodeToPNG(tex);
                    string icon = JsonUtility.ToJson(exportObj, false);

                    item.ItemIcon   = icon;
                    item.isDefault  = equipBP.isDefault;
                    item.StackUntil = equipBP.StackUntil;

                    item.Bundle    = equipBP.Bundle;
                    item.AssetName = equipBP.AssetName;

                    item.ItemDescription = equipBP.ItemDescription;

                    inventoryEquipment.Add(item);
                }
                else
                {
                    InventoryItem item   = new InventoryItem();
                    ItemBlueprint itemBP = inventory.GetInventory()[i].item;

                    item.ItemName = itemBP.ItemName;

                    Texture2D tex = itemBP.ItemIcon.texture;
                    exportObj.x     = tex.width;
                    exportObj.y     = tex.height;
                    exportObj.bytes = ImageConversion.EncodeToPNG(tex);
                    string icon = JsonUtility.ToJson(exportObj, false);

                    item.ItemIcon   = icon;
                    item.isDefault  = itemBP.isDefault;
                    item.StackUntil = itemBP.StackUntil;

                    item.Bundle    = itemBP.Bundle;
                    item.AssetName = itemBP.AssetName;

                    item.ItemDescription = itemBP.ItemDescription;

                    inventoryItems.Add(item);
                }
            }
        }
    }
Ejemplo n.º 8
0
    public void Remove(ItemBase toRemove, int amount)
    {
        //InventoryItem myInvItem;
        if (toRemove is Equipment)
        {
            InventoryEquipment myEq = myEquipments.Find(x => x.item.name == toRemove.name);
            //myInvItem = new InventoryEquipment ((Equipment)toRemove, toRemove.durability);

            bool didRemove = false;
            if (myEq != null)
            {
                myEq.chargesLeft -= amount;
                if (myEq.chargesLeft <= 0)
                {
                    myEquipments.Remove(myEq);
                    didRemove = true;
                }
            }
            else
            {
                DataLogger.LogError("Cant remove item! " + toRemove.name + " - " + amount.ToString());
            }

            if (didRemove)
            {
                if (toRemove.name == activeEquipment.item.name)
                {
                    activeEquipment = null;
                }
            }
        }
        else if (toRemove is Ingredient)
        {
            InventoryIngredient myIng = myIngredients.Find(x => x.item.name == toRemove.name);
            //myInvItem = new InventoryIngredient ((Ingredient)toRemove, toRemove.durability);
            if (myIng != null)
            {
                myIng.chargesLeft -= amount;
                if (myIng.chargesLeft <= 0)
                {
                    myIngredients.Remove(myIng);
                }
            }
            else
            {
                DataLogger.LogError("Cant remove item! " + toRemove.name + " - " + amount.ToString());
            }
        }
        else
        {
            InventoryPotion myPot = myPotions.Find(x => x.item.name == toRemove.name);
            //myInvItem = new InventoryPotion ((Potion)toRemove, toRemove.durability);
            if (myPot != null)
            {
                myPot.chargesLeft -= amount;
                if (myPot.chargesLeft <= 0)
                {
                    myPotions.Remove(myPot);
                }
            }
            else
            {
                DataLogger.LogError("Cant remove item! " + toRemove.name + " - " + amount.ToString());
            }
        }
    }
Ejemplo n.º 9
0
 private void Awake()
 {
     instance = this;
 }