Beispiel #1
0
        protected override void DerivedWash(DLink pDLink)
        {
            Debug.Assert(pDLink != null);
            GONode pNode = (GONode)pDLink;

            pNode.Clear();
        }
Beispiel #2
0
        protected override void DerivedDumpNode(DLink pDLink)
        {
            Debug.Assert(pDLink != null);
            GONode pNode = (GONode)pDLink;

            pNode.DumpGONode();
        }
Beispiel #3
0
        protected override DLink DerivedCreateNode()
        {
            DLink pNode = new GONode();

            Debug.Assert(pNode != null);

            return(pNode);
        }
Beispiel #4
0
        //to destroy game objects that are hit
        public static void Dettach(GameObject pGameObject)
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            //Remeber: a doublly linked list of trees

            //whatever game object we get, we have to travel up its tree
            // to its its tree's root/ upper most parent
            Debug.Assert(pGameObject != null);
            GameObject pTemp = pGameObject;

            GameObject pRoot = null;

            while (pTemp != null)
            {
                pRoot = pTemp;
                pTemp = (GameObject)Iterator.GetParent(pTemp);
                //keep traveling up the tree

                //exit out at the top of the tree
            }

            //Found the tree our game object is in
            // now go traverse the DLink list to that tree
            GONode pTree = (GONode)pGOMan.BaseGetActive();

            while (pTree != null)
            {
                //check if the game objects match
                if (pTree.poGameObject == pRoot)
                {
                    break;
                }

                pTree = (GONode)pTree.pNext;
            }

            //Now we are in the tree with the Game Object
            //we need to remove
            Debug.Assert(pTree != null);
            Debug.Assert(pTree.poGameObject != null);

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

            Debug.Assert(pParent != null);


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

            Debug.Assert(pChild == null);

            //finally
            //Remove Gamobject from its parent composite
            pParent.Remove(pGameObject);
        }
Beispiel #5
0
        public static void Remove(GONode pNode)
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            Debug.Assert(pNode != null);
            pGOMan.BaseRemove(pNode);
        }
Beispiel #6
0
        private GONodeMan(int reserverNum = 3, int growth = 1)
            : base()
        {
            this.BaseIntialize(reserverNum, growth);

            this.poNodeCompare = new GONode();
            this.poNullGO      = new NullGO();

            this.poNodeCompare.poGameObject = this.poNullGO;
        }
Beispiel #7
0
        public static GONode Attach(GameObject pGObject)
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            GONode pNode = (GONode)pGOMan.BaseAdd();

            Debug.Assert(pNode != null);

            pNode.Set(pGObject);
            return(pNode);
        }
Beispiel #8
0
        public static GameObject Find(GameObject.Name name)
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            pGOMan.poNodeCompare.poGameObject.SetName(name);

            GONode pNode = (GONode)pGOMan.BaseFind(pGOMan.poNodeCompare);

            Debug.Assert(pNode != null);

            return(pNode.poGameObject);
        }
Beispiel #9
0
        protected override bool DerivedCompare(DLink pDLink1, DLink pDLink2)
        {
            Debug.Assert(pDLink1 != null);
            Debug.Assert(pDLink2 != null);

            GONode pSNode1 = (GONode)pDLink1;
            GONode pSNode2 = (GONode)pDLink2;

            Boolean status = false;

            if (pSNode1.poGameObject.GetName() == pSNode2.poGameObject.GetName())
            {
                status = true;
            }

            return(status);
        }
Beispiel #10
0
        public static void Update()
        {
            // go through active list and update everything in it
            // while loop

            GONodeMan pMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pMan != null);

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

            GONode pGONode = (GONode)pMan.BaseGetActive();


            while (pGONode != null)
            {
                //Debug.WriteLine("update: GameObjectTree {0} ({1})", pGONode.poGameObject, pGONode.poGameObject.GetHashCode());
                //Debug.WriteLine("   +++++");
                if (pGONode.poGameObject.GetPlayerOption() == true)
                {
                    ReverseIterator pRev = new ReverseIterator(pGONode.poGameObject);

                    //need to update the children 1st then work our way back up the tree
                    // So depth first(ReverseIterator)
                    // maintaines integrity of the bounding collision rectangles
                    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("   ------");
                    pGONode = (GONode)pGONode.pNext;
                }
            }
        }