//Ask the manager for an item //Randomly select a type of item to generate //return null if there is no availability for that type public Item GetItem() { //get a random number between 0 and 100 int chance = PROP.random.Next(0, 101); ItemType typeToMake = ItemType.Life; //default item GameObject obj = null; //object to put inside the item //Determine which item to return //if no item return null //if no items of the random type chosen remain, return null also if (chance >= chanceLife.X && chance <= chanceLife.Y) { if (HasRemaining(ItemType.Life)) { obj = new Life(); typeToMake = ItemType.Life; } } else if (chance >= chanceWeapon.X && chance <= chanceWeapon.Y) { if (HasRemaining(ItemType.Weapon)) { //randomly select a weapon type form available list int rand = PROP.random.Next(0, weapons.Count); obj = Creator.CreateWeapon(weapons[rand]); typeToMake = ItemType.Weapon; } } else { return null; } if (obj == null) return null; else return Creator.CreateItem(typeToMake, obj, ref slider); }
public void GiveLife() { Life l = new Life(); l.LoadContent(); lives.Add(l); }