Example #1
0
        public static Bomb ActivateBomb(UFOCategory pUFO)
        {
            UFOMan pUFOMan = UFOMan.PrivInstance();

            Debug.Assert(pUFOMan != null);

            Bomb pBombObj = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombFork, new FallTuning(), pUFO.x, pUFO.y, pUFO);

            pUFOMan.pBomb = pBombObj;

            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);
            SpriteBatch pSB_Box    = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);

            pBombObj.ActivateCollisionSprite(pSB_Box);
            pBombObj.ActivateGameSprite(pSB_Aliens);

            // Attach the missile to the missile root
            GameObject pBombRoot = GameObjectMan.Find(GameObject.Name.BombRoot);

            Debug.Assert(pBombRoot != null);

            // Add to GameObject Tree - {update and collisions}
            pBombRoot.Add(pUFOMan.pBomb);

            return(pUFOMan.pBomb);
        }
Example #2
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);
        }
        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();
            }
        }
Example #4
0
        public static void InitializeGrid()
        {
            // get Alien Grid From ReservedChildren Group
            AliensGrid Grid = (AliensGrid)GameObjectMan.Find(0, 0).GameObj;

            //if Grid has Child in the object pool
            DLinkedNode Col = Grid.Reservedchildren.GetHead();

            if (Col != null)
            {
                ResetGrid(Grid);

                // Update xs and ys of the whole grid
                UpdateGridPos(60, 530 - 30 * Nums.Level);

                // next line is necessary
                PlayBatchMan.Find(BatchName.Box).Add(GetGrid().CollisionObj.Box);
            }
            else
            {   // if Aliens Grid is not in the object pool. create new Grid Obj
                for (int j = 1; j <= 11; j++)
                {
                    Composite col = AlienObjectFactory.CreatComposite(j);
                    Grid.Add(col);
                }
            }
            _AlienGridMan._AlienGrid = Grid;
        }
        private static Ship ActivateShip(SpriteBatchMan pSpriteBatchMan)
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            // copy over safe copy
            Ship pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 150, 50);

            pShipMan.pShip = pShip;

            // Attach the sprite to the correct sprite batch
            SpriteBatch pSB_Aliens = pSpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            pSB_Aliens.Attach(pShip.poProxySprite);

            SpriteBatch pSB_Box = pSpriteBatchMan.Find(SpriteBatch.Name.Boxes);

            pSB_Box.Attach(pShip.GetColObject().pColSprite);

            // Attach the missile to the missile root
            GameObject pShipRoot = GameObjectMan.Find(GameObject.Name.ShipRoot);

            Debug.Assert(pShipRoot != null);

            // Add to GameObject Tree - {update and collisions}
            pShipRoot.Add(pShipMan.pShip);

            return(pShipMan.pShip);
        }
Example #6
0
        public static void InitializeBomb(float x, float y)
        {
            // get Bomb Group
            BombCol BCol = (BombCol)GameObjectMan.Find(0, 10).GameObj;

            // if bullet is in the object pool
            if (BCol.Reservedchildren.GetHead() != null)
            {
                _BombMan.Bomb = (BombLeaf)BCol.Reservedchildren.GetHead();
                BCol.Reservedchildren.Remove(_BombMan.Bomb);
                UpdateBombPos(x, y);
                _BombMan.Bomb.ResetStrategy();
                // next line is necessary
                PlayBatchMan.Find(BatchName.Box).Add(GetBomb().CollisionObj.Box);
                PlayBatchMan.Find(BatchName.Box).Add(BCol.CollisionObj.Box);
            }
            else    // if bullet is not in the object pool. create new Bullet Obj
            {
                GetRandomBomb();
                UpdateBombPos(x, y);
            }


            BCol.Add(GetBomb());
        }
Example #7
0
        public static Missile ActivateMissile()
        {
            //ensure call Create() first
            ShipMan pShipMan = ShipMan.GetInstance();

            Debug.Assert(pShipMan != null);

            // create Missile
            Missile pMissile = new Missile(GameObject.Name.Missile, GameSprite.Name.Missile, 400, 100);

            pShipMan.pMissile = pMissile;

            // activate collision sprite and game sprite
            pMissile.activateCollisionSprite(SpriteBatchMan.Find(SpriteBatch.Name.Boxes));
            pMissile.activateGameSprite(SpriteBatchMan.Find(SpriteBatch.Name.Missiles));

            // attach missile to missile group
            GameObject pMissileGroup = GameObjectMan.Find(GameObject.Name.MissileGroup);

            Debug.Assert(pMissileGroup != null);

            // Add to GameObject
            pMissileGroup.add(pShipMan.pMissile);

            return(pShipMan.pMissile);
        }
        override public void Execute(float deltaTime)
        {
            int pFreq = pRandom.Next(1, 10) / this.nCurrLevel;

            AlienGrid     pGrid  = (AlienGrid)GameObjectMan.Find(GameObject.Name.AlienGrid);
            AlienCategory pAlien = pGrid.GetRandomAlien();

            // HACK don't crash pleease
            if (pAlien == null)
            {
                TimerMan.Add(TimeEvent.Name.BombSpawn, this, pFreq);
                return;
            }

            int          type          = pRandom.Next(0, 2);
            FallStrategy pFallStrategy = null;

            switch (type)
            {
            case (0):
                pFallStrategy = new FallZigZag();
                break;

            case (1):
                pFallStrategy = new FallDagger();
                break;

            case (2):
                pFallStrategy = new FallStraight();
                break;
            }
            type = pRandom.Next(0, 2);
            GameSprite.Name pGameSpriteName = GameSprite.Name.Uninitialized;
            switch (type)
            {
            case (0):
                pGameSpriteName = GameSprite.Name.BombZigZag;
                break;

            case (1):
                pGameSpriteName = GameSprite.Name.BombDagger;
                break;

            case (2):
                pGameSpriteName = GameSprite.Name.BombStraight;
                break;
            }

            Bomb pBomb = new Bomb(GameObject.Name.Bomb, pGameSpriteName, pFallStrategy, pAlien.x, pAlien.y);

            pBomb.ActivateCollisionSprite(this.pSB_Boxes);
            pBomb.ActivateGameSprite(this.pSB_Bombs);

            GameObject pBombRoot = GameObjectMan.Find(GameObject.Name.BombRoot);

            Debug.Assert(pBombRoot != null);

            pBombRoot.Add(pBomb);
            TimerMan.Add(TimeEvent.Name.BombSpawn, this, pFreq);
        }
Example #9
0
        override public void Execute(float deltaTime)
        {
            float value = pRandom.Next(10, 60);
            UFO   pUFO  = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 100, 515);

            ColPair pColPair = ColPairMan.Add(ColPair.Name.UFO_WallLeft, pUFO, this.pWallLeft);

            pColPair.Attach(new UFOWallLeftObserver());

            pColPair = ColPairMan.Add(ColPair.Name.UFO_WallRight, pUFO, this.pWallRight);
            pColPair.Attach(new UFOWallRightObserver());

            MissileGroup pMissile = (MissileGroup)GameObjectMan.Find(GameObject.Name.MissileGroup);

            pColPair = ColPairMan.Add(ColPair.Name.UFOMissile, pUFO, pMissile);
            pColPair.Attach(new RemoveUFOObserver());

            pUFO.ActivateCollisionSprite(this.pSB_Boxes);
            pUFO.ActivateGameSprite(this.pSB_Aliens);
            GameObjectMan.Attach(pUFO);

            Sound.Name pSoundName = Sound.Name.Uninitialized;
            switch (pRandom.Next(0, 1))
            {
            case (0):
                pSoundName = Sound.Name.UFOLow;
                break;

            case (1):
                pSoundName = Sound.Name.UFOHigh;
                break;
            }
            SoundMan.PlaySound(pSoundName);
            TimerMan.Add(TimeEvent.Name.UFO, this, value);
        }
        public static Missile ActivateMissile()
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            // copy over safe copy
            // This can be cleaned up more... no need to re-calling new()
            Missile pMissile = new Missile(GameObject.Name.Missile, GameSprite.Name.Missile, 400, 100);

            pShipMan.pMissile = pMissile;

            // Attached to SpriteBatches
            SpriteBatch pSB_Aliens = instance.pSpriteBatchMan.Find(SpriteBatch.Name.Aliens);
            SpriteBatch pSB_Boxes  = instance.pSpriteBatchMan.Find(SpriteBatch.Name.Boxes);

            pMissile.ActivateCollisionSprite(pSB_Boxes);
            pMissile.ActivateGameSprite(pSB_Aliens);

            // Attach the missile to the missile root
            GameObject pMissileGroup = GameObjectMan.Find(GameObject.Name.MissileGroup);

            Debug.Assert(pMissileGroup != null);

            // Add to GameObject Tree - {update and collisions}
            pMissileGroup.Add(pShipMan.pMissile);

            return(pShipMan.pMissile);
        }
Example #11
0
        public static Ship ActivateShip()
        {
            //ensure call Create() first
            ShipMan pShipMan = ShipMan.GetInstance();

            Debug.Assert(pShipMan != null);

            // create ship
            Ship pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 440, 90);

            pShipMan.pShip = pShip;

            // attach sprite to correct sprite batch
            SpriteBatch pSB_Ships = SpriteBatchMan.Find(SpriteBatch.Name.Ships);

            pSB_Ships.attach(pShip.getProxySprite());

            // attach ship to ship group
            GameObject pShipGroup = GameObjectMan.Find(GameObject.Name.ShipGroup);

            Debug.Assert(pShipGroup != null);

            // add to GameObject
            pShipGroup.add(pShipMan.pShip);
            pShip.activateCollisionSprite(SpriteBatchMan.Find(SpriteBatch.Name.Boxes));

            return(pShipMan.pShip);
        }
Example #12
0
        public static Bomb ActiveBomb()
        {
            //ensure call Create() first
            BombMan pMan = BombMan.GetInstance();

            Debug.Assert(pMan != null);

            GameSprite.Name spriteName    = GameSprite.Name.BombDagger + pMan.randNum.Next(3);
            FallStrategy    pFallStrategy = pMan.chooseFallStrategy(spriteName);

            Debug.Assert(pFallStrategy != null);

            // create Bomb
            Bomb pBomb = new Bomb(GameObject.Name.Bomb, spriteName, pFallStrategy, 100, 100);

            // activate collision sprite and game sprite
            pBomb.activateGameSprite(SpriteBatchMan.Find(SpriteBatch.Name.Bombs));
            pBomb.activateCollisionSprite(SpriteBatchMan.Find(SpriteBatch.Name.Boxes));

            //attach Bomb to BombGroup
            GameObject pBombGroup = GameObjectMan.Find(GameObject.Name.BombGroup);

            Debug.Assert(pBombGroup != null);

            // add to GameObject
            pBombGroup.add(pBomb);

            return(pBomb);
        }
Example #13
0
        private static Ship ActivateShip(SndObserver pSnd)
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            // copy over safe copy
            Ship pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 300, 55, pSnd);

            pShipMan.pShip = pShip;

            // Attach the sprite to the correct sprite batch
            //SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);
            //pSB_Aliens.Attach(pShip.pProxySprite);

            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);
            SpriteBatch pSB_Boxes  = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);

            pShip.ActivateCollisionSprite(pSB_Boxes);
            pShip.ActivateGameSprite(pSB_Aliens);

            // Attach the missile to the missile root
            GameObject pShipRoot = GameObjectMan.Find(GameObject.Name.ShipRoot);

            Debug.Assert(pShipRoot != null);

            // Add to GameObject Tree - {update and collisions}
            pShipRoot.Add(pShipMan.pShip);

            return(pShipMan.pShip);
        }
        public override void Notify()
        {
            Bomb pBomb = null;

            if (this.pSubject.pObjA.name == GameObject.Name.Bomb)
            {
                pBomb = (Bomb)this.pSubject.pObjA;
            }
            else if (this.pSubject.pObjB.name == GameObject.Name.Bomb)
            {
                pBomb = (Bomb)this.pSubject.pObjB;
            }

            Debug.Assert(pBomb != null);

            pBomb.Reset();

            pBomb.Remove();

            if (showSplat == true)
            {
                // TODO: Splat Alien - needs a better way
                this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatBomb, pBomb.x, pBomb.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.SplatRemoveBomb, new SplatRemoveEvent(this.pSplat), 0.5f);
            }
        }
Example #15
0
        public static void ChangeSceneInternal(GameObject pGameObject)
        {
            ForwardIterator pFor = new ForwardIterator(pGameObject);

            Component pNode = pFor.First();

            pFor.Next();
            if (pFor.IsDone())
            {
                GameObject pUFORoot = GameObjectMan.Find(GameObject.Name.UFORoot);
                UFO        pUFO     = (UFO)Iterator.GetChild(pUFORoot);
                pUFO.StopSound();

                int mode      = SceneStateGame.GetPlayMode();
                int currLevel = SceneStateGame.GetCurrLevel();

                String pScore1 = Int32.Parse(FontMan.Find(Font.Name.Score1).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScore1(pScore1);

                String pScore2 = Int32.Parse(FontMan.Find(Font.Name.Score2).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScore2(pScore2);

                String pScoreHigh = Int32.Parse(FontMan.Find(Font.Name.ScoreHigh).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScoreHigh(pScoreHigh);

                SceneStateGame.SetStay(true);

                int currPlayer = SceneStateGame.GetCurrPlayer();

                if (currLevel == 1)
                {
                    SceneStateGame.SetPlayerLevel(currPlayer, 2);
                    SceneStateGame.SetBaseY(450.0f);
                    SceneStateGame.SetMoveRate(1.0f);
                }
                else
                {
                    SceneStateGame.SetPlayerLevel(currPlayer, 1);
                    SceneStateGame.SetBaseY(600.0f);
                    SceneStateGame.SetMoveRate(1.5f);
                    //no need to change to the next player, when finish level 2, same player, back to level 1
                    //SceneStateGame.SetCurrPlayer(currPlayer == mode ? 1 : 2);
                }

                //currLevel = SceneStateGame.GetCurrLevel();
                //if (currLevel == 1)
                //{
                //    SceneStateGame.SetBaseY(600.0f);
                //    SceneStateGame.SetMoveRate(1.5f);
                //}
                //else
                //{
                //    SceneStateGame.SetBaseY(450.0f);
                //    SceneStateGame.SetMoveRate(1.0f);
                //}

                Scene pScene = SceneMan.GetScene();
                pScene.Unload();
            }
        }
        override public void Execute(float deltaTime)
        {
            this.pUFO = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, -20, 530);
            Debug.Assert(this.pUFO != null);
            pUFO.ActivateCollisionSprite(this.pSB_Boxes);
            pUFO.ActivateGameSprite(this.pSB_Aliens);

            pUFO.animate = true;

            SwapDirection();

            // Attach the missile to the Bomb root
            GameObject pUFORoot = GameObjectMan.Find(GameObject.Name.UFORoot);

            Debug.Assert(pUFORoot != null);

            // Add to GameObject Tree - {update and collisions}
            pUFORoot.Add(pUFO);

            // Add timer event UFO Tempo
            UFOTempoEvent pUFOTempo = new UFOTempoEvent(pUFO);

            pUFOTempo.Attach(SoundEngine.Name.UFO_HighPitch);
            TimerMan.Add(TimeEvent.Name.UFOSoundTempo, pUFOTempo, 0.5f);

            // Add timer event
            TimerMan.Add(TimeEvent.Name.UFORandom, this, pRandom.Next(8, 25));

            // Add timer event for UFO Bombs
            TimerMan.Add(TimeEvent.Name.BombRandomUFO, new BombSpawnEvent(pRandom, pUFO), pRandom.Next(1, 4));
        }
Example #17
0
        public static Bomb ActivateBomb(AlienCategory pAlien)
        {
            AlienMan pAlienMan = AlienMan.PrivInstance();

            Debug.Assert(pAlienMan != null);

            // copy over safe copy
            byte[] buffer = Guid.NewGuid().ToByteArray();
            int    iSeed  = BitConverter.ToInt32(buffer, 0);
            Random random = new Random(iSeed);

            Bomb pBombObj = null;
            int  randint  = random.Next(0, 4);

            switch (randint)
            {
            case 0:
                pBombObj = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombDagger, new FallDagger(), pAlien.x, pAlien.y, pAlien);
                break;

            case 1:
                pBombObj = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombRolling, new FallRolling(), pAlien.x, pAlien.y, pAlien);
                break;

            case 2:
                pBombObj = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombZigZag, new FallZigZag(), pAlien.x, pAlien.y, pAlien);
                break;

            case 3:
                pBombObj = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombStraight, new FallStraight(), pAlien.x, pAlien.y, pAlien);
                break;

            default:
                Debug.Assert(false);
                break;
            }

            pAlienMan.pBomb = pBombObj;

            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);
            SpriteBatch pSB_Box    = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);

            pBombObj.ActivateCollisionSprite(pSB_Box);
            pBombObj.ActivateGameSprite(pSB_Aliens);

            // Attach the missile to the missile root
            GameObject pBombRoot = GameObjectMan.Find(GameObject.Name.BombRoot);

            Debug.Assert(pBombRoot != null);

            // Add to GameObject Tree - {update and collisions}
            pBombRoot.Add(pAlienMan.pBomb);

            return(pAlienMan.pBomb);
        }
Example #18
0
        public static Ship ActivateShip(Ship pShip)
        {
            // Attach the sprite to the correct sprite batch
            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            pSB_Aliens.Attach(pShip.pProxySprite);

            GameObject pShipRoot = GameObjectMan.Find(GameObject.Name.ShipRoot);

            Debug.Assert(pShipRoot != null);

            // Add to GameObject Tree - {update and collisions}
            pShipRoot.Add(pShip);
            return(pShip);
        }
Example #19
0
        public SpawnUFOCommand(Random pRandom, WallLeft pWallLeft, WallRight pWallRight)
        {
            this.pUFO = GameObjectMan.Find(GameObject.Name.UFO);
            Debug.Assert(this.pUFO != null);

            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.pRandom    = pRandom;
            this.pWallLeft  = pWallLeft;
            this.pWallRight = pWallRight;
        }
        public BombSpawnEvent(int nCurrLevel, Random pRandom)
        {
            this.nCurrLevel = nCurrLevel;

            this.pBombRoot = GameObjectMan.Find(GameObject.Name.BombRoot);
            Debug.Assert(this.pBombRoot != null);

            this.pSB_Bombs = SpriteBatchMan.Find(SpriteBatch.Name.Bombs);
            Debug.Assert(this.pSB_Bombs != null);

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

            this.pRandom = pRandom;
        }
Example #21
0
        public static void KillAll()
        {
            BombCol     BCol  = (BombCol)GameObjectMan.Find(0, 10).GameObj;
            DLinkedNode Child = BCol.GetFirstChild();

            while (Child != null)
            {
                // Kill all Child
                DLinkedNode NextChild = Child.Next;

                BCol.Remove((BombLeaf)Child);
                // Remove Box Obj
                PlayBatchMan.Find(BatchName.Box).Remove(((BombLeaf)Child).CollisionObj.Box);
                PlayBatchMan.Find(BatchName.Bombs).Remove(((BombLeaf)Child).GetProxy());
                Child = NextChild;
            }
        }
Example #22
0
        public static UFO ActiveUFO()
        {
            UFOMan pUFOMan = UFOMan.GetInstance();

            Debug.Assert(pUFOMan != null);

            UFO pUFO = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 10.0f, 925.0f);

            pUFOMan.pUFO = pUFO;
            pUFOMan.pUFO.activateGameSprite(SpriteBatchMan.Find(SpriteBatch.Name.UFO));
            pUFOMan.pUFO.activateCollisionSprite(SpriteBatchMan.Find(SpriteBatch.Name.Boxes));
            GameObject pUFORoot = GameObjectMan.Find(GameObject.Name.UFORoot);

            pUFORoot.add(pUFOMan.pUFO);

            return(pUFOMan.pUFO);
        }
        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);
        }
        public UFOSpawnEvent(Random pRandom)
        {
            this.pUFORoot = GameObjectMan.Find(GameObject.Name.UFORoot);
            Debug.Assert(this.pUFORoot != null);

            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.direction = Direction.Right;
            this.UFODelta  = 2.7f;

            this.time = 15.0f;

            this.pRandom = pRandom;
        }
Example #25
0
        private void MoveDonw()
        {
            GameObject pAlienGroup = GameObjectMan.Find(GameObject.Name.AlienGroup);

            ReverseIterator pRev  = new ReverseIterator(pAlienGroup);
            Component       pNode = pRev.First();

            while (!pRev.IsDone())
            {
                GameObject pGameObj = (GameObject)pNode;

                float nextPosY = pGameObj.GetY() - 20;

                pGameObj.SetXY(pGameObj.GetX(), nextPosY);

                pNode = pRev.Next();
            }
        }
Example #26
0
        public BombSpawnEvent(Random pRandom, GameObject gameObj)
        {
            this.pBombRoot = GameObjectMan.Find(GameObject.Name.BombRoot);
            Debug.Assert(this.pBombRoot != null);

            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.pRandom = pRandom;

            this.time = 2.0f;

            this.pGrid      = null;
            this.pAlienBomb = null;
            this.pGameObj   = gameObj;
        }
        public override void Execute()
        {
            // Let the gameObject deal with this...
            this.pMissile.Remove();

            if (showSplat == true)
            {
                // TODO: Splat Alien - needs a better way
                this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatMissile, pMissile.x, pMissile.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.SplatRemoveMissile, new SplatRemoveEvent(this.pSplat), 0.5f);
            }
        }
Example #28
0
File: UFOMan.cs Project: xfanw/Game
        public static void InitialUFO()
        {
            UFOCol UCol = (UFOCol)GameObjectMan.Find(50, 50).GameObj;

            if (UCol.Reservedchildren.GetHead() != null)
            {
                _UFOMan.UFO = (UFOLeaf)UCol.Reservedchildren.GetHead();
                UCol.Reservedchildren.Remove(GetUFO());
                UpdateUFOPos();
                PlayBatchMan.Find(BatchName.Box).Add(GetUFO().CollisionObj.Box);
                PlayBatchMan.Find(BatchName.Box).Add(UCol.CollisionObj.Box);
            }
            else
            {
                _UFOMan.UFO = new UFOLeaf(GameSpriteName.UFO, 400, 200, 50, 6);
                UpdateUFOPos();
            }
            UCol.Add(_UFOMan.UFO);
        }
Example #29
0
        public void createLifes()
        {
            this.pLifeGroup = (ShipLifeGroup)GameObjectMan.Find(GameObject.Name.ShipLifeGroup);
            SpriteBatch pSB_Lifes = SpriteBatchMan.Find(SpriteBatch.Name.Lifes);
            SpriteBatch pSB_Boxes = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);

            Ship  pShip;
            float startX = 40.0f;
            float startY = 30.0f;
            float gap    = 60.0f;

            for (int i = 0; i < this.lifeRemain; i++)
            {
                pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, startX, startY);
                pShip.activateGameSprite(pSB_Lifes);
                pShip.activateCollisionSprite(pSB_Boxes);
                this.pLifeGroup.add(pShip);
                startX += gap;
            }
        }
Example #30
0
        public static Missile ActivateMissile(Ship pShip)
        {
            Missile pMissile = pShip.GetMissile();
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);
            SpriteBatch pSB_Boxes  = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);

            pMissile.ActivateCollisionSprite(pSB_Boxes);
            pMissile.ActivateGameSprite(pSB_Aliens);
            pMissile.pPlayer = pShip.pPlayer;

            GameObject pMissileGroup = GameObjectMan.Find(GameObject.Name.MissileGroup);

            Debug.Assert(pMissileGroup != null);

            pMissileGroup.Add(pMissile);
            return(pMissile);
        }