コード例 #1
0
ファイル: UFOManager.cs プロジェクト: wangjo22/Final
        private UFOManager()
        {
            this.pSB_Sprite = SpriteBatchManager.Find(SpriteBatch.Name.GameSprites);
            Debug.Assert(this.pSB_Sprite != null);

            this.pSB_CollisionBox = SpriteBatchManager.Find(SpriteBatch.Name.BoxSprites);
            Debug.Assert(this.pSB_CollisionBox != null);

            this.pUFO = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 0.0f, -100.0f);
            this.pSB_Sprite.Attach(pUFO.pProxySprite);
            this.pSB_CollisionBox.Attach(pUFO.pColObject.pBoxSprite);
            this.pRandom = new Random();
        }
コード例 #2
0
        // TODO Move Types out of gameobject and into here

        public InvaderFactory(SpriteBatch.Name spriteBatchName, SpriteBatch.Name boxSpriteBatchName, GameObjectComposite pGOComposite = null)
        {
            this.pSpriteBatch = SpriteBatchManager.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            this.pBoxSpriteBatch = SpriteBatchManager.Find(boxSpriteBatchName);
            Debug.Assert(this.pBoxSpriteBatch != null);

            if (pGOComposite != null)
            {
                this.pGOComposite = pGOComposite;
            }
        }
コード例 #3
0
ファイル: BombSpawnEvent.cs プロジェクト: ccaunca/Projects
        public BombSpawnEvent(Grid pGrid)
        {
            this.pBombRoot = GameObjectManager.Find(GameObjectName.BombRoot);
            Debug.Assert(this.pBombRoot != null);

            this.sbAliens = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            Debug.Assert(sbAliens != null);

            this.sbBoxes = SpriteBatchManager.Find(SpriteBatchName.Boxes);
            Debug.Assert(sbBoxes != null);

            this.pGrid = pGrid;
        }
コード例 #4
0
        public BombFactory(SpriteBatch.Name spriteBatchName, SpriteBatch.Name boxSpriteBatchName, InvaderGrid pInvaderGrid, WallManager pWallMan)
        {
            Debug.Assert(pInvaderGrid != null);
            this.pInvaderGrid = pInvaderGrid;

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

            this.pSpriteBatch = SpriteBatchManager.Find(spriteBatchName);
            Debug.Assert(this.pSpriteBatch != null);

            this.pBoxSpriteBatch = SpriteBatchManager.Find(boxSpriteBatchName);
            Debug.Assert(this.pBoxSpriteBatch != null);
        }
コード例 #5
0
        public static void ActivateMissile()
        {
            SpriteBatch pAliensBatch = SpriteBatchManager.Find(SpriteBatch.Name.Aliens);
            SpriteBatch pBoxBatch    = SpriteBatchManager.Find(SpriteBatch.Name.Boxes);

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

            Debug.Assert(pMissileGroup != null);

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

            pMissileGroup.Add(pMissile);
        }
コード例 #6
0
        public static void ActivateShip()
        {
            SpriteBatch pAliensBatch = SpriteBatchManager.Find(SpriteBatch.Name.Aliens);
            SpriteBatch pBoxBatch    = SpriteBatchManager.Find(SpriteBatch.Name.Boxes);

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

            Debug.Assert(pShipRoot != null);

            pShip.pProxySprite.Set(GameSprite.Name.Ship);
            pShip.poColObj.poColRect.Set(pShip.pProxySprite.pSprite.GetScreenRect());

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

            pShipRoot.Add(pShip);
        }
コード例 #7
0
        public override void ReinitializeLevel(GameManager pGameManager)
        {
            SoundManager.StopAllSounds();
            TimerManager.PurgeAllNodes();
            GameObjectManager.PurgeAllNodes();
            SpriteBatch pSBatch = SpriteBatchManager.Find(SpriteBatch.Name.Boxes);

            pSBatch.GetSBNodeManager().PurgeAllNodes();
            pSBatch = SpriteBatchManager.Find(SpriteBatch.Name.Sprites);
            pSBatch.GetSBNodeManager().PurgeAllNodes();
            ColPairManager.PurgeAllNodes();
            DelayedObjectManager.PurgeAll();

            PlayerOneInit(pGameManager);
            pGameManager.poPlayer1.RestoreManagerStates(pGameManager.pGame.GetTime());
            pGameManager.SetActivePlayer(PlayerArtifact.Name.PlayerOne);
        }
コード例 #8
0
        public override void Update()
        {
            int lives = ScoreManager.UpdateLives();

            if (lives == 0)
            {
                Debug.WriteLine("Game Over!");
            }
            else
            {
                PCSTree     pRootTree = GameObjectManager.GetRootTree();
                SpriteBatch sbBoxes   = SpriteBatchManager.Find(SpriteBatchName.Boxes);
                SpriteBatch sbAliens  = SpriteBatchManager.Find(SpriteBatchName.Aliens);
                //MissileRoot pMissileRoot = new MissileRoot(GameObjectName.MissileRoot, SpriteBaseName.Null, 0.0f, 0.0f, 0);
                //pMissileRoot.ActivateCollisionSprite(sbBoxes);
                ShipRoot pShipRoot = (ShipRoot)GameObjectManager.Find(GameObjectName.ShipRoot);
                pShipRoot.ActivateCollisionSprite(sbBoxes);
                pShipRoot.ActivateGameSprite(sbAliens);
                ShipManager.Create();
                AnimationSprite animSpriteSquids = new AnimationSprite(SpriteBaseName.Squid);
                animSpriteSquids.Attach(ImageName.SquidA);
                animSpriteSquids.Attach(ImageName.SquidB);
                AnimationSprite animSpriteCrabs = new AnimationSprite(SpriteBaseName.Crab);
                animSpriteCrabs.Attach(ImageName.CrabA);
                animSpriteCrabs.Attach(ImageName.CrabB);
                AnimationSprite animSpriteOctopi = new AnimationSprite(SpriteBaseName.Octopus);
                animSpriteOctopi.Attach(ImageName.OctopusA);
                animSpriteOctopi.Attach(ImageName.OctopusB);
                SoundCommand playFastInvader1 = new SoundCommand(SoundName.fastInvader1);
                SoundCommand playFastInvader2 = new SoundCommand(SoundName.fastInvader2);
                SoundCommand playFastInvader3 = new SoundCommand(SoundName.fastInvader3);
                SoundCommand playFastInvader4 = new SoundCommand(SoundName.fastInvader4);
                Grid         pGrid            = (Grid)GameObjectManager.Find(GameObjectName.Grid);
                float        marchSpeed       = pGrid.marchSpeed;
                TimerManager.Add(TimerEventName.MoveGrid, marchSpeed, marchSpeed, new MoveGridEvent());
                TimerManager.Add(TimerEventName.AnimateSquids, marchSpeed, marchSpeed, animSpriteSquids);
                TimerManager.Add(TimerEventName.AnimateCrabs, marchSpeed, marchSpeed, animSpriteCrabs);
                TimerManager.Add(TimerEventName.AnimateOctopi, marchSpeed, marchSpeed, animSpriteOctopi);
                TimerManager.Add(TimerEventName.PlayFastInvaders4, marchSpeed, 4 * marchSpeed, playFastInvader4);
                TimerManager.Add(TimerEventName.PlayFastInvaders1, 2 * marchSpeed, 4 * marchSpeed, playFastInvader1);
                TimerManager.Add(TimerEventName.PlayFastInvaders2, 3 * marchSpeed, 4 * marchSpeed, playFastInvader2);
                TimerManager.Add(TimerEventName.PlayFastInvaders3, 4 * marchSpeed, 4 * marchSpeed, playFastInvader3);
                TimerManager.Add(TimerEventName.BombSpawn, 1.0f, 1.0f, new BombSpawnEvent(pGrid));
            }
        }
コード例 #9
0
        public static void DeactivateMissile()
        {
            SpriteBatch pSB_Sprites = SpriteBatchManager.Find(SpriteBatch.Name.Sprites);
            SpriteBatch pSB_Boxes   = SpriteBatchManager.Find(SpriteBatch.Name.Boxes);

            //pSB_Sprites.GetSBNodeManager().PrintReport();
            //pSB_Boxes.GetSBNodeManager().PrintReport();
            ShipManager pShipMan = ShipManager.PrivInstance();

            Debug.Assert(pShipMan != null);
            pShipMan.pMissile.GetColObject().enabled = false;
            pShipMan.pMissile.Remove();
            //Debug.WriteLine("Missile has been deactivated");


            //pSB_Sprites.GetSBNodeManager().PrintReport();
            //pSB_Boxes.GetSBNodeManager().PrintReport();
        }
コード例 #10
0
        public static Font Add(Font.Name name, SpriteBatch.Name SB_Name, String pMessage, Glyph.Name glyphName, float xStart, float yStart)
        {
            FontManager pMan = FontManager.PrivGetInstance();

            Font pNode = (Font)pMan.BaseAdd();

            Debug.Assert(pNode != null);

            pNode.Set(name, pMessage, glyphName, xStart, yStart);

            // Add to sprite batch
            SpriteBatch pSB = SpriteBatchManager.Find(SB_Name);

            Debug.Assert(pSB != null);
            Debug.Assert(pNode.pFontSprite != null);
            pSB.Attach(pNode.pFontSprite);

            return(pNode);
        }
コード例 #11
0
        private BombManager()
        {
            this.pSB_Bombs = SpriteBatchManager.Find(SpriteBatch.Name.BombSprites);
            Debug.Assert(this.pSB_Bombs != null);

            this.pSB_BombCollisionBox = SpriteBatchManager.Find(SpriteBatch.Name.BoxSprites);
            Debug.Assert(this.pSB_BombCollisionBox != null);

            this.pStraight = this.CreateBomb(BombType.Straight);
            Debug.Assert(this.pStraight != null);

            this.pZigZag = this.CreateBomb(BombType.ZigZag);
            Debug.Assert(this.pZigZag != null);

            this.pCross = this.CreateBomb(BombType.Cross);
            Debug.Assert(this.pCross != null);

            this.pBombGroup = null;
        }
コード例 #12
0
        public static Font Add(Font.Name name, SpriteBatch.Name SB_Name, String pMessage, float xStart, float yStart, float width, float height)
        {
            FontManager pMan = FontManager.pActiveMan;

            Font pNode = (Font)pMan.BaseAdd();

            Debug.Assert(pNode != null);

            pNode.Set(name, pMessage, xStart, yStart, width, height);

            // Add to sprite batch
            SpriteBatch pSB = SpriteBatchManager.Find(SB_Name);

            Debug.Assert(pSB != null);
            Debug.Assert(pNode.pFontSprite != null);
            pSB.Attach(pNode.pFontSprite);

            return(pNode);
        }
コード例 #13
0
ファイル: PlayerManager.cs プロジェクト: wangjo22/Final
        private Missile CreateMissile()
        {
            Missile pMissile = new Missile(GameObject.Name.Missile, GameSprite.Name.Missile, -100, 0.0f);

            Debug.Assert(pMissile != null);

            SpriteBatch pSB_GameSprite = SpriteBatchManager.Find(SpriteBatch.Name.GameSprites);
            SpriteBatch pSB_BoxSprite  = SpriteBatchManager.Find(SpriteBatch.Name.BoxSprites);

            pSB_GameSprite.Attach(pMissile.pProxySprite);
            pSB_BoxSprite.Attach(pMissile.pColObject.pBoxSprite);

            GameObject pGroup = GameObjectManager.Find(GameObject.Name.MissileGroup);

            Debug.Assert(pGroup != null);
            pGroup.Add(pMissile);

            return(pMissile);
        }
コード例 #14
0
ファイル: PlayerManager.cs プロジェクト: wangjo22/Final
        // This method should be called
        // after PlayerGroup and MissileGroup are inserted Game Object Manager
        private Player CreatePlayer()
        {
            Player pPlayer = new Player(GameObject.Name.Player, GameSprite.Name.Player, Constant.WINDOW_WIDTH / 2, 100.0f);

            Debug.Assert(pPlayer != null);

            SpriteBatch pSB_GameSprite = SpriteBatchManager.Find(SpriteBatch.Name.GameSprites);
            SpriteBatch pSB_BoxSprite  = SpriteBatchManager.Find(SpriteBatch.Name.BoxSprites);

            pSB_GameSprite.Attach(pPlayer.pProxySprite);
            pSB_BoxSprite.Attach(pPlayer.pColObject.pBoxSprite);

            GameObject pGroup = GameObjectManager.Find(GameObject.Name.PlayerGroup);

            Debug.Assert(pGroup != null);
            pGroup.Add(pPlayer);

            return(pPlayer);
        }
コード例 #15
0
        public override void Update()
        {
            //Debug.WriteLine("RemoveShipObserver: {0} {1}", this.pSubject.goA, this.pSubject.goB);
            GameObject ship = ShipManager.GetShip();

            if (ship != null)
            {
                ship.Remove();
                GameObject pShipRoot = GameObjectManager.Find(GameObjectName.ShipRoot);
                pShipRoot.Remove();
            }
            Alien       pExplosion = new Explosion(GameObjectName.Explosion, SpriteBaseName.Explosion, AlienType.Explosion, ship, ColorName.Green, 0);
            SpriteBatch sbAliens   = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            SpriteBatch sbBoxes    = SpriteBatchManager.Find(SpriteBatchName.Boxes);

            pExplosion.ActivateGameSprite(sbAliens);
            pExplosion.ActivateCollisionSprite(sbBoxes);
            GameObjectManager.AttachTree(pExplosion);

            Game pGame = GameManager.GetGame();
            //pGame.Pause();
            int lives = ScoreManager.UpdateLives();

            if (lives == 0)
            {
                pGame.roundNum = 1;
                TimerManager.ClearTimerManager();
                pExplosion.Remove();
                pGame.Die();
                TimerManager.Add(TimerEventName.GameStart, TimerManager.GetCurrentTime() + 10.0f, 10.0f, new GameStartEvent(pGame));
            }
            else
            {
                TimerManager.Add(TimerEventName.RemoveGameObject, TimerManager.GetCurrentTime(), TimerManager.GetCurrentTime(), new RemoveGameObjectCommand(pExplosion));
                PCSTree pRootTree = GameObjectManager.GetRootTree();
                //ShipRoot pShipRoot = (ShipRoot)GameObjectManager.Find(GameObjectName.ShipRoot);
                //pShipRoot.ActivateCollisionSprite(sbBoxes);
                //pShipRoot.ActivateGameSprite(sbAliens);
                ShipManager.Create(GameManager.GetCollisionBoxes());
            }
        }
コード例 #16
0
        public static Bomb CreateBomb(AlienColumn pOwner)
        {
            // each column owns one instance of a bomb that is reused.
            // create a null bomb
            Bomb pBomb = new Bomb(pOwner);

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

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

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

            Debug.Assert(pBombRoot != null);

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

            return(pBomb);
        }
コード例 #17
0
        public ExplodingAlien(GameObject.Name name, GameSprite.Name spriteName, int index, float posX, float posY)
            : base(name, spriteName, index, AlienType.Type.AlienExplosion)
        {
            this.x = posX;
            this.y = posY;

            //this exploding alien will always be marked for death
            this.markForDeath = true;

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

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



            //set the color of the proxy sprite;
            this.pProxySprite.pSprite.ChangeColor(1.0f, 1.0f, 1.0f, 1.0f);
        }
コード例 #18
0
        public static Ship ActivateShip()
        {
            ShipManager pShipMan = ShipManager.PrivInstance();

            Debug.Assert(pShipMan != null);

            pShipMan.pShip.SetPos(Constants.shipXPos, Constants.shipYPos);

            // Attach to Game Object Manager
            GameObjectManager.Attach(pShipMan.pShip);

            // Attach the sprite to the correct sprite batch
            SpriteBatch pInvaders = SpriteBatchManager.Find(SpriteBatch.Name.Sprites);

            pInvaders.Attach(pShipMan.pShip.pProxySprite);

            // Attach the spriteBox to the correct sprite batch
            SpriteBatch pBoxes = SpriteBatchManager.Find(SpriteBatch.Name.Boxes);

            pBoxes.Attach(pShipMan.pShip.poColObj.pColSprite);

            return(pShipMan.pShip);
        }
コード例 #19
0
        public override void Notify()
        {
            SpriteBatch pSB_Box = SpriteBatchManager.Find(SpriteBatch.Name.ShieldSprites);

            pSB_Box.GetSBNodeManager().ToggleDraw();
        }
コード例 #20
0
        protected override void derivedUpdate(InputSubject pInputSubject)
        {
            SpriteBatch pSBatch = SpriteBatchManager.Find(SpriteBatch.Name.Boxes);

            pSBatch.enabled = !pSBatch.enabled;
        }
コード例 #21
0
        public Game(bool isFirstRound, bool areCollisionBoxesActive)
        {   // Active Game
            this.SetState(GameStateEnum.Active);
            SpriteBatch sbBoxes      = SpriteBatchManager.Find(SpriteBatchName.Boxes);
            SpriteBatch sbAliens     = SpriteBatchManager.Find(SpriteBatchName.Aliens);
            PCSTree     pRootTree    = GameObjectManager.GetRootTree();
            WallRoot    pWallRoot    = (WallRoot)GameObjectManager.Find(GameObjectName.WallRoot);
            BombRoot    pBombRoot    = (BombRoot)GameObjectManager.Find(GameObjectName.BombRoot);
            MissileRoot pMissileRoot = (MissileRoot)GameObjectManager.Find(GameObjectName.MissileRoot);
            ShipRoot    pShipRoot    = (ShipRoot)GameObjectManager.Find(GameObjectName.ShipRoot);
            UFORoot     pUFORoot     = (UFORoot)GameObjectManager.Find(GameObjectName.UFORoot);
            ShieldRoot  pShieldRoot1 = (ShieldRoot)GameObjectManager.Find(GameObjectName.ShieldRoot, 1);
            ShieldRoot  pShieldRoot2 = (ShieldRoot)GameObjectManager.Find(GameObjectName.ShieldRoot, 2);
            ShieldRoot  pShieldRoot3 = (ShieldRoot)GameObjectManager.Find(GameObjectName.ShieldRoot, 3);
            ShieldRoot  pShieldRoot4 = (ShieldRoot)GameObjectManager.Find(GameObjectName.ShieldRoot, 4);

            if (isFirstRound)
            {
                // Create Walls
                pWallRoot = new WallRoot(GameObjectName.WallRoot, SpriteBaseName.Null, 0.0f, 0.0f, 0);
                pRootTree.Insert(pWallRoot, null);
                if (areCollisionBoxesActive)
                {
                    pWallRoot.ActivateCollisionSprite(sbBoxes);
                }
                WallTop pWallTop = new WallTop(GameObjectName.WallTop, SpriteBaseName.Null, 448.0f, 950.0f, 850.0f, 30.0f, 0);
                pRootTree.Insert(pWallTop, pWallRoot);
                if (areCollisionBoxesActive)
                {
                    pWallTop.ActivateCollisionSprite(sbBoxes);
                }
                pWallTop.ActivateGameSprite(sbAliens);

                WallRight pWallRight = new WallRight(GameObjectName.WallRight, SpriteBaseName.Null, 896.0f, 500.0f, 50.0f, 900.0f, 0);
                pRootTree.Insert(pWallRight, pWallRoot);
                if (areCollisionBoxesActive)
                {
                    pWallRight.ActivateCollisionSprite(sbBoxes);
                }
                pWallRight.ActivateGameSprite(sbAliens);

                WallLeft pWallLeft = new WallLeft(GameObjectName.WallLeft, SpriteBaseName.Null, 0.0f, 500.0f, 50.0f, 900.0f, 0);
                pRootTree.Insert(pWallLeft, pWallRoot);
                if (areCollisionBoxesActive)
                {
                    pWallLeft.ActivateCollisionSprite(sbBoxes);
                }
                pWallLeft.ActivateGameSprite(sbAliens);

                WallBottom pWallBottom = new WallBottom(GameObjectName.WallBottom, SpriteBaseName.Null, 448.0f, 50.0f, 850.0f, 30.0f, 0);
                pRootTree.Insert(pWallBottom, pWallRoot);
                if (areCollisionBoxesActive)
                {
                    pWallBottom.ActivateCollisionSprite(sbBoxes);
                }
                pWallBottom.ActivateGameSprite(sbAliens);
                GameObjectManager.AttachTree(pWallRoot);

                // Create ShipRoot and MissileRoot
                pMissileRoot = new MissileRoot(GameObjectName.MissileRoot, SpriteBaseName.Null, 0.0f, 0.0f, 0);
                pRootTree.Insert(pMissileRoot, null);
                if (areCollisionBoxesActive)
                {
                    pMissileRoot.ActivateCollisionSprite(sbBoxes);
                }
                GameObjectManager.AttachTree(pMissileRoot);
                pShipRoot = new ShipRoot(GameObjectName.ShipRoot, SpriteBaseName.Null, 0.0f, 0.0f);
                pRootTree.Insert(pShipRoot, null);
                if (areCollisionBoxesActive)
                {
                    pShipRoot.ActivateCollisionSprite(sbBoxes);
                }
                pShipRoot.ActivateGameSprite(sbAliens);
                GameObjectManager.AttachTree(pShipRoot);
                ShipManager.Create(areCollisionBoxesActive);

                // Create BombRoot
                pBombRoot = new BombRoot(GameObjectName.BombRoot, SpriteBaseName.Null, 0.0f, 0.0f, 0);
                pRootTree.Insert(pBombRoot, null);
                if (areCollisionBoxesActive)
                {
                    pBombRoot.ActivateCollisionSprite(sbBoxes);
                }
                GameObjectManager.AttachTree(pBombRoot);

                // Create UFORoot
                pUFORoot = new UFORoot(GameObjectName.UFORoot, SpriteBaseName.Null, 0.0f, 0.0f);
                pRootTree.Insert(pUFORoot, null);
                if (areCollisionBoxesActive)
                {
                    pUFORoot.ActivateCollisionSprite(sbBoxes);
                }
                pUFORoot.ActivateGameSprite(sbAliens);
                GameObjectManager.AttachTree(pUFORoot);
                UFOManager.Create(areCollisionBoxesActive);

                // Create Shields
                pShieldRoot1 = GenerateShield(pRootTree, 100.0f, 200.0f, 1);
                pShieldRoot2 = GenerateShield(pRootTree, 100.0f + 1 * 200, 200.0f, 2);
                pShieldRoot3 = GenerateShield(pRootTree, 100.0f + 2 * 200, 200.0f, 3);
                pShieldRoot4 = GenerateShield(pRootTree, 100.0f + 3 * 200, 200.0f, 4);
            }
            else
            {
                _gridStartingHeight -= 100.0f;
            }

            PopulateAlienGrid(_gridStartingHeight);
            Alien pGridRoot = (Alien)GameObjectManager.Find(GameObjectName.Grid);

            // Create CollisionPairs
            CollisionPair cpMissileWall = CollisionPairManager.Add(CollisionPairName.MissilevTop, pMissileRoot, pWallRoot);

            Debug.Assert(cpMissileWall != null);
            cpMissileWall.subject.RegisterObserver(new RemoveMissileObserver());
            cpMissileWall.subject.RegisterObserver(new ShipReadyObserver());

            CollisionPair cpBombWall = CollisionPairManager.Add(CollisionPairName.BombsvBottom, pBombRoot, pWallRoot);

            Debug.Assert(cpBombWall != null);
            cpBombWall.subject.RegisterObserver(new RemoveBombObserver());

            CollisionPair cpMissilevGrid = CollisionPairManager.Add(CollisionPairName.MissilevGrid, pMissileRoot, pGridRoot);

            Debug.Assert(cpMissilevGrid != null);
            cpMissilevGrid.subject.RegisterObserver(new RemoveMissileObserver());
            cpMissilevGrid.subject.RegisterObserver(new RemoveAlienObserver());
            cpMissilevGrid.subject.RegisterObserver(new ShipReadyObserver());
            cpMissilevGrid.subject.RegisterObserver(new AlienDeathSoundObserver());
            cpMissilevGrid.subject.RegisterObserver(new SplatObserver());
            cpMissilevGrid.subject.RegisterObserver(new UpdateScoreObserver());

            CollisionPair cpUFOMissile = CollisionPairManager.Add(CollisionPairName.MissilevUFO, pMissileRoot, pUFORoot);

            cpUFOMissile.subject.RegisterObserver(new RemoveMissileObserver());
            cpUFOMissile.subject.RegisterObserver(new RemoveUFOObserver());
            cpUFOMissile.subject.RegisterObserver(new ShipReadyObserver());
            cpUFOMissile.subject.RegisterObserver(new AlienDeathSoundObserver());
            cpUFOMissile.subject.RegisterObserver(new SplatObserver());
            cpUFOMissile.subject.RegisterObserver(new UpdateScoreObserver());
            cpUFOMissile.subject.RegisterObserver(new UFODeathSoundObserver());

            CollisionPair cpUFOWalls = CollisionPairManager.Add(CollisionPairName.UFOvWalls, pUFORoot, pWallRoot);

            cpUFOWalls.subject.RegisterObserver(new UFOWallObserver());

            CollisionPair cpGridvWalls = CollisionPairManager.Add(CollisionPairName.GridvWalls, pGridRoot, pWallRoot);

            Debug.Assert(cpGridvWalls != null);
            cpGridvWalls.subject.RegisterObserver(new GridXObserver());
            cpGridvWalls.subject.RegisterObserver(new GridYObserver());

            CollisionPair cpGridvShip = CollisionPairManager.Add(CollisionPairName.GridvShip, pGridRoot, pShipRoot);

            cpGridvShip.subject.RegisterObserver(new GameOverObserver());
            cpGridvShip.subject.RegisterObserver(new ShipDeathSoundObserver());

            CollisionPair cpMissileShield1 = CollisionPairManager.Add(CollisionPairName.MissilevShields, pMissileRoot, pShieldRoot1);

            cpMissileShield1.subject.RegisterObserver(new RemoveMissileObserver());
            cpMissileShield1.subject.RegisterObserver(new RemoveBrickObserver());
            cpMissileShield1.subject.RegisterObserver(new ShipReadyObserver());
            CollisionPair cpBombShield1 = CollisionPairManager.Add(CollisionPairName.BombsvShields, pBombRoot, pShieldRoot1);

            cpBombShield1.subject.RegisterObserver(new RemoveBombObserver());
            cpBombShield1.subject.RegisterObserver(new RemoveBrickObserver());

            CollisionPair cpMissileShield2 = CollisionPairManager.Add(CollisionPairName.MissilevShields, pMissileRoot, pShieldRoot2);

            cpMissileShield2.subject.RegisterObserver(new RemoveMissileObserver());
            cpMissileShield2.subject.RegisterObserver(new RemoveBrickObserver());
            cpMissileShield2.subject.RegisterObserver(new ShipReadyObserver());
            CollisionPair cpBombShield2 = CollisionPairManager.Add(CollisionPairName.BombsvShields, pBombRoot, pShieldRoot2);

            cpBombShield2.subject.RegisterObserver(new RemoveBombObserver());
            cpBombShield2.subject.RegisterObserver(new RemoveBrickObserver());

            CollisionPair cpBombShield3 = CollisionPairManager.Add(CollisionPairName.BombsvShields, pBombRoot, pShieldRoot3);

            cpBombShield3.subject.RegisterObserver(new RemoveBombObserver());
            cpBombShield3.subject.RegisterObserver(new RemoveBrickObserver());
            CollisionPair cpMissileShield3 = CollisionPairManager.Add(CollisionPairName.MissilevShields, pMissileRoot, pShieldRoot3);

            cpMissileShield3.subject.RegisterObserver(new RemoveMissileObserver());
            cpMissileShield3.subject.RegisterObserver(new RemoveBrickObserver());
            cpMissileShield3.subject.RegisterObserver(new ShipReadyObserver());

            CollisionPair cpBombShield4 = CollisionPairManager.Add(CollisionPairName.BombsvShields, pBombRoot, pShieldRoot4);

            cpBombShield4.subject.RegisterObserver(new RemoveBombObserver());
            cpBombShield4.subject.RegisterObserver(new RemoveBrickObserver());
            CollisionPair cpMissileShield4 = CollisionPairManager.Add(CollisionPairName.MissilevShields, pMissileRoot, pShieldRoot4);

            cpMissileShield4.subject.RegisterObserver(new RemoveMissileObserver());
            cpMissileShield4.subject.RegisterObserver(new RemoveBrickObserver());
            cpMissileShield4.subject.RegisterObserver(new ShipReadyObserver());

            CollisionPair cpBombMissile = CollisionPairManager.Add(CollisionPairName.BombsvMissile, pBombRoot, pMissileRoot);

            cpBombMissile.subject.RegisterObserver(new RemoveBombObserver());
            cpBombMissile.subject.RegisterObserver(new RemoveMissileObserver());
            cpBombMissile.subject.RegisterObserver(new ShipReadyObserver());
            cpBombMissile.subject.RegisterObserver(new SplatObserver());

            CollisionPair cpBombShip = CollisionPairManager.Add(CollisionPairName.BombsvShip, pBombRoot, pShipRoot);

            cpBombShip.subject.RegisterObserver(new RemoveBombObserver());
            cpBombShip.subject.RegisterObserver(new RemoveShipObserver());
            cpBombShip.subject.RegisterObserver(new ShipDeathSoundObserver());
            cpBombShip.subject.RegisterObserver(new ShipEndObserver());

            //TimerManager.ClearTimerManager();
        }
コード例 #22
0
        public override void LoadContent()
        {
            //---------------------------------------------------------------------------------------------------------
            // Create all the managers!
            //---------------------------------------------------------------------------------------------------------

            TextureManager.Create();
            ImageManager.Create();
            SpriteManager.Create();
            SoundManager.Create();
            BoxSpriteManager.Create();
            SpriteBatchManager.Create();
            TimerManager.Create();
            ProxySpriteManager.Create();
            ProxyBoxSpriteManager.Create();
            GameObjectManager.Create();
            ColPairManager.Create();
            GlyphManager.Create();
            FontManager.Create();

            //---------------------------------------------------------------------------------------------------------
            // Add the Sound Assets
            //---------------------------------------------------------------------------------------------------------
            SoundManager.Add(Sound.Name.InvaderMarch1, 0.05f);
            SoundManager.Add(Sound.Name.InvaderMarch2, 0.05f);
            SoundManager.Add(Sound.Name.InvaderMarch3, 0.05f);
            SoundManager.Add(Sound.Name.InvaderMarch4, 0.05f);

            SoundManager.Add(Sound.Name.Invaderkilled, 0.025f);

            SoundManager.Add(Sound.Name.Shoot, 0.025f);

            SoundManager.Add(Sound.Name.UFOHighPitch);
            SoundManager.Add(Sound.Name.UFOLowPitch, 0.01f);

            SoundManager.Add(Sound.Name.Uninitialized);

            //---------------------------------------------------------------------------------------------------------
            // Add the Texture and all the Images
            //---------------------------------------------------------------------------------------------------------
            TextureManager.Add(Texture.Name.Invader);
            Texture pTexture = TextureManager.Add(Texture.Name.Consolas36pt);

            FontManager.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt);

            ImageManager.Add(Image.Name.ShieldBrick);
            ImageManager.Add(Image.Name.Ship);
            ImageManager.Add(Image.Name.Missile);
            ImageManager.Add(Image.Name.SmallInvader1);
            ImageManager.Add(Image.Name.SmallInvader2);
            ImageManager.Add(Image.Name.MediumInvader1);
            ImageManager.Add(Image.Name.MediumInvader2);
            ImageManager.Add(Image.Name.LargeInvader1);
            ImageManager.Add(Image.Name.LargeInvader2);
            ImageManager.Add(Image.Name.UFO);

            ImageManager.Add(Image.Name.BombPlain);

            ImageManager.Add(Image.Name.BombZigZag1);
            ImageManager.Add(Image.Name.BombZigZag2);
            ImageManager.Add(Image.Name.BombZigZag3);
            ImageManager.Add(Image.Name.BombZigZag4);

            ImageManager.Add(Image.Name.BombDagger1);
            ImageManager.Add(Image.Name.BombDagger2);
            ImageManager.Add(Image.Name.BombDagger3);
            ImageManager.Add(Image.Name.BombDagger4);

            ImageManager.Add(Image.Name.BombRolling1);
            ImageManager.Add(Image.Name.BombRolling2);
            ImageManager.Add(Image.Name.BombRolling3);

            ImageManager.Add(Image.Name.InvaderDeath1);
            ImageManager.Add(Image.Name.InvaderDeath2);
            ImageManager.Add(Image.Name.UFODeath);
            ImageManager.Add(Image.Name.ShipDeath1);
            ImageManager.Add(Image.Name.ShipDeath2);
            ImageManager.Add(Image.Name.BombDeath);

            //---------------------------------------------------------------------------------------------------------
            // Add all the Sprites and BoxSprites (x,y pos not needed since its determined by factory upon object creation)
            //---------------------------------------------------------------------------------------------------------
            SpriteManager.Add(Sprite.Name.ShieldBrick, Image.Name.ShieldBrick, 0, 0, Constants.shieldBrickWidth, Constants.shieldBrickHeight, new Azul.Color(0.0f, 0.5f, 0.0f));
            SpriteManager.Add(Sprite.Name.Ship, Image.Name.Ship, 0, 0, Constants.shipWidth, Constants.shipHeight);
            SpriteManager.Add(Sprite.Name.Missile, Image.Name.Missile, 0, 0, Constants.missileWidth, Constants.missileHeight);
            SpriteManager.Add(Sprite.Name.SmallInvader, Image.Name.SmallInvader1, 0, 0, Constants.smallInvaderWidth, Constants.smallInvaderHeight, new Azul.Color(0.5f, 0.0f, 0.5f));
            SpriteManager.Add(Sprite.Name.MediumInvader, Image.Name.MediumInvader1, 0, 0, Constants.mediumInvaderWidth, Constants.mediumInvaderHeight, new Azul.Color(0.3f, 0.0f, 0.75f));
            SpriteManager.Add(Sprite.Name.LargeInvader, Image.Name.LargeInvader1, 0, 0, Constants.largeInvaderWidth, Constants.largeInvaderHeight, new Azul.Color(0.25f, 0.0f, 1.0f));
            SpriteManager.Add(Sprite.Name.UFO, Image.Name.UFO, 0, 0, Constants.UFOWidth, Constants.UFOHeight, new Azul.Color(0.75f, 0.2f, 0.2f));

            SpriteManager.Add(Sprite.Name.BombPlain, Image.Name.BombPlain, 0, 0, Constants.bombPlainWidth, Constants.bombPlainHeight);
            SpriteManager.Add(Sprite.Name.BombZigZag, Image.Name.BombZigZag1, 0, 0, Constants.bombZigZagWidth, Constants.bombZigZagHeight);
            SpriteManager.Add(Sprite.Name.BombDagger, Image.Name.BombDagger1, 0, 0, Constants.bombDaggerWidth, Constants.bombDaggerHeight);
            SpriteManager.Add(Sprite.Name.BombRolling, Image.Name.BombRolling1, 0, 0, Constants.bombRollingWidth1, Constants.bombRollingHeight1);

            SpriteManager.Add(Sprite.Name.InvaderDeath, Image.Name.InvaderDeath1, -50, -50, Constants.largeInvaderWidth, Constants.largeInvaderHeight, new Azul.Color(0.5f, 0.5f, 0.1f));
            SpriteManager.Add(Sprite.Name.BombDeath, Image.Name.BombDeath, -50, -50, Constants.bombDaggerWidth, Constants.bombDaggerHeight, new Azul.Color(0.75f, 0.1f, 0.1f));

            // Add BoxSprites (size of box gets determined by GameObject's ColObject)
            BoxSpriteManager.Add(BoxSprite.Name.ShipBox, new Azul.Color(0.25f, 1.0f, 0.5f));
            BoxSpriteManager.Add(BoxSprite.Name.MissileBox, new Azul.Color(0.25f, 1.0f, 0.5f));
            BoxSpriteManager.Add(BoxSprite.Name.SmallInvaderBox, new Azul.Color(1.0f, 0.0f, 0.0f));
            BoxSpriteManager.Add(BoxSprite.Name.MediumInvaderBox, new Azul.Color(1.0f, 0.0f, 0.0f));
            BoxSpriteManager.Add(BoxSprite.Name.LargeInvaderBox, new Azul.Color(1.0f, 0.0f, 0.0f));
            BoxSpriteManager.Add(BoxSprite.Name.InvaderColumnBox, new Azul.Color(0.0f, 1.0f, 0.0f));
            BoxSpriteManager.Add(BoxSprite.Name.InvaderGridBox, new Azul.Color(0.25f, 0.25f, 1.0f));
            BoxSpriteManager.Add(BoxSprite.Name.UFOBox, new Azul.Color(1.0f, 0.0f, 1.0f));
            BoxSpriteManager.Add(BoxSprite.Name.WallBox, new Azul.Color(1.0f, 1.0f, 0.0f));
            BoxSpriteManager.Add(BoxSprite.Name.GameSpaceBox, new Azul.Color(1.0f, 1.0f, 1.0f));
            BoxSpriteManager.Add(BoxSprite.Name.ShieldBrickBox, new Azul.Color(0.0f, 0.0f, 0.0f));
            BoxSpriteManager.Add(BoxSprite.Name.ShieldColumnBox, new Azul.Color(0.25f, 0.25f, 0.75f));
            BoxSpriteManager.Add(BoxSprite.Name.ShieldBox, new Azul.Color(0.25f, 0.75f, 0.25f));
            BoxSpriteManager.Add(BoxSprite.Name.ShieldZoneBox, new Azul.Color(0.25f, 0.25f, 1.0f));
            BoxSpriteManager.Add(BoxSprite.Name.BombBox, new Azul.Color(0.25f, 0.25f, 1.0f));

            // Create batches for group processing and rendering
            SpriteBatchManager.Add(SpriteBatch.Name.Texts);
            SpriteBatchManager.Add(SpriteBatch.Name.Boxes);
            SpriteBatchManager.Add(SpriteBatch.Name.Sprites);
            SpriteBatch pSBatch = SpriteBatchManager.Find(SpriteBatch.Name.Boxes);

            pSBatch.enabled = false;

            pSBatch = SpriteBatchManager.Add(SpriteBatch.Name.Deaths);
            pSBatch.Attach(SpriteManager.Find(Sprite.Name.BombDeath));
            pSBatch.Attach(SpriteManager.Find(Sprite.Name.InvaderDeath));

            //---------------------------------------------------------------------------------------------------------
            // Create Header Fonts
            //---------------------------------------------------------------------------------------------------------

            Font pScoreHeader1   = FontManager.Add(Font.Name.ScoreHeader1, SpriteBatch.Name.Texts, " SCORE<1> ", Glyph.Name.Consolas36pt, 100, 1000);
            Font pScoreHeader2   = FontManager.Add(Font.Name.ScoreHeader2, SpriteBatch.Name.Texts, " SCORE<2> ", Glyph.Name.Consolas36pt, 650, 1000);
            Font HighScoreHeader = FontManager.Add(Font.Name.HighScoreHeader, SpriteBatch.Name.Texts, "HI-SCORE", Glyph.Name.Consolas36pt, 400, 1000);

            FontManager.Add(Font.Name.Score1, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, pScoreHeader1.pFontSprite.x + 30, 960);
            FontManager.Add(Font.Name.Score2, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, pScoreHeader2.pFontSprite.x + 30, 960);
            FontManager.Add(Font.Name.HighScore, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, HighScoreHeader.pFontSprite.x + 30, 960);

            Font pLives   = FontManager.Add(Font.Name.Lives, SpriteBatch.Name.Texts, "0", Glyph.Name.Consolas36pt, 50, 100);
            Font pCredits = FontManager.Add(Font.Name.Credits, SpriteBatch.Name.Texts, "CREDITS  00", Glyph.Name.Consolas36pt, 650, 100);

            GameManager.Create(this);
            GameManager.SetGameState(GameManager.State.AttractScreen);
            GameManager.Initialize();

            // Setup toggle boxes input observer
            InputSubject pInputSubject = InputManager.GetBSubject();

            pInputSubject.Attach(new ToggleSpriteBoxObserver());
        }
コード例 #23
0
ファイル: ShipManager.cs プロジェクト: Smybarr/space_invaders
        private static Ship CreateShips()
        {
            ShipManager pShipMan = ShipManager.privInstance();

            Debug.Assert(pShipMan != null);

            // get the game object tree
            PCSTree rootGamObjTree = GameObjectManager.GetRootTree();

            Debug.Assert(rootGamObjTree != null);

            //create the root - coordinates are 0 since it's a root
            //ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);
            //DeathManager.Attach(shipRoot);

            //todo find the ship object from loading instead of creating a new one
            // copy over safe copy (new or find precreated game object)

            //todo - refactor this using object pooling for ships - also will need more than these 3 ships w/ two player!
            //Create 3 ships total-----------------

            //create the starting ship;
            Ship pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 0, pShipMan.startShip_PosX, pShipMan.startShip_PosY);

            //set as the ship managers current ship
            pShipMan.pCurrentShip = pShip;

            // Attach the sprite to the correct sprite batch
            SpriteBatch pSB_GameSprites = SpriteBatchManager.Find(SpriteBatch.Name.GameSprites);
            SpriteBatch pSB_Boxes       = SpriteBatchManager.Find(SpriteBatch.Name.SpriteBoxes);

            pSB_GameSprites.Attach(pShip.pProxySprite);
            pShip.ActivateCollisionSprite(pSB_Boxes);


            // Attach the ship to the ship root
            // get the root (created before this function was called)
            GameObject pShipRoot = GameObjectManager.Find(GameObject.Name.ShipRoot);

            Debug.Assert(pShipRoot != null);

            // Add current ship tree to GameObject Tree - {update and collisions}
            rootGamObjTree.Insert(pShipMan.pCurrentShip, pShipRoot);

            //TESTING - CREATING 2 EXTRA SHIPS-------------------------------------------

            //extra ship one
            Ship pShipOne = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 1, pShipMan.extraShipOne_X, pShipMan.extraShip_Y);

            //add to the ship tree as well as root game object tree
            rootGamObjTree.Insert(pShipOne, pShipMan.pCurrentShip);

            // Attach the sprite to the correct sprite batch

            pSB_GameSprites.Attach(pShipOne.pProxySprite);
            pShipOne.ActivateGameSprite(pSB_GameSprites);
            pShipOne.ActivateCollisionSprite(pSB_Boxes);

            //update the position of the new ship
            pShipOne.Update();

            //extra ship two
            Ship pShipTwo = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 2, pShipMan.extraShipTwo_X, pShipMan.extraShip_Y);


            //add to the ship tree as well as root game object tree
            rootGamObjTree.Insert(pShipTwo, pShipOne);

            // Attach the sprite to the correct sprite batch
            pSB_GameSprites.Attach(pShipTwo.pProxySprite.pSprite);
            pShipTwo.ActivateGameSprite(pSB_GameSprites);
            pShipTwo.ActivateCollisionSprite(pSB_Boxes);

            //update the position of the new ship
            pShipTwo.Update();

            //END TESTING OF CREATING 2 EXTRA SHIPS-------------------------------------------


            //attach the shipRoot tree to the root game object tree
            //GameObjectManager.AttachTree(pShipRoot, rootGamObjTree);
            GameObjectManager.AttachTree(pShipRoot);

            return(pShipMan.pCurrentShip);
        }
コード例 #24
0
ファイル: ExplosionManager.cs プロジェクト: wangjo22/Final
 private ExplosionManager()
 {
     this.pSprite      = SpriteBatchManager.Find(SpriteBatch.Name.ExplosionEffectSprite);
     this.pPlayerExpld = new PlayerExplosion(GameObject.Name.PlayerExplision, GameSprite.Name.Player_Explosion, -10.0f, -10.0f);
 }
コード例 #25
0
ファイル: WallFactory.cs プロジェクト: ccaunca/Projects
 public WallFactory(PCSTree tree)
 {
     this.pSpriteBoxBatch = SpriteBatchManager.Find(SpriteBatchName.Boxes);
     Debug.Assert(this.pSpriteBoxBatch != null);
     this.pTree = tree;
 }