Exemplo n.º 1
0
    private void UnequipItem(I_item itemToUnequip)
    {
        switch (GetItemType(itemToUnequip))
        {
        case "ArmorGem":

            ArmorGem ag = (ArmorGem)itemToUnequip;
            playerStats.ArmBonus        -= ag.ArmBonus;
            playerStats.HealthRegen     -= ag.HpRegenBonus;
            playerStats.ManaRegen       -= ag.MpRegenBonus;
            playerStats.StrBonus        -= ag.StrBonus;
            playerStats.DexBonus        -= ag.DexBonus;
            playerStats.IntBonus        -= ag.IntBonus;
            playerStats.FireResistance  -= ag.FireResBonus;
            playerStats.WaterResistance -= ag.WaterResBonus;
            playerStats.EarthResistance -= ag.EarthResBonus;
            playerStats.WindResistance  -= ag.WindResBonus;

            break;

        case "WeaponGem":

            WeaponGem wp = (WeaponGem)itemToUnequip;
            playerStats.ChargePower -= wp.ChargePwrBonus;
            playerStats.AtkBonus    -= wp.AtkDmgBonus;
            playerStats.StrBonus    -= wp.StrBonus;
            playerStats.DexBonus    -= wp.DexBonus;
            playerStats.IntBonus    -= wp.IntBonus;
            playerStats.FireDamage  -= wp.FireDmgBonus;
            playerStats.WaterDamage -= wp.WaterDmgBonus;
            playerStats.EarthDamage -= wp.EarthDmgBonus;
            playerStats.WindDamage  -= wp.WindDmgBonus;

            break;
        }

        playerStats.UpdateBaseStats();
        UpdateStatInfo();
    }
Exemplo n.º 2
0
    private void GenerateTooltip(bool isEmpty)
    {
        Text  itemName     = itemInfo.transform.GetChild(0).GetComponent <Text>();
        Text  itemTier     = itemInfo.transform.GetChild(1).GetComponent <Text>();
        Text  itemHeader   = itemInfo.transform.GetChild(2).GetComponent <Text>();
        Text  itemDesc     = itemInfo.transform.GetChild(3).GetComponent <Text>();
        Image windowBorder = itemInfo.transform.GetChild(6).GetComponent <Image>();

        List <Text> statList = new List <Text>();
        Dictionary <string, float> foundStats = new Dictionary <string, float>();

        for (int i = 0; i < 5; i++)
        {
            statList.Add(itemInfo.transform.GetChild(4).transform.GetChild(i).GetComponent <Text>());
        }

        for (int i = 0; i < 5; i++)
        {
            statList.Add(itemInfo.transform.GetChild(5).transform.GetChild(i).GetComponent <Text>());
        }

        Color propertyColor;

        if (!isEmpty)
        {
            I_item currentItem = invMarker.CurrentSlot.StoredItem;
            itemName.text   = currentItem.Name;
            itemDesc.text   = currentItem.Description;
            itemTier.text   = "Tier " + currentItem.Tier;
            itemHeader.text = "[" + currentItem.HeaderDescription + "]";

            switch (currentItem.Tier)
            {
            case 1:

                propertyColor      = new Color(0, 255, 0);
                itemTier.color     = propertyColor;
                windowBorder.color = propertyColor;

                break;

            case 2:

                propertyColor      = new Color(0, 255, 255);
                itemTier.color     = propertyColor;
                windowBorder.color = propertyColor;

                break;
            }

            switch (GetItemType(currentItem))
            {
            case "ArmorGem":

                propertyColor    = new Color(0, 0.3656104f, 1);
                itemHeader.color = propertyColor;

                for (int i = 0; i < statList.Count; i++)
                {
                    statList[i].text = null;
                }

                ArmorGem ag = (ArmorGem)currentItem;
                foundStats = ag.GetStats();
                int statIndex = 0;

                foreach (KeyValuePair <string, float> stat in foundStats)
                {
                    if (stat.Value > 0)
                    {
                        statList[statIndex].text = "+ " + stat.Value + " " + stat.Key;
                        statIndex++;
                    }
                    else if (stat.Value < 0)
                    {
                        statList[statIndex].text = "- " + Mathf.Abs(stat.Value) + " " + stat.Key;
                        statIndex++;
                    }
                    else
                    {
                        statList[statIndex].text = null;
                    }
                }

                break;

            case "WeaponGem":

                propertyColor    = new Color(1, 0, 0.2169275f);
                itemHeader.color = propertyColor;

                for (int i = 0; i < statList.Count; i++)
                {
                    statList[i].text = null;
                }

                WeaponGem wg = (WeaponGem)currentItem;
                foundStats = wg.GetStats();
                statIndex  = 0;

                foreach (KeyValuePair <string, float> stat in foundStats)
                {
                    if (stat.Value > 0)
                    {
                        statList[statIndex].text = "+ " + stat.Value + " " + stat.Key;
                        statIndex++;
                    }
                    else if (stat.Value < 0)
                    {
                        statList[statIndex].text = "- " + Mathf.Abs(stat.Value) + " " + stat.Key;
                        statIndex++;
                    }
                    else
                    {
                        statList[statIndex].text = null;
                    }
                }

                break;

            case "SimplePotion":

                propertyColor    = new Color(1, 0, 1);
                itemHeader.color = propertyColor;

                for (int i = 0; i < statList.Count; i++)
                {
                    statList[i].text = null;
                }

                SimplePotion sp = (SimplePotion)currentItem;
                foundStats = sp.GetStats();
                statIndex  = 0;

                foreach (KeyValuePair <string, float> stat in foundStats)
                {
                    if (stat.Key == "Recovery time")
                    {
                        statList[statIndex].text = stat.Value + "s " + stat.Key;
                    }
                    else
                    {
                        if (stat.Value > 0)
                        {
                            statList[statIndex].text = "+ " + stat.Value + " " + stat.Key;
                            statIndex++;
                        }
                        else if (stat.Value < 0)
                        {
                            statList[statIndex].text = "- " + Mathf.Abs(stat.Value) + " " + stat.Key;
                            statIndex++;
                        }
                        else
                        {
                            statList[statIndex].text = null;
                        }
                    }
                }

                break;
            }
        }
        else
        {
            itemName.text      = null;
            itemTier.text      = null;
            itemHeader.text    = null;
            itemDesc.text      = null;
            windowBorder.color = Color.white;

            for (int i = 0; i < statList.Count; i++)
            {
                statList[i].text = null;
            }
        }
    }