Example #1
0
        protected void BaseUpdateBoundingBox(Component pStart)
        {
            GameObject pNode = (GameObject)pStart;

            // point to ColTotal
            CollisionRect ColTotal = this.poCollisionObject.poCollisionRect;

            // Get the first child
            pNode = (GameObject)Iterator.GetChild(pNode);

            if (pNode != null)
            {
                // Initialized the union to the first block
                ColTotal.Set(pNode.poCollisionObject.poCollisionRect);

                // loop through sliblings
                while (pNode != null)
                {
                    ColTotal.union(pNode.poCollisionObject.poCollisionRect);

                    // go to next sibling
                    pNode = (GameObject)Iterator.GetSibling(pNode);
                }

                //this.poColObj.poColRect.Set(201, 201, 201, 201);
                this.x = this.poCollisionObject.poCollisionRect.x;
                this.y = this.poCollisionObject.poCollisionRect.y;

                //  Debug.WriteLine("x:{0} y:{1} w:{2} h:{3}", ColTotal.x, ColTotal.y, ColTotal.width, ColTotal.height);
            }
        }
Example #2
0
        static public void Collide(GameObject pSafeTreeA, GameObject pSafeTreeB)
        {
            // A vs B
            GameObject pNodeA = pSafeTreeA;
            GameObject pNodeB = pSafeTreeB;

            while (pNodeA != null)
            {
                // Restart compare
                pNodeB = pSafeTreeB;

                while (pNodeB != null)
                {
                    // who is being tested?
                    //Debug.WriteLine("ColPair:    test:  {0}, {1}", pNodeA.name, pNodeB.name);

                    // Get rectangles
                    ColRect rectA = pNodeA.GetColObject().poColRect;
                    ColRect rectB = pNodeB.GetColObject().poColRect;

                    // test them
                    if (ColRect.Intersect(rectA, rectB))
                    {
                        // Boom - it works (Visitor in Action)
                        pNodeA.Accept(pNodeB);
                        break;
                    }

                    pNodeB = (GameObject)Iterator.GetSibling(pNodeB);
                }

                pNodeA = (GameObject)Iterator.GetSibling(pNodeA);
            }
        }
        //----------------------------------------------------------------------
        // Static methods
        //----------------------------------------------------------------------
        public static void Collide(GameObject pSafeTreeA, GameObject pSafeTreeB)
        {
            // treeA vs treeB
            GameObject pNodeA = pSafeTreeA;
            GameObject pNodeB = pSafeTreeB;

            while (pNodeA != null)
            {
                // restart compare
                pNodeB = pSafeTreeB;

                while (pNodeB != null)
                {
                    //Debug.WriteLine("ColPair:    test:  {0}, {1}", pNodeA.getName(), pNodeB.getName());

                    // get rectangles
                    CollisionRect rectA = pNodeA.poCollisionObject.poCollisionRect;
                    CollisionRect rectB = pNodeB.poCollisionObject.poCollisionRect;

                    if (CollisionRect.Intersect(rectA, rectB))
                    {
                        // when rectA and rectB are intersected
                        pNodeA.accept(pNodeB);
                        break;
                    }

                    pNodeB = (GameObject)Iterator.GetSibling(pNodeB);
                }

                pNodeA = (GameObject)Iterator.GetSibling(pNodeA);
            }
        }
        //----------------------------------------------------------------------------------
        // Static Methods
        //----------------------------------------------------------------------------------
        public static void Collide(GameObject pTreeNodeA, GameObject pTreeNodeB)
        {
            // Cache A & B
            GameObject pNodeA = pTreeNodeA;
            GameObject pNodeB = pTreeNodeB;

            while (pNodeA != null)
            {
                // Start back at the top
                pNodeB = pTreeNodeB;

                while (pNodeB != null)
                {
                    //Debug.WriteLine("ColPair:    test:  {0}, {1}", pNodeA.GetName(), pNodeB.GetName());

                    // Get Rectangles
                    CollRect rectA = pNodeA.GetCollObj().poColRect;
                    CollRect rectB = pNodeB.GetCollObj().poColRect;

                    // Check
                    if (CollRect.Intersect(rectA, rectB))
                    {
                        // Success, liftoff!!
                        pNodeA.Accept(pNodeB);
                        break;
                    }

                    pNodeB = (GameObject)Iterator.GetSibling(pNodeB);
                }

                pNodeA = (GameObject)Iterator.GetSibling(pNodeA);
            }
        }
Example #5
0
        protected void BaseUpdateBoundingBox(Component pStart)
        {
            GameObject pNode = (GameObject)pStart;

            // point to ColTotal
            CollRect ColTotal = this.poCollObj.poColRect;

            ColTotal.width  = 0;
            ColTotal.height = 0;

            // Get the first child
            pNode = (GameObject)Iterator.GetChild(pNode);

            if (pNode != null)
            {
                // Initialized the union to the first block
                ColTotal.Set(pNode.poCollObj.poColRect);

                while (pNode != null)
                {
                    ColTotal.Union(pNode.poCollObj.poColRect);

                    //move onto next sibling
                    pNode = (GameObject)Iterator.GetSibling(pNode);
                }

                this.x = this.poCollObj.poColRect.x;
                this.y = this.poCollObj.poColRect.y;
            }
        }
Example #6
0
        static public void Collide(GameObject pSafeTreeA, GameObject pSafeTreeB)
        {
            GameObject pNodeA = pSafeTreeA;
            GameObject pNodeB = pSafeTreeB;

            while (pNodeA != null)
            {
                pNodeB = pSafeTreeB;

                while (pNodeB != null)
                {
                    ColRect rectA = pNodeA.GetColObject().poColRect;
                    ColRect rectB = pNodeB.GetColObject().poColRect;

                    if (ColRect.Intersect(rectA, rectB))
                    {
                        pNodeA.Accept(pNodeB);
                        break;
                    }

                    pNodeB = (GameObject)Iterator.GetSibling(pNodeB);
                }

                pNodeA = (GameObject)Iterator.GetSibling(pNodeA);
            }
        }
Example #7
0
        static public void Collide(GameObject pSafeTreeA, GameObject pSafeTreeB)
        {
            GameObject pNodeA = pSafeTreeA;
            GameObject pNodeB = pSafeTreeB;



            while (pNodeA != null)
            {
                pNodeB = pSafeTreeB;

                while (pNodeB != null)
                {
                    //Debug.WriteLine("ColPair:    test:  {0}, {1}", pNodeA.GetName(), pNodeB.GetName() );

                    ColRect rectA = pNodeA.GetColObject().poColRect;
                    ColRect rectB = pNodeB.GetColObject().poColRect;

                    //check if their is a collision
                    if (ColRect.Intersect(rectA, rectB))
                    {
                        //then see what the reaction is
                        pNodeA.Accept(pNodeB);

                        break;
                    }

                    pNodeB = (GameObject)Iterator.GetSibling(pNodeB);
                }

                pNodeA = (GameObject)Iterator.GetSibling(pNodeA);
            }
        }
Example #8
0
        // method for classes that inherit from Game Object
        // updates x, y, height, and width for the collision rectangle that encapsulates the child collission rectangles
        protected void BaseUpdateBoundingBox(Component pStart)
        {
            GameObject pNode = (GameObject)pStart;

            //get collision retangle so we can update in a loop of it's children
            ColRect ColTotal = this.poColObj.poColRect;

            //Get its first child so we can do a loop
            pNode = (GameObject)Iterator.GetChild(pNode);

            if (pNode != null)
            {
                //make "this" parent collision rectangle start off
                //as the size of its first child
                ColTotal.Set(pNode.poColObj.poColRect);

                //Now we loop through children
                //and make parent collision box bigger via a union method
                while (pNode != null)
                {
                    ColTotal.Union(pNode.poColObj.poColRect);

                    pNode = (GameObject)Iterator.GetSibling(pNode);
                }


                this.x = this.poColObj.poColRect.x;
                this.y = this.poColObj.poColRect.y;
            }
        }
Example #9
0
        static public void Collide(GameObject pSafeTreeA, GameObject pSafeTreeB)
        {
            // A vs B
            GameObject pNodeA = pSafeTreeA;
            GameObject pNodeB = pSafeTreeB;

            while (pNodeA != null)
            {
                // Restart compare
                pNodeB = pSafeTreeB;

                while (pNodeB != null)
                {
                    // Get rectangles
                    ColRect rectA = pNodeA.poColObj.poColRect;
                    ColRect rectB = pNodeB.poColObj.poColRect;

                    // test them
                    if (ColRect.Intersect(rectA, rectB))
                    {
                        // Boom - it works (Visitor in Action)
                        pNodeA.Accept(pNodeB);
                        break;
                    }

                    pNodeB = (GameObject)Iterator.GetSibling(pNodeB);
                }

                pNodeA = (GameObject)Iterator.GetSibling(pNodeA);
            }
        }
Example #10
0
        //FOR THE RECORD
        //I'm not proud of this, but i created another collision with a slight difference for columns
        // i'm breaking the D.R.Y rule, but i'm sucking right now
        static public void CollideColumns(GameObject pSafeTreeA, GameObject pSafeTreeB)
        {
            GameObject pNodeA = pSafeTreeA;
            GameObject pNodeB = pSafeTreeB;

            while (pNodeA != null)
            {
                pNodeB = pSafeTreeB;

                while (pNodeB != null)
                {
                    //Debug.WriteLine("ColPair:    test:  {0}, {1}", pNodeA.GetName(), pNodeB.GetName());

                    ColRect rectA = pNodeA.GetColObject().poColRect;
                    ColRect rectB = pNodeB.GetColObject().poColRect;

                    //check if their is a collision
                    if (ColRect.Intersect(rectA, rectB))
                    {
                        //then see what the reaction is
                        pNodeA.Accept(pNodeB);
                        break;
                    }

                    //this is the change and questionable part
                    //finicky when the aliens weren't close enough
                    Component pComp = (Component)pNodeB.pNext;

                    //Checked all the Columns and there weren't any collisions so... continue
                    if (pComp == null)
                    {
                        break;
                    }

                    //check the next column
                    if (pComp.holder == Component.Container.COMPOSITE)
                    {
                        Component pTemp    = (Component)pNodeB;
                        Component pParent  = pTemp.pParent;
                        Component pSibling = ForwardIterator.GetSibling(pParent);

                        //if there are no more columns check the children of the last column?
                        if (pSibling == null)
                        {
                            pNodeB = (GameObject)ForwardIterator.GetChild(pNodeB);
                            continue;
                        }

                        pNodeB = (GameObject)ForwardIterator.GetChild(pSibling);
                        continue;
                    }
                    pNodeB = (GameObject)Iterator.GetSibling(pNodeB);
                }

                pNodeA = (GameObject)Iterator.GetSibling(pNodeA);
            }
        }
        public void DropBomb()
        {
            GameObject temp = (GameObject)this.GetFirstChild();

            while (temp != null)
            {
                if (temp.pProxySprite.pSprite.name != GameSprite.Name.NullObject)
                {
                    this.state.DropBomb(this);
                    break;
                }
                temp = (GameObject)Iterator.GetSibling(temp);
            }
        }
Example #12
0
        public void Shoot()
        {
            AliensCol shootingCol = (AliensCol)Iterator.GetChild(this);
            int       size        = children.Size();
            int       col         = Rand.GetNext(1, size);

            if (Iterator.GetSibling(shootingCol) != null)
            {
                for (int i = 0; i < col; i++)
                {
                    shootingCol = (AliensCol)Iterator.GetSibling(shootingCol);
                }
                BombMan.InitializeBomb(shootingCol.x, shootingCol.y - shootingCol.CollisionObj.Rect.height / 2 - 10);
            }
        }
Example #13
0
        protected void BaseUpdateBoundingBox(Component pStart)
        {
            GameObject pNode    = (GameObject)pStart;
            ColRect    ColTotal = this.poColObj.poColRect;

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

            if (pNode != null)
            {
                ColTotal.Set(pNode.poColObj.poColRect);
                while (pNode != null)
                {
                    ColTotal.Union(pNode.poColObj.poColRect);
                    pNode = (GameObject)Iterator.GetSibling(pNode);
                }

                this.x = this.poColObj.poColRect.x;
                this.y = this.poColObj.poColRect.y;
            }
        }
Example #14
0
        public static void Collide(GameObject pSafeTreeA, GameObject pSafeTreeB)
        {
            GameObject NodeA = pSafeTreeA;
            GameObject NodeB = pSafeTreeB;

            while (NodeA != null)
            {
                NodeB = pSafeTreeB;
                while (NodeB != null)
                {
                    CollisionRect rectA = NodeA.CollisionObj.Rect;
                    CollisionRect rectB = NodeB.CollisionObj.Rect;

                    if (rectA.Intersect(rectB))
                    {
                        NodeA.Accept(NodeB);
                        break;
                    }
                    NodeB = (GameObject)Iterator.GetSibling(NodeB);
                }
                NodeA = (GameObject)Iterator.GetSibling(NodeA);
            }
        }
Example #15
0
        public override void Execute(float deltaTime)
        {
            float NewTime    = RandomManager.RandomInt(1, 3);
            float randColumn = RandomManager.RandomInt(1, 12);

            AlienGrid   pGrid   = (AlienGrid)GameObjectManager.Find(GameObject.Name.AlienGrid);
            AlienColumn pColumn = (AlienColumn)pGrid.GetFirstChild();

            AlienColumn temp = pColumn;
            int         col  = 0;

            while (temp != null)
            {
                col++;
                if (col == randColumn)
                {
                    temp.DropBomb();
                }
                temp = (AlienColumn)Iterator.GetSibling(temp);
            }

            // Add itself back to timer
            TimerManager.Add(TimeEvent.Name.DropBomb, this, NewTime);
        }
Example #16
0
        public static void Remove(GameObject pNode, SpriteBatchMan pSpriteBatchMan)
        {
            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.poGameObj == 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.poGameObj != 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.poGameObj != pNode);

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

            Debug.Assert(pParent != null);

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

            //Debug.Assert(pChild == null);
            if (pChild == null)
            {
                // remove the node
                pParent.Remove(pNode);
            }
            else
            {
                GameObject pSibling = (GameObject)Iterator.GetSibling(pChild);
                while (pSibling != null)
                {
                    pChild.Remove(pSpriteBatchMan);
                    pChild   = pSibling;
                    pSibling = (GameObject)Iterator.GetSibling(pChild);
                }
                pChild.Remove(pSpriteBatchMan);
                pParent.Remove(pNode);
            }


            // TODO - Recycle pNode
        }