コード例 #1
0
ファイル: Item.cs プロジェクト: dbirtola/Clicker
    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();
        }
    }
コード例 #2
0
ファイル: Item.cs プロジェクト: dbirtola/Clicker
    //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);
    }
コード例 #3
0
 override protected void Awake()
 {
     base.Awake();
     //implicitProperty = new ItemProperty();
     implicitProperty = new CriticalChanceProperty(this);
 }