View Single Post
Old 02-14-2007, 03:25 PM   #1 (permalink)
Nochte
Forum Expert
 
Join Date: Feb 2005
Age: 24
Posts: 985
Send a message via AIM to Nochte
Default Mixed-type collections?

It's been a SUPER long time since I've worked with C#, so I'm a bit fuzzy on this one.
Here's what I've got:

I have two classes; Player, and AIPlayer. AIPlayer is derived from Player. I want to use a container that will hold both types, and be able to call methods from each object as its own class. I've attempted ArrayList, using similar to the following code:
Code:
System.Collections.ArrayList players = new System.Collections.ArrayList();
Player one = new Player();
AIPlayer two = new AIPlayer();
players.Add(one);
players.Add(two);

players[0].Move;
players[1].Move;
...etc
players[0] returns an object, not a player or AIPlayer.
Ideas?
__________________
Quote:
Originally Posted by kkjjkk View Post
how sad you people call yourselves scripters and you can't even format an emulator game into something completely differnt....no wounder y'all are stuck here with no real scripting jobs unlike me. please go back to school.
QFDA
Nochte is offline   Reply With Quote