コード例 #1
0
ファイル: DropTable.cs プロジェクト: billybillyjim/Quepland_2
    public Drop GetDrop()
    {
        if (Drops.Count == 0)
        {
            Console.WriteLine("DropTable unset for monster.");
            return(null);
        }
        int size = Drops.Select(x => x.Weight).Sum();
        int roll = rand.Next(0, size + 1);

        foreach (Drop drop in Drops)
        {
            if (roll <= drop.Weight)
            {
                //MessageManager.AddMessage("You received " + drop.Amount + " " + drop.ItemName + ".");

                return(drop);
            }
            roll -= drop.Weight;
        }
        return(null);
    }