Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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();
            }
        }
Ejemplo n.º 4
0
        //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);
        }
Ejemplo n.º 5
0
        public void moveGrid()
        {
            PCSTreeForwardIterator pcsIterator = new PCSTreeForwardIterator(this);

            Debug.Assert(pcsIterator != null);
            PCSNode    node = pcsIterator.First();
            GameObject gameObj;

            while (node != null)
            {
                gameObj    = (GameObject)node;
                gameObj.x += this.deltaX;
                if (this.edgeHit)
                {
                    gameObj.y -= this.deltaY;
                }
                node = pcsIterator.Next();
            }
            this.edgeHit = false;
        }
Ejemplo n.º 6
0
        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;
            }
        }