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); } }
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(); } }
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; } }
override public void Notify(float xCurs, float yCurs) { var inter = ColRect.Intersect(this.pFont.pFontSprite.pColRect, new ColRect(xCurs, yCurs, 1, 1)); if (!this.pState && inter) { Sound.Name sound = Sound.Name.Uninitialized; switch (this.pRandom.Next(0, 3)) { case (0): sound = Sound.Name.Invader1; break; case (1): sound = Sound.Name.Invader2; break; case (2): sound = Sound.Name.Invader3; break; case (3): sound = Sound.Name.Invader4; break; } SoundMan.PlaySound(sound); this.pFont.SetColor(1.0f, 1.0f, 1.0f); this.pState = true; } else if (!inter) { this.pState = false; this.pFont.SetColor(0.60f, 0.60f, 0.60f); } }
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); } }
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); } }
override public void Notify(float xCurs, float yCurs) { if (ColRect.Intersect(this.pFont.pFontSprite.pColRect, new ColRect(xCurs, yCurs, 1, 1))) { SceneContext.SetState(SceneContext.Scene.Select); } }
override public void Notify(float xCurs, float yCurs) { if (ColRect.Intersect(this.pFont.pFontSprite.pColRect, new ColRect(xCurs, yCurs, 1, 1))) { SceneContext.SetState(SceneContext.Scene.Aliens); SoundMan.PlaySound(Sound.Name.Shoot); } }
//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); } }