예제 #1
0
    private void ReadjustWeightTableAfterRemove(int removedIndex)
    {
        int weightToRemove = _weightTable[removedIndex].orb.weight;

        _weightTable.RemoveAt(removedIndex);
        int weightCount = _weightTable.Count;

        for (int weightIndex = removedIndex; weightIndex < weightCount; weightIndex++)
        {
            WeightedEntry entry = _weightTable[weightIndex];
            entry.accumulatedWeight  -= weightToRemove;
            _weightTable[weightIndex] = entry;
        }

        _totalWeight -= weightToRemove;
    }
예제 #2
0
 public RandomChoice(WeightedEntry[] entries)
 {
     this.entries = entries;
     weightSum = entries.Sum(e => e.weight);
 }