Ejemplo n.º 1
0
        public void Add(int id, int weight)
        {
            WeightRandomDataBase item = new WeightRandomDataBase(id)
            {
                weight = weight
            };

            this.list.Add(item);
            this.allweight += weight;
        }
Ejemplo n.º 2
0
        public int GetRandom()
        {
            this.ran = GameLogic.Random(0, this.allweight);
            int num   = 0;
            int count = this.list.Count;

            while (num < count)
            {
                WeightRandomDataBase base2 = this.list[num];
                if (this.ran < base2.weight)
                {
                    return(base2.id);
                }
                this.ran -= base2.weight;
                num++;
            }
            throw new Exception(Utils.FormatString("WeightRandom.GetRandom Weight Random Error!!!", Array.Empty <object>()));
        }