public static void Update() { //ensure call Create() first GameObjectMan pMan = GameObjectMan.GetInstance(); Debug.Assert(pMan != null); GameObjectNode pGameObjectNode = (GameObjectNode)pMan.baseGetActiveList(); while (pGameObjectNode != null) { ReverseIterator pRev = new ReverseIterator(pGameObjectNode.getGameObject()); Component pNode = pRev.first(); while (!pRev.isDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.update(); pNode = pRev.next(); } pGameObjectNode = (GameObjectNode)pGameObjectNode.pNext; } }
// Updates all the nodes in the tree public static void update() { GameObjectNodeManager gamMInstance = GameObjectNodeManager.getSingletonInstance(); Debug.Assert(gamMInstance != null); GameObjectNode root = (GameObjectNode)gamMInstance.activeList; Debug.Assert(root != null); while (root != null) { // PCSTreeForwardIterator pcsTreeIter = new PCSTreeForwardIterator(root.getGameObject()); PCSTreeReverseIterator pcsTreeIter = new PCSTreeReverseIterator(root.getGameObject()); Debug.Assert(pcsTreeIter != null); //iterate all the nodes inside the roots GameObject gameObj = (GameObject)pcsTreeIter.First(); while (!pcsTreeIter.IsDone()) { gameObj.update(); gameObj = (GameObject)pcsTreeIter.Next(); } root = (GameObjectNode)root.pNext; } }
public override void remove() { this.poCollisionObject.poCollisionRect.Set(0, 0, 0, 0); base.update(); // update parent (missile root) GameObject pParent = (GameObject)this.pParent; pParent.update(); // remove it base.remove(); }
//--------------------------------------------------------------------------------------------------------- // Override abstract method //--------------------------------------------------------------------------------------------------------- public override void remove() { // the root object is being drawn // 1. set size to zero this.poCollisionObject.poCollisionRect.Set(0, 0, 0, 0); base.update(); // 2. update the parent GameObject pParent = (GameObject)this.pParent; pParent.update(); // remove it base.remove(); }
public static StraightMissile activateMissile() { ShipManager shipMan = ShipManager.getSingleton(); Debug.Assert(shipMan != null); GameObjectNode gon = GameObjectNodeManager.findGameObjectNode(GameObject.GameObjectName.MissileRoot); PCSTree pcsTree = gon.getPCSTree(); GameObject gameObj = gon.getGameObject(); Debug.Assert(pcsTree != null); Debug.Assert(gameObj != null); // StraightMissile missile = new StraightMissile(GameObject.GameObjectName.StraightMissile, Sprite.SpriteName.Straight, 1, 400, 100f,Missile.MissileType.Straight); ///to do StraightMissile missile = (StraightMissile)FactoryManager.getMissileFactry().createMissile(Missile.MissileType.StraightMissile, GameObject.GameObjectName.StraightMissile, 1, 300, 200); //StraightMissile missile = (StraightMissile)GhostManager.find(GameObject.GameObjectName.StraightMissile); //if(missile==null) //{ // missile = (StraightMissile)FactoryManager.getMissileFactry().createMissile(Missile.MissileType.StraightMissile, GameObject.GameObjectName.StraightMissile, 1, 300, 200); //} //StraightMissile missile = (StraightMissile)GhostManager.find(GameObject.GameObjectName.StraightMissile); shipMan.missile = missile; // SpriteBatch missileBatch = SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Missiles); // SpriteBatch boxBatch = SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Boxes); // Debug.Assert(missileBatch != null); // Debug.Assert(boxBatch != null); // missile.addSpriteToBatch(missileBatch); // missile.addCollisionToBatch(boxBatch); GameObject pMissileRoot = GameObjectNodeManager.find(GameObject.GameObjectName.MissileRoot); Debug.Assert(pMissileRoot != null); ///////////////////////////Not sure // pcsTree.Insert(missile, pMissileRoot); // pcsTree.GetRoot. pMissileRoot.update(); return(missile); }