Example #1
0
    public void AddRandomProperty()
    {
        bool wasEquipped = GetEquipped();

        if (wasEquipped)
        {
            Unequip();
        }

        ItemProperty newProperty = null;
        int          roll        = 0;

        do
        {
            roll = Random.Range(0, 6);
            switch (roll)
            {
            case 0:
                newProperty = new BonusHealthProperty(this);
                break;

            case 1:
                newProperty = new CriticalChanceProperty(this);
                break;

            case 2:
                newProperty = new CriticalDamageProperty(this);
                break;

            case 3:
                newProperty = new BonusArmorProperty(this);
                break;

            case 4:
                newProperty = new ManaPerTapProperty(this);
                break;

            case 5:
                newProperty = new PoisonDamageProperty(this);
                break;
            }
        } while (HasPropertyOfType(newProperty.GetType()) == true);

        // newProperty.Roll();
        properties.Add(newProperty);

        if (wasEquipped)
        {
            Equip();
        }
    }
Example #2
0
    //Probably a better and safer way to do this than string comparison, but this works for now

    ItemProperty AddProperty(string propertyName)
    {
        ItemProperty newProperty = null;

        switch (propertyName)
        {
        case "BonusHealthProperty":
            newProperty = new BonusHealthProperty(this);
            break;

        case "CriticalChanceProperty":
            newProperty = new CriticalChanceProperty(this);
            break;

        case "CriticalDamageProperty":
            newProperty = new CriticalDamageProperty(this);
            break;

        case "BonusArmorProperty":
            newProperty = new BonusArmorProperty(this);
            break;

        case "ManaPerTapProperty":
            newProperty = new ManaPerTapProperty(this);
            break;

        case "PoisonDamageProperty":
            newProperty = new PoisonDamageProperty(this);
            break;

        default:
            Debug.LogError("Unable to load property of type: " + propertyName);
            return(null);
        }

        Debug.Log("Loaded property: " + newProperty.GetType().ToString());
        properties.Add(newProperty);

        return(newProperty);
    }