Ejemplo n.º 1
0
        public static void Update()
        {
            GameObjectMan pMan = GameObjectMan.PrivGetInstance();

            Debug.Assert(pMan != null);

            //Debug.WriteLine("---------------");

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

            while (pGameObjectNode != null)
            {
                //Debug.WriteLine("update: GameObjectTree {0} ({1})", pGameObjectNode.poGameObj, pGameObjectNode.poGameObj.GetHashCode());
                // Debug.WriteLine("   +++++");
                ReverseIterator pRev = new ReverseIterator(pGameObjectNode.poGameObj);

                Component pNode = pRev.First();
                while (!pRev.IsDone())
                {
                    GameObject pGameObj = (GameObject)pNode;

                    //Debug.WriteLine("update: {0} ({1})", pGameObj, pGameObj.GetHashCode());
                    pGameObj.Update();

                    pNode = pRev.Next();
                }

                //Debug.WriteLine("   ------");
                pGameObjectNode = (GameObjectNode)pGameObjectNode.pNext;
            }
        }
Ejemplo n.º 2
0
        public static void Remove(GameObject pNode)
        {
            Debug.Assert(pNode != null);
            GameObjectMan pMan = GameObjectMan.PrivGetInstance();

            GameObject pSafetyNode = pNode;

            // OK so we have a linked list of trees (Remember that)

            // 1) find the tree root (we already know its the most parent)

            GameObject pTmp  = pNode;
            GameObject pRoot = null;

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

            // 2) pRoot is the tree we are looking for
            // now walk the active list looking for pRoot

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

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

            // 3) pTree is the tree that holds pNode
            //  Now remove the node from that tree

            Debug.Assert(pTree != null);
            Debug.Assert(pTree.pGameObj != null);

            // Is pTree.poGameObj same as the node we are trying to delete?
            // Answer: should be no... since we always have a group (that was a good idea)

            Debug.Assert(pTree.pGameObj != pNode);

            GameObject pParent = (GameObject)Iterator.GetParent(pNode);

            Debug.Assert(pParent != null);

            GameObject pChild = (GameObject)Iterator.GetChild(pNode);

            Debug.Assert(pChild == null);

            // remove the node
            pParent.Remove(pNode);

            // Still need to optimize
        }
Ejemplo n.º 3
0
        public static void Dump()
        {
            GameObjectMan pMan = GameObjectMan.PrivGetInstance();

            Debug.Assert(pMan != null);

            pMan.BaseDump();
        }
Ejemplo n.º 4
0
        public static void Remove(GameObjectNode pNode)
        {
            GameObjectMan pMan = GameObjectMan.PrivGetInstance();

            Debug.Assert(pMan != null);

            Debug.Assert(pNode != null);
            pMan.BaseRemove(pNode);
        }
Ejemplo n.º 5
0
        public static GameObjectNode Attach(GameObject pGameObject)
        {
            GameObjectMan pMan = GameObjectMan.PrivGetInstance();

            Debug.Assert(pMan != null);

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

            Debug.Assert(pNode != null);

            pNode.Set(pGameObject);
            return(pNode);
        }
Ejemplo n.º 6
0
        public static GameObject Find(GameObject.Name name)
        {
            GameObjectMan pMan = GameObjectMan.PrivGetInstance();

            Debug.Assert(pMan != null);

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

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

            Debug.Assert(pNode != null);

            return(pNode.poGameObj);
        }
Ejemplo n.º 7
0
        public static void Destroy()
        {
            // Get the instance
            GameObjectMan pMan = GameObjectMan.PrivGetInstance();

            Debug.Assert(pMan != null);
#if (TRACK_DESTRUCTOR_MAN)
            Debug.WriteLine("--->GameSpriteMan.Destroy()");
#endif
            pMan.BaseDestroy();

#if (TRACK_DESTRUCTOR_MAN)
            Debug.WriteLine("     {0} ({1})", pMan.poNodeCompare, pMan.poNodeCompare.GetHashCode());
            Debug.WriteLine("     {0} ({1})", GameSpriteMan.pInstance, GameSpriteMan.pInstance.GetHashCode());
#endif

            pMan.poNodeCompare      = null;
            GameObjectMan.pInstance = null;
        }