Пример #1
0
        public static Font Add(FontName fontName, int key, TextureName texName, float x, float y, float w, float h)
        {
            FontManager fontMan = FontManager.GetInstance();
            Font        font    = (Font)fontMan.BaseAdd();

            Debug.Assert(font != null);
            font.Set(fontName, key, texName, x, y, w, h);
            return(font);
        }
Пример #2
0
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pUFO;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

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

            pA.Remove();

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

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

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

            SoundMan.PlaySound(Sound.Name.InvaderKilled);

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

            explosion.ActivateGameSprite(pSB_UFOs);
            GameObjectMan.Attach(explosion);
            TimerMan.Add(TimeEvent.Name.RemoveExplosion, new RemoveExplosionCommand(explosion), 0.25f);
        }
Пример #3
0
        public static Font Add(Font.Name name, SpriteBatch pSpriteBatch, String pMessage, Glyph.Name glyphName, float xStart, float yStart)
        {
            FontManager pInstance = FontManager.PrivGetInstance();

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

            Debug.Assert(pNode != null);

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

            // Add to sprite batch
            Debug.Assert(pSpriteBatch != null);
            Debug.Assert(pNode.pFontSprite != null);
            pSpriteBatch.Attach(pNode.pFontSprite);

            return(pNode);
        }
Пример #4
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);
        }
Пример #5
0
        public static Font Add(Font.Name name, SpriteBatch.Name SB_Name, String pMessage, Glyph.Name glyphName, float xStart, float yStart)
        {
            FontMan pMan = FontMan.privGetInstance();

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

            Debug.Assert(pNode != null);

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

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

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

            return(pNode);
        }
Пример #6
0
        public static Font Add(Font.Name fontName, SpriteNodeBatch.Name SpriteBatch_Name, String pMessage, Glyph.Name glyphName, float px, float py)
        {
            FontManager pManager = FontManager.privGetInstance();

            Font pNode = (Font)pManager.baseAdd();

            Debug.Assert(pNode != null);

            pNode.Set(fontName, pMessage, glyphName, px, py);

            // Add to sprite batch
            SpriteNodeBatch pSriteBatch = SpriteNodeBatchManager.Find(SpriteBatch_Name);

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

            return(pNode);
        }
Пример #7
0
        // PA2: Factory Method
        public Font AddFont(Font.Name name, SpriteBatch.Name SB_Name, String pMessage, Glyph.Name glyphName, float xStart, float yStart)
        {
            Font pNode = (Font)this.PullFromReserved();

            Debug.Assert(pNode != null);

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

            // Add to sprite batch
            SpriteBatch sb = SpriteBatchManager.getInstance().AddSpriteBatch(SB_Name, 1);

            sb.AddSprite(pNode.pFontSprite);

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

            this.Add(pNode);


            return(pNode);
        }
Пример #8
0
        public static Font Add(Font.Name name, SpriteBatch.Name SB_Name, String pMessage, Glyph.Name glyphName, float x, float y)
        {
            FontMan pFMan = FontMan.PrivGetInstance();

            Debug.Assert(pFMan != null);

            Font pFNode = (Font)pFMan.BaseAdd();

            Debug.Assert(pFNode != null);

            pFNode.Set(name, pMessage, glyphName, x, y);

            SpriteBatch pSpriteBatch = SpriteBatchMan.Find(SB_Name);

            Debug.Assert(pSpriteBatch != null);

            Debug.Assert(pFNode.pFontSprite != null);
            pSpriteBatch.Attach(pFNode.pFontSprite);

            return(pFNode);
        }
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pAlien;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

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

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

            pGrid.nNumActive--;

            pA.Remove();

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

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

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

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

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

            pTimeEvent.deltaTime -= 0.01f;

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

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

            //---------------------------------------------------------------------------------------------------------
            // Scene Transition
            //---------------------------------------------------------------------------------------------------------
            if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 1)
            {
                PlayerMan.WriteHighScores();
                pPlayer.nCurrLevel++;
                SceneContext.GetState().Initialize();
                if (SceneContext.bMultiplayer)
                {
                    SceneContext.SetState(SceneContext.Scene.MultiPlay);
                }
                else
                {
                    SceneContext.SetState(SceneContext.Scene.SinglePlay);
                }
            }
            else if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 2)
            {
                PlayerMan.WriteHighScores();
                SceneContext.SetState(SceneContext.Scene.Credits);
            }
        }