public void MoveGrid() { // Initialize PCSTreeForwardIterator pIterator = new PCSTreeForwardIterator(this); Debug.Assert(pIterator != null); PCSNode pNode = pIterator.First(); while (!pIterator.IsDone()) { // delta GameObject pGameObj = (GameObject)pNode; pGameObj.x += this.delta; // Advance pNode = pIterator.Next(); } this.total += this.delta; if (this.total > 400.0f || this.total < 0.0f) { this.delta *= -1.0f; } }
public static GameObject Find(GameObjectName goName, int index = 0) { GameObjectManager goMan = GameObjectManager.GetInstance(); GameObjectNode pRoot = (GameObjectNode)goMan.pActive; GameObject pGameObj = null; bool found = false; while (pRoot != null && found == false) { PCSTreeForwardIterator iter = new PCSTreeForwardIterator(pRoot.pGameObject); pGameObj = (GameObject)iter.First(); while (!iter.IsDone()) { if ((pGameObj.gameObjectName == goName) && (pGameObj.index == index)) { found = true; break; } pGameObj = (GameObject)iter.Next(); } pRoot = (GameObjectNode)pRoot.pDNext; } return(pGameObj); }
private void privMoveGrid() { PCSTreeForwardIterator iterator = new PCSTreeForwardIterator(this); Debug.Assert(iterator != null); PCSNode pNode = iterator.First(); while (!iterator.IsDone()) { Bomb bomb = (Bomb)pNode; if (bomb.active) { bomb.y -= this.delta; } //gameObj.y -= this.delta; pNode = iterator.Next(); } }
//public static GameObject Find(GameObject.Name name) //{ // //get the singleton // GameObjectManager pMan = privGetInstance(); // // Compare functions only compares two Nodes // GameObjectManager.pRefNode.pGameObj.SetName(name); // GameObjectNode pNode = (GameObjectNode)pMan.baseFindNode(GameObjectManager.pRefNode); // Debug.Assert(pNode != null); // return pNode.pGameObj; //} public static GameObject Find(GameObject.Name name, int index = 0) { GameObjectManager pMan = GameObjectManager.privGetInstance(); // Compare functions only compares two Nodes GameObjectManager.pRefNode.pGameObj.SetName(name); GameObjectManager.pRefNode.pGameObj.index = index; GameObjectNode pRoot = (GameObjectNode)pMan.baseGetActive(); GameObject pGameObj = null; bool found = false; while (pRoot != null && found == false) { // OK at this point, I have a Root tree, // need to walk the tree completely before moving to next tree //forward navigation PCSTreeForwardIterator pIterator = new PCSTreeForwardIterator(pRoot.pGameObj); // Initialize pGameObj = (GameObject)pIterator.First(); //while (pGameObj != null) while (!pIterator.IsDone()) { //check for both matching name and index if (pGameObj.GetName() == GameObjectManager.pRefNode.pGameObj.GetName() && pGameObj.index == GameObjectManager.pRefNode.pGameObj.index) { found = true; break; } // Advance pGameObj = (GameObject)pIterator.Next(); } // Goto Next tree pRoot = (GameObjectNode)pRoot.pMNext; } return(pGameObj); }
public static void Update() { GameObjectManager pMan = GameObjectManager.privGetInstance(); //get the root game object GameObjectNode pRoot = (GameObjectNode)pMan.baseGetActive(); while (pRoot != null) { // OK at this point, I have a Root tree, // need to walk the tree completely before moving to next tree //todo double check on forward or reverse iteration //PCSTreeIterator pIterator = new PCSTreeIterator(pRoot.pGameObj); PCSTreeForwardIterator pIterator = new PCSTreeForwardIterator(pRoot.pGameObj); //PCSTreeReverseIterator pIterator = new PCSTreeReverseIterator(pRoot.pGameObj); // Initialize the first game object pointer GameObject pGameObj = (GameObject)pIterator.First(); //iterate through and update all GameObjects in this tree/subtree //Debug.WriteLine("-------"); while (!pIterator.IsDone()) { //Debug.WriteLine(" {0}", pGameObj.GetName()); pGameObj.Update(); // Advance pGameObj = (GameObject)pIterator.Next(); } // Go to next tree pRoot = (GameObjectNode)pRoot.pMNext; } }