Exemplo n.º 1
0
    void Update()
    {
        if (Input.GetKeyDown(KeybindManager.Keybinds[KeybindFunction.I_INVENTORY]))
        {
            CanvasGroup group = GetComponent <CanvasGroup>();
            group.alpha        = Mathf.Abs(group.alpha - 1);
            group.interactable = group.blocksRaycasts = !group.blocksRaycasts;
        }

        for (int i = 0; i < 6; i++)
        {
            for (int j = 0; j < 6; j++)
            {
                Item tempItem = playerInventory.FetchItemInSlot((i * 6) + j);
                if (tempItem != null)
                {
                    itemPane.GetChild(i).GetChild(j).GetChild(0).GetComponent <Image>().sprite = tempItem.Icon;
                }
                else
                {
                    itemPane.GetChild(i).GetChild(j).GetChild(0).GetComponent <Image>().sprite = null;
                }
            }
        }
    }
Exemplo n.º 2
0
    private void Update()
    {
        if (RecipeCrafter.IsUsingInput)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            CanvasGroup group = GetComponent <CanvasGroup>();
            group.alpha          = 0;
            group.blocksRaycasts = false;
            group.interactable   = false;
        }

        if (Input.GetKeyDown(KeybindManager.Keybinds[KeybindFunction.I_INVENTORY]))
        {
            CanvasGroup group = GetComponent <CanvasGroup>();
            group.alpha = Mathf.Abs(group.alpha - 1);
            if (group.alpha == 1)
            {
                Interface_Controller.instance.InterfaceEvents["OpenInventory"].Invoke();
            }
            group.interactable = group.blocksRaycasts = !group.blocksRaycasts;
            UpdateResourceListQuantities();
        }


        for (int i = 0; i < itemPane.childCount; i++)
        {
            for (int j = 0; j < itemPane.GetChild(i).childCount; j++)
            {
                Item tempItem = playerInventory.FetchItemInSlot(i * itemPane.GetChild(i).childCount + j);
                if (tempItem != null)
                {
                    itemPane.GetChild(i).GetChild(j).GetComponent <Image>().sprite = tempItem.Icon;
                }
                else
                {
                    itemPane.GetChild(i).GetChild(j).GetComponent <Image>().sprite = emptySlotIcon;
                }
            }
        }

        //Connecting Equipped Items
        Transform equippedRoot = characterPane.Find("Equipment/Gear_Column");

        if (displayEquippedWeaponTab)
        {
            for (int i = 1; i < 5; i++)
            {
                Item myItem = Player_Accessor_Script.EquipmentScript.FetchItemSlot(i - 1);
                if (myItem != null)
                {
                    equippedRoot.GetChild(i).GetChild(0).GetComponent <Image>().sprite = myItem.Icon;
                    equippedRoot.GetChild(i).GetChild(1).GetComponent <Text>().text    = myItem.ItemName;
                }
                else
                {
                    equippedRoot.GetChild(i).GetChild(0).GetComponent <Image>().sprite = emptySlotIcon;
                    equippedRoot.GetChild(i).GetChild(1).GetComponent <Text>().text    = "Empty";
                }
            }
        }
        else
        {
            if (Player_Accessor_Script.EquipmentScript.Helmet != null)
            {
                equippedRoot.GetChild(1).GetChild(0).GetComponent <Image>().sprite = Player_Accessor_Script.EquipmentScript.Helmet.Icon;
                equippedRoot.GetChild(1).GetChild(1).GetComponent <Text>().text    = Player_Accessor_Script.EquipmentScript.Helmet.ItemName;
            }
            else
            {
                equippedRoot.GetChild(1).GetChild(0).GetComponent <Image>().sprite = emptySlotIcon;
                equippedRoot.GetChild(1).GetChild(1).GetComponent <Text>().text    = "Empty";
            }

            if (Player_Accessor_Script.EquipmentScript.Chestplate != null)
            {
                equippedRoot.GetChild(2).GetChild(0).GetComponent <Image>().sprite = Player_Accessor_Script.EquipmentScript.Chestplate.Icon;
                equippedRoot.GetChild(2).GetChild(1).GetComponent <Text>().text    = Player_Accessor_Script.EquipmentScript.Chestplate.ItemName;
            }
            else
            {
                equippedRoot.GetChild(2).GetChild(0).GetComponent <Image>().sprite = emptySlotIcon;
                equippedRoot.GetChild(2).GetChild(1).GetComponent <Text>().text    = "Empty";
            }

            if (Player_Accessor_Script.EquipmentScript.LegArmor != null)
            {
                equippedRoot.GetChild(3).GetChild(0).GetComponent <Image>().sprite = Player_Accessor_Script.EquipmentScript.LegArmor.Icon;
                equippedRoot.GetChild(3).GetChild(1).GetComponent <Text>().text    = Player_Accessor_Script.EquipmentScript.LegArmor.ItemName;
            }
            else
            {
                equippedRoot.GetChild(3).GetChild(0).GetComponent <Image>().sprite = emptySlotIcon;
                equippedRoot.GetChild(3).GetChild(1).GetComponent <Text>().text    = "Empty";
            }

            if (Player_Accessor_Script.EquipmentScript.EquippedTool != null)
            {
                equippedRoot.GetChild(4).GetChild(0).GetComponent <Image>().sprite = Player_Accessor_Script.EquipmentScript.EquippedTool.Icon;
                equippedRoot.GetChild(4).GetChild(1).GetComponent <Text>().text    = Player_Accessor_Script.EquipmentScript.EquippedTool.ItemName;
            }
            else
            {
                equippedRoot.GetChild(4).GetChild(0).GetComponent <Image>().sprite = emptySlotIcon;
                equippedRoot.GetChild(4).GetChild(1).GetComponent <Text>().text    = "Empty";
            }
        }

        //Calculating Stats for Display
        if (displayResistsTab)
        {
            Transform resistPanel = statsPanel.Find("Resists");
            //resistPanel.Find("MightText").GetComponent<Text>().text = "Might: " + Player_Accessor_Script.EquipmentScript.Might;
            //resistPanel.Find("DexterityText").GetComponent<Text>().text = "Dexterity: " + Player_Accessor_Script.EquipmentScript.Dexterity;
            //resistPanel.Find("IntelligenceText").GetComponent<Text>().text = "Intelligence: " + Player_Accessor_Script.EquipmentScript.Intelligence;
            //resistPanel.Find("ArmorText").GetComponent<Text>().text = "Armor: " + Player_Accessor_Script.DetailsScript.ElementalResists[ElementalResistances.PHYSICAL];
            for (int i = 0; i < 4; i++)
            {
                resistPanel.GetChild(i).Find(((ElementalResistances)(i * 2)).ToString() + "Text").GetComponent <Text>().text         = Mathf.RoundToInt(Player_Accessor_Script.DetailsScript.ElementalResists[((ElementalResistances)(i * 2))]).ToString();
                resistPanel.GetChild(i).Find(((ElementalResistances)(i * 2)).ToString() + "Image").GetComponent <Image>().sprite     = Resources.Load <Sprite>("StatIcons/" + ((ElementalResistances)(i * 2)).ToString());
                resistPanel.GetChild(i).Find(((ElementalResistances)(1 + i * 2)).ToString() + "Text").GetComponent <Text>().text     = Mathf.RoundToInt(Player_Accessor_Script.DetailsScript.ElementalResists[((ElementalResistances)(1 + i * 2))]).ToString();
                resistPanel.GetChild(i).Find(((ElementalResistances)(1 + i * 2)).ToString() + "Image").GetComponent <Image>().sprite = Resources.Load <Sprite>("StatIcons/" + ((ElementalResistances)(i * 2 + 1)).ToString());
            }
        }
        else
        {
            statsPanel.Find("Stats/MightText").GetComponent <Text>().text        = "Might: " + Player_Accessor_Script.EquipmentScript.Might;
            statsPanel.Find("Stats/DexterityText").GetComponent <Text>().text    = "Dexterity: " + Player_Accessor_Script.EquipmentScript.Dexterity;
            statsPanel.Find("Stats/IntelligenceText").GetComponent <Text>().text = "Intelligence: " + Player_Accessor_Script.EquipmentScript.Intelligence;
            statsPanel.Find("Stats/ArmorText").GetComponent <Text>().text        = "Armor: " + Player_Accessor_Script.DetailsScript.ElementalResists[ElementalResistances.PHYSICAL];
        }

        //Populating active perks
        Transform perkRoot = characterPane.Find("Attributes/Perks/Stats");

        for (int i = perkRoot.childCount - 1; i >= 0; i--)
        {
            DestroyImmediate(perkRoot.GetChild(i).gameObject);
        }

        for (int i = 0; i < playerEquipment.ActivePerks.Count; i++)
        {
            GameObject entry = Instantiate(perkCardEntry, perkRoot, false);
            entry.GetComponent <Text>().text = playerEquipment.ActivePerks[i].ToString().Replace('_', ' ');
        }
    }
Exemplo n.º 3
0
    public void EquipItem(int slot)
    {
        if (!weaponSlotsUnlocked[currentWeaponSlot])
        {
            return;
        }

        Item itemRef = inventory.FetchItemInSlot(slot);

        if (itemRef == null)
        {
            return;
        }

        if (itemRef.MyItemType == ItemType.WEAPON)
        {
            Weapon wep = (inventory.PullItemFromInventory("Weapon", slot) as Weapon);
            if (wep == null)
            {
                return;
            }

            if (wep.perks == null)
            {
                wep.perks = new List <LegendaryPerk>();
            }

            for (int i = 0; i < wep.perks.Count; i++)
            {
                ActivePerks.Add(wep.perks[i]);
            }

            if (wep == null)
            {
                return;
            }

            wep.lib = aLib;
            wep.PopulateSkills();

            if (equippedWeapon != null)
            {
                for (int i = 0; i < equippedWeapon.perks.Count; i++)
                {
                    ActivePerks.Remove(equippedWeapon.perks[i]);
                }
                for (int i = 0; i < 4; i++)
                {
                    if (equippedWeapon.SkillSet[i] != null)
                    {
                        equippedWeapon.SkillSet[i].isSelected = false;
                        equippedWeapon.SkillSet[i]            = null;
                    }
                }
                inventory.AddItemToInventory(equippedWeapon);
            }

            equippedWeapon = wep;
            foreach (GameObject weapon in weaponLinkModel)
            {
                weapon.SetActive(false);
                if (weapon.name == wep.Type.ToString())
                {
                    weapon.SetActive(true);
                }
            }

            switch (currentWeaponSlot)
            {
            case (0):
                firstSlot = wep;
                break;

            case (1):
                secondSlot = wep;
                break;

            case (2):
                thirdSlot = wep;
                break;

            case (3):
                fourthSlot = wep;
                break;

            default:
                firstSlot = wep;
                break;
            }
        }
        else if (itemRef.MyItemType == ItemType.HELMET || itemRef.MyItemType == ItemType.PLATELEGS || itemRef.MyItemType == ItemType.CHESTPLATE)
        {
            Armor armorRef;
            if (itemRef.MyItemType == ItemType.HELMET)
            {
                armorRef = inventory.PullItemFromInventory("", slot) as Helmet;
                if (Helmet != null)
                {
                    inventory.AddItemToInventory(Helmet);
                }

                Helmet = armorRef;
            }
            else if (itemRef.MyItemType == ItemType.CHESTPLATE)
            {
                armorRef = inventory.PullItemFromInventory("", slot) as Chestplate;
                if (Chestplate != null)
                {
                    inventory.AddItemToInventory(Chestplate);
                }

                Chestplate = armorRef;
            }
            else if (itemRef.MyItemType == ItemType.PLATELEGS)
            {
                armorRef = inventory.PullItemFromInventory("", slot) as Platelegs;
                if (LegArmor != null)
                {
                    inventory.AddItemToInventory(LegArmor);
                }

                LegArmor = armorRef;
            }
        }
        else if (itemRef.MyItemType == ItemType.TOOL)
        {
            //UnequipTool();
            //EquipTool();
        }
        abilities_Interface.UpdateSkillCooldowns();
        abilities_Interface.UpdateSkillIcons();
        Ability_Select_Interface.instance.ResetRefIndex();
        SaveCharacterData();
        inventory.SaveInventory();
        GetComponent <Player_Details_Script>().MaxHealth = BonusHealth;
    }