Exemplo n.º 1
0
    /// <summary>
    /// This method processes the drop requests.
    /// </summary>
    private void ProcessRequest()
    {
        ItemDropInfo processDrop = _requestItemDrops.Dequeue();

        // Condition for dropping an equipment
        if (_equipments.Count != 0 && Random.Range(0, 100) < DropRateEquipment)
        {
            // Condition for dropping an item
            if (Random.Range(0, 100) < processDrop.DropRate)
            {
                _itemIndex = Random.Range(0, _equipments.Count);    // Getting the item index

                _equipments[_itemIndex].gameObject.SetActive(true); // Enabling the item

                // Dropping the item
                _equipments[_itemIndex].DropItem(Equipments, processDrop.Position);

                _equipments.RemoveAt(_itemIndex); // Removing the item from index
            }
        }
        // Condition for dropping a consumable item
        else if (_consumables.Count != 0 && Random.Range(0, 100) < DropRateConsumables)
        {
            // Condition for dropping an item
            if (Random.Range(0, 100) < processDrop.DropRate)
            {
                _itemIndex = Random.Range(0, _consumables.Count);    // Getting the item index

                _consumables[_itemIndex].gameObject.SetActive(true); // Enabling the item

                // Dropping the item
                _consumables[_itemIndex].DropItem(Consumables, processDrop.Position);

                _consumables.RemoveAt(_itemIndex); // Removing the item from index
            }
        }
        // Condition for dropping a coin item
        else if (_coins.Count != 0 && Random.Range(0, 100) < DropRateCoins)
        {
            _coins[0].gameObject.SetActive(true);             // Enabling the item

            _coins[0].SetConsumableAmount(processDrop.Value); // Setting the
                                                              // consumable
                                                              // amount

            _coins[0].DropItem(Coins, processDrop.Position);  // Dropping
                                                              // the item

            _coins.RemoveAt(0);                               // Removing the item
        }

        _isProcessing = false; // Processing done
    }
Exemplo n.º 2
0
    public void add_drop_table(Item item, float chance, RangeInt count)
    {
        var l        = DropInfos.ToList();
        var new_item = new ItemDropInfo();

        new_item.item        = item;
        new_item.drop_chance = chance;
        new_item.DropCount   = count;

        l.Add(new_item);
        DropInfos = l.ToArray();
        DropCount++;
    }