- Home /
Checking Item class
I arranged full equipment so you can put on the chest armor, helmet and other things. All items are stored as Items (thats main class), and there are also classes which inherit from Items (Weapon, Armor, Jewelry). Now in Weapon, Armor and Jewelry class i defined enums with types of following items, so for example theres Dagger, Sword and Axe in Weapons, Helmet, Chest and Gloves in Armors. Now when I equip weapon I'd like to check if the Item() (because inventory is storing everything as Item()) is actually a Weapon() or Armor(). And how after that I can access variables from those classes?
I had another enum in Item class, so I could do that without troubles, but I don't think its correct way to do it. If there's another way, please let me know.
Never $$anonymous$$d. I found that I can access those variables by typing ((Weapon)inventory[cnt])((Armor)inventory[cnt]) etc. Thanks anyways :]
You should convert that comment into an answer and accept it.
Answer by yoger · Feb 19, 2013 at 03:44 PM
Never mind. I found that I can access those variables by typing ((Weapon)inventory[cnt])((Armor)inventory[cnt]) etc. Thanks anyways :]
Your answer
Follow this Question
Related Questions
c# Unexpected symbol '=' in struct, class..... 1 Answer
I need to find inventory and item system, and to save them 0 Answers
Inventory armor wielding proplem,How to convert from derived to base 1 Answer
Inventory, Items and Equipment: is there a good way to make them? 3 Answers
'Item' class with various effects 2 Answers