Exemplo n.º 1
0
        public ColObject(ProxySprite pProxySprite)
        {
            Debug.Assert(pProxySprite != null);

            // Create Collision Rect
            // Use the reference sprite to set size and shape
            // need to refactor if you want it different
            GameSprite pSprite = pProxySprite.pSprite;

            Debug.Assert(pSprite != null);

            // Origin is in the UPPER RIGHT
            this.poColRect = new ColRect(pSprite.GetScreenRect());
            Debug.Assert(this.poColRect != null);

            // Create the box sprite

            //WORKING
            //this.pColSprite = BoxSpriteManager.Add(GameSprite.Name.Box, this.poColRect.x, this.poColRect.y, this.poColRect.width, this.poColRect.height);

            //TEST
            this.pColSprite = BoxSpriteManager.Add(pProxySprite.pSprite.GetName(), this.poColRect.x, this.poColRect.y, this.poColRect.width, this.poColRect.height);


            ////get the box name from the matching sprite name;
            //BoxSprite.Name colBoxName = (BoxSprite.Name) pProxySprite.pSprite.GetName();
            //Debug.Assert(colBoxName != null);
            //this.pColSprite = BoxSpriteManager.Find(colBoxName);
            //this.pColSprite.SetScreenRect(this.poColRect.x, this.poColRect.y, this.poColRect.width, this.poColRect.height);
            //Debug.Assert(this.pColSprite != null);

            this.pColSprite.SetLineColor(1.0f, 1.0f, 0.0f);
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------------------
        // Constructor
        //--------------------------------------------------------------------------------------------
        public CollisionObject(ProxySprite proxySprite)
        {
            Debug.Assert(proxySprite != null);

            GameSprite pSprite = proxySprite.pSprite;

            Debug.Assert(pSprite != null);

            this.pColRect = new CollisionRect(pSprite.GetScreenRect());
            Debug.Assert(this.pColRect != null);

            this.pBoxSprite = BoxSpriteManager.Add(BoxSprite.Name.CollisionBox, this.pColRect.x, this.pColRect.y, this.pColRect.width, this.pColRect.height);
            Debug.Assert(this.pBoxSprite != null);
            this.pBoxSprite.SetColor(1.0f, 1.0f, 1.0f);
        }
Exemplo n.º 3
0
        //----------------------------------------------------------------------------------
        // Data
        //----------------------------------------------------------------------------------
        //public BoxSprite pCollSprite;
        //public CollRect poColRect;


        //----------------------------------------------------------------------------------
        // Constructors
        //----------------------------------------------------------------------------------
        public NullCollisionObject(ProxySprite pProxySprite)
        {
            Debug.Assert(pProxySprite != null);

            GameSprite pGameSprite = pProxySprite.pSprite;

            Debug.Assert(pGameSprite != null);

            // Origin is in the upper-right
            this.poColRect = new CollRect(pGameSprite.GetScreenRect());
            Debug.Assert(this.poColRect != null);


            // Create the Sprite
            this.pCollSprite = BoxSpriteManager.Add(BoxSprite.Name.Box, this.poColRect.x, this.poColRect.y, this.poColRect.width, this.poColRect.height);
            Debug.Assert(this.pCollSprite != null);
            this.pCollSprite.SetLineColor(1.0f, 1.0f, 1.0f);
        }
Exemplo n.º 4
0
        public static void Create(int numNodes = 5, int growthSize = 2)
        {
            // make sure values are ressonable
            Debug.Assert(numNodes > 0);
            Debug.Assert(growthSize > 0);

            // initialize the singleton here
            Debug.Assert(pInstance == null);

            // Do the initialization
            if (pInstance == null)
            {
                pInstance = new BoxSpriteManager(numNodes, growthSize);

                BoxSpriteManager.Add(BoxSprite.Name.Uninitialized, 0, 0, Constants.uninitializedWidth, Constants.uninitializedHeight);

                BoxSpriteManager.Add(BoxSprite.Name.NullObject, 0, 0, 0, 0);
            }
        }
        public CollisionObject(ProxySprite pProxySprite)
        {
            Debug.Assert(pProxySprite != null);

            // Create Collision Rect
            // Use the reference sprite to set size and shape
            // need to refactor if you want it different
            GameSprite pSprite = pProxySprite.pSprite;

            Debug.Assert(pSprite != null);

            // Origin is in the UPPER RIGHT
            this.poColRect = new CollisionRect(pSprite.GetScreenRect());
            Debug.Assert(this.poColRect != null);

            // Create the sprite
            this.pColSprite = BoxSpriteManager.Add(BoxSprite.Name.Box, this.poColRect.x, this.poColRect.y, this.poColRect.width, this.poColRect.height);
            Debug.Assert(this.pColSprite != null);
            this.pColSprite.SetLineColor(1.0f, 1.0f, 0.0f);
        }
Exemplo n.º 6
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());
        }