protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine(this.GetHashCode() + " RemoveBombObserver: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); // Bomb will always be pObjB GameObject pGameObjA = pColSubject.pObjA; GameObject pGameObjB = pColSubject.pObjB; Debug.Assert(pGameObjA != null); Debug.Assert(pGameObjB != null); if (pGameObjA.name == GameObject.Name.Bomb) { this.pBomb = (Bomb)pGameObjA; } else if (pGameObjB.name == GameObject.Name.Bomb) { this.pBomb = (Bomb)pGameObjB; } else { Debug.Assert(false, "Neither of the objects are Bombs"); } //Debug.WriteLine("Set state of Invader to true" + this.pBomb.pInvaderWhoDroppedMe); if (this.pBomb.bMarkForDeath == false) { this.pBomb.pInvaderWhoDroppedMe.canLaunchBomb = true; pBomb.bMarkForDeath = true; OneTimeAnimation pDeathAnimation = new OneTimeAnimation(Sprite.Name.BombDeath, this.pBomb.x, this.pBomb.y); pDeathAnimation.Attach(Image.Name.BombDeath); TimerManager.Add(TimeEvent.Name.InvaderDeath, pDeathAnimation, 0.1f); // Delay - remove object later RemoveBombObserver pObserver = new RemoveBombObserver(this); DelayedObjectManager.Attach(pObserver); } }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("RemoveInvaderObserver: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); if (pColSubject.pObjA.name == GameObject.Name.SmallInvader || pColSubject.pObjA.name == GameObject.Name.MediumInvader || pColSubject.pObjA.name == GameObject.Name.LargeInvader || pColSubject.pObjA.name == GameObject.Name.UFO) { this.pInvader = (InvaderCategory)pColSubject.pObjA; } else if (pColSubject.pObjB.name == GameObject.Name.SmallInvader || pColSubject.pObjB.name == GameObject.Name.MediumInvader || pColSubject.pObjB.name == GameObject.Name.LargeInvader || pColSubject.pObjB.name == GameObject.Name.UFO) { this.pInvader = (InvaderCategory)pColSubject.pObjB; } else { Debug.Assert(false, "Neither Object is not an Invader!"); } Debug.Assert(this.pInvader != null); if (pInvader.bMarkForDeath == false) { pInvader.bMarkForDeath = true; OneTimeAnimation pDeathAnimation = new OneTimeAnimation(Sprite.Name.InvaderDeath, this.pInvader.x, this.pInvader.y); pDeathAnimation.Attach(Image.Name.InvaderDeath2); pDeathAnimation.Attach(Image.Name.InvaderDeath1); TimerManager.Add(TimeEvent.Name.InvaderDeath, pDeathAnimation, 0.05f); // Delay - remove object later RemoveInvaderObserver pObserver = new RemoveInvaderObserver(this); DelayedObjectManager.Attach(pObserver); } }