コード例 #1
0
        public static void Remove(GameObject pNode)
        {
            Debug.Assert(pNode != null);
            GameObjectManager pMan = GameObjectManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            // pNode may be part of a tree. If so, find it's root.
            // The root will be on the GameObjectManager's Linked list
            GameObject pRoot = null;
            GameObject pTmp  = pNode;

            while (pTmp != null)
            {
                pRoot = pTmp;
                pTmp  = (GameObject)pTmp.GetParent();
            }

            Debug.Assert(pRoot != null);

            // Now that we have the root of pNode's tree, or we have pNode if it has no parent
            // lets find that node on the GameObjectManager's Linked list
            GameObjectNode pTree = (GameObjectNode)pMan.BaseGetActive();

            while (pTree != null)
            {
                if (pTree.pGameObj == pRoot)
                {
                    // found it
                    break;
                }
                // Goto Next tree
                pTree = (GameObjectNode)pTree.GetNext();
            }

            // pTree should now be holding the node that matches Root
            Debug.Assert(pTree != null);

            // we shouldn't kills nodes with families right?
            // we aren't monsters
            Debug.Assert(pNode.GetFirstChild() == null);

            // check to see if pTree is just holding pNode or if
            // it is holding a tree containing pNode
            GameObject pNodeParent = (GameObject)pNode.GetParent();

            if (pTree.pGameObj == pNode)
            {
                // pNode is not part of a tree so just remove it.
                Debug.Assert(pNodeParent == null);
                Remove(pTree);
            }
            else
            {
                // pNode is a part of a tree so we'll use the node's
                // parent composite remove method to remove it.
                Debug.Assert(pNodeParent != null);
                pNodeParent.Remove(pNode);
            }
        }
コード例 #2
0
        public static void PullFromMemento(ManagerMemento pMemento)
        {
            GameObjectManager pMan = GameObjectManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            pMan.BasePullFromMemento(pMemento);
        }
コード例 #3
0
ファイル: GameObjectManager.cs プロジェクト: wangjo22/Final
        public static void Update()
        {
            GameObjectManager pMan = GameObjectManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            GameObjectNode pNode = (GameObjectNode)pMan.BaseGetActive();

            //= new ReverseIterator(pNode.pGameObject);

            while (pNode != null)
            {
                // Update the node
                Debug.Assert(pNode.pGameObject != null);

                //ReverseIterator pRIter = new ReverseIterator(pNode.pGameObject);
                GameObjectManager.poReverseIterator.TakeHierachy(pNode.pGameObject);
                GameObject pComponent = (GameObject)GameObjectManager.poReverseIterator.First();
                while (!poReverseIterator.IsDone())
                {
                    //pComponent.Print();
                    pComponent.Update();
                    pComponent = (GameObject)GameObjectManager.poReverseIterator.Next();
                }
                //pNode.pGameObject.Update();

                pNode = (GameObjectNode)pNode.pNext;
            }
        }
コード例 #4
0
        public static void PurgeAllNodes()
        {
            GameObjectManager pMan = GameObjectManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            // TODO this will not remove  the game objects properly or safely
            pMan.BasePurgeAllNodes();
        }
コード例 #5
0
        public static void Remove(GameObjectNode pNode)
        {
            GameObjectManager pMan = GameObjectManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            Debug.Assert(pNode != null);
            pMan.BaseRemove(pNode);
        }
コード例 #6
0
        public static void PrintReport()
        {
            Debug.WriteLine("--------------------------------------------------------------------------------");
            Debug.WriteLine("------------------------------ Game Object Manager -----------------------------");
            Debug.WriteLine("--------------------------------------------------------------------------------");

            GameObjectManager pMan = GameObjectManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            pMan.BasePrintReport();
        }
コード例 #7
0
        public static GameObjectNode Attach(GameObject pGameObject)
        {
            GameObjectManager pMan = GameObjectManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            GameObjectNode pNode = (GameObjectNode)pMan.BaseAdd();

            Debug.Assert(pNode != null);

            pNode.Set(pGameObject);
            return(pNode);
        }
コード例 #8
0
        public static GameObject Find(GameObject.Name name)
        {
            GameObjectManager pMan = GameObjectManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            // Compare functions only compares two Nodes
            pMan.poNodeCompare.pGameObj.name = name;

            GameObjectNode pNode = (GameObjectNode)pMan.BaseFind(pMan.poNodeCompare);

            Debug.Assert(pNode != null);

            return(pNode.pGameObj);
        }
コード例 #9
0
        public static void Update()
        {
            GameObjectManager pMan = GameObjectManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            GameObjectNode pNode = (GameObjectNode)pMan.BaseGetActive();

            while (pNode != null)
            {
                // Update the node
                Debug.Assert(pNode.pGameObj != null);

                pNode.pGameObj.Update();

                pNode = (GameObjectNode)pNode.GetNext();
            }
        }
コード例 #10
0
        public static void NonTreeRemove(GameObject pNode)
        {
            Debug.Assert(pNode != null);
            GameObjectManager pMan = GameObjectManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            GameObjectNode pGameObjNode = (GameObjectNode)pMan.BaseGetActive();

            while (pGameObjNode != null)
            {
                if (pGameObjNode.pGameObj == pNode)
                {
                    // found it
                    break;
                }
                // Goto Next tree
                pGameObjNode = (GameObjectNode)pGameObjNode.GetNext();
            }

            Debug.Assert(pGameObjNode != null);
            Remove(pGameObjNode);
        }