Esempio n. 1
0
        /// <summary>
        /// Drop table
        /// </summary>
        protected void DropItems()
        {
            Random random = new Random();

            if (DropTable.Count > 0)
            {
                // get a random index from the drop table
                int   randomIndex = random.Next(0, DropTable.Count);
                float randomNum   = (float)random.NextDouble(); // gets a random float to compare to
                                                                // compare the random number to the dictionary entry at the given random index. If the randnum is less than or equal to the entry, drop the item.
                if (randomNum <= DropTable.ElementAt(randomIndex).Value)
                {
                    // drop the item at the monster positiion
                    SceneManager.GetCurrentScene().DropItemAtPosition(ItemData.New(DropTable.ElementAt(randomIndex).Key), this.Transform.Position);
                }
            }
        }