Graphics Reference
In-Depth Information
public void InitNewBattle()
{
// initialize our hashtables ready for putting objects into
battlePositions= new Hashtable();
battleFinished= new Hashtable();
battleControllers= new Hashtable();
sortedPositions= new Hashtable();
currentID=0;
numberOfBattlers=0;
}
public int GetUniqueID(BattleController theBattleController)
{
// whenever an id is requested, we increment the ID counter.
// this value never gets reset, so it should always
// return a unique id (NOTE: these are unique to each battle)
currentID++;
// now set up some default data for this new player
if(battlePositions==null)
InitNewBattle();
// this player will be in last position
battlePositions.Add(currentID, battlePositions.Count + 1);
// store a reference to the battle controller, to talk to later
battleControllers.Add ( currentID, theBattleController );
// default finished state
battleFinished[currentID]=false;
// increment our battler counter so that we don't have to do
// any counting or lookup whenever we need it
numberOfBattlers++;
// pass this id back out for the battle controller to use
return currentID;
}
public void SetBattlePosition(int anID, int aPos)
{
if(battlePositions.ContainsKey(anID))
{
// we already have an entry in the battle positions
// table, so let's modify it
battlePositions[anID]=aPos;
} else {
// we have no data for this player yet, so let's add
// it to the battlePositions hashtable
battlePositions.Add(anID,aPos);
}
}
public int GetBattlePosition(int anID)
{
// just returns the entry for this ID in the battlePositions
// hashtable
Search WWH ::




Custom Search