public void build(cBiota pbiota) { removeAll(); //Clear it out. for (int i = 0; i < pbiota.Size; i++) { for (int j = i + 1; j < pbiota.Size; j++) { smartAdd(pbiota.GetAt(i), pbiota.GetAt(j)); } } }
//Constructors public cGame() { _seedcount = COUNTSTART; _gameover = false; _maxscore = MAXSCORE; _scorecorrection = 0; _wrapflag = cCritter.WRAP; _bDragging = false; _pfocus = null; _pplayer = null; _border = new cRealBox3(cGame.WORLDWIDTH, cGame.WORLDHEIGHT); //Default no zsize, computes faster. _pskybox = null; _cursorpos = new cVector3(0.0f, 0.0f); _level = 1; _spritetype = cGame.ST_SPRITETYPENOTUSED; _menuflags = (cGame.MENU_ALL & ~cGame.MENU_AUTOPLAY & ~cGame.MENU_HOPPER); _newgame = true; //Fix the static readonlys /* Reset the various static readonlys that may have been set to different values by previously * running some other game. */ cCritter.Maxspeed = cGame.CRITTERMAXSPEED; cCritter.MinRadius = cGame.CRITTERMINRADIUS; cCritter.MaxRadius = cGame.CRITTERMAXRADIUS; cCritter.BulletRadius = cGame.BULLETRADIUS; //Allocate the pointer variables. _pbiota = new cBiota(this); _pcollider = new cCollider(); _pcontroller = Framework.Keydev; _plightingmodel = new cLightingModel(true); //Default lighting model enables lights. setBorder(cGame.WORLDWIDTH, cGame.WORLDHEIGHT, 0.0f); // setBorder initializes _pskybox as well //Set the player, we want to make sure a game always has a player setPlayer(new cCritterPlayer(this)); //Sets _pplayer AND adds it to _pbiota. }
public cGame(cBiota pbiota) { _pcollider = new cCollider(); _pcontroller = Framework.Keydev; _pbiota = pbiota; _pbiota.setGame(this); _pfocus = new cCritter(); _border = new cRealBox3(); _pskybox = new cSpriteTextureBox(); _plightingmodel = new cLightingModel(); _cursorpos = new cVector3(); //Deleting the _pbiota killed off your _pplayer, so you need to get a new one. if (_pbiota.Size > 0) // use the first member of pbiota if there is one. { _pplayer = _pbiota.GetAt(0); } else //otherwise make a dummy. { _pplayer = new cCritter(); cCritter pdummyplayer = new cCritter(); setPlayer(pdummyplayer); } }