protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("AwardPointsObserver: {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!"); } // Delay - Awards points later //AwardPointsObserver pObserver = new AwardPointsObserver(this); //DelayedObjectManager.Attach(pObserver); //Debug.WriteLine("{0} awarding {1} Points", this, this.pInvader.value); GameManager.AwardPoints(this.pInvader.value); }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("Grid_Observer: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); // Grid will always be pObjB GameObject pGameObjA = pColSubject.pObjA; GameObject pGameObjB = pColSubject.pObjB; Debug.Assert(pGameObjA != null); Debug.Assert(pGameObjB != null); InvaderGrid pGrid = null; if (pGameObjA.name == GameObject.Name.InvaderGrid) { pGrid = (InvaderGrid)pGameObjA; } else if (pGameObjB.name == GameObject.Name.InvaderGrid) { pGrid = (InvaderGrid)pGameObjB; } else { Debug.Assert(false, "Neither of the objects are InvaderGrid"); } pGrid.SetState(InvaderGridManager.State.CollidingRightWall); }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("RemoveShipObserver: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); // Missle will always be pObjA GameObject pGameObjA = pColSubject.pObjA; GameObject pGameObjB = pColSubject.pObjB; Debug.Assert(pGameObjA != null); Debug.Assert(pGameObjB != null); Ship pShip = null; if (pGameObjA.name == GameObject.Name.Ship) { pShip = (Ship)pGameObjA; } else if (pGameObjB.name == GameObject.Name.Ship) { pShip = (Ship)pGameObjB; } else { Debug.Assert(false, "Neither of the objects are Ship"); } if (pShip.bMarkForDeath == false) { pShip.bMarkForDeath = true; // Delay - remove object later //RemoveShipObserver pObserver = new RemoveShipObserver(); //DelayedObjectManager.Attach(pObserver); //Debug.WriteLine("~~~~ {0} MARKING SHIP FOR DEATH ~~~~~", this); } }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("RemoveShieldBrickObserver: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); // No Clue which is which so just check the names GameObject pGameObjA = pColSubject.pObjA; GameObject pGameObjB = pColSubject.pObjB; Debug.Assert(pGameObjA != null); Debug.Assert(pGameObjB != null); if (pGameObjA.name == GameObject.Name.ShieldBrick) { this.pShieldBrick = pGameObjA; } else if (pGameObjB.name == GameObject.Name.ShieldBrick) { this.pShieldBrick = pGameObjB; } else { Debug.Assert(false, "Neither of the objects are shields"); } if (this.pShieldBrick.bMarkForDeath == false) { this.pShieldBrick.bMarkForDeath = true; // Delay - remove object later RemoveShieldBrickObserver pObserver = new RemoveShieldBrickObserver(this); DelayedObjectManager.Attach(pObserver); } }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("ShipRemoveMissileObserver: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); // Missle will always be pObjA GameObject pGameObjA = pColSubject.pObjA; GameObject pGameObjB = pColSubject.pObjB; Debug.Assert(pGameObjA != null); Debug.Assert(pGameObjB != null); Missile pMissile = null; if (pGameObjA.name == GameObject.Name.Missle) { pMissile = (Missile)pGameObjA; } else if (pGameObjB.name == GameObject.Name.Missle) { pMissile = (Missile)pGameObjB; } else { Debug.Assert(false, "Neither of the objects are Missle"); } if (pMissile.bMarkForDeath == false) { pMissile.bMarkForDeath = true; // Delay - remove object later ShipRemoveMissileObserver pObserver = new ShipRemoveMissileObserver(); DelayedObjectManager.Attach(pObserver); } }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("ShipMissileReadyObserver: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); Ship pShip = ShipManager.GetShip(); pShip.SetShootState(ShipManager.ShootState.MissileReady); }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("Ship_WallRightObserver: {0} vs {1}", pColSubject.pObjA.name, pColSubject.pObjB.name); // Obj B will always be ship Ship pShip = (Ship)pColSubject.pObjB; pShip.SetMotionState(ShipManager.MotionState.LeftOnly); }
//EDIT THE FOLLOWING METHODS--------------------- public ColPair() : base() { this.treeA = null; this.treeB = null; this.name = ColPair.Name.Blank; this.index = 0; this.poSubject = new ColSubject(); }
public ColPair() : base() { this.treeA = null; this.treeB = null; this.name = ColPair.Name.Uninitialized; this.poSubject = new ColSubject(); Debug.Assert(this.poSubject != null); }
public ColPair() : base() { this.treeA = null; this.treeB = null; this.name = ColPair.Name.Not_Initialized; this.poSubject = new ColSubject(this); Debug.Assert(this.poSubject != null); this.bMarkForDeath = false; }
protected override void derivedUpdate(ColSubject pColSubject) { //Debug.WriteLine("[Observer({4})] ColPair {5}({3}) - RemoveCollisionPairObserver: {0} vs {1}({2})", pColSubject.pObjA.name, pColSubject.pObjB.name, pColSubject.pObjB.GetHashCode(), this.pColPair.GetHashCode(), this.GetHashCode(), this.pColPair.name); //Debug.WriteLine(this.pColPair + "MARKED FOR DEATH"); if (this.pColPair.bMarkForDeath == false) { //ColPairManager.PrintReport(); this.pColPair.bMarkForDeath = true; //Delay - remove object later RemoveCollisionPairObserver pObserver = new RemoveCollisionPairObserver(this); DelayedObjectManager.Attach(pObserver); } }
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); } }
public Observer() { next = null; subj = null; }
protected override void derivedUpdate(ColSubject pColSubject) { SpeedUpGridMarchObserver pObserver = new SpeedUpGridMarchObserver(this.speedUpMultiplier); DelayedObjectManager.Attach(pObserver); }
public void setSubject(ColSubject subject) { subj = subject; }
protected abstract void derivedUpdate(ColSubject pColSubject);
public void set(Type t, GameObject.Name tA, GameObject.Name tB) { this.treeA = GameObjectManager.find(tA); this.treeB = GameObjectManager.find(tB); this.type = t; this.subject = new ColSubject(); collided = false; }