Exemple #1
0
        static public GameObject GetSiblingGameObject(GameObject pNode)
        {
            Debug.Assert(pNode != null);
            GameObject pGameObj = (GameObject)ForwardIterator.GetSibling(pNode);

            return(pGameObj);
        }
Exemple #2
0
        protected void BaseUpdateBoundingBox()
        {
            // Go to first child
            Component  pComponent = (Component)this;
            GameObject pNode      = (GameObject)ForwardIterator.GetChild(pComponent);

            Debug.Assert(pNode != null);

            CollisionRect ColTotal = this.pCollisionObject.GetCollisionRect();

            ColTotal.Set(pNode.GetCollisionObject().GetCollisionRect());

            // loop through sliblings
            while (pNode != null)
            {
                ColTotal.Union(pNode.GetCollisionObject().GetCollisionRect());

                // go to next sibling
                pComponent = ForwardIterator.GetSibling(pNode);

                if (pComponent != null)
                {
                    pNode = (GameObject)pComponent;
                }
                else
                {
                    pNode = null;
                }
            }

            this.x = this.GetCollisionObject().GetCollisionRect().x;
            this.y = this.GetCollisionObject().GetCollisionRect().y;

            //Debug.WriteLine("x:{0} y:{1} w:{2} h:{3}", ColTotal.x, ColTotal.y, ColTotal.width, ColTotal.height);
        }
Exemple #3
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);
            }
        }
Exemple #4
0
        static public GameObject GetSiblingGameObject(GameObject pNode)
        {
            GameObject pGameObj = null;

            Component pComponent = ForwardIterator.GetSibling(pNode);

            if (pComponent != null)
            {
                pGameObj = (GameObject)pComponent;
            }

            return(pGameObj);
        }
Exemple #5
0
        protected void BaseUpdateBoundingBox()
        {
            GameObject pNode = (GameObject)ForwardIterator.GetChild(this);
            CollisionRect pBigRect = this.pColObject.pColRect;
            if (pNode != null)
            {
                pBigRect.Set(pNode.pColObject.pColRect);
            }
            while (pNode != null)
            {
                pBigRect.Union(pNode.pColObject.pColRect);
                pNode = (GameObject)ForwardIterator.GetSibling(pNode);
            }

            this.x = this.pColObject.pColRect.x;
            this.y = this.pColObject.pColRect.y;
        }