Esempio n. 1
0
        static public void FwdCollide(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}({2}), {1}({3})", pNodeA.name, pNodeB.name, pNodeA.GetHashCode(), pNodeB.GetHashCode());

                    // 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)
                        // Debug.WriteLine("Collision Detected!");
                        pNodeA.Accept(pNodeB);
                        break;
                    }

                    pNodeB = (GameObject)pNodeB.GetNextSibling();
                }

                pNodeA = (GameObject)pNodeA.GetNextSibling();
            }
        }
Esempio n. 2
0
        public static void Collide(GameObject pSafeTreeA, GameObject pSafeTreeB)
        {
            // A vs B
            GameObject pNodeA = pSafeTreeA;
            GameObject pNodeB = pSafeTreeB;

            //     Debug.WriteLine("\nColPair: start {0}, {1}", pNodeA.name, pNodeB.name);
            while (pNodeA != null)
            {
                // Restart compare
                pNodeB = pSafeTreeB;

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

                    // 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)pNodeB.pSibling;
                }
                pNodeA = (GameObject)pNodeA.pSibling;
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
0
        public override void Update()
        {
            //privMoveGrid

            // Go to first child
            PCSNode pNode = (PCSNode)this;

            pNode = pNode.pChild;

            // Set ColTotal to first child
            GameObject pGameObj = (GameObject)pNode;

            //todo add an AlienRoot to continue game after all aliens are destroyed
            //without a semi-permenant alien root, system breaks after last alien/column is destroyed,
            //thus destroying the grid and returning a null game object here;
            ColRect ColTotal = this.poColObj.poColRect;

            ColTotal.Set(pGameObj.GetColObject().poColRect);

            // loop through sliblings
            while (pNode != null)
            {
                pGameObj = (GameObject)pNode;
                ColTotal.Union(pGameObj.GetColObject().poColRect);

                // go to next sibling
                pNode = pNode.pSibling;
            }

            //this.pColObj.pColRect.Set(201, 201, 201, 201);
            this.x = this.poColObj.poColRect.x;
            this.y = this.poColObj.poColRect.y;

            //Debug.WriteLine("x:{0} y:{1} w:{2} h:{3}", ColTotal.x, ColTotal.y, ColTotal.width, ColTotal.height);

            base.baseUpdateBoundingBox();
            base.Update();
        }