Beispiel #1
0
        public override void VisitInvaderCategory(InvaderCategory pInvader)
        {
            //Debug.WriteLine("in ShieldZone, visit from InvaderCategory");
            GameObject pGameObj = (GameObject)this.GetFirstChild();

            ColPair.FwdCollide(pGameObj, pInvader);
        }
        public static InvaderCategory GetRandomBombDropper(InvaderGrid pGrid)
        {
            InvaderGridManager pMan = InvaderGridManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            InvaderCategory pTmpInvader = null;

            // Find a random bottom row invader to drop the bomb
            int           numColumns        = pGrid.GetNumChildren();
            int           randomColumnIndex = pMan.pRandom.Next(numColumns);
            InvaderColumn pColumn           = (InvaderColumn)pGrid.GetChild(randomColumnIndex);

            pTmpInvader = (InvaderCategory)pColumn.GetChild(0);

            // Check to see if the invader drop the bomb, if not go find another invader

            InvaderCategory pInvader = null;

            for (int i = 0; i < numColumns; i++)
            {
                randomColumnIndex = pMan.pRandom.Next(numColumns);
                pColumn           = (InvaderColumn)pGrid.GetChild(randomColumnIndex);
                pTmpInvader       = (InvaderCategory)pColumn.GetChild(0);
                if (pTmpInvader.canLaunchBomb)
                {
                    pInvader = pTmpInvader;
                    break;
                }
            }

            return(pInvader);
        }
        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);
        }
Beispiel #4
0
 public Bomb(GameObject.Name name, Sprite.Name spriteName, BoxSprite.Name boxSpriteName, float posX, float posY)
     : base(name, spriteName, boxSpriteName)
 {
     this.x      = posX;
     this.y      = posY;
     this.speedY = -5.0f;
     this.pInvaderWhoDroppedMe = null;
 }
Beispiel #5
0
        public override void VisitInvaderCategory(InvaderCategory pInvader)
        {
            //Debug.WriteLine("   --->DONE<----");
            ColPair pColPair = ColPairManager.GetActiveColPair();

            Debug.Assert(pColPair != null);
            pColPair.SetCollision(this, pInvader);
            pColPair.NotifyListeners();
        }
Beispiel #6
0
        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 override void Wash()
 {
     this.pInvader = null;
 }
 public AwardPointsObserver(AwardPointsObserver pRIObserver)
 {
     this.pInvader = pRIObserver.pInvader;
 }
Beispiel #9
0
 public virtual void VisitInvaderCategory(InvaderCategory pInvader)
 {
     // no differed to subcass
     Debug.WriteLine("Visit by InvaderCategory not implemented");
     Debug.Assert(false);
 }
Beispiel #10
0
 public RemoveInvaderObserver()
 {
     this.pInvader = null;
 }
Beispiel #11
0
 public RemoveInvaderObserver(RemoveInvaderObserver pRIObserver)
 {
     this.pInvader = pRIObserver.pInvader;
 }
 public RemoveUFOObserver(RemoveUFOObserver pRUObserver)
 {
     this.pInvader = pRUObserver.pInvader;
 }
 public RemoveUFOObserver(IrrKlang.ISound pHardwareSound)
 {
     this.pInvader       = null;
     this.pHardwareSound = pHardwareSound;
 }
Beispiel #14
0
        public Bomb Create(Type type)
        {
            InvaderCategory pInvader = InvaderGridManager.GetRandomBombDropper(this.pInvaderGrid);
            Bomb            pBomb    = null;

            if (pInvader != null)
            {
                float posX = pInvader.x;
                float posY = pInvader.y;

                switch (type)
                {
                case Type.Plain:
                    pBomb = new Bomb(GameObject.Name.Bomb, Sprite.Name.BombPlain, BoxSprite.Name.BombBox, posX, posY);
                    break;

                case Type.ZigZag:
                    pBomb = new Bomb(GameObject.Name.Bomb, Sprite.Name.BombZigZag, BoxSprite.Name.BombBox, posX, posY);
                    break;

                case Type.Dagger:
                    pBomb = new Bomb(GameObject.Name.Bomb, Sprite.Name.BombDagger, BoxSprite.Name.BombBox, posX, posY);
                    break;

                case Type.Rolling:
                    pBomb = new Bomb(GameObject.Name.Bomb, Sprite.Name.BombRolling, BoxSprite.Name.BombBox, posX, posY);
                    break;

                default:
                    // something is wrong
                    Debug.Assert(false, "Bomb type not supported by this factory");
                    break;
                }

                // set pointer back to invader who dropped the bomb
                pBomb.pInvaderWhoDroppedMe = pInvader;
                pBomb.pInvaderWhoDroppedMe.canLaunchBomb = false; //block this invader from dropping another bomb until curren bomb dies

                // add it to the gameObjectManager
                Debug.Assert(pBomb != null);
                GameObjectManager.Attach(pBomb);

                // Attached to Batches
                this.pBoxSpriteBatch.Attach(pBomb.poColObj.pColSprite);
                this.pSpriteBatch.Attach(pBomb.pProxySprite);

                // Add Collision Pairs and Observers
                ColPair pMissile_BombColPair = ColPairManager.Add(ColPair.Name.Missile_Bomb, pBomb, ShipManager.GetMissile());
                Debug.Assert(pMissile_BombColPair != null);

                ColPair pBomb_FloorColPair = ColPairManager.Add(ColPair.Name.Bomb_Floor, pBomb, pWallMan.GetFloor());
                Debug.Assert(pBomb_FloorColPair != null);

                ColPair pBomb_ShipColPair = ColPairManager.Add(ColPair.Name.Bomb_Ship, pBomb, ShipManager.GetShip());
                Debug.Assert(pBomb_ShipColPair != null);

                // Observers for Bomb vs Missile
                pMissile_BombColPair.Attach(new RemoveCollisionPairObserver(pMissile_BombColPair));
                pMissile_BombColPair.Attach(new RemoveCollisionPairObserver(pBomb_FloorColPair));
                pMissile_BombColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShipColPair));
                pMissile_BombColPair.Attach(new ShipMissileReadyObserver());
                pMissile_BombColPair.Attach(new ShipRemoveMissileObserver());
                pMissile_BombColPair.Attach(new RemoveBombObserver());

                //// Observers for Bomb vs Floor
                pBomb_FloorColPair.Attach(new RemoveCollisionPairObserver(pBomb_FloorColPair));
                pBomb_FloorColPair.Attach(new RemoveCollisionPairObserver(pMissile_BombColPair));
                pBomb_FloorColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShipColPair));
                pBomb_FloorColPair.Attach(new RemoveBombObserver());

                // Observers for Bomb vs Ship
                pBomb_ShipColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShipColPair));
                pBomb_ShipColPair.Attach(new RemoveCollisionPairObserver(pBomb_FloorColPair));
                pBomb_ShipColPair.Attach(new RemoveCollisionPairObserver(pMissile_BombColPair));
                pBomb_ShipColPair.Attach(new RemoveShipObserver());
                pBomb_ShipColPair.Attach(new RemoveBombObserver());


                GameObject pShieldZone = GameObjectManager.UnsafeFind(GameObject.Name.ShieldZone);
                if (pShieldZone != null)
                {
                    // Add Collision pair for Bomb vs Shields
                    ColPair pBomb_ShieldColPair = ColPairManager.Add(ColPair.Name.Bomb_Shield, pBomb, pShieldZone);
                    Debug.Assert(pBomb_ShieldColPair != null);

                    // Added observers to previous shield pairs to remove the bomb vs shield col pair
                    pMissile_BombColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShieldColPair));
                    pBomb_FloorColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShieldColPair));
                    pBomb_ShipColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShieldColPair));

                    // Observers for Bomb vs Shield
                    pBomb_ShieldColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShieldColPair));
                    pBomb_ShieldColPair.Attach(new RemoveCollisionPairObserver(pBomb_FloorColPair));
                    pBomb_ShieldColPair.Attach(new RemoveCollisionPairObserver(pMissile_BombColPair));
                    pBomb_ShieldColPair.Attach(new RemoveCollisionPairObserver(pBomb_ShipColPair));
                    pBomb_ShieldColPair.Attach(new RemoveBombObserver());
                    pBomb_ShieldColPair.Attach(new RemoveShieldBrickObserver());
                }
            }

            return(pBomb);
        }
Beispiel #15
0
 public override void Remove()
 {
     this.pInvaderWhoDroppedMe = null;
     base.Remove();
 }