public void InitDrop(string[] s) { int index = 0; int length = s.Length; while (index < length) { string str = s[index]; char[] separator = new char[] { ',' }; string[] strArray = str.Split(separator); EntityMonsterBase.DropData item = new EntityMonsterBase.DropData { GoodID = int.Parse(strArray[0]), Weight = int.Parse(strArray[1]) }; this.mDropList.Add(item); this.DropWeight += item.Weight; index++; } }
public int GetRandom() { int num = GameLogic.Random(0, this.DropWeight); int num2 = 0; int count = this.mDropList.Count; while (num2 < count) { EntityMonsterBase.DropData data = this.mDropList[num2]; if (num < data.Weight) { if (data.GoodID > 0) { return(data.GoodID); } break; } num -= data.Weight; num2++; } return(0); }