//----------------------------------------------------------------------------------
        // Abstract Methods
        //----------------------------------------------------------------------------------

        public override void Notify()
        {
            // Delete missile
            //Debug.WriteLine("RemoveBrickObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            this.pAlien = (AlienGO)this.pSubject.pObjB;


            Debug.Assert(this.pAlien != null);

            if (pAlien.bMarkForDeath == false)
            {
                //Award points
                int points = ((AlienGO)this.pAlien).GetPoints();
                Debug.WriteLine(" +{0} points!", points);
                Score.IncreaseScore(points);
                Score.Refresh();

                pAlien.bMarkForDeath = true;
                //   Delay
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                DelayedObjectManager.Attach(pObserver);
            }
            else
            {
                pAlien.bMarkForDeath = true;
            }
        }
示例#2
0
        private RemoveAlienObserver(RemoveAlienObserver m)
        {
            Debug.Assert(m.pAlien != null);
            this.pAlien = m.pAlien;

            this.pEvent = new RemoveAlienEvent();
        }
示例#3
0
        public override void Update()
        {
            //Debug.WriteLine("RemoveAlienObserver: {0} {1}", this.pSubject.goA, this.pSubject.goB);
            GameObject pAlien = this.pSubject.goB;

            if (pAlien.markedForDeath == false)
            {
                pAlien.markedForDeath = true;
                RemoveAlienObserver pObserver = new RemoveAlienObserver(pAlien);
                DelayedGameObjectManager.Attach(pObserver);
            }
        }
        public RemoveAlienObserver(RemoveAlienObserver m)
        {
            Debug.Assert(m.pAlien != null);
            this.pAlien = m.pAlien;

            this.pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);
            Debug.Assert(this.pSB_Aliens != null);

            this.pSB_Boxes = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);
            Debug.Assert(this.pSB_Boxes != null);

            this.scenePlay = m.scenePlay;
        }
示例#5
0
        public override void Notify()
        {
            this.pAlien = this.pSubject.pObjB;

            if (this.pAlien.bMarkForDeath == false)
            {
                this.pAlien.bMarkForDeath = true;

                // Delay - remove object later
                // TODO - reduce the new functions
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                DelayedObjectManager.Attach(pObserver);
            }
        }
        public override void Notify()
        {
            this.pGameObj = (GameObject)this.pSubject.pObjA;
            this.pAlien   = (AlienCategory)this.pSubject.pObjB;
            Debug.Assert(this.pAlien != null);

            if (pAlien.bMarkForDeath == false)
            {
                pAlien.bMarkForDeath = true;
                //   Delay
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                DelayedObjectMan.Attach(pObserver);
            }
        }
示例#7
0
        //---------------------------------------------------------------------------------------------------------
        // Override abstract method
        //---------------------------------------------------------------------------------------------------------
        public override void notify()
        {
            //Debug.WriteLine("RemoveAlien_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            this.pAlien = this.pSubject.pObjA;
            Debug.Assert(this.pAlien != null);

            if (pAlien.bMarkForDeath == false)
            {
                pAlien.bMarkForDeath = true;
                //   Delay
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                DelayedObjectMan.Attach(pObserver);
            }
        }
示例#8
0
 public override void Execute(float deltaTime, TimeEvent.Name name)
 {
     if (this.pGameObject.bMarkForDeath == false)
     {
         this.pGameObject.bMarkForDeath = true;
         //   Delay
         //switch (this.pGameObject.name)
         //{
         //    case GameObject.Name.Ship:
         //        ShipMan.DettachShip();
         //        break;
         //}
         RemoveAlienObserver pObserver = new RemoveAlienObserver(pSpriteBatchMan);
         pObserver.SetGameObject(this.pGameObject);
         DelayedObjectMan.Attach(pObserver);
     }
 }
        public override void Notify()
        {
            // Delete missile
            //Debug.WriteLine("RemoveBrickObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            this.pAlien = this.pSubject.pObjB;
            //Image pImage = ImageMan.Find(Image.Name.Splash);
            //this.pAlien.poProxySprite.Set(GameSprite.Name.Splash);
            //this.pAlien.Update();
            Debug.Assert(this.pAlien != null);

            if (pAlien.bMarkForDeath == false)
            {
                pAlien.bMarkForDeath = true;
                //   Delay
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this, pSpriteBatchMan);
                DelayedObjectMan.Attach(pObserver);
            }
        }
        public override void Notify()
        {
            // At this point we have two game objects
            // Actually we can control the objects in the visitor
            // Alphabetical ordering... A is missile,  B is wall

            // This cast will throw an exception if I'm wrong
            this.pAlien = (AlienCategory)this.pSubject.pObjB;

            if (pAlien.bMarkForDeath == false)
            {
                pAlien.bMarkForDeath = true;

                // Delay - remove object later
                // TODO - reduce the new functions
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                DelayedObjectMan.Attach(pObserver);
            }
        }
示例#11
0
        public override void Notify()
        {
            //remove alien
            //Debug.WriteLine("RemoveAlienObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            //a little tricky ObjA is the missile, we are not alphabetical
            //because of how the missile observer is set up
            this.pAlien = (AlienCategory)this.pSubject.pObjB;
            Debug.Assert(this.pAlien != null);



            if (pAlien.bMarkForDeath == false)
            {
                pAlien.bMarkForDeath = true;

                if (pAlien.GetName() == GameObject.Name.Squid)
                {
                    PlayerMan.SetP1Score(30);
                }

                else if (pAlien.GetName() == GameObject.Name.Crab)
                {
                    PlayerMan.SetP1Score(40);
                }

                else
                {
                    PlayerMan.SetP1Score(50);
                }

                //pass brick reference to manager thats executes/removes objects later
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                DelayedObjectMan.Attach(pObserver);
            }
        }
 public RemoveAlienObserver(RemoveAlienObserver b, SpriteBatchMan pSpriteBatchMan)
 {
     Debug.Assert(b != null);
     this.pAlien          = b.pAlien;
     this.pSpriteBatchMan = pSpriteBatchMan;
 }
示例#13
0
 public RemoveAlienObserver(RemoveAlienObserver a)
 {
     this.pAlien     = a.pAlien;
     this.pComposite = a.pComposite;
 }
示例#14
0
        public override void Notify()
        {
            //Delete Alien
            //Debug.WriteLine("RemoveShieldBrickObserver: {0} {1}", this.subject.gameObject_A, this.subject.gameObject_B);

            //set this observer's alien object as the subject's pointer object that got hit
            //this.pAlienObj = (AlienType)this.pSubject.pObjB;
            this.pAlienObj = (GameObject)this.pSubject.pObjB;
            Debug.Assert(this.pAlienObj != null);

            //set the alien object as markedForDeath
            if (this.pAlienObj.markForDeath == false)
            {
                this.pAlienObj.markForDeath = true;

                ////hold the x, y coordinates of the target alien;
                //int index = pAlienObj.index;
                //float target_X = pAlienObj.pProxySprite.x;
                //float target_Y = pAlienObj.pProxySprite.y;

                ////create the alien explosion object to temporarily replace the normal alien object in the grid
                //ExplodingAlien pExplodeAlien = new ExplodingAlien(GameObject.Name.ExplodingAlien, GameSprite.Name.AlienExplosion, index, target_X, target_Y);

                ////get the right sprite batch and activate the explosion sprite
                //SpriteBatch pSB_GameSprites = SpriteBatchManager.Find(SpriteBatch.Name.GameSprites);
                //SpriteBatch pSB_Boxes = SpriteBatchManager.Find(SpriteBatch.Name.SpriteBoxes);

                ////activate the game and collision sprites
                //pExplodeAlien.ActivateGameSprite(pSB_GameSprites);
                //pExplodeAlien.ActivateCollisionSprite(pSB_Boxes);

                ////hold a pointer to old alien and its parent;
                //GameObject targetAlien = (GameObject)this.pAlienObj;
                //GameObject parentColumn = (GameObject)targetAlien.pParent;

                ////make sure the parent exists;
                //Debug.Assert(parentColumn != null);

                ////remove the alien
                //targetAlien.Remove();
                //Debug.WriteLine("removing alien {0} at x:{1}, y: {2}, sx: {3}, sy: {4}", targetAlien.pProxySprite.pSprite.GetName(),
                //    targetAlien.pProxySprite.x,
                //    targetAlien.pProxySprite.y,
                //    targetAlien.pProxySprite.sx,
                //    targetAlien.pProxySprite.sy
                //);

                ////hot swap the object pointers!
                ////set this remove alien's pAlienObj pointer to explosion alien;
                //this.pAlienObj = pExplodeAlien;

                ////insert the explosion alien as a child of column (where old alien used to be)
                //PCSTree rootGamObjTree = GameObjectManager.GetRootTree();
                //Debug.Assert(rootGamObjTree != null);

                ////update the coordinate data to render in old spot (GameObjectManager already called update)
                //this.pAlienObj.Update();

                //rootGamObjTree.Insert(this.pAlienObj, parentColumn);

                //Debug.WriteLine("added exploding alien {0} at x:{1}, y: {2}, sx: {3}, sy: {4}", pExplodeAlien.pProxySprite.pSprite.GetName(),
                //    pExplodeAlien.pProxySprite.x,
                //    pExplodeAlien.pProxySprite.y,
                //    pExplodeAlien.pProxySprite.sx,
                //    pExplodeAlien.pProxySprite.sy
                //);

                //Debug.WriteLine("added this pAlienObj {0} at x:{1}, y: {2}, sx: {3}, sy: {4}", this.pAlienObj.pProxySprite.pSprite.GetName(),
                //    this.pAlienObj.pProxySprite.x,
                //    this.pAlienObj.pProxySprite.y,
                //    this.pAlienObj.pProxySprite.sx,
                //    this.pAlienObj.pProxySprite.sy
                //);


                ////before removal, swap the sprite of JUST THIS ALIEN'S sprite image to the explosion sprite
                ////this forces ALL sprites to do the pop animation. dumb proxy sprites
                //this.pAlienObj.ChangeImage(Image.Name.AlienExplosionPop);

                //test - try and hot swap proxy sprite with this game sprite?
                //Azul.Rect pProxySpriteRect = this.pAlienObj.pProxySprite.pSprite.GetScreenRect();
                //Azul.Color white = new Azul.Color(1, 1, 1);
                //Image pImage = ImageManager.Find(Image.Name.AlienExplosionPop);

                float currentTime = Simulation.GetTimeStep();
                float totalTime   = Simulation.GetTotalTime();


                //Delay
                //todo create an ObserverManager or refactor DelayObjectManager to pool observer objects - avoid using new at all cost!
                RemoveAlienObserver observer = new RemoveAlienObserver(this);
                DelayedObjectManager.Attach(observer);
            }
            else
            {
                Debug.Assert(false);
            }
        }
示例#15
0
 public RemoveAlienObserver(RemoveAlienObserver a)
 {
     Debug.Assert(a != null);
     this.pAlienObj = a.pAlienObj;
 }
示例#16
0
 public RemoveAlienObserver(RemoveAlienObserver m)
 {
     Debug.Assert(m != null);
     this.pAlien = m.pAlien;
 }
示例#17
0
        public override void Notify()
        {
            // Delete missile
            //Debug.WriteLine("RemoveAlienObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // This cast will throw an exception if wrong
            this.pAlien     = (Alien)this.pSubject.pObjA;
            this.pComposite = null;

            // Remove Alien from composite
            Composite       pAlienGrid = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.AlienGrid);
            ForwardIterator pFwdIter   = new ForwardIterator(pAlienGrid);

            Component pNode = pFwdIter.First();

            while (!pFwdIter.IsDone())
            {
                if (pNode.containerType == Component.Container.LEAF)
                {
                    // If Component is target alien
                    if (pNode.GetHashCode() == this.pAlien.GetHashCode())
                    {
                        // Remove Alien from column
                        pNode.pParent.Remove(pNode);

                        Component parentComposite = pNode.pParent;
                        // If column is now empty, delete column
                        if (parentComposite.GetFirstChild() == null)
                        {
                            // Delete empty column from parent composite
                            if (parentComposite.pParent != null)
                            {
                                parentComposite.pParent.Remove(parentComposite);
                            }

                            if (!((GameObject)parentComposite).IsMarkedForDeath())
                            {
                                // Delay - remove object later
                                this.pComposite = (GameObject)parentComposite;
                                this.pComposite.MarkForDeath();
                            }
                        }

                        break;
                    }
                }

                pNode = pFwdIter.Next();
            }

            if (!pAlien.IsMarkedForDeath())
            {
                pAlien.MarkForDeath();

                // Delay - remove object later
                RemoveAlienObserver pObserver = new RemoveAlienObserver(this);
                GameStateManager.GetGame().GetStateDelayedObjectManager().Attach(pObserver);
            }

            // Faster grid speed (shorter delta)
            float newSpeed = GameStateManager.GetGame().GetStateAlienGridSpeed() - 0.013f;

            if (newSpeed > 0.0f)
            {
                // Increase Alien Grid Speed
                GameStateManager.GetGame().SetStateAlienGridSpeed(newSpeed);
            }
        }
示例#18
0
 public RemoveAlienObserver(RemoveAlienObserver b)
 {
     this.pAlien = b.pAlien;
 }
 public RemoveAlienObserver(RemoveAlienObserver b)
 {
     Debug.Assert(b != null);
     this.pAlien   = b.pAlien;
     this.pGameObj = b.pGameObj;
 }