//GET: list object, delegate object public static void UseSpecialAbilities(List <Creature> creatures, IsUsable isUsable) { //loop every creature foreach (var creature in creatures) { if (isUsable(creature)) { creature.GetSpecialAbility(); } else { Console.WriteLine("Cannot used that skill!"); } } }
// // interact with object in inventory // -we want to use the primary use of the object // -so get the object at this index, and use it public void UseItemAtIndex(int index) { // if it's usable // first get the object at index // then if it's usable, use it if (index < objs.Count) { IsCollectible ic = objs[index]; if (ic != null) { // GameObject invObj = ic.gameObject; IsUsable hasUse = invObj.GetComponent <IsUsable>(); if (hasUse != null) { // //invObj.SetActive(true); Remove(ic); hasUse.Use(this.gameObject); //invObj); //dhdh - todo: make sure we pass the right collection owner here //invObj.SetActive(false); } } } }