Exemplo n.º 1
0
        public override void Notify()
        {
            this.debouceCount++;
            //debounceLimit is a static var in InputObserver.cs
            if (this.debouceCount % debounceLimit == 1)
            {
                //Debug.WriteLine("Moving Left");
            }
            Ship pShip = ShipMan.GetShip();

            pShip.MoveLeft();
        }
Exemplo n.º 2
0
        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------
        public Ship(GameObject.Name name, GameSprite.Name spriteName, float posX, float posY)
            : base(name, spriteName, ShipCategory.Type.Ship)
        {
            this.x = posX;
            this.y = posY;

            this.shipSpeed = 3.0f;
            this.state     = null;

            this.pMoveState  = ShipMan.GetState(ShipMan.State.MoveLeftRight);
            this.pShootState = null;
        }
Exemplo n.º 3
0
 public override void unLoadContent(Scene pScene)
 {
     GameObjectMan.Reset();
     TimerMan.Reset();
     InputMan.Reset();
     CollisionPairMan.Reset();
     SpriteBatchMan.Reset();
     BoxSpriteMan.Reset();
     ProxySpriteMan.Reset();
     UFOMan.Reset();
     ShipMan.Reset();
 }
Exemplo n.º 4
0
        //---------------------------------------------------------
        // Static methods
        //---------------------------------------------------------
        public static void Create()
        {
            // ensure the instance of ShipMan has not been created
            Debug.Assert(pInstance == null);

            if (pInstance == null)
            {
                pInstance = new ShipMan();
            }

            Debug.Assert(pInstance != null);
        }
Exemplo n.º 5
0
        public static void Destroy()
        {
            ShipMan pMan = ShipMan.instance;

            pMan.pShip    = null;
            pMan.pMissile = null;

            pMan.pStateReady         = null;
            pMan.pStateMissileFlying = null;
            pMan.pStateEnd           = null;
            pMan.pSpriteBatchMan     = null;
            ShipMan.instance         = null;
        }
Exemplo n.º 6
0
        //----------------------------------------------------------------------------------
        // Shoot
        //----------------------------------------------------------------------------------
        public override void ShootMissile(Ship pShip)
        {
            Missile pMissile = ShipMan.ActivateMissile();

            pMissile.SetPos(pShip.x, pShip.y + 20);

            //play sound
            Ship.soundEngine.SoundVolume = 0.15f;
            Ship.soundEngine.Play2D(Ship.shootSound, false, false, false);

            // switch states
            this.Handle(pShip);
        }
Exemplo n.º 7
0
        public static void CreateShipLifes()
        {
            //ensure call Create() first
            ShipMan pShipMan = ShipMan.GetInstance();

            Debug.Assert(pShipMan != null);


            pInstance.pShip = ActivateShip();

            pInstance.pShip.setState(ShipMan.State.Ready);
            pInstance.pShip.setPositionState(ShipMan.State.Normal);
            pInstance.pShip.createLifes();
        }
Exemplo n.º 8
0
        public override void ShootMissile(Ship pShip)
        {
            Missile pMissile = ShipMan.ActivateMissile();

            pSndEngine.SoundVolume = 0.2f;
            pSndEngine.Play2D("shoot.wav");

            pMissile.SetPos(pShip.x, pShip.y + 15);
            pMissile.SetActive(true);

            //then sets you to missile flying state
            //aka u cant shoot a missile
            this.Handle(pShip);
        }
Exemplo n.º 9
0
        public static Ship CreateShip()
        {
            if (instance == null)
            {
                instance = new ShipMan();
            }

            Debug.Assert(instance != null);

            Ship pShip = ActivateShip();

            pShip.SetState(ShipMan.State.Ready);
            return(pShip);
        }
Exemplo n.º 10
0
        public static void Create()
        {
            Debug.Assert(instance == null);

            if (instance == null)
            {
                instance = new ShipMan();
            }

            Debug.Assert(instance != null);

            instance.poShip = ActivateShip();
            instance.poShip.SetShootState(ShipMan.ShootState.Ready);
            instance.poShip.SetMoveState(ShipMan.MoveState.FreeMove);
        }
        public override void UnLoadContent()
        {
            TimerMan.Destroy();
            TextureMan.Destroy();
            ImageMan.Destroy();
            GameSpriteMan.Destroy();
            BoxSpriteMan.Destroy();
            pSpriteBatchMan.Destroy();
            ProxySpriteMan.Destroy();
            GlyphMan.Destroy();

            //GameObjectMan.Destroy();
            ColPairMan.Destroy();
            FontMan.Destroy();
            ShipMan.Destroy();
        }
Exemplo n.º 12
0
        //public override void Transition()
        //{
        //    // update SpriteBatchMan()
        //    SpriteBatchMan.SetActive(this.poSpriteBatchMan);
        //}

        public override void Entering()
        {
            // update SpriteBatchMan()
            SpriteBatchMan.SetActive(this.poSpriteBatchMan);
            GameObjectMan.SetActive(this.poGameObjectMan);
            TimerMan.SetActive(this.poTimerMan);
            ShipMan.SetActive(this.poShipMan);
            DelayedObjectMan.SetActive(this.poDelayedObjectMan);

            // Update timer since last pause
            float t0    = GlobalTimer.GetTime();
            float t1    = this.TimeAtPause;
            float delta = t0 - t1;

            TimerMan.PauseUpdate(delta);
        }
        public override void Notify()
        {
            WallCategory pWall = (WallCategory)this.pSubject.pObjB;
            //Debug.WriteLine("Ship hits " + pWall.name);

            Ship pShip = ShipMan.GetShip();

            if (pWall.name == GameObject.Name.WallRight)
            {
                pShip.SetState(ShipMan.State.NotMovingRight);
            }
            else if (pWall.name == GameObject.Name.WallLeft)
            {
                pShip.SetState(ShipMan.State.NotMovingLeft);
            }
        }
Exemplo n.º 14
0
        public override void Notify()
        {
            // we need to revert lvl1 or lvl2 to original forms
            // because we lost and will need to re-load content

            //ship was hit take a life and subtract from score

            PlayerMan.P1TakeLife();
            PlayerMan.SetP1Score(-250);

            float P1lives = PlayerMan.GetP1Lives();

            SpaceInvaders pGame = GameMan.GetGame();

            //check if they have more lives
            if (P1lives == 0)
            {
                // last life i was stil able to shoot
                Ship pShip = ShipMan.GetShip();

                pShip.SetShootState(ShipMan.ShootState.End);
                pShip.SetMoveState(ShipMan.MoveState.NoMove);

                GameState pState = pGame.GetCurrentState();

                if (pState.GetStateName() == GameMan.State.InGame)
                {
                    InGameState pLvl1 = (InGameState)pState;
                    pLvl1.SetStateToggle(false);

                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 5.0f);
                }

                else if (pState.GetStateName() == GameMan.State.LVL2)
                {
                    InGameStateLV2 pLvl2 = (InGameStateLV2)pState;
                    pLvl2.SetStateToggle(false);

                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 5.0f);
                }
            }

            else
            {
                //do nothing
            }
        }
Exemplo n.º 15
0
        public override void Notify()
        {
            Ship pShip = ShipMan.GetShip();

            if (this.pSubject.pObjB.GetName() == GameObject.Name.BumperRight)
            {
                pShip.SetMoveState(ShipMan.State.MoveLeft);
            }
            else if (this.pSubject.pObjB.GetName() == GameObject.Name.BumperLeft)
            {
                pShip.SetMoveState(ShipMan.State.MoveRight);
            }
            else
            {
                Debug.Assert(false);
            }
        }
Exemplo n.º 16
0
        public static void Create()
        {
            // make sure its the first time
            //Debug.Assert(pInstance == null);

            // Do the initialization
            if (pInstance == null)
            {
                pInstance = new ShipMan();
            }

            Debug.Assert(pInstance != null);

            // Stuff to initialize after the instance was created
            pInstance.pShip = ActivateShip();
            pInstance.pShip.SetState(ShipMan.State.Ready);
        }
Exemplo n.º 17
0
        public static ShipState GetState(ShipMan.State state)
        {
            //ensure call Create() first
            ShipMan pShipMan = ShipMan.GetInstance();

            Debug.Assert(pShipMan != null);

            ShipState pShipState = null;

            switch (state)
            {
            case ShipMan.State.Ready:
                pShipState = pShipMan.pStateReady;
                break;

            case ShipMan.State.MissileFlying:
                pShipState = pShipMan.pStateMissileFlying;
                break;

            case ShipMan.State.End:
                pShipState = pShipMan.pStateEnd;
                break;

            case ShipMan.State.Normal:
                pShipState = pShipMan.pStateNormal;
                break;

            case ShipMan.State.MostLeft:
                pShipState = pShipMan.pStateMostLeft;
                break;

            case ShipMan.State.MostRight:
                pShipState = pShipMan.pStateMostRight;
                break;

            case ShipMan.State.Stay:
                pShipState = pShipMan.pStateStay;
                break;

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

            return(pShipState);
        }
Exemplo n.º 18
0
        public static void Create(SpriteBatchMan pSpriteBatchMan)
        {
            // make sure its the first time
            Debug.Assert(instance == null);

            // Do the initialization
            if (instance == null)
            {
                instance = new ShipMan();
            }

            Debug.Assert(instance != null);

            // Stuff to initialize after the instance was created
            instance.pShip = ActivateShip(pSpriteBatchMan);
            instance.pShip.SetState(ShipMan.State.Ready);
            instance.pSpriteBatchMan = pSpriteBatchMan;
        }
Exemplo n.º 19
0
        public static void Create(SndObserver pSnd)
        {
            // make sure its the first time
            // Debug.Assert(instance == null);

            // Do the initialization
            if (instance == null)
            {
                instance = new ShipMan();
            }

            Debug.Assert(instance != null);

            // Stuff to initialize after the instance was created
            instance.pShip = ActivateShip(pSnd);
            instance.pShip.SetState(ShipMan.State.Ready);
            instance.pShip.SetMoveState(ShipMan.State.MoveBoth);
        }
Exemplo n.º 20
0
        public static ShipState GetState(State state)
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            ShipState pShipState = null;

            switch (state)
            {
            case ShipMan.State.Ready:
                pShipState = pShipMan.pStateReady;
                break;

            case ShipMan.State.MissileFlying:
                pShipState = pShipMan.pStateMissileFlying;
                break;

            case ShipMan.State.Dead:
                pShipState = pShipMan.pStateDead;
                break;

            case ShipMan.State.MoveLeftRight:
                pShipState = pShipMan.pMoveLeftRightState;
                break;

            case ShipMan.State.MoveLeft:
                pShipState = pShipMan.pMoveLeftState;
                break;

            case ShipMan.State.MoveRight:
                pShipState = pShipMan.pMoveRightState;
                break;


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

            return(pShipState);
        }
Exemplo n.º 21
0
        public static Missile ActivateMissile(Ship pShip)
        {
            Missile pMissile = pShip.GetMissile();
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

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

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

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

            Debug.Assert(pMissileGroup != null);

            pMissileGroup.Add(pMissile);
            return(pMissile);
        }
        public override void Notify()
        {
            if (GamePlayingState.playLives > 1)
            {
                GamePlayingState.playLives -= 1;
                //Debug.Assert(ShipMan.GetShip() == null);
                ShipMan.Attach(pSpriteBatchMan);
            }
            else
            {
                CheckPlayerStatusObserver pCheck = new CheckPlayerStatusObserver(this);
                DelayedObjectMan.Attach(pCheck);
                //SpaceInvaders pSI = SpaceInvaders.GetInstance();
                //pSI.UnLoadContent();

                //pSI.SetState(SpaceInvaders.State.EndGameState);

                //pSI.LoadContent();
                //if (pSI.scoreOne > pSI.scoreTwo)
                //{
                //    if (pSI.scoreOne > pSI.scoreHigh)
                //    {
                //        pSI.scoreHigh = pSI.scoreOne;
                //    }
                //}
                //else
                //{
                //    if (pSI.scoreTwo > pSI.scoreHigh)
                //    {
                //        pSI.scoreHigh = pSI.scoreTwo;
                //    }
                //}


                //MoveToEndStateEvent pMoveToEndEvent = new MoveToEndStateEvent(pSI);
                //TimerMan.Add(TimeEvent.Name.MoveToEndState, pMoveToEndEvent, 0.5f);
            }
        }
Exemplo n.º 23
0
        public static ShipState GetState(State state)
        {
            //ShipMan pShipMan = ShipMan.PrivInstance();
            ShipMan pShipMan = ShipMan.instance;

            Debug.Assert(pShipMan != null);

            ShipState pShipState = null;

            switch (state)
            {
            case ShipMan.State.Ready:
                pShipState = pShipMan.pStateReady;
                break;

            case ShipMan.State.MissileFlying:
                pShipState = pShipMan.pStateMissileFlying;
                break;

            case ShipMan.State.End:
                pShipState = pShipMan.pStateEnd;
                break;

            case ShipMan.State.NotMovingRight:
                pShipState = pShipMan.pStateNotMovingRight;
                break;

            case ShipMan.State.NotMovingLeft:
                pShipState = pShipMan.pStateNotMovingLeft;
                break;

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

            return(pShipState);
        }
Exemplo n.º 24
0
        public static Ship ActivateShip()
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

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

            ShipMan.Add(pShip);

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

            pSB_Aliens.Attach(pShip.pProxySprite);

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

            Debug.Assert(pShipRoot != null);

            // Add to GameObject Tree - {update and collisions}
            pShipRoot.Add(pShip);
            return(pShip);
        }
Exemplo n.º 25
0
        public static Missile ActivateMissile()
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            pShipMan.pMissile = new Missile(GameObject.Name.Missile, GameSprite.Name.Missile, 10, 10);

            //attach missile to missile group(should be missileRoot)
            GameObject pMissileGroup = GONodeMan.Find(GameObject.Name.MissileGroup);

            Debug.Assert(pMissileGroup != null);

            pMissileGroup.Add(pShipMan.pMissile);

            SpriteBatch pSB_Projectiles = SpriteBatchMan.Find(SpriteBatch.Name.Projectiles);
            SpriteBatch pSB_Boxes       = SpriteBatchMan.Find(SpriteBatch.Name.Boxes);

            pShipMan.pMissile.ActivateGameSprite(pSB_Projectiles);
            pShipMan.pMissile.ActivateCollisionSprite(pSB_Boxes);


            return(pShipMan.pMissile);
        }
Exemplo n.º 26
0
        public static Ship CreateInactiveShip(int xPos, int yPos)
        {
            ShipMan pShipMan = ShipMan.PrivInstance();

            Debug.Assert(pShipMan != null);

            // copy over safe copy
            Ship pShip = new Ship(GameObject.Name.ShipInactive, GameSprite.Name.ShipInactive, xPos, yPos);

            pShip.SetState(ShipMan.State.Inactive);

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

            pSB_Aliens.Attach(pShip.pProxySprite);

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

            Debug.Assert(pShipRoot != null);

            pShipRoot.Add(pShip);
            GameObjectMan.Attach(pShip);
            return(pShip);
        }
Exemplo n.º 27
0
 public void SetMoveState(ShipMan.State inState)
 {
     this.moveState = ShipMan.GetState(inState);
 }
Exemplo n.º 28
0
        //-------------------------------------------------------------------------------
        // Override abstract methods
        //-------------------------------------------------------------------------------
        public override void notify()
        {
            Ship pShip = ShipMan.GetShip();

            pShip.moveLeft();
        }
Exemplo n.º 29
0
        public override void LoadContent()
        {
            // -----------------------------------------------------------------------------
            // ---------------------- Sound Setup ------------------------------------------
            // -----------------------------------------------------------------------------

            SoundManager.Add(Sound.Name.Fastinvader1, "fastinvader1.wav");
            SoundManager.Add(Sound.Name.Fastinvader2, "fastinvader2.wav");
            SoundManager.Add(Sound.Name.Fastinvader3, "fastinvader3.wav");
            SoundManager.Add(Sound.Name.Fastinvader4, "fastinvader4.wav");
            SoundManager.Add(Sound.Name.Shoot, "shoot.wav");
            SoundManager.Add(Sound.Name.Explosion, "explosion.wav");
            SoundManager.Add(Sound.Name.InvaderKilled, "invaderkilled.wav");
            SoundManager.Add(Sound.Name.UFO_HighPitch, "ufo_highpitch.wav");
            SoundManager.Add(Sound.Name.UFO_LowPitch, "ufo_lowpitch.wav");


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

            TextureManager.Add(Texture.Name.SpaceInvaders, "SpaceInvaders.tga");
            TextureManager.Add(Texture.Name.Invaders, "birds_N_shield.tga");
            Texture pTexture = TextureManager.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga");

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

            // -----------------------------------------------------------------------------
            // -------------------- Creating Images ----------------------------------------
            // -----------------------------------------------------------------------------

            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.AlienExplosion, Texture.Name.SpaceInvaders, 83, 3, 13, 8);
            ImageManager.Add(Image.Name.Saucer, Texture.Name.SpaceInvaders, 99, 3, 16, 8);
            ImageManager.Add(Image.Name.SaucerExplosion, Texture.Name.SpaceInvaders, 118, 3, 21, 8);

            ImageManager.Add(Image.Name.Ship, Texture.Name.SpaceInvaders, 3, 14, 13, 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.Missile, Texture.Name.SpaceInvaders, 3, 29, 1, 4);
            ImageManager.Add(Image.Name.MissileExplosion, Texture.Name.SpaceInvaders, 7, 25, 8, 8);

            ImageManager.Add(Image.Name.Wall, Texture.Name.Invaders, 40, 185, 20, 10);

            ImageManager.Add(Image.Name.BombStraight, Texture.Name.Invaders, 111, 101, 5, 49);
            ImageManager.Add(Image.Name.BombZigZagA, Texture.Name.SpaceInvaders, 18, 26, 3, 7);
            ImageManager.Add(Image.Name.BombZigZagB, Texture.Name.SpaceInvaders, 24, 26, 3, 7);
            ImageManager.Add(Image.Name.BombZigZagC, Texture.Name.SpaceInvaders, 30, 26, 3, 7);
            ImageManager.Add(Image.Name.BombZigZagD, Texture.Name.SpaceInvaders, 36, 26, 3, 7);
            ImageManager.Add(Image.Name.BombDaggerA, Texture.Name.SpaceInvaders, 42, 27, 3, 6);
            ImageManager.Add(Image.Name.BombDaggerB, Texture.Name.SpaceInvaders, 48, 27, 3, 6);
            ImageManager.Add(Image.Name.BombDaggerC, Texture.Name.SpaceInvaders, 54, 27, 3, 6);
            ImageManager.Add(Image.Name.BombDaggerD, Texture.Name.SpaceInvaders, 60, 27, 3, 6);
            ImageManager.Add(Image.Name.BombRollingA, Texture.Name.SpaceInvaders, 65, 26, 3, 7);
            ImageManager.Add(Image.Name.BombRollingB, Texture.Name.SpaceInvaders, 70, 26, 3, 7);
            ImageManager.Add(Image.Name.BombRollingC, Texture.Name.SpaceInvaders, 75, 26, 3, 7);
            ImageManager.Add(Image.Name.BombRollingD, Texture.Name.SpaceInvaders, 80, 26, 3, 7);
            ImageManager.Add(Image.Name.BombExplosion, Texture.Name.SpaceInvaders, 86, 25, 6, 8);

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



            // -----------------------------------------------------------------------------
            // ---------------------- Creating GameSprites ---------------------------------
            // -----------------------------------------------------------------------------
            float dim = 33.0f;
            float sm  = dim;
            float md  = dim * 1.15f;
            float lg  = dim * 1.30f;


            GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.SquidA, 200, 400, sm, sm);
            GameSpriteManager.Add(GameSprite.Name.Alien, Image.Name.AlienA, 200, 200, md, md);
            GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.OctopusA, 200, 300, lg, lg);

            GameSpriteManager.Add(GameSprite.Name.Saucer, Image.Name.Saucer, 300, 250, 60, 30);
            GameSpriteManager.Add(GameSprite.Name.SaucerExplosion, Image.Name.SaucerExplosion, 300, 250, 60, 30);
            GameSpriteManager.Add(GameSprite.Name.AlienExplosion, Image.Name.AlienExplosion, -10, -10, dim, dim);

            // Utility for ship state movement

            float projWidth  = 8.0f;
            float projHeight = 16.0f;

            GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, 0, 0, 0.5f * projWidth, 0.75f * projHeight);
            GameSpriteManager.Add(GameSprite.Name.MissileExplosion, Image.Name.MissileExplosion, 0, 0, 0.7f * dim, 0.7f * dim);
            GameSpriteManager.Add(GameSprite.Name.Ship, Image.Name.Ship, 400, 100, 60, 21);
            GameSpriteManager.Add(GameSprite.Name.ShipExplosionA, Image.Name.ShipExplosionA, 400, 100, 90, 31);
            GameSpriteManager.Add(GameSprite.Name.ShipExplosionB, Image.Name.ShipExplosionB, 400, 100, 90, 31);

            GameSpriteManager.Add(GameSprite.Name.Wall, Image.Name.Wall, 448, 100, 850, 4);

            GameSpriteManager.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 100, 100, projWidth, projHeight);
            GameSpriteManager.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZagA, 200, 200, projWidth, projHeight);
            GameSpriteManager.Add(GameSprite.Name.BombDagger, Image.Name.BombDaggerA, 100, 100, projWidth, projHeight);
            GameSpriteManager.Add(GameSprite.Name.BombRolling, Image.Name.BombRollingA, 100, 100, projWidth, projHeight);
            GameSpriteManager.Add(GameSprite.Name.BombExplosion, Image.Name.BombExplosion, 100, 100, 0.5f * dim, 0.7f * dim);



            float brick_w = 12.0f;
            float brick_h = 6.0f;

            GameSpriteManager.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, brick_w, brick_h);
            GameSpriteManager.Add(GameSprite.Name.Brick_LeftTop0, Image.Name.BrickLeft_Top0, 50, 25, brick_w, brick_h);
            GameSpriteManager.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, brick_w, brick_h);
            GameSpriteManager.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, brick_w, brick_h);
            GameSpriteManager.Add(GameSprite.Name.Brick_RightTop0, Image.Name.BrickRight_Top0, 50, 25, brick_w, brick_h);
            GameSpriteManager.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, brick_w, brick_h);
            GameSpriteManager.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, brick_w, brick_h);



            // -----------------------------------------------------------------------------
            // ---------------------- Create Sprite Node Batches ---------------------------
            // -----------------------------------------------------------------------------



            SpriteNodeBatch pBatch_Texts      = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Texts, 2);
            SpriteNodeBatch pBatch_Player     = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Players, 5);
            SpriteNodeBatch pBatch_TheSwarm   = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.TheSwarm, 10);
            SpriteNodeBatch pBatch_Explosions = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Explosions, 20);
            SpriteNodeBatch pBatch_Shields    = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Shields, 200);
            SpriteNodeBatch pBatch_Boxes      = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Boxes, 400);

            pBatch_Boxes.SetDrawStatus(false);
            Debug.WriteLine("Finished : Loading Sprite Batches");

            // -----------------------------------------------------------------------------
            // ---------------------- Instantiate Local GameObject Manager -----------------
            // -----------------------------------------------------------------------------

            // Moved to CreateManagers()


            // -----------------------------------------------------------------------------
            // ---------------------- Font Setup ------------------------------------------
            // -----------------------------------------------------------------------------

            Font pFont;

            int topTextLine = 980;

            pFont = FontManager.Add(Font.Name.Score1_Title, SpriteNodeBatch.Name.Texts, "SCORE<1>", Glyph.Name.Consolas36pt, 100, topTextLine);
            pFont = FontManager.Add(Font.Name.HighScore_Title, SpriteNodeBatch.Name.Texts, "HI-SCORE<1>", Glyph.Name.Consolas36pt, 350, topTextLine);
            pFont = FontManager.Add(Font.Name.Score2_Title, SpriteNodeBatch.Name.Texts, "SCORE<2>", Glyph.Name.Consolas36pt, 650, topTextLine);


            int scoreTextLine = 940;
            int x_shift       = 40;

            pFont = FontManager.Add(Font.Name.Score1, SpriteNodeBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 100 + x_shift, scoreTextLine);
            pFont = FontManager.Add(Font.Name.HighScore, SpriteNodeBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 350 + x_shift, scoreTextLine);
            pFont = FontManager.Add(Font.Name.Score2, SpriteNodeBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 650 + x_shift, scoreTextLine);


            FontManager.Add(Font.Name.LifeCount, SpriteNodeBatch.Name.Texts, "3", Glyph.Name.Consolas36pt, 100, 50);



            // -----------------------------------------------------------------------------
            // ---------------------- Create Bomb GameObjects -------------------------------
            // -----------------------------------------------------------------------------
            BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pBombRoot.ActivateCollisionSprite(pBatch_Boxes);
            GameObjectManager.Attach(pBombRoot);



            // -----------------------------------------------------------------------------
            // ---------------------- Create Explosion GameObjects -------------------------------
            // -----------------------------------------------------------------------------
            ExplosionFactory EF             = new ExplosionFactory(SpriteNodeBatch.Name.Explosions, SpriteNodeBatch.Name.Boxes);
            GameObject       pExplosionRoot = EF.Build(GameObject.Name.ExplosionRoot, 0.0f, 0.0f);


            // -----------------------------------------------------------------------------
            // ---------------------- Create Grids of Nested GameObjects -------------------
            // -----------------------------------------------------------------------------



            GameObject   pWallGroup;
            GameObject   pSwarmGrid;
            GameObject   pUFOGrid;
            GameObject   pShieldRoot;
            MissileGroup pMissileGroup = CreateMissleGroup(pBatch_Player, pBatch_Boxes);
            GameObject   pBumperGroup  = CreateBumperGroup(pBatch_Player, pBatch_Boxes);

            pWallGroup = CreateWalls(pBatch_TheSwarm, pBatch_Boxes);
            Debug.WriteLine("Finished : Creating the walls");



            AlienFactory AF = new AlienFactory(SpriteNodeBatch.Name.TheSwarm, SpriteNodeBatch.Name.Boxes);

            pSwarmGrid = AF.Build(GameObject.Name.AlienGrid);
            AF.swarmAnimation(pSwarmGrid);
            Debug.WriteLine("Finished : Creating the Swarm");



            pUFOGrid = AF.Build(GameObject.Name.UFOGrid);
            AF.UFOAnimation(pUFOGrid);
            Debug.WriteLine("Finished : Creating the UfO Boss");



            Debug.WriteLine("Create Animations Gamesprites");
            pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f);
            ShieldFactory SF = new ShieldFactory(SpriteNodeBatch.Name.Shields, SpriteNodeBatch.Name.Boxes, pShieldRoot);

            pShieldRoot = SF.Build(GameObject.Name.ShieldRoot);

            // -----------------------------------------------------------------------------
            // ---------------------- Create Ship GameObject ----------------------
            // -----------------------------------------------------------------------------

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

            GameObjectManager.Attach(pShipRoot);
            ShipMan.Create();
            Debug.WriteLine("Finished : Creating the ShipRoot and Ship");



            // -----------------------------------------------------------------------------
            // ---------------------- Collision Pairs --------------------------------------
            // -----------------------------------------------------------------------------


            // Alien vs Missile
            CollPair pAttackAliens = CollPairManager.Add(CollPair.Name.Alien_Missle, pMissileGroup, pSwarmGrid);

            Debug.Assert(pAttackAliens != null);
            pAttackAliens.Attach(new ShipReadyObserver());
            pAttackAliens.Attach(new RemoveMissileObserver());
            pAttackAliens.Attach(new RemoveAlienObserver());
            pAttackAliens.Attach(new SoundObserverKillAlien());
            pAttackAliens.Attach(new ExplosionSpriteObserver(GameSprite.Name.AlienExplosion));

            // Alien vs Shild
            CollPair pAlienHitShield = CollPairManager.Add(CollPair.Name.Alien_Shield, pSwarmGrid, pShieldRoot);

            pAlienHitShield.Attach(new RemoveBrickObserver());
            pAlienHitShield.Attach(new SoundObserverExplosion());

            // AlienGrid vs Left/Right Wall
            CollPair pHitWall = CollPairManager.Add(CollPair.Name.Alien_SideWalls, pSwarmGrid, pWallGroup);

            Debug.Assert(pHitWall != null);
            pHitWall.Attach(new GridObserver());


            //// AlienGrid vs Bottom Wall
            //CollPair pBottomWall = CollPairManager.Add(CollPair.Name.Alien_BottomWall, pSwarmGrid, pWallGroup);
            //Debug.Assert(pHitWall != null);
            //pBottomWall.Attach(new GameOverObserver());


            // Bumper vs Ship
            CollPair pHitBumper = CollPairManager.Add(CollPair.Name.Bumper_Ship, pBumperGroup, pShipRoot);

            pHitBumper.Attach(new BumperObserver());


            // Bomb vs Ship
            CollPair pHitShip = CollPairManager.Add(CollPair.Name.Bomb_Ship, pBombRoot, pShipRoot);

            pHitShip.Attach(new RemoveBombObserver());
            pHitShip.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion));
            pHitShip.Attach(new SoundObserverExplosion());
            pHitShip.Attach(new ShipTakeDamageObserver());  // triggers GAMEOVER
            pHitShip.Attach(new ExplosionSpriteObserver(GameSprite.Name.ShipExplosionA));
            pHitShip.Attach(new ExplosionSpriteObserver(GameSprite.Name.ShipExplosionB, 0.4f));
            //pHitShip.Attach(new GameOverObserver());


            // Bomb vs Bottom
            CollPair pHitBottom = CollPairManager.Add(CollPair.Name.Bomb_WallBottom, pBombRoot, pWallGroup);

            pHitBottom.Attach(new RemoveBombObserver());
            pHitBottom.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion));

            // Bomb vs Missile
            CollPair pBombvsMissile = CollPairManager.Add(CollPair.Name.Bomb_Missile, pBombRoot, pMissileGroup);

            pBombvsMissile.Attach(new ShipReadyObserver());
            pBombvsMissile.Attach(new RemoveBombObserver());
            pBombvsMissile.Attach(new RemoveMissileObserver());
            pBombvsMissile.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion));
            pBombvsMissile.Attach(new SoundObserverExplosion());


            // Bomb vs Shield
            CollPair pHitBombShield = CollPairManager.Add(CollPair.Name.Bomb_Shield, pBombRoot, pShieldRoot);

            pHitBombShield.Attach(new RemoveBombObserver());
            pHitBombShield.Attach(new RemoveBrickObserver());
            pHitBombShield.Attach(new SoundObserverExplosion());
            pHitBombShield.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion));


            // Missile vs Top-Wall
            CollPair pHitTopWall = CollPairManager.Add(CollPair.Name.Missile_WallTop, pMissileGroup, pWallGroup);

            Debug.Assert(pHitTopWall != null);
            pHitTopWall.Attach(new ShipReadyObserver());
            pHitTopWall.Attach(new RemoveMissileObserver());  //ShipRemoveMissileObserver()
            pHitTopWall.Attach(new ExplosionSpriteObserver(GameSprite.Name.MissileExplosion));


            // Missile vs Shield
            CollPair pColPair = CollPairManager.Add(CollPair.Name.Missile_Shield, pMissileGroup, pShieldRoot);

            pColPair.Attach(new ShipReadyObserver());
            pColPair.Attach(new RemoveMissileObserver());
            pColPair.Attach(new RemoveBrickObserver());
            pColPair.Attach(new SoundObserverExplosion());



            // UFO vs WallGroup
            CollPair pUFOvsWall = CollPairManager.Add(CollPair.Name.Saucer_Wall, pUFOGrid, pWallGroup);

            pUFOvsWall.Attach(new GridObserverUFO());



            // UFO vs Missile
            CollPair pUFOvsMissile = CollPairManager.Add(CollPair.Name.Missile_UFO, pMissileGroup, pUFOGrid);

            pUFOvsMissile.Attach(new ShipReadyObserver());
            pUFOvsMissile.Attach(new RemoveMissileObserver());
            pUFOvsMissile.Attach(new RemoveUFOObserver());
            pUFOvsMissile.Attach(new SoundObserverKillAlien());
            pUFOvsMissile.Attach(new ExplosionSpriteObserver(GameSprite.Name.SaucerExplosion));

            Debug.WriteLine("Finished : Loading Collision Pairs");



            // -----------------------------------------------------------------------------
            // ---------------------- Test Input Handles -----------------------------------
            // -----------------------------------------------------------------------------

            // Creation moved to createManagers()

            InputSubject pInputSubject;

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

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

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

            pInputSubject = InputManager.GetBkeySubject();
            pInputSubject.Attach(new RenderCollisionBoxesObserver());


            Simulation.SetState(Simulation.State.Realtime);

            Debug.WriteLine("Finished : Loading Input Subject");
        }
Exemplo n.º 30
0
 // tells ship what state it should be in....
 //can it Shoot? can it move L or R?
 public void SetShootState(ShipMan.ShootState inState)
 {
     this.state = ShipMan.GetShootState(inState);
 }