public void DebugItem(Item i) { string ItemInfo = "The item name is: " + i.GetName() + " and it weighs " + i.GetWeight() + " kg"; string ExtraInfo = ""; if (i is AccessItem) { AccessItem ai = (AccessItem)i; ExtraInfo = " and open's door: " + ai.GetDoorId(); } else if (i is BonusItem) { BonusItem bi = (BonusItem)i; ExtraInfo = "and gives you: " + bi.GetPoints() + " points"; } Debug.Log(ItemInfo + ExtraInfo); }
private void DebugItem(Item i) { string itemInfo = "The item: " + i.GetName() + " weighs " + i.GetWeight() + "Kg"; string extraInfo = ""; if (i is AccessItem) { AccessItem ai = (AccessItem)i; extraInfo = " and opens door: " + ai.GetDoorId(); } else if (i is BonusItem) { BonusItem bi = (BonusItem)i; extraInfo = " and give you: " + bi.GetPoints() + " points"; } Debug.Log(itemInfo + extraInfo); }
private void DebugItem(Item i) { string defaultInfo = "ITEM CREATED: " + i.GetName() + " // " + i.GetWeight() + "KG"; string extraInfo = ""; //Interspection if (i is AccessItem) { AccessItem ai = (AccessItem)i; extraInfo = "and opens door: " + ai.GetDoorId(); } else if (i is BonusItem) { BonusItem ai = (BonusItem)i; extraInfo = "and opens door: " + ai.GetPoints(); } Debug.Log(defaultInfo + extraInfo); }
public void DebugItem(Item i) { string itemInfo = "The item's name is " + i.GetName() + " and weighs " + i.GetWeight() + " Kg"; string extraInfo = ""; if (i is AccessItem) { //casting //Transforming item 'i' in an AccessItem to access more variables AccessItem ai = (AccessItem)i; extraInfo = " and opens door: " + ai.GetDoorId(); } else if (i is BonusItem) { //casting //Transforming item 'i' in an BonusItem to access more variables BonusItem bi = (BonusItem)i; extraInfo = " and gives you: " + bi.GetPoints(); } print(itemInfo + extraInfo); }