I am trying to write a simple war game - tile based. Each unit has several characteristics that I would like to store in some sort of custom array but I have not been able to work out how.
Fow instance, each unit has the following characteristics:
- Name (string)
- Cost (integer)
- Movement (integer)
- Attack (integer)
- Defense (integer)
- Wounded (boolean)
I was hoping to make some sort of custom array so I could do the following:
unit(5).attack = 4
unit(6).name = "dave"
Unfortunately, I haven't the faintest idea how to do this. I tried messing around with creating a custom class (based on the collection superclass) but I couldn't get it to work.
Could anyone offer any suggestions please?
Fow instance, each unit has the following characteristics:
- Name (string)
- Cost (integer)
- Movement (integer)
- Attack (integer)
- Defense (integer)
- Wounded (boolean)
I was hoping to make some sort of custom array so I could do the following:
unit(5).attack = 4
unit(6).name = "dave"
Unfortunately, I haven't the faintest idea how to do this. I tried messing around with creating a custom class (based on the collection superclass) but I couldn't get it to work.
Could anyone offer any suggestions please?