Exemplo n.º 1
0
    public void DropItem()
    {
        WeightedRoll chanceToDrop = new WeightedRoll(
            new WeightedParam(() => _dropChance = 0, 100),
            new WeightedParam(() => _dropChance = 1, dropWeight));

        chanceToDrop.Execute();

        //Debug.Log(_dropChance);
        if (_dropChance == 1)
        {
            int       equipRoll = Random.Range(0, EquipmentDrops.Capacity);
            IdlerName idler     = (IdlerName)Random.Range(0, 7);

            Equipment drop = new Equipment(ItemDatabase.GetRandomEquipment());

            WeightedRoll gradeRoll = new WeightedRoll(
                new WeightedParam(() => drop.SelectGrade(GradeType.Common), GradeWeights[0]),
                new WeightedParam(() => drop.SelectGrade(GradeType.Uncommon), GradeWeights[1]),
                new WeightedParam(() => drop.SelectGrade(GradeType.Rare), GradeWeights[2]),
                new WeightedParam(() => drop.SelectGrade(GradeType.Epic), GradeWeights[3]),
                new WeightedParam(() => drop.SelectGrade(GradeType.Legendary), GradeWeights[4]));

            gradeRoll.Execute();
            drop.SetStats(idler);

            Player.Instance.AddItem(drop);
        }
    }
Exemplo n.º 2
0
    public void InstantiateAnItem()
    {
        Equipment clone = new Equipment(ItemDatabase.GetEquipmentByID(LootTable[Random.Range(0, LootTable.Capacity)]));
        IdlerName idler = (IdlerName)Random.Range(0, 7);

        WeightedRoll roll = new WeightedRoll(
            new WeightedParam(() => clone.SelectGrade(GradeType.Common), 30),
            new WeightedParam(() => clone.SelectGrade(GradeType.Uncommon), 10),
            new WeightedParam(() => clone.SelectGrade(GradeType.Rare), 5),
            new WeightedParam(() => clone.SelectGrade(GradeType.Epic), 3),
            new WeightedParam(() => clone.SelectGrade(GradeType.Legendary), 1));

        roll.Execute();

        clone.SetStats(idler);

        Player.Instance.AddItem(clone);
    }