Esempio n. 1
0
        public override void Execute()
        {
            GameObject pAlienObject = (GameObject)this.pAlien;
            GameObject pColumn      = (GameObject)Iterator.GetParent(pAlienObject);

            SpaceInvaders pGame = GameMan.GetGame();


            //always remove the alien
            pAlienObject.Remove();

            //check if Column has aliens left
            //true means we have no more children, and safe to remove column
            if (PrivCheckParent(pColumn) == true)
            {
                GameObject pGroup = (GameObject)Iterator.GetParent(pColumn);
                pColumn.Remove();

                //check if Grid/Group had any columns left
                //true means we have no more children, and safe to change states
                if (PrivCheckParent(pGroup) == true)
                {
                    //We just beat a wave, so call the the states handle
                    // to either go to next wave or to see if its the end of the game
                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(true), 5.0f);
                }
            }
        }
Esempio n. 2
0
        public static void Remove(GameObject pNode)
        {
            // Keenan(delete.E)
            Debug.Assert(pNode != null);
            //GameObjectMan pMan = GameObjectMan.privGetInstance();
            GameObjectMan pMan = GameObjectMan.pActiveGOMan;

            GameObject pSafetyNode = pNode;

            // OK so we have a linked list of trees (Remember that)

            // 1) find the tree root (we already know its the most parent)

            GameObject pTmp  = pNode;
            GameObject pRoot = null;

            while (pTmp != null)
            {
                pRoot = pTmp;
                pTmp  = (GameObject)Iterator.GetParent(pTmp);
            }

            // 2) pRoot is the tree we are looking for
            // now walk the active list looking for pRoot

            GameObjectNode pTree = (GameObjectNode)pMan.baseGetActive();

            while (pTree != null)
            {
                if (pTree.pGameObj == pRoot)
                {
                    // found it
                    break;
                }
                // Goto Next tree
                pTree = (GameObjectNode)pTree.pNext;
            }

            // 3) pTree is the tree that holds pNode
            //  Now remove the node from that tree
            //Debug.Assert(pTree != null);
            //Debug.Assert(pTree.pGameObj != null);

            // Is pTree.poGameObj same as the node we are trying to delete?
            // Answer: should be no... since we always have a group (that was a good idea)
            //Debug.Assert(pTree.pGameObj != pNode);

            GameObject pParent = (GameObject)Iterator.GetParent(pNode);

            Debug.Assert(pParent != null);

            GameObject pChild = (GameObject)Iterator.GetChild(pNode);

            Debug.Assert(pChild == null);

            // remove the node
            pParent.Remove(pNode);

            // TODO - Recycle pNode
        }
Esempio n. 3
0
        public void MoveAcross()
        {
            UFORoot pUFORoot = (UFORoot)Iterator.GetParent(this);
            float   delta    = pUFORoot.GetDeltaMove();

            this.x += delta;
        }
        public override void Execute()
        {
            if (scenePlay.numLives > 1)
            {
                GameObject pA = (GameObject)this.pShip;
                GameObject pB = (GameObject)Iterator.GetParent(pA);

                pA.Remove();

                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);

                // TODO: Splat Alien - needs a better way
                this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatShip, pShip.x, pShip.y);
                pSplat.ActivateCollisionSprite(this.pSB_Boxes);
                pSplat.ActivateGameSprite(this.pSB_Aliens);

                GameObject pSplatbRoot = GameObjectMan.Find(GameObject.Name.SplatRoot);
                Debug.Assert(pSplatbRoot != null);
                pSplatbRoot.Add(pSplat);

                TimerMan.Add(TimeEvent.Name.SplatRemoveShip, new SplatRemoveEvent(this.pSplat), 0.6f);

                this.scenePlay.RemoveLife();
            }
        }
Esempio n. 5
0
        public override void Execute()
        {
            // Let the gameObject deal with this...
            //this.pAlien.Remove();

            GameObject pA = (GameObject)this.pUFO;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            pA.Remove();

            // TODO:  update score - may need a better way (maybe an observer)
            SceneContext sc = SceneContext.GetInstance();

            sc.GetState().UpdateScore(this.pUFO.GetScore());

            // TODO: Splat Alien - needs a better way
            this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatUFO, pUFO.x, pUFO.y);
            pSplat.ActivateCollisionSprite(this.pSB_Boxes);
            pSplat.ActivateGameSprite(this.pSB_Aliens);

            GameObject pSplatbRoot = GameObjectMan.Find(GameObject.Name.SplatRoot);

            Debug.Assert(pSplatbRoot != null);
            pSplatbRoot.Add(pSplat);

            TimerMan.Add(TimeEvent.Name.SplatRemoveUFO, new SplatRemoveEvent(this.pSplat), 0.5f);
        }
Esempio n. 6
0
        //to destroy game objects that are hit
        public static void Dettach(GameObject pGameObject)
        {
            GONodeMan pGOMan = GONodeMan.PrivGetInstance();

            Debug.Assert(pGOMan != null);

            //Remeber: a doublly linked list of trees

            //whatever game object we get, we have to travel up its tree
            // to its its tree's root/ upper most parent
            Debug.Assert(pGameObject != null);
            GameObject pTemp = pGameObject;

            GameObject pRoot = null;

            while (pTemp != null)
            {
                pRoot = pTemp;
                pTemp = (GameObject)Iterator.GetParent(pTemp);
                //keep traveling up the tree

                //exit out at the top of the tree
            }

            //Found the tree our game object is in
            // now go traverse the DLink list to that tree
            GONode pTree = (GONode)pGOMan.BaseGetActive();

            while (pTree != null)
            {
                //check if the game objects match
                if (pTree.poGameObject == pRoot)
                {
                    break;
                }

                pTree = (GONode)pTree.pNext;
            }

            //Now we are in the tree with the Game Object
            //we need to remove
            Debug.Assert(pTree != null);
            Debug.Assert(pTree.poGameObject != null);

            GameObject pParent = (GameObject)Iterator.GetParent(pGameObject);

            Debug.Assert(pParent != null);


            GameObject pChild = (GameObject)Iterator.GetChild(pGameObject);

            Debug.Assert(pChild == null);

            //finally
            //Remove Gamobject from its parent composite
            pParent.Remove(pGameObject);
        }
Esempio n. 7
0
 override public void DumpNode()
 {
     if (Iterator.GetParent(this) != null)
     {
         Debug.WriteLine(" GameObject Name:({0}) parent:{1} <---- Composite", this.GetHashCode(), Iterator.GetParent(this).GetHashCode());
     }
     else
     {
         Debug.WriteLine(" GameObject Name:({0}) parent:null <---- Composite", this.GetHashCode());
     }
 }
Esempio n. 8
0
 private void PrintMyself()
 {
     if (Iterator.GetParent(this) != null)
     {
         Debug.WriteLine("GameObject : ({0}) | Parent : ({1}) <---- Composite", this.GetHashCode(), Iterator.GetParent(this).GetHashCode());
     }
     else
     {
         Debug.WriteLine("GameObject : ({0}) | Parent : null <---- Composite : root", this.GetHashCode());
     }
 }
        public override void Execute()
        {
            GameObject pBomb     = this.pBomb;
            GameObject pBombRoot = (GameObject)Iterator.GetParent(pBomb);

            GameObject pMissile     = this.pMissile;
            GameObject pMissileRoot = (GameObject)Iterator.GetParent(pMissile);

            pBomb.Remove();
            pMissile.Remove();
        }
Esempio n. 10
0
        public static void Remove(GameObject pNode)
        {
            Debug.Assert(pNode != null);
            GameObjectMan pMan = GameObjectMan.privGetInstance();

            GameObject pSafetyNode = pNode;

            GameObject pTmp  = pNode;
            GameObject pRoot = null;

            while (pTmp != null)
            {
                pRoot = pTmp;
                pTmp  = (GameObject)Iterator.GetParent(pTmp);
            }

            GameObjectNode pTree = (GameObjectNode)pMan.baseGetActive();

            while (pTree != null)
            {
                if (pTree.poGameObj == pRoot)
                {
                    break;
                }
                pTree = (GameObjectNode)pTree.pNext;
            }

            Debug.Assert(pTree != null);
            Debug.Assert(pTree.poGameObj != null);

            if (pTree.poGameObj == pNode)
            {
                return;
            }
            Debug.Assert(pTree.poGameObj != pNode);

            GameObject pParent = (GameObject)Iterator.GetParent(pNode);

            Debug.Assert(pParent != null);

            GameObject pChild = (GameObject)Iterator.GetChild(pNode);

            Debug.Assert(pChild == null);

            pParent.Remove(pNode);
            pParent.Update();

            // TODO - Recycle pNode
        }
Esempio n. 11
0
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pUFO;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            float x = this.pUFO.x;
            float y = this.pUFO.y;

            pA.Remove();

            // Hacks
            if (this.pGameObj is MissileGroup)
            {
                Missile pMissile = (Missile)Iterator.GetChild(this.pGameObj);

                // bug but don't crash please
                if (pMissile == null)
                {
                    return;
                }

                Player pPlayer = pMissile.pPlayer;
                pPlayer.nPoints += this.pUFO.GetPoints();
                Font.Name pFontName = Font.Name.Uninitialized;
                if (pPlayer.n == 1)
                {
                    pFontName = Font.Name.Score1Value;
                }
                if (pPlayer.n == 2)
                {
                    pFontName = Font.Name.Score2Value;
                }
                Font pScore = FontMan.Find(pFontName);
                pScore.Set(pFontName,
                           pPlayer.nPoints.ToString(),
                           Glyph.Name.Consolas20pt,
                           pScore.pFontSprite.x,
                           pScore.pFontSprite.y);
            }

            SoundMan.PlaySound(Sound.Name.InvaderKilled);

            Explosion   explosion = new Explosion(GameObject.Name.Explosion, GameSprite.Name.Explosion, x, y);
            SpriteBatch pSB_UFOs  = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            explosion.ActivateGameSprite(pSB_UFOs);
            GameObjectMan.Attach(explosion);
            TimerMan.Add(TimeEvent.Name.RemoveExplosion, new RemoveExplosionCommand(explosion), 0.25f);
        }
Esempio n. 12
0
        public static void Remove(GameObject gameObject)
        {
            GameObject Parent = (GameObject)Iterator.GetParent(gameObject);

            if (Parent != null)
            {
                Parent.Remove(gameObject);
                if (Parent.GetFirstChild() == null)
                {
                    Parent.RemoveBox();
                    Remove(Parent);
                }
                Parent.Update();
            }
        }
        public override void Execute()
        {
            // Resiter the change with the Level
            Level.KilledUFO();

            //  if this brick removed the last child in the column, then remove column
            // Debug.WriteLine(" alien {0}  parent {1}", this.pAlien, this.pAlien.pParent);
            GameObject pA = (GameObject)this.pAlien;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            pB.bMarkForDeath = true;

            pA.Remove();
            Debug.WriteLine("---- Hiding : Missile Destroyed");
            TimerManager.Add(TimeEvent.Name.HideUFO, new HideUFO((AlienGrid)pB), ((AlienGrid)pB).movementTimeInterval);
        }
Esempio n. 14
0
        public static void Remove(GameObject pNode)
        {
            Debug.Assert(pNode != null);

            //ensure call Create() first
            GameObjectMan pMan = GameObjectMan.GetInstance();

            Debug.Assert(pMan != null);

            // 1. find tree root
            GameObject pTmp  = pNode;
            GameObject pRoot = null;

            while (pTmp != null)
            {
                pRoot = pTmp;
                pTmp  = (GameObject)Iterator.GetParent(pTmp);
            }

            // 2. pRoot is the tree we looking for, walk the active list looking for pTree
            GameObjectNode pTree = (GameObjectNode)pMan.baseGetActiveList();

            while (pTree != null)
            {
                if (pTree.getGameObject() == pRoot)
                {
                    break;
                }

                // go to next tree
                pTree = (GameObjectNode)pTree.pNext;
            }

            // 3. pTree is the tree that holds pNode, remove pNode from pTree
            Debug.Assert(pTree != null);
            Debug.Assert(pTree.getGameObject() != null);

            // always have a group
            Debug.Assert(pTree.getGameObject() != pNode);

            GameObject pParent = (GameObject)Iterator.GetParent(pNode);

            Debug.Assert(pParent != null);

            // remove the node
            pParent.remove(pNode);
        }
        public override void Execute()
        {
            // Let the gameObject deal with this...
            //this.pAlien.Remove();

            GameObject pA = (GameObject)this.pAlien;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            pA.Remove();

            // TODO: Need a better way...
            if (privCheckParent(pB) == true)
            {
                GameObject pC = (GameObject)Iterator.GetParent(pB);
                pB.Remove();

                if (privCheckParent(pC) == true)
                {
                    //pC.Remove();

                    // Recreate Grid on last alien delete
                    AlienGrid pGrid = (AlienGrid)pC;
                    pGrid.GenerateAlien(GameObjectMan.GetActive());
                    pGrid.ResetSpeed();
                    this.scenePlay.AddLife();
                }
            }

            // TODO:  update score - may need a better way (maybe an observer)
            SceneContext sc = SceneContext.GetInstance();

            sc.GetState().UpdateScore(this.pAlien.scoreValue);


            // TODO: Splat Alien - needs a better way
            this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatAlien, pAlien.x, pAlien.y);
            pSplat.ActivateCollisionSprite(this.pSB_Boxes);
            pSplat.ActivateGameSprite(this.pSB_Aliens);

            GameObject pSplatbRoot = GameObjectMan.Find(GameObject.Name.SplatRoot);

            Debug.Assert(pSplatbRoot != null);
            pSplatbRoot.Add(pSplat);

            TimerMan.Add(TimeEvent.Name.SplatRemoveAlien, new SplatRemoveEvent(this.pSplat), 0.5f);
        }
Esempio n. 16
0
        public override void execute(float deltaTime)
        {
            GameObject pParent = (GameObject)Iterator.GetParent(this.pGameObject);

            this.pGameObject.remove();

            while (checkParent(pParent))
            {
                GameObject pGrandParent = (GameObject)Iterator.GetParent(pParent);
                //if (pParent.getName() == GameObject.Name.AlienGroup) break;
                if (pGrandParent == null)
                {
                    break;
                }

                pParent.remove();
                pParent = pGrandParent;
            }
        }
        public override void Execute()
        {
            // Let the gameObject deal with this...
            GameObject pA = (GameObject)this.pAlien;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            pA.Remove();

            // TODO: Need a better way...
            if (PrivCheckParent(pB) == true)
            {
                GameObject pC = (GameObject)Iterator.GetParent(pB);
                pB.Remove();

                if (PrivCheckParent(pC) == true)
                {
                    SceneMan.ChangeSceneInternal(pC);
                }
            }
        }
Esempio n. 18
0
        public override void Execute()
        {
            //  if this brick removed the last child in the column, then remove column
            // Debug.WriteLine(" brick {0}  parent {1}", this.pBrick, this.pBrick.pParent);
            GameObject pA = (GameObject)this.pBrick;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            pA.Remove();

            // TODO: Need a better way...
            if (privCheckParent(pB) == true)
            {
                GameObject pC = (GameObject)Iterator.GetParent(pB);
                pB.Remove();

                if (privCheckParent(pC) == true)
                {
                    //        pC.Remove();
                }
            }
        }
Esempio n. 19
0
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pBrick;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            pA.Remove();

            if (!(this.pObjA is AlienGrid))
            {
                SoundMan.PlaySound(Sound.Name.Explode);
            }

            if (privCheckParent(pB) == true)
            {
                GameObject pC = (GameObject)Iterator.GetParent(pB);
                pB.Remove();

                if (privCheckParent(pC) == true)
                {
                    //pC.Remove();
                }
            }
        }
Esempio n. 20
0
        public override void Execute()
        {
            GameObject pBrickObject = (GameObject)this.pBrick;
            GameObject pColumn      = (GameObject)Iterator.GetParent(pBrickObject);

            SpaceInvaders pGame = GameMan.GetGame();

            //always remove the brick
            pBrickObject.Remove();

            //check if Column has bricks left
            //true means we have no more children, and safe to remove column
            if (PrivCheckParent(pColumn) == true)
            {
                GameObject pGroup = (GameObject)Iterator.GetParent(pColumn);
                pColumn.Remove();

                //Check if Shield has any columns left
                if (PrivCheckParent(pGroup) == true)
                {
                    pGroup.Remove();
                }
            }
        }
        public override void Execute()
        {
            // Resiter the change with the Level
            Level.KilledAlien();

            //  if this brick removed the last child in the column, then remove column
            // Debug.WriteLine(" alien {0}  parent {1}", this.pAlien, this.pAlien.pParent);
            GameObject pA = (GameObject)this.pAlien;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            pA.Remove();

            // TODO: Need a better way...
            if (privCheckParent(pB) == true)
            {
                GameObject pC = (GameObject)Iterator.GetParent(pB);
                pB.Remove();

                if (privCheckParent(pC) == true)
                {
                    //pC.Remove();
                }
            }
        }
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pAlien;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            float x = this.pAlien.x;
            float y = this.pAlien.y;

            AlienGrid pGrid = (AlienGrid)this.pAlien.pParent.pParent;

            pGrid.nNumActive--;

            pA.Remove();

            // TODO: Need a better way...
            if (privCheckParent(pB) == true)
            {
                GameObject pC = (GameObject)Iterator.GetParent(pB);
                pB.Remove();

                if (privCheckParent(pC) == true)
                {
                    pC.Remove();
                }
            }

            Missile pMissile = (Missile)this.pGameObj;
            Player  pPlayer  = pMissile.pPlayer;

            //
            Font.Name pFontName = Font.Name.Uninitialized;
            if (this.pGameObj is MissileCategory)
            {
                pPlayer.nPoints += this.pAlien.GetPoints();
                Font pScore = null;
                if (pPlayer.n == 1)
                {
                    pScore    = FontMan.Find(Font.Name.Score1Value);
                    pFontName = Font.Name.Score1Value;
                }
                if (pPlayer.n == 2)
                {
                    pScore    = FontMan.Find(Font.Name.Score2Value);
                    pFontName = Font.Name.Score2Value;
                }
                pScore.Set(pFontName,
                           pPlayer.nPoints.ToString(),
                           Glyph.Name.Consolas20pt,
                           pScore.pFontSprite.x,
                           pScore.pFontSprite.y);
            }

            //---------------------------------------------------------------------------------------------------------
            // Sound
            //---------------------------------------------------------------------------------------------------------
            SoundMan.PlaySound(Sound.Name.InvaderKilled);
            TimeEvent pTimeEvent = TimerMan.Find(TimeEvent.Name.ScenePlaySound);

            pTimeEvent.deltaTime -= 0.01f;

            //---------------------------------------------------------------------------------------------------------
            // Explosion
            //---------------------------------------------------------------------------------------------------------
            Explosion   explosion  = new Explosion(GameObject.Name.Explosion, GameSprite.Name.Explosion, x, y);
            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            explosion.ActivateGameSprite(pSB_Aliens);
            GameObjectMan.Attach(explosion);
            TimerMan.Add(TimeEvent.Name.RemoveExplosion, new RemoveExplosionCommand(explosion), 0.25f);

            //---------------------------------------------------------------------------------------------------------
            // Scene Transition
            //---------------------------------------------------------------------------------------------------------
            if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 1)
            {
                PlayerMan.WriteHighScores();
                pPlayer.nCurrLevel++;
                SceneContext.GetState().Initialize();
                if (SceneContext.bMultiplayer)
                {
                    SceneContext.SetState(SceneContext.Scene.MultiPlay);
                }
                else
                {
                    SceneContext.SetState(SceneContext.Scene.SinglePlay);
                }
            }
            else if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 2)
            {
                PlayerMan.WriteHighScores();
                SceneContext.SetState(SceneContext.Scene.Credits);
            }
        }
Esempio n. 23
0
 override public void Dump()
 {
     Debug.WriteLine(" GameObject Name: {0} ({1}) parent:{2}", this.GetName(), this.GetHashCode(), ((Composite)Iterator.GetParent(this)).GetName());
 }
Esempio n. 24
0
 public override void Print()
 {
     Debug.WriteLine("\t\t   GameObject Name : {0} ({1}) | My Parent : ({2})", this.GetName(), this.GetHashCode(), Iterator.GetParent(this).GetHashCode());
 }