Esempio n. 1
0
    private void Start()
    {
        button.onClick.AddListener(RemoveItem);
        button.gameObject.SetActive(false);
        var tag = transform.name.Replace("Slot", "");

        ItemSlot = (Armour.PossibleArmourSlots)System.Enum.Parse(typeof(Armour.PossibleArmourSlots), tag);
    }
Esempio n. 2
0
    public void Init(int value, Armour.PossibleArmourSlots slotName)
    {
        this.ArmourValue = value;
        this.ArmourSlot  = slotName;

        if (value == 0)
        {
            armourType = Armour.ArmourType.Cloth;
        }
        else
        {
            var slotArmourValue = Armour.GetArmourValue(slotName);

            if ((float)value / slotArmourValue < 0.25)
            {
                armourType = Armour.ArmourType.Light;
            }
            else if ((float)value / slotArmourValue < 0.75)
            {
                armourType = Armour.ArmourType.Medium;
            }
            else if ((float)value / slotArmourValue < 1)
            {
                armourType = Armour.ArmourType.Heavy;
            }
        }

        Strength  = RandomNumberGenerator.GetRandom(6);
        Intellect = RandomNumberGenerator.GetRandom(6);
        Stamina   = RandomNumberGenerator.GetRandom(6);

        var attributesSum = Strength + Intellect + Stamina;

        if (attributesSum <= 5)
        {
            rarity = Armour.Rarity.Common;
        }
        else if (attributesSum <= 10)
        {
            rarity = Armour.Rarity.Rare;
        }
        else if (attributesSum <= 14)
        {
            rarity = Armour.Rarity.Epic;
        }
        else
        {
            rarity = Armour.Rarity.Legendary;
        }

        name = string.Format("{0:9} {1:8} {2:10}", rarity.ToString(), armourType.ToString(), ArmourSlot.ToString());

        var path = "images/" + ArmourSlot.ToString().ToLower();

        icon = Resources.Load <Sprite>(path);

        if (icon == null)
        {
            Debug.Log(path);
        }
    }