Esempio n. 1
0
        public static void Reset()
        {
            //ensure call Create() first
            GameObjectMan pMan = GameObjectMan.GetInstance();

            Debug.Assert(pMan != null);

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

            while (pGameObjectNode != null)
            {
                Component pGameObject = (Component)pGameObjectNode.getGameObject();
                while (pGameObject.holder == Component.Container.Composite)
                {
                    Composite pComposite = (Composite)pGameObject;

                    pGameObject       = (Component)pComposite.poHead;
                    pComposite.poHead = null;
                    pComposite.poLast = null;
                    if (pGameObject == null || pGameObject.holder == Component.Container.Leaf)
                    {
                        break;
                    }
                }

                pGameObjectNode = (GameObjectNode)pGameObjectNode.pNext;
            }
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
        public static void Remove(GameObjectNode pNode)
        {
            //ensure call Create() first
            GameObjectMan pMan = GameObjectMan.GetInstance();

            Debug.Assert(pMan != null);

            Debug.Assert(pMan != null);
            pMan.baseRemove(pNode);
        }
Esempio n. 4
0
        public static void Destory()
        {
            //ensure call Create() first
            GameObjectMan pMan = GameObjectMan.GetInstance();

            Debug.Assert(pMan != null);

            pMan.baseDestory();

            pMan.poNodeForCompare   = null;
            pMan.poNullGameObject   = null;
            GameObjectMan.pInstance = null;
        }
Esempio n. 5
0
        public static GameObjectNode Attach(GameObject pGameObject)
        {
            //ensure call Create() first
            GameObjectMan pMan = GameObjectMan.GetInstance();

            Debug.Assert(pMan != null);

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

            Debug.Assert(pNode != null);

            pNode.set(pGameObject);
            return(pNode);
        }
Esempio n. 6
0
        public static GameObject Find(GameObject.Name name)
        {
            //ensure call Create() first
            GameObjectMan pMan = GameObjectMan.GetInstance();

            Debug.Assert(pMan != null);

            pMan.poNodeForCompare.getGameObject().setName(name);

            GameObjectNode pNode = (GameObjectNode)pMan.baseFind(pMan.poNodeForCompare);

            Debug.Assert(pNode != null);

            return(pNode.getGameObject());
        }
Esempio n. 7
0
        public static void Remove(GameObject pNode)
        {
            Debug.Assert(pNode != null);

            //ensure call Create() first
            GameObjectMan pMan = GameObjectMan.GetInstance();

            Debug.Assert(pMan != null);

            // 1. find tree root
            GameObject pTmp  = pNode;
            GameObject pRoot = null;

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

            // 2. pRoot is the tree we looking for, walk the active list looking for pTree
            GameObjectNode pTree = (GameObjectNode)pMan.baseGetActiveList();

            while (pTree != null)
            {
                if (pTree.getGameObject() == pRoot)
                {
                    break;
                }

                // go to next tree
                pTree = (GameObjectNode)pTree.pNext;
            }

            // 3. pTree is the tree that holds pNode, remove pNode from pTree
            Debug.Assert(pTree != null);
            Debug.Assert(pTree.getGameObject() != null);

            // always have a group
            Debug.Assert(pTree.getGameObject() != pNode);

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

            Debug.Assert(pParent != null);

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