Пример #1
0
        public static void UpdateTimerManager(Grid pGrid)
        {
            float decayFactor     = pGrid.decayFactor;
            float bombDecayFactor = pGrid.bombDecayFactor;

            pGrid.UpdateMarchSpeed(decayFactor);
            pGrid.UpdateBombFrequency();

            float   newTriggerTime;
            float   newDeltaTime;
            Command cmd;
            // need to update the game TimerEvents to accommodate updated values
            TimerEvent timerEvent = TimerManager.Find(TimerEventName.MoveGrid);

            if (timerEvent != null)
            {
                newTriggerTime = timerEvent.triggerTime - decayFactor;
                newDeltaTime   = timerEvent.deltaTime - decayFactor;
                cmd            = timerEvent.command;
                TimerManager.Remove(timerEvent);
                TimerManager.Add(TimerEventName.MoveGrid, newTriggerTime, newDeltaTime, cmd);
            }

            timerEvent = TimerManager.Find(TimerEventName.AnimateSquids);
            if (timerEvent != null)
            {
                newTriggerTime = timerEvent.triggerTime - decayFactor;
                newDeltaTime   = timerEvent.deltaTime - decayFactor;
                cmd            = timerEvent.command;
                TimerManager.Remove(timerEvent);
                TimerManager.Add(TimerEventName.AnimateSquids, newTriggerTime, newDeltaTime, cmd);
            }

            timerEvent = TimerManager.Find(TimerEventName.AnimateCrabs);
            if (timerEvent != null)
            {
                newTriggerTime = timerEvent.triggerTime - decayFactor;
                newDeltaTime   = timerEvent.deltaTime - decayFactor;
                cmd            = timerEvent.command;
                TimerManager.Remove(timerEvent);
                TimerManager.Add(TimerEventName.AnimateCrabs, newTriggerTime, newDeltaTime, cmd);
            }

            timerEvent = TimerManager.Find(TimerEventName.AnimateOctopi);
            if (timerEvent != null)
            {
                newTriggerTime = timerEvent.triggerTime - decayFactor;
                newDeltaTime   = timerEvent.deltaTime - decayFactor;
                cmd            = timerEvent.command;
                TimerManager.Remove(timerEvent);
                TimerManager.Add(TimerEventName.AnimateOctopi, newTriggerTime, newDeltaTime, cmd);
            }

            timerEvent = TimerManager.Find(TimerEventName.PlayFastInvaders4);
            if (timerEvent != null)
            {
                newTriggerTime = timerEvent.triggerTime - decayFactor * 4;
                newDeltaTime   = timerEvent.deltaTime - decayFactor * 4;
                cmd            = timerEvent.command;
                TimerManager.Remove(timerEvent);
                TimerManager.Add(TimerEventName.PlayFastInvaders4, newTriggerTime, newDeltaTime, cmd);
            }

            timerEvent = TimerManager.Find(TimerEventName.PlayFastInvaders1);
            if (timerEvent != null)
            {
                newTriggerTime = timerEvent.triggerTime - decayFactor * 4;
                newDeltaTime   = timerEvent.deltaTime - decayFactor * 4;
                cmd            = timerEvent.command;
                TimerManager.Remove(timerEvent);
                TimerManager.Add(TimerEventName.PlayFastInvaders1, newTriggerTime, newDeltaTime, cmd);
            }

            timerEvent = TimerManager.Find(TimerEventName.PlayFastInvaders2);
            if (timerEvent != null)
            {
                newTriggerTime = timerEvent.triggerTime - decayFactor * 4;
                newDeltaTime   = timerEvent.deltaTime - decayFactor * 4;
                cmd            = timerEvent.command;
                TimerManager.Remove(timerEvent);
                TimerManager.Add(TimerEventName.PlayFastInvaders2, newTriggerTime, newDeltaTime, cmd);
            }

            timerEvent = TimerManager.Find(TimerEventName.PlayFastInvaders3);
            if (timerEvent != null)
            {
                newTriggerTime = timerEvent.triggerTime - decayFactor * 4;
                newDeltaTime   = timerEvent.deltaTime - decayFactor * 4;
                cmd            = timerEvent.command;
                TimerManager.Remove(timerEvent);
                TimerManager.Add(TimerEventName.PlayFastInvaders3, newTriggerTime, newDeltaTime, cmd);
            }

            timerEvent = TimerManager.Find(TimerEventName.BombSpawn);
            if (timerEvent != null)
            {
                newTriggerTime = timerEvent.triggerTime - bombDecayFactor;
                newDeltaTime   = timerEvent.deltaTime - bombDecayFactor;
                cmd            = timerEvent.command;
                TimerManager.Remove(timerEvent);
                TimerManager.Add(TimerEventName.BombSpawn, newTriggerTime, newDeltaTime, cmd);
            }
        }
Пример #2
0
        public static void Dump()
        {
            TimerManager timerMan = TimerManager.GetInstance();

            timerMan.BaseDump();
        }
Пример #3
0
        public static float GetCurrentTime()
        {
            TimerManager timerMan = TimerManager.GetInstance();

            return(timerMan.currentTime);
        }
Пример #4
0
        // create 5 * 11 alien grid for given player at given location
        public static GameObject CreateAlienGrid(SpriteBatch.Name sbName, float x, float y)
        {
            // squid
            // crab
            // octopus
            GameSprite alienGridSprite = GameSpriteFactory.CreateCompositeSprite(GameObject.Category.AlienGrid, GameObject.CompositeType.Grid
                                                                                 , x, y, Image.Name.Nothing);

            Image explosionImage = ImageManager.getInstance().FindImageByName(Image.Name.AlienExplosion);


            GlobalPlayerStats.playerstats pStats;

            if (sbName == SpriteBatch.Name.Player1)
            {
                pStats = GlobalPlayerStats.Player1;
            }
            else
            {
                pStats = GlobalPlayerStats.Player2;
            }

            GameObject alienGrid = alienGridSprite.pGameObject;

            // 11 columns
            for (int i = 0; i < 11; i++)
            {
                GameSprite.Name gName;
                Image.Name      imgName;
                Image.Name      altImgName;

                GameSprite       gs;
                SwapImgAnimation swapAni;

                GameSprite alienCol = GameSpriteFactory.CreateCompositeSprite(GameObject.Category.AlienCol, GameObject.CompositeType.Column
                                                                              , x, y, Image.Name.Nothing);

                // 5 rows
                for (int j = 0; j < 5; j++)
                {
                    if (j == 0)
                    {
                        gName      = GameSprite.Name.Squid;
                        imgName    = Image.Name.Squid_1;
                        altImgName = Image.Name.Squid_2;
                    }
                    else if (j < 3)
                    {
                        gName      = GameSprite.Name.Crab;
                        imgName    = Image.Name.Crab_1;
                        altImgName = Image.Name.Crab_2;
                    }
                    else
                    {
                        gName      = GameSprite.Name.Octopus;
                        imgName    = Image.Name.Octopus_1;
                        altImgName = Image.Name.Octopus_2;
                    }

                    gs = CreateGameSprite(GameObject.Category.Alien, gName, sbName, x + i * 60f, y - j * 55f, 40.0f, 40.0f, imgName);
                    gs.addImage(altImgName);
                    gs.pExplosionImage = explosionImage;

                    // Add SwapImage animations
                    swapAni = new SwapImgAnimation(gs.pGameObject, 1.0f - 0.05f * pStats.currentLevel);
                    TimerManager.getInstance().Add(TimerEvent.Name.SwapImageAnimation, swapAni, 1.0f - 0.05f * pStats.currentLevel);

                    // Add Sprite to column
                    alienCol.pGameObject.AddChild(gs.pGameObject);
                }

                // Set Bomb Dropping logic
                alienCol.pGameObject.dropID = i;
                BombDropCommand dropCmd = new BombDropCommand(alienCol.pGameObject, pStats.currentLevel);
                TimerManager.getInstance().Add(TimerEvent.Name.DropBombCommand, dropCmd, 3.0f - 0.2f * pStats.currentLevel);

                // --add col to the batch
                SpriteBatchManager.getInstance().FindSpriteBatchByName(sbName).AddSprite(alienCol);

                alienGrid.AddChild(alienCol.pGameObject);
            }

            // Configure alien advance animation
            alienGrid.CompositeSetDelta(20.0f);
            AlienAdvanceAnimation alienAdv = new AlienAdvanceAnimation(alienGrid, 1.0f - 0.05f * pStats.currentLevel);

            TimerManager.getInstance().Add(TimerEvent.Name.AlienAdvanceAnimation, alienAdv, 1.0f - 0.1f * pStats.currentLevel);
            // -- add grid to the batch
            if (GlobalConfiguration.showCollisionRect)
            {
                SpriteBatchManager.getInstance().FindSpriteBatchByName(sbName).AddSprite(alienGrid.colliRect.box);
            }

            SpriteBatchManager.getInstance().FindSpriteBatchByName(sbName).AddSprite(alienGridSprite);

            return(alienGrid);
        }
Пример #5
0
 // Constructor
 public SceneState()
 {
     this.TimeAtPause = TimerManager.GetCurrentTime();
 }
Пример #6
0
        // game methods

        public override void load()
        {
            //---------------------------------------------------------------------------------------------------------
            // Create sprite batch
            //---------------------------------------------------------------------------------------------------------
            SpriteBatchManager.getInstance().AddSpriteBatch(SpriteBatch.Name.Player1, 2);

            //---------------------------------------------------------------------------------------------------------
            // Create game sprites
            //---------------------------------------------------------------------------------------------------------
            GameObject alienGrid = GameSpriteFactory.CreateAlienGrid(SpriteBatch.Name.Player1, 100f, 800f - GlobalPlayerStats.Player1.currentLevel * 20f);

            TimerManager.getInstance().Add(new TimerEvent(TimerEvent.Name.ReleaseUFOCommand, new ReleaseUFOCommand(), 0.5f));

            // PA6 Create shield
            ShieldFactory shieldFactory = new ShieldFactory();

            GameObject shieldGrid_1 = shieldFactory.CreateShield(SpriteBatch.Name.Player1, 150f, 300f, 15f, 7.5f);
            GameObject shieldGrid_2 = shieldFactory.CreateShield(SpriteBatch.Name.Player1, 350f, 300f, 15f, 7.5f);
            GameObject shieldGrid_3 = shieldFactory.CreateShield(SpriteBatch.Name.Player1, 550f, 300f, 15f, 7.5f);
            GameObject shieldGrid_4 = shieldFactory.CreateShield(SpriteBatch.Name.Player1, 750f, 300f, 15f, 7.5f);

            // Collision Pair setup
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallAlien, ProjectileTracker.pLeftWall, alienGrid);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallAlien, ProjectileTracker.pRightWall, alienGrid);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallMissile, ProjectileTracker.pTopWall, ProjectileTracker.pMissile);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.AlienMissile, alienGrid, ProjectileTracker.pMissile);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldMissile, shieldGrid_1, ProjectileTracker.pMissile);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldMissile, shieldGrid_2, ProjectileTracker.pMissile);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldMissile, shieldGrid_3, ProjectileTracker.pMissile);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldMissile, shieldGrid_4, ProjectileTracker.pMissile);


            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_1, ProjectileTracker.pDaggerBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_1, ProjectileTracker.pZigZagBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_1, ProjectileTracker.pRollingBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_2, ProjectileTracker.pDaggerBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_2, ProjectileTracker.pZigZagBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_2, ProjectileTracker.pRollingBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_3, ProjectileTracker.pDaggerBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_3, ProjectileTracker.pZigZagBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_3, ProjectileTracker.pRollingBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_4, ProjectileTracker.pDaggerBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_4, ProjectileTracker.pZigZagBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_4, ProjectileTracker.pRollingBomb);

            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallBomb, ProjectileTracker.pBottomWall, ProjectileTracker.pDaggerBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallBomb, ProjectileTracker.pBottomWall, ProjectileTracker.pZigZagBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallBomb, ProjectileTracker.pBottomWall, ProjectileTracker.pRollingBomb);

            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.MissileBomb, ProjectileTracker.pMissile, ProjectileTracker.pDaggerBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.MissileBomb, ProjectileTracker.pMissile, ProjectileTracker.pZigZagBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.MissileBomb, ProjectileTracker.pMissile, ProjectileTracker.pRollingBomb);

            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShipBomb, ProjectileTracker.pShip, ProjectileTracker.pDaggerBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShipBomb, ProjectileTracker.pShip, ProjectileTracker.pZigZagBomb);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShipBomb, ProjectileTracker.pShip, ProjectileTracker.pRollingBomb);

            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.UFOMissile, ProjectileTracker.pUFO, ProjectileTracker.pMissile);
            ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldAlien, alienGrid, ProjectileTracker.pMissile);
        }
        public override void Initialize()
        {
            this.poGameObjectManager = new GameObjectManager(3, 1);
            GameObjectManager.SetActive(this.poGameObjectManager);

            this.poTimerManager = new TimerManager(3, 1);
            TimerManager.SetActive(this.poTimerManager);

            this.poCollisionPairManager = new CollisionPairManager(3, 1);
            CollisionPairManager.SetActive(this.poCollisionPairManager);

            //---------------------------------------------------------------------------------------------------------
            // Create SpriteBatch
            //---------------------------------------------------------------------------------------------------------
            this.poSpriteBatchManager = new SpriteBatchManager(3, 1);
            SpriteBatchManager.SetActive(this.poSpriteBatchManager);

            SpriteBatch pAliensBatch  = SpriteBatchManager.Add(SpriteBatch.Name.Aliens, 1);
            SpriteBatch pBoxBatch     = SpriteBatchManager.Add(SpriteBatch.Name.Boxes, 2);
            SpriteBatch pShieldsBatch = SpriteBatchManager.Add(SpriteBatch.Name.Shields, 3);
            SpriteBatch pNullBatch    = SpriteBatchManager.Add(SpriteBatch.Name.NullObjects, 4);
            SpriteBatch pTexts        = SpriteBatchManager.Add(SpriteBatch.Name.Texts, 5);

            pBoxBatch.SetDrawBool(false);

            //---------------------------------------------------------------------------------------------------------
            // Input
            //---------------------------------------------------------------------------------------------------------
            this.poInputManager = new InputManager();
            InputManager.SetActive(this.poInputManager);

            InputSubject pInputSubject;

            pInputSubject = InputManager.GetArrowRightSubject();
            pInputSubject.Attach(new MoveRightObserver());

            pInputSubject = InputManager.GetArrowLeftSubject();
            pInputSubject.Attach(new MoveLeftObserver());

            pInputSubject = InputManager.GetSpaceSubject();
            pInputSubject.Attach(new ShootObserver());
            pInputSubject.Attach(new ShootSoundObserver());

            pInputSubject = InputManager.GetCKeySubject();
            pInputSubject.Attach(new ToggleCollisionBoxObserver());

            Simulation.SetState(Simulation.State.Realtime);
            //---------------------------------------------------------------------------------------------------------
            // Create Texts
            //---------------------------------------------------------------------------------------------------------

            this.poFontManager = new FontManager(3, 1);
            FontManager.SetActive(this.poFontManager);

            FontManager.Add(Font.Name.Header, SpriteBatch.Name.Texts, "SCORE<1>       HI-SCORE       SCORE<2>", 20f, SpaceInvaders.ScreenHeight - 20f, 15f, 25f);
            FontManager.Add(Font.Name.Player1Score, SpriteBatch.Name.Texts, "0000", 65f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f);
            FontManager.Add(Font.Name.Player2Score, SpriteBatch.Name.Texts, "0000", SpaceInvaders.ScreenWidth - 156f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f);
            FontManager.Add(Font.Name.HiScore, SpriteBatch.Name.Texts, "0000", 380f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f);
            FontManager.Add(Font.Name.Lives, SpriteBatch.Name.Texts, "3", 40f, 40f, 15f, 25f);


            //---------------------------------------------------------------------------------------------------------
            // Create Walls
            //---------------------------------------------------------------------------------------------------------

            // Wall Root
            WallGroup pWallGroup = new WallGroup(GameObject.Name.WallGroup, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pWallGroup.ActivateGameSprite(pAliensBatch);//even need this?
            pWallGroup.ActivateCollisionSprite(pBoxBatch);

            WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.NullObject, SpaceInvaders.ScreenWidth - 15, SpaceInvaders.ScreenHeight / 2, 20, SpaceInvaders.ScreenHeight - 110);

            pWallRight.ActivateCollisionSprite(pBoxBatch);

            WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.NullObject, 20, SpaceInvaders.ScreenHeight / 2, 20, SpaceInvaders.ScreenHeight - 110);

            pWallLeft.ActivateCollisionSprite(pBoxBatch);

            WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.NullObject, 450, SpaceInvaders.ScreenHeight - 70, SpaceInvaders.ScreenWidth - 10, 30);

            pWallTop.ActivateCollisionSprite(pBoxBatch);

            WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.Ground, 450, 60, SpaceInvaders.ScreenWidth - 10, 5);

            pWallBottom.ActivateGameSprite(pAliensBatch);
            pWallBottom.ActivateCollisionSprite(pBoxBatch);

            // Add to the composite the children
            pWallGroup.Add(pWallRight);
            pWallGroup.Add(pWallLeft);
            pWallGroup.Add(pWallTop);
            pWallGroup.Add(pWallBottom);

            GameObjectManager.Attach(pWallGroup);

            //---------------------------------------------------------------------------------------------------------
            // Create Bomb Root
            //---------------------------------------------------------------------------------------------------------

            BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pBombRoot.ActivateGameSprite(pAliensBatch);//change? even need this?
            pBombRoot.ActivateCollisionSprite(pBoxBatch);

            GameObjectManager.Attach(pBombRoot);

            DropBombEvent pBombEvent = new DropBombEvent();

            TimerManager.Add(TimeEvent.Name.DropBomb, pBombEvent, 3.0f);

            //---------------------------------------------------------------------------------------------------------
            // Create Missile Root
            //---------------------------------------------------------------------------------------------------------

            // Missile Root
            MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pMissileGroup.ActivateGameSprite(pAliensBatch);//change? even need this?
            pMissileGroup.ActivateCollisionSprite(pBoxBatch);

            GameObjectManager.Attach(pMissileGroup);

            //---------------------------------------------------------------------------------------------------------
            // Create Ship Root
            //---------------------------------------------------------------------------------------------------------

            ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pShipRoot.ActivateGameSprite(pAliensBatch);//change? even need this?
            pShipRoot.ActivateCollisionSprite(pBoxBatch);

            GameObjectManager.Attach(pShipRoot);

            ShipManager.ActivateShip();
            ShipManager.ActivateMissile();

            //---------------------------------------------------------------------------------------------------------
            // Create UFO and UFO Root
            //---------------------------------------------------------------------------------------------------------
            UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pUFORoot.ActivateGameSprite(pAliensBatch);//change? even need this?
            pUFORoot.ActivateCollisionSprite(pBoxBatch);

            GameObjectManager.Attach(pUFORoot);

            OrangeSaucer pUFO = new OrangeSaucer(GameObject.Name.OrangeSaucer, GameSprite.Name.OrangeSaucer, 20f, SpaceInvaders.ScreenHeight - 110f);

            pUFO.ActivateGameSprite(pAliensBatch);//change? even need this?
            pUFO.ActivateCollisionSprite(pBoxBatch);

            pUFORoot.Add(pUFO);
            pUFO.Remove();


            SpawnUFOEvent pUFOEvent = new SpawnUFOEvent();

            TimerManager.Add(TimeEvent.Name.UFOSpawn, pUFOEvent, RandomManager.RandomInt(15, 45));

            //---------------------------------------------------------------------------------------------------------
            // Create Aliens
            //---------------------------------------------------------------------------------------------------------

            AlienFactory AF         = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes);
            AlienGrid    pAlienGrid = (AlienGrid)AF.Create(GameObject.Name.AlienGrid);


            for (int i = 0; i < 11; i++)
            {
                GameObject pCol = AF.Create(GameObject.Name.AlienColumn);
                GameObject pGameObject;
                pGameObject = AF.Create(GameObject.Name.PurpleOctopus, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 364f);
                pCol.Add(pGameObject);

                pGameObject = AF.Create(GameObject.Name.PurpleOctopus, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 298f);
                pCol.Add(pGameObject);

                pGameObject = AF.Create(GameObject.Name.BlueCrab, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 232f);
                pCol.Add(pGameObject);

                pGameObject = AF.Create(GameObject.Name.BlueCrab, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 166f);
                pCol.Add(pGameObject);

                pGameObject = AF.Create(GameObject.Name.GreenSquid, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 100f);
                pCol.Add(pGameObject);

                pAlienGrid.Add(pCol);
            }
            GameObjectManager.Attach(pAlienGrid);

            pAlienGrid.Attach(new MoveAlienSoundObserver());
            pAlienGrid.Attach(new MoveAlienGridObserver());

            AlienGridMoveEvent pGridMoveEvent = new AlienGridMoveEvent();

            TimerManager.Add(TimeEvent.Name.MoveAlienGrid, pGridMoveEvent, pAlienGrid.GetMoveRate());

            //---------------------------------------------------------------------------------------------------------
            // Timer Animations
            //---------------------------------------------------------------------------------------------------------

            // Create an animation sprite
            AnimationSprite pAnimOctopus = new AnimationSprite(GameSprite.Name.PurpleOctopus);
            AnimationSprite pAnimCrab    = new AnimationSprite(GameSprite.Name.BlueCrab);
            AnimationSprite pAnimSquid   = new AnimationSprite(GameSprite.Name.GreenSquid);

            // attach several images to cycle

            pAnimOctopus.Attach(Image.Name.OctopusA);
            pAnimOctopus.Attach(Image.Name.OctopusB);

            pAnimCrab.Attach(Image.Name.AlienA);
            pAnimCrab.Attach(Image.Name.AlienB);

            pAnimSquid.Attach(Image.Name.SquidA);
            pAnimSquid.Attach(Image.Name.SquidB);

            // add AnimationSprite to timer
            TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimOctopus, pAlienGrid.GetMoveRate());
            TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimCrab, pAlienGrid.GetMoveRate());
            TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimSquid, pAlienGrid.GetMoveRate());

            //---------------------------------------------------------------------------------------------------------
            // Shield
            //---------------------------------------------------------------------------------------------------------

            // Create the factory
            Composite pShieldRoot = (Composite) new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            GameObjectManager.Attach(pShieldRoot);
            ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot);

            float start_x = 160.0f;
            float start_y = 200.0f;
            float off_x;
            float brickWidth  = 12.0f;
            float brickHeight = 7.0f;

            GameObject pShieldGrid;
            GameObject pShieldCol;

            for (int i = 0; i < 4; i++)
            {
                off_x = 0;
                SF.SetParent(pShieldRoot);
                pShieldGrid = SF.Create(GameObject.Name.ShieldGrid);

                //------Col1
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick_LeftTop1, start_x, start_y + 8 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick_LeftTop0, start_x, start_y + 9 * brickHeight);

                //-------Col2
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

                off_x += brickWidth;
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

                //-------Col3
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

                off_x += brickWidth;
                SF.Create(GameObject.Name.ShieldBrick_LeftBottom, start_x + off_x, start_y + 2 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

                //-------Col4
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

                off_x += brickWidth;
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

                //-------Col5
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

                off_x += brickWidth;
                SF.Create(GameObject.Name.ShieldBrick_RightBottom, start_x + off_x, start_y + 2 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

                //-------Col6
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

                off_x += brickWidth;
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight);

                //-------Col7
                SF.SetParent(pShieldGrid);
                pShieldCol = SF.Create(GameObject.Name.ShieldColumn);
                SF.SetParent(pShieldCol);

                off_x += brickWidth;
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick_RightTop1, start_x + off_x, start_y + 8 * brickHeight);
                SF.Create(GameObject.Name.ShieldBrick_RightTop0, start_x + off_x, start_y + 9 * brickHeight);

                start_x += 170;
            }


            //---------------------------------------------------------------------------------------------------------
            // Create Null Ship Lives
            //---------------------------------------------------------------------------------------------------------

            ScenePlay2.ShipLives = 3;

            PlayerLivesComposite pNullObjs = new PlayerLivesComposite();

            Ship pNullShip1 = new Ship(GameObject.Name.Null_Object, GameSprite.Name.Ship, 120.0f, 40.0f);

            pNullShip1.ActivateGameSprite(pNullBatch);
            pNullObjs.Add(pNullShip1);

            Ship pNullShip2 = new Ship(GameObject.Name.Null_Object, GameSprite.Name.Ship, 180.0f, 40.0f);

            pNullShip2.ActivateGameSprite(pNullBatch);
            pNullObjs.Add(pNullShip2);

            GameObjectManager.Attach(pNullObjs);

            //---------------------------------------------------------------------------------------------------------
            // Create CollisionPairs
            //---------------------------------------------------------------------------------------------------------

            //Why does the order that left/right wall are added matter??????? reverse order breaks game
            CollisionPair pShipWallRightPair = CollisionPairManager.Add(CollisionPair.Name.Ship_Wall_Right, pShipRoot, pWallRight);

            Debug.Assert(pShipWallRightPair != null);

            CollisionPair pShipWallLeftPair = CollisionPairManager.Add(CollisionPair.Name.Ship_Wall_Left, pShipRoot, pWallLeft);

            Debug.Assert(pShipWallLeftPair != null);

            CollisionPair pAlienMissilePair = CollisionPairManager.Add(CollisionPair.Name.Alien_Missile, pMissileGroup, pAlienGrid);

            Debug.Assert(pAlienMissilePair != null);

            CollisionPair pMissileWallPair = CollisionPairManager.Add(CollisionPair.Name.Missile_Wall_Top, pMissileGroup, pWallTop);

            Debug.Assert(pMissileWallPair != null);

            CollisionPair pAlienWallPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Wall, pAlienGrid, pWallGroup);

            Debug.Assert(pAlienWallPair != null);

            CollisionPair pAlienWallBottomPair = CollisionPairManager.Add(CollisionPair.Name.Alien_WallBottom, pAlienGrid, pWallBottom);

            Debug.Assert(pAlienWallBottomPair != null);

            CollisionPair pBombWallPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Wall_Bottom, pBombRoot, pWallBottom);

            Debug.Assert(pBombWallPair != null);

            CollisionPair pBombShieldPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Shield, pBombRoot, pShieldRoot);

            Debug.Assert(pBombShieldPair != null);

            CollisionPair pMissileShieldPair = CollisionPairManager.Add(CollisionPair.Name.Missile_Shield, pMissileGroup, pShieldRoot);

            Debug.Assert(pMissileShieldPair != null);

            CollisionPair pBombShipPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Ship, pBombRoot, ShipManager.GetShip());

            Debug.Assert(pBombShipPair != null);

            CollisionPair pBombMissilePair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Missile, pBombRoot, ShipManager.GetMissile());

            Debug.Assert(pBombMissilePair != null);

            CollisionPair pAlienShieldPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Shield, pShieldRoot, pAlienGrid);

            Debug.Assert(pAlienShieldPair != null);

            CollisionPair pUFOMissilePair = CollisionPairManager.Add(CollisionPair.Name.UFO_Missile, pMissileGroup, pUFORoot);

            Debug.Assert(pUFOMissilePair != null);

            //TODO consolidate these news
            pShipWallLeftPair.Attach(new ShipStopLeftObserver());
            pShipWallRightPair.Attach(new ShipStopRightObserver());

            pMissileWallPair.Attach(new ShipRemoveMissileObserver());

            pAlienMissilePair.Attach(new ShipRemoveMissileObserver());
            pAlienMissilePair.Attach(new RemoveAlienObserver());
            pAlienMissilePair.Attach(new DeadAlienSoundObserver());
            pAlienMissilePair.Attach(new AddP2PointsObserver());
            pAlienMissilePair.Attach(new IncreaseAlienSpeedObserver());

            pAlienWallPair.Attach(new GridObserver());

            pBombWallPair.Attach(new RemoveBombObserver());

            pBombShieldPair.Attach(new RemoveBombObserver());
            pBombShieldPair.Attach(new RemoveBrickObserver());

            pMissileShieldPair.Attach(new ShipRemoveMissileObserver());
            pMissileShieldPair.Attach(new RemoveBrickObserver());

            pBombShipPair.Attach(new RemoveBombObserver());
            pBombShipPair.Attach(new RemoveShipObserver());
            pBombShipPair.Attach(new DeadShipSoundObserver());
            pBombShipPair.Attach(new RemoveP2LifeObserver());
            pBombShipPair.Attach(new ChangeP2StateObserver());

            pBombMissilePair.Attach(new RemoveBombObserver());
            pBombMissilePair.Attach(new ShipRemoveMissileObserverAltPair());

            pAlienShieldPair.Attach(new RemoveBrickObserver());

            pUFOMissilePair.Attach(new RemoveUFOObserver());
            pUFOMissilePair.Attach(new ShipRemoveMissileObserver());
            pUFOMissilePair.Attach(new AddP2PointsObserver());
            pUFOMissilePair.Attach(new DeadUFOSoundObserver());

            pAlienWallBottomPair.Attach(new DeadShipSoundObserver());
            pAlienWallBottomPair.Attach(new RemoveAllP2LivesObserver());
        }
Пример #8
0
        public override void Execute(float deltaTime)
        {
            SpaceInvaders pGame = GameStateManager.GetGame();

            pGame.SetResetLevelFlag(false);

            // Ghost any remaining Shields
            ShieldGroup pShieldGroup = (ShieldGroup)GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.ShieldGroup);

            ShieldFactory.DestroyShields(pShieldGroup);

            // Ghost any remaining Aliens (Only necessary for Game reset)
            AlienGrid pAlienGrid = (AlienGrid)GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.AlienGrid);

            AlienFactory.DestroyAlienGrid(pAlienGrid);

            // Clear TimeEvents
            TimeEvent tEvent = TimerManager.Pop();

            while (tEvent != null)
            {
                // Kill any remaining TimerEvents
                tEvent = TimerManager.Pop();
            }

            // Recreate shields
            GameObject pShield;

            pShield = ShieldFactory.RecreateShield(110, 150);
            pShieldGroup.Add(pShield);
            pShield = ShieldFactory.RecreateShield(310, 150);
            pShieldGroup.Add(pShield);
            pShield = ShieldFactory.RecreateShield(510, 150);
            pShieldGroup.Add(pShield);
            pShield = ShieldFactory.RecreateShield(710, 150);
            pShieldGroup.Add(pShield);

            // Adjust Starting Speed
            float newStartingSpeed = pGame.GetStateLevelInitialAlienGridSpeed() - 0.05f;

            pGame.SetStateLevelInitialAlienGridSpeed(newStartingSpeed);
            pGame.SetStateAlienGridSpeed(newStartingSpeed);

            // Adjust Starting Position
            float newStartingYPosition = pGame.GetStateLevelInitialAlienGridYPosition() - 40.0f;

            pGame.SetStateLevelInitialAlienGridYPosition(newStartingYPosition);

            // Recreate AlienGrid
            AlienFactory.RecreateAlienGrid(pAlienGrid, newStartingSpeed, GameStateManager.GetGame().GetGameInitialGridXPosition(), newStartingYPosition);

            pGame.GetStateGameObjectManager().Print();
            pGame.GetStateSpriteBatchManager().Print();

            // Queue up Time Events
            QueuedTimeEventManager qtem = pGame.GetStateQueuedTimeEventManager();

            qtem.Enqueue(TimeEvent.Name.AlienGridMovementSound, new AlienGridMovementSound(), newStartingSpeed);
            qtem.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.SquidAlien), newStartingSpeed);
            qtem.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.CrabAlien), newStartingSpeed);
            qtem.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.JellyfishAlien), newStartingSpeed);
            qtem.Enqueue(TimeEvent.Name.DropBomb, new DropBombCommand(), 1.0f);
            qtem.Enqueue(TimeEvent.Name.DropBomb, new DropBombCommand(), 3.0f);
        }
Пример #9
0
 public override void Start(Game pGame)
 {
     ScoreManager.ClearScore();
     this.Handle(pGame);
     TimerManager.Add(TimerEventName.SetGameState, TimerManager.GetCurrentTime() + 5.0f, TimerManager.GetCurrentTime() + 5.0f, new GameSelectEvent());
 }
Пример #10
0
        protected virtual void PlayerTwoInit(GameManager pGameManager)
        {
            float levelSpeed = 0.75f / pGameManager.pActivePlayer.level;

            pGameManager.poPlayer2.pGrid = InvaderGridManager.GenerateGrid(pGameManager.pActivePlayer.level);
            //Debug.WriteLine("Generated Grid ({0}) for P2", pGameManager.poPlayer2.pGrid.GetHashCode());

            pGameManager.poPlayer2.pShieldZone = ShieldBuilder.CreateShieldZone(175, 300, 150, 4);

            //---------------------------------------------------------------------------------------------------------
            // Create GameSpace and Wall Objects
            //---------------------------------------------------------------------------------------------------------
            WallManager pWallMan = new WallManager();

            //Debug.WriteLine("WallLeft Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.leftWallXPos, Constants.leftWallYPos, Constants.leftWallWidth, Constants.leftWallHeight);
            //Debug.WriteLine("WallRight Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.rightWallXPos, Constants.rightWallYPos, Constants.rightWallWidth, Constants.rightWallHeight);
            //Debug.WriteLine("Ceiling Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.ceilingXPos, Constants.ceilingYPos, Constants.ceilingWidth, Constants.ceilingHeight);
            //Debug.WriteLine("Floor Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.floorXPos, Constants.floorYPos, Constants.floorWidth, Constants.floorHeight);

            //---------------------------------------------------------------------------------------------------------
            // Set up Sprite Animations
            //---------------------------------------------------------------------------------------------------------
            // Set up animations for the 3 basic Invaders
            AnimationSprite pSmInvaderAnim = new AnimationSprite(Sprite.Name.SmallInvader);

            pSmInvaderAnim.Attach(Image.Name.SmallInvader1);
            pSmInvaderAnim.Attach(Image.Name.SmallInvader2);

            AnimationSprite pMedInvaderAnim = new AnimationSprite(Sprite.Name.MediumInvader);

            pMedInvaderAnim.Attach(Image.Name.MediumInvader1);
            pMedInvaderAnim.Attach(Image.Name.MediumInvader2);

            AnimationSprite pLgInvaderAnim = new AnimationSprite(Sprite.Name.LargeInvader);

            pLgInvaderAnim.Attach(Image.Name.LargeInvader1);
            pLgInvaderAnim.Attach(Image.Name.LargeInvader2);

            // Add the Invader animations as timed events to the TimerManager
            TimerManager.Add(TimeEvent.Name.SmInvaderMarchAnimation, pSmInvaderAnim, levelSpeed);
            TimerManager.Add(TimeEvent.Name.MedInvaderMarchAnimation, pMedInvaderAnim, levelSpeed);
            TimerManager.Add(TimeEvent.Name.LgInvaderMarchAnimation, pLgInvaderAnim, levelSpeed);

            // Set up bomb animations
            AnimationSprite pBombZigZagAnim = new AnimationSprite(Sprite.Name.BombZigZag);

            pBombZigZagAnim.Attach(Image.Name.BombZigZag1);
            pBombZigZagAnim.Attach(Image.Name.BombZigZag2);
            pBombZigZagAnim.Attach(Image.Name.BombZigZag3);
            pBombZigZagAnim.Attach(Image.Name.BombZigZag4);

            AnimationSprite pBombDaggerAnim = new AnimationSprite(Sprite.Name.BombDagger);

            pBombDaggerAnim.Attach(Image.Name.BombDagger1);
            pBombDaggerAnim.Attach(Image.Name.BombDagger2);
            pBombDaggerAnim.Attach(Image.Name.BombDagger3);
            pBombDaggerAnim.Attach(Image.Name.BombDagger4);

            AnimationSprite pBombRollingAnim = new AnimationSprite(Sprite.Name.BombRolling);

            pBombRollingAnim.Attach(Image.Name.BombRolling1);
            pBombRollingAnim.Attach(Image.Name.BombRolling2);

            // Add the bomb animations as timed events to the TimerManager
            TimerManager.Add(TimeEvent.Name.BombAnimation, pBombZigZagAnim, 0.25f);
            TimerManager.Add(TimeEvent.Name.BombAnimation, pBombDaggerAnim, 0.25f);
            TimerManager.Add(TimeEvent.Name.BombAnimation, pBombRollingAnim, 0.25f);


            //---------------------------------------------------------------------------------------------------------
            // Set up TimedSoundEffects
            //---------------------------------------------------------------------------------------------------------
            TimedSoundEffects pGridMarchingSounds = new TimedSoundEffects();

            pGridMarchingSounds.Attach(Sound.Name.InvaderMarch4);
            pGridMarchingSounds.Attach(Sound.Name.InvaderMarch3);
            pGridMarchingSounds.Attach(Sound.Name.InvaderMarch2);
            pGridMarchingSounds.Attach(Sound.Name.InvaderMarch1);

            TimerManager.Add(TimeEvent.Name.GridMarchSoundEffects, pGridMarchingSounds, levelSpeed);

            //---------------------------------------------------------------------------------------------------------
            // Setting up the collisions for the player ship and missile
            //---------------------------------------------------------------------------------------------------------
            Ship    pShip    = ShipManager.ActivateShip();
            Missile pMissile = ShipManager.GetMissile();

            //---------------------------------------------------------------------------------------------------------
            // Add Collision Pairs and their Observers
            //---------------------------------------------------------------------------------------------------------
            // Applies to both players
            // ship vs left wall
            ColPair pShip_WallLeftColPair = ColPairManager.Add(ColPair.Name.Ship_WallLeft, pShip, pWallMan.GetWallLeft());

            Debug.Assert(pShip_WallLeftColPair != null);
            pShip_WallLeftColPair.Attach(new Ship_WallLeftObserver());
            // ship vs Right wall
            ColPair pShip_WallRightColPair = ColPairManager.Add(ColPair.Name.Ship_WallRight, pShip, pWallMan.GetWallRight());

            Debug.Assert(pShip_WallRightColPair != null);
            pShip_WallRightColPair.Attach(new Ship_WallRightObserver());
            // Missile vs Ceiling
            ColPair pMissile_CeilingColPair = ColPairManager.Add(ColPair.Name.Missile_Ceiling, pMissile, pWallMan.GetCeiling());

            Debug.Assert(pMissile_CeilingColPair != null);
            pMissile_CeilingColPair.Attach(new ShipMissileReadyObserver());
            pMissile_CeilingColPair.Attach(new ShipRemoveMissileObserver());

            //---------------------------------------------------------------------------------------------------------
            // Set up Random UFO Spawns
            //---------------------------------------------------------------------------------------------------------
            RandomlySpawnUFO pRandomUfoEvent = new RandomlySpawnUFO(30.0f, pMissile, pWallMan);

            TimerManager.Add(TimeEvent.Name.RandomlySpawnUFO, pRandomUfoEvent, 10.0f);


            //---------------------------------------------------------------------------------------------------------
            // Create Alien Grid and random bomb drops
            //---------------------------------------------------------------------------------------------------------
            BombFactory       pBombFactory     = new BombFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pGameManager.poPlayer2.pGrid, pWallMan);
            RandomlySpawnBomb pRandomBombEvent = new RandomlySpawnBomb(2.0f, pBombFactory);

            TimerManager.Add(TimeEvent.Name.RandomBombSpawn, pRandomBombEvent, 2.0f);

            // Applies to players seperately
            // Set up timing for Grid and UFO motion
            TimeBasedMover pGridMover = new TimeBasedMover(pGameManager.poPlayer2.pGrid);

            TimerManager.Add(TimeEvent.Name.TimedGridMover, pGridMover, levelSpeed);

            //---------------------------------------------------------------------------------------------------------
            // Create the Shields
            //---------------------------------------------------------------------------------------------------------

            // Applies to each player seperately
            // grid vs leftwall
            ColPair pGrid_WallLeftColPair = ColPairManager.Add(ColPair.Name.Grid_WallLeft, pGameManager.poPlayer2.pGrid, pWallMan.GetWallLeft());

            Debug.Assert(pGrid_WallLeftColPair != null);
            pGrid_WallLeftColPair.Attach(new Grid_WallLeftObserver());
            // Grid vs rightwall
            ColPair pGrid_WallRightcolPair = ColPairManager.Add(ColPair.Name.Grid_WallRight, pGameManager.poPlayer2.pGrid, pWallMan.GetWallRight());

            Debug.Assert(pGrid_WallRightcolPair != null);
            pGrid_WallRightcolPair.Attach(new Grid_WallRightObserver());
            // Grid vs ship
            ColPair pShip_GridColPair = ColPairManager.Add(ColPair.Name.Ship_Grid, pShip, pGameManager.poPlayer2.pGrid);

            Debug.Assert(pShip_GridColPair != null);
            pShip_GridColPair.Attach(new RemoveShipObserver());
            // Grid vs Missile
            ColPair pMissile_GridColPair = ColPairManager.Add(ColPair.Name.Missile_Grid, pMissile, pGameManager.poPlayer2.pGrid);

            Debug.Assert(pMissile_GridColPair != null);
            pMissile_GridColPair.Attach(new ShipRemoveMissileObserver());
            pMissile_GridColPair.Attach(new ShipMissileReadyObserver());
            pMissile_GridColPair.Attach(new RemoveInvaderObserver());
            pMissile_GridColPair.Attach(new AwardPointsObserver());
            // Grid vs Shields
            ColPair pGrid_ShieldZoneColPair = ColPairManager.Add(ColPair.Name.Grid_ShieldZone, pGameManager.poPlayer2.pGrid, pGameManager.poPlayer2.pShieldZone);

            pGrid_ShieldZoneColPair.Attach(new RemoveShieldBrickObserver());

            // Missile vs Shields
            ColPair pMissile_ShieldZoneColPair = ColPairManager.Add(ColPair.Name.Missile_ShieldZone, pMissile, pGameManager.poPlayer2.pShieldZone);

            pMissile_ShieldZoneColPair.Attach(new ShipMissileReadyObserver());
            pMissile_ShieldZoneColPair.Attach(new ShipRemoveMissileObserver());
            pMissile_ShieldZoneColPair.Attach(new RemoveShieldBrickObserver());


            // STORE Current State of managers into manager mementos
            pGameManager.poPlayer2.ArchiveManagerStates(pGameManager.pGame.GetTime());
        }
Пример #11
0
 public override void Leaving()
 {
     // update SpriteBatchMan()
     this.TimeAtPause = TimerManager.GetCurrentTime();
 }
Пример #12
0
        //-----------------------------------------------------------------------------
        // Game::LoadContent()
        //		Allows you to load all content needed for your engine,
        //	    such as objects, graphics, etc.
        //-----------------------------------------------------------------------------
        public override void LoadContent()
        {
            //---------------------------------------------------------------------------------------------------------
            // Manager initialization
            //---------------------------------------------------------------------------------------------------------
            TextureManager.Create(1, 1);
            ImageManager.Create(5, 2);
            GameSpriteManager.Create(4, 2);
            BoxSpriteManager.Create(3, 1);
            SpriteBatchManager.Create(3, 1);
            ProxySpriteManager.Create(10, 1);
            TimerManager.Create(3, 1);
            GameObjectManager.Create(3, 1);
            CollisionPairManager.Create(3, 1);
            InputManager.Create();
            SoundManager.Create();

            GlyphManager.Create(3, 1);
            FontManager.Create(3, 1);
            ScoreManager.Create();



            //---------------------------------------------------------------------------------------------------------
            // Load the Textures
            //---------------------------------------------------------------------------------------------------------
            TextureManager.Add(Texture.Name.Aliens, "aliens14x14.tga");
            TextureManager.Add(Texture.Name.Shield, "birds_N_shield.tga");
            TextureManager.Add(Texture.Name.Consolas36pt, "consolas36pt.tga");
            FontManager.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt);

            //---------------------------------------------------------------------------------------------------------
            // Create Images
            //---------------------------------------------------------------------------------------------------------
            ImageManager.Add(Image.Name.Octopus0, Texture.Name.Aliens, 56, 28, 168, 112);
            ImageManager.Add(Image.Name.Octopus1, Texture.Name.Aliens, 56, 182, 168, 112);
            ImageManager.Add(Image.Name.Crab1, Texture.Name.Aliens, 322, 182, 154, 112);
            ImageManager.Add(Image.Name.Crab0, Texture.Name.Aliens, 322, 28, 154, 112);
            ImageManager.Add(Image.Name.Squid0, Texture.Name.Aliens, 616, 28, 112, 112);
            ImageManager.Add(Image.Name.Squid1, Texture.Name.Aliens, 616, 182, 112, 112);
            ImageManager.Add(Image.Name.UFO, Texture.Name.Aliens, 84, 504, 224, 98);
            ImageManager.Add(Image.Name.Missile, Texture.Name.Aliens, 378, 798, 14, 98);
            ImageManager.Add(Image.Name.Player, Texture.Name.Aliens, 57, 336, 182, 112);
            ImageManager.Add(Image.Name.BombCross, Texture.Name.Aliens, 196, 798, 42, 84);
            ImageManager.Add(Image.Name.BombStraight, Texture.Name.Aliens, 630, 798, 14, 98);
            ImageManager.Add(Image.Name.BombZigZag, Texture.Name.Aliens, 574, 644, 42, 98);

            ImageManager.Add(Image.Name.UFO_Explosion, Texture.Name.Aliens, 42, 643, 294, 112);
            ImageManager.Add(Image.Name.Player_Explosion1, Texture.Name.Aliens, 308, 336, 210, 112);
            ImageManager.Add(Image.Name.Player_Explosion2, Texture.Name.Aliens, 560, 336, 224, 112);
            ImageManager.Add(Image.Name.Missile_Explosion, Texture.Name.Aliens, 406, 490, 112, 112);
            ImageManager.Add(Image.Name.Alien_Explosion2, Texture.Name.Aliens, 574, 490, 182, 112);
            ImageManager.Add(Image.Name.Bomb_Explosion, Texture.Name.Aliens, 700, 798, 84, 112);

            ImageManager.Add(Image.Name.Brick, Texture.Name.Shield, 20, 210, 10, 5);
            ImageManager.Add(Image.Name.BrickLeft_Top0, Texture.Name.Shield, 15, 180, 10, 5);
            ImageManager.Add(Image.Name.BrickLeft_Top1, Texture.Name.Shield, 15, 185, 10, 5);
            ImageManager.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Shield, 35, 215, 10, 5);
            ImageManager.Add(Image.Name.BrickRight_Top0, Texture.Name.Shield, 75, 180, 10, 5);
            ImageManager.Add(Image.Name.BrickRight_Top1, Texture.Name.Shield, 75, 185, 10, 5);
            ImageManager.Add(Image.Name.BrickRight_Bottom, Texture.Name.Shield, 55, 215, 10, 5);



            //---------------------------------------------------------------------------------------------------------
            // Create Sprites
            //---------------------------------------------------------------------------------------------------------
            GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.Squid0, 400, 200, Constant.ALIEN_WIDTH - 10, Constant.ALIEN_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.Octopus0, 50, 500, Constant.ALIEN_WIDTH, Constant.ALIEN_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.Crab, Image.Name.Crab0, 100, 300, Constant.ALIEN_WIDTH, Constant.ALIEN_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, Constant.WINDOW_WIDTH / 2, 0, 4, 20);
            GameSpriteManager.Add(GameSprite.Name.Player, Image.Name.Player, Constant.WINDOW_WIDTH / 2, 30, 40.0f, 25.0f);
            GameSpriteManager.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 6, 25.0f);
            GameSpriteManager.Add(GameSprite.Name.BombCross, Image.Name.BombCross, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 6, 25.0f);
            GameSpriteManager.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 6, 25.0f);
            GameSpriteManager.Add(GameSprite.Name.UFO, Image.Name.UFO, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 40, 20);
            GameSpriteManager.Add(GameSprite.Name.Missile_Explosion, Image.Name.Missile_Explosion, 0, 0, 10, 10);

            GameSpriteManager.Add(GameSprite.Name.UFO_Explosion, Image.Name.UFO_Explosion, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 40, 20);
            GameSpriteManager.Add(GameSprite.Name.Player_Explosion, Image.Name.Player_Explosion1, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 40, 25.0f);
            GameSpriteManager.Add(GameSprite.Name.Bomb_Explosion, Image.Name.Bomb_Explosion, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 10, 10);
            GameSpriteManager.Add(GameSprite.Name.Alien_Explosion, Image.Name.Alien_Explosion2, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, Constant.ALIEN_WIDTH, Constant.ALIEN_HEIGHT);


            GameSpriteManager.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickLeft_Top0, Image.Name.BrickLeft_Top0, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickLeft_Top1, Image.Name.BrickLeft_Top1, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickLeft_Bottom, Image.Name.BrickLeft_Bottom, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickRight_Top0, Image.Name.BrickRight_Top0, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickRight_Top1, Image.Name.BrickRight_Top1, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);
            GameSpriteManager.Add(GameSprite.Name.BrickRight_Bottom, Image.Name.BrickRight_Bottom, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT);



            //---------------------------------------------------------------------------------------------------------
            // Create SpriteBatch
            //---------------------------------------------------------------------------------------------------------
            SpriteBatch pSB_Aliens  = SpriteBatchManager.Add(SpriteBatch.Name.GameSprites);
            SpriteBatch pSB_Boxes   = SpriteBatchManager.Add(SpriteBatch.Name.BoxSprites);
            SpriteBatch pSB_Shields = SpriteBatchManager.Add(SpriteBatch.Name.ShieldSprites);
            SpriteBatch pSB_Bombs   = SpriteBatchManager.Add(SpriteBatch.Name.BombSprites);
            SpriteBatch pSB_Texts   = SpriteBatchManager.Add(SpriteBatch.Name.TextSprite);
            SpriteBatch pSB_Effect  = SpriteBatchManager.Add(SpriteBatch.Name.ExplosionEffectSprite);

            pSB_Boxes.GetSBNodeManager().ToggleDraw();

            AlienGroup pAlienGroup = new AlienGroup(GameObject.Name.AlienGroup, GameSprite.Name.NullObject, -1, 0.0f, 0.0f);

            pSB_Boxes.Attach(pAlienGroup.pColObject.pBoxSprite);
            GameObjectManager.Attach(pAlienGroup);

            ShieldGroup pShieldGroup = new ShieldGroup(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, -1, 0.0f, 0.0f);

            pSB_Boxes.Attach(pShieldGroup.pColObject.pBoxSprite);
            GameObjectManager.Attach(pShieldGroup);

            AlienManager.Create();
            ShieldNodeManager.Create();

            GameSceneManager.Create();
            GameScene.Create();
            GameScene.SetGameScene(GameState.SceneName.Select);
        }
Пример #13
0
 public override void Execute()
 {
     // Remove it from the screen later
     //Debug.WriteLine("EXECUTING... REMOVE EXPLOSION");
     TimerManager.Add(TimeEvent.Name.ExplodeAndRemove, new ExplosionEvent(this.pExplosion), 0.3f);
 }
Пример #14
0
        //-----------------------------------------------------------------------------
        // Game::LoadContent()
        //		Allows you to load all content needed for your engine,
        //	    such as objects, graphics, etc.
        //-----------------------------------------------------------------------------
        public override void LoadContent()
        {
            ScreenWidth  = this.GetScreenWidth();
            ScreenHeight = this.GetScreenHeight();

            //---------------------------------------------------------------------------------------------------------
            // Init Managers
            //---------------------------------------------------------------------------------------------------------

            //Constant Managers
            TextureManager.Create(1, 1);
            ImageManager.Create(5, 2);
            SoundManager.Create(3, 1);
            GameSpriteManager.Create(4, 2);
            BoxSpriteManager.Create(3, 1);
            CollisionStateManager.Create();
            GlyphManager.Create(3, 1);
            Simulation.Create();
            RandomManager.Create();
            BombManager.Create();
            ShipManager.Create();

            //State-unique Managers
            SpriteBatchManager.Create();
            GameObjectManager.Create();
            InputManager.Create();
            FontManager.Create();
            TimerManager.Create();
            CollisionPairManager.Create();



            //ProxySpriteManager.Create(10, 1);//not in use currently

            //---------------------------------------------------------------------------------------------------------
            // Load the Textures
            //---------------------------------------------------------------------------------------------------------

            TextureManager.Add(Texture.Name.SpaceInvaders, "SpaceInvaders.tga");

            //---------------------------------------------------------------------------------------------------------
            // Load Sounds
            //---------------------------------------------------------------------------------------------------------

            SoundManager.Add(Sound.Name.Invader1, "fastinvader1.wav");
            SoundManager.Add(Sound.Name.Invader2, "fastinvader2.wav");
            SoundManager.Add(Sound.Name.Invader3, "fastinvader3.wav");
            SoundManager.Add(Sound.Name.Invader4, "fastinvader4.wav");

            SoundManager.Add(Sound.Name.Shoot, "invaderkilled.wav");
            SoundManager.Add(Sound.Name.DeadAlien, "shoot.wav");
            SoundManager.Add(Sound.Name.UFO, "ufo_highpitch.wav");
            SoundManager.Add(Sound.Name.UFOExplosion, "ufo_lowpitch.wav");
            SoundManager.Add(Sound.Name.Explosion, "explosion.wav");

            //---------------------------------------------------------------------------------------------------------
            // Create Images
            //---------------------------------------------------------------------------------------------------------

            // --- aliens ---

            ImageManager.Add(Image.Name.OctopusA, Texture.Name.SpaceInvaders, 3, 3, 12, 8);
            ImageManager.Add(Image.Name.OctopusB, Texture.Name.SpaceInvaders, 18, 3, 12, 8);
            ImageManager.Add(Image.Name.AlienA, Texture.Name.SpaceInvaders, 33, 3, 11, 8);
            ImageManager.Add(Image.Name.AlienB, Texture.Name.SpaceInvaders, 47, 3, 11, 8);
            ImageManager.Add(Image.Name.SquidA, Texture.Name.SpaceInvaders, 61, 3, 8, 8);
            ImageManager.Add(Image.Name.SquidB, Texture.Name.SpaceInvaders, 72, 3, 8, 8);
            ImageManager.Add(Image.Name.Saucer, Texture.Name.SpaceInvaders, 99, 3, 16, 8);

            ImageManager.Add(Image.Name.Missile, Texture.Name.SpaceInvaders, 3, 29, 1, 4);
            ImageManager.Add(Image.Name.Ship, Texture.Name.SpaceInvaders, 3, 14, 13, 8);

            ImageManager.Add(Image.Name.AlienExplosion, Texture.Name.SpaceInvaders, 83, 3, 13, 8);
            ImageManager.Add(Image.Name.SaucerExplosion, Texture.Name.SpaceInvaders, 118, 3, 21, 8);
            ImageManager.Add(Image.Name.ShipExplosionA, Texture.Name.SpaceInvaders, 19, 14, 16, 8);
            ImageManager.Add(Image.Name.ShipExplosionB, Texture.Name.SpaceInvaders, 38, 14, 16, 8);

            ImageManager.Add(Image.Name.MissileExplosion, Texture.Name.SpaceInvaders, 7, 25, 8, 8);
            ImageManager.Add(Image.Name.BombExplosion, Texture.Name.SpaceInvaders, 86, 25, 6, 8);

            ImageManager.Add(Image.Name.BombDagger, Texture.Name.SpaceInvaders, 42, 27, 3, 6);
            ImageManager.Add(Image.Name.BombZigZag, Texture.Name.SpaceInvaders, 18, 26, 3, 7);
            ImageManager.Add(Image.Name.BombStraight, Texture.Name.SpaceInvaders, 65, 26, 3, 7);

            ImageManager.Add(Image.Name.ShieldBrick, Texture.Name.SpaceInvaders, 120, 35, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_LeftTop0, Texture.Name.SpaceInvaders, 115, 30, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_LeftTop1, Texture.Name.SpaceInvaders, 116, 31, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_LeftBottom, Texture.Name.SpaceInvaders, 119, 43, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_RightTop0, Texture.Name.SpaceInvaders, 132, 31, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_RightTop1, Texture.Name.SpaceInvaders, 130, 31, 4, 2);
            ImageManager.Add(Image.Name.ShieldBrick_RightBottom, Texture.Name.SpaceInvaders, 126, 43, 4, 2);

            //---------------------------------------------------------------------------------------------------------
            // Create Glyphs
            //---------------------------------------------------------------------------------------------------------
            GlyphManager.Add(Glyph.Name.Space, 32, Texture.Name.SpaceInvaders, 99, 56, 5, 7);

            GlyphManager.Add(Glyph.Name.Asterisk, 42, Texture.Name.SpaceInvaders, 115, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Hyphen, 45, Texture.Name.SpaceInvaders, 131, 56, 5, 7);

            GlyphManager.Add(Glyph.Name.Zero, 48, Texture.Name.SpaceInvaders, 3, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.One, 49, Texture.Name.SpaceInvaders, 11, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Two, 50, Texture.Name.SpaceInvaders, 19, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Three, 51, Texture.Name.SpaceInvaders, 27, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Four, 52, Texture.Name.SpaceInvaders, 35, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Five, 53, Texture.Name.SpaceInvaders, 43, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Six, 54, Texture.Name.SpaceInvaders, 51, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Seven, 55, Texture.Name.SpaceInvaders, 59, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Eight, 56, Texture.Name.SpaceInvaders, 67, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Nine, 57, Texture.Name.SpaceInvaders, 75, 56, 5, 7);

            GlyphManager.Add(Glyph.Name.LessThan, 60, Texture.Name.SpaceInvaders, 83, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Equals, 61, Texture.Name.SpaceInvaders, 107, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.GreaterThan, 62, Texture.Name.SpaceInvaders, 91, 56, 5, 7);
            GlyphManager.Add(Glyph.Name.Question, 63, Texture.Name.SpaceInvaders, 123, 56, 5, 7);

            GlyphManager.Add(Glyph.Name.A, 65, Texture.Name.SpaceInvaders, 3, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.B, 66, Texture.Name.SpaceInvaders, 11, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.C, 67, Texture.Name.SpaceInvaders, 19, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.D, 68, Texture.Name.SpaceInvaders, 27, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.E, 69, Texture.Name.SpaceInvaders, 35, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.F, 70, Texture.Name.SpaceInvaders, 43, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.G, 71, Texture.Name.SpaceInvaders, 51, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.H, 72, Texture.Name.SpaceInvaders, 59, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.I, 73, Texture.Name.SpaceInvaders, 67, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.J, 74, Texture.Name.SpaceInvaders, 75, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.K, 75, Texture.Name.SpaceInvaders, 83, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.L, 76, Texture.Name.SpaceInvaders, 91, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.M, 77, Texture.Name.SpaceInvaders, 99, 36, 5, 7);
            GlyphManager.Add(Glyph.Name.N, 78, Texture.Name.SpaceInvaders, 3, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.O, 79, Texture.Name.SpaceInvaders, 11, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.P, 80, Texture.Name.SpaceInvaders, 19, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.Q, 81, Texture.Name.SpaceInvaders, 27, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.R, 82, Texture.Name.SpaceInvaders, 35, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.S, 83, Texture.Name.SpaceInvaders, 43, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.T, 84, Texture.Name.SpaceInvaders, 51, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.U, 85, Texture.Name.SpaceInvaders, 59, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.V, 86, Texture.Name.SpaceInvaders, 67, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.W, 87, Texture.Name.SpaceInvaders, 75, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.X, 88, Texture.Name.SpaceInvaders, 83, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.Y, 89, Texture.Name.SpaceInvaders, 91, 46, 5, 7);
            GlyphManager.Add(Glyph.Name.Z, 90, Texture.Name.SpaceInvaders, 99, 46, 5, 7);


            //---------------------------------------------------------------------------------------------------------
            // Create Sprites
            //---------------------------------------------------------------------------------------------------------

            // --- aliens ---

            GameSpriteManager.Add(GameSprite.Name.PurpleOctopus, Image.Name.OctopusA, 50, 300, 49, 33);
            GameSpriteManager.Add(GameSprite.Name.BlueCrab, Image.Name.AlienB, 200, 100, 45, 33);
            GameSpriteManager.Add(GameSprite.Name.GreenSquid, Image.Name.SquidA, 200, 300, 33, 33);
            GameSpriteManager.Add(GameSprite.Name.OrangeSaucer, Image.Name.Saucer, 50, 550, 59, 33, new Azul.Color(1.0f, 0.0f, 0.0f, 1.0f));

            //-----Missile----
            GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, 50, 50, 3, 15);
            //----Player Ship----
            GameSpriteManager.Add(GameSprite.Name.Ship, Image.Name.Ship, 500, 100, 50, 30, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));

            //---Explosions---
            GameSpriteManager.Add(GameSprite.Name.AlienExplosion, Image.Name.AlienExplosion, 50, 50, 33, 33);
            GameSpriteManager.Add(GameSprite.Name.ShipExplosion, Image.Name.ShipExplosionA, 50, 50, 55, 35);
            GameSpriteManager.Add(GameSprite.Name.SaucerExplosion, Image.Name.SaucerExplosion, 50, 50, 45, 35, new Azul.Color(1.0f, 0.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.BombExplosion, Image.Name.BombExplosion, 50, 50, 25, 25);
            GameSpriteManager.Add(GameSprite.Name.MissileExplosionRed, Image.Name.MissileExplosion, 50, 50, 20, 20, new Azul.Color(1.0f, 0.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.MissileExplosionGreen, Image.Name.MissileExplosion, 50, 50, 20, 20, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.MissileExplosionWhite, Image.Name.MissileExplosion, 50, 50, 20, 20);

            //----Bombs----
            GameSpriteManager.Add(GameSprite.Name.BombDagger, Image.Name.BombDagger, 50, 50, 10, 25);
            GameSpriteManager.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 50, 50, 10, 25);
            GameSpriteManager.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 50, 50, 10, 25);

            //----Shield----
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick, Image.Name.ShieldBrick, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_LeftTop0, Image.Name.ShieldBrick_LeftTop0, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_LeftTop1, Image.Name.ShieldBrick_LeftTop1, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_LeftBottom, Image.Name.ShieldBrick_LeftBottom, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_RightTop0, Image.Name.ShieldBrick_RightTop0, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_RightTop1, Image.Name.ShieldBrick_RightTop1, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));
            GameSpriteManager.Add(GameSprite.Name.ShieldBrick_RightBottom, Image.Name.ShieldBrick_RightBottom, 50, 25, 12, 7, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));

            //----Ground----
            GameSpriteManager.Add(GameSprite.Name.Ground, Image.Name.ShieldBrick, 50, 50, SpaceInvaders.ScreenWidth - 10, 5, new Azul.Color(0.0f, 1.0f, 0.0f, 1.0f));

            //--------------------------------------------------------------------------
            //Create Scenes
            //--------------------------------------------------------------------------
            pHiScore      = 0;
            pPlayer1Score = 0;
            pPlayer2Score = 0;

            pSceneContext = new SceneContext();
        }
Пример #15
0
        public override void Update()
        {
            UFORoot pUFORoot = (UFORoot)this.pSubject.goA;
            UFO     pUFO     = (UFO)pUFORoot.pChild;

            if (pUFO != null)
            {
                Wall pWall = (Wall)this.pSubject.goB;

                if ((pUFO.pStrategy is UFOMoveLeft && pWall.gameObjectName == GameObjectName.WallLeft) ||
                    (pUFO.pStrategy is UFOMoveRight && pWall.gameObjectName == GameObjectName.WallRight))
                {
                    if (UFOManager.IsUFOActive())
                    {
                        Debug.WriteLine("RemoveUFO TimerEvent added for {0}", pUFO.GetHashCode());
                        TimerManager.Add(TimerEventName.RemoveUFO, TimerManager.GetCurrentTime() + 1.0f, TimerManager.GetCurrentTime() + 1.0f, new RemoveUFOCommand());
                        TimerManager.Add(TimerEventName.StopUFOSound, TimerManager.GetCurrentTime() + 0.5f, TimerManager.GetCurrentTime() + 0.5f, new StopUFOSoundCommand());
                    }
                    //pUFO.Remove();
                    //pUFORoot.Remove();
                }
            }
        }
Пример #16
0
        //----------------------------------------------------------------------------------
        // Animation Methods
        //----------------------------------------------------------------------------------
        public void UFOAnimation(GameObject pBossGrid, float movementTimeInterval = 1.0f)
        {
            AlienGrid pUfoGrid = (AlienGrid)pBossGrid;

            TimerManager.Add(TimeEvent.Name.SpawnUFO, new SpawnUFO(pUfoGrid), 10.0f);
        }
Пример #17
0
        private void SpawnUFO()
        {
            int random = UFOManager.GetRandom().Next(7, 10);

            this.pUFO = UFOManager.ActivateUFO(GameManager.GetCollisionBoxes());
            TimerManager.Add(TimerEventName.PlayUFOSound, TimerManager.GetCurrentTime() + 0.2f, 0.2f, new StartUFOSoundCommand());
            TimerManager.Add(TimerEventName.UFOSpawnBomb, TimerManager.GetCurrentTime() + (float)UFOManager.GetRandom().Next(1, 6), TimerManager.GetCurrentTime() + (float)UFOManager.GetRandom().Next(1, 6), new UFOBombSpawnEvent());
        }
Пример #18
0
        //----------------------------------------------------------------------------------
        // Methods
        //----------------------------------------------------------------------------------

        public override void Execute(float deltaTime)
        {
            this.pAlienGrid.DropGrid();
            //Debug.WriteLine("   ------ DROPPED");
            TimerManager.Add(TimeEvent.Name.MoveGridOffWall, new MoveGridOffWall(this.pAlienGrid), this.pAlienGrid.movementTimeInterval);
        }