コード例 #1
0
 public virtual void VisitShieldGrid(ShieldGrid s)
 {
     //shouldn't call this
     //need to implement in concrete class
     Debug.WriteLine("Visit by ShieldGrid not implemented");
     Debug.Assert(false);
 }
コード例 #2
0
        public GameObject Create(ShieldCategory.Type type, GameObject.Name gameName, GameObject pContainer = null, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Brick:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop1, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop0, posX, posY);
                break;

            case ShieldCategory.Type.LeftBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftBottom, posX, posY);
                break;

            case ShieldCategory.Type.RightTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop1, posX, posY);
                break;

            case ShieldCategory.Type.RightTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop0, posX, posY);
                break;

            case ShieldCategory.Type.RightBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightBottom, posX, posY);
                break;

            case ShieldCategory.Type.Root:
                pShield = new ShieldRoot(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(0.0f, 0.0f, 1.0f);
                //Debug.Assert(false);
                break;

            case ShieldCategory.Type.Grid:
                pShield = new ShieldGrid(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(0.0f, 1.0f, 0.0f);
                break;

            case ShieldCategory.Type.Column:
                pShield = new ShieldColumn(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(1.0f, 0.0f, 0.0f);
                break;

            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }

            this.AttachTo(pShield, pContainer);
            return(pShield);
        }
コード例 #3
0
        public override void VisitShieldGrid(ShieldGrid m)
        {
            // BirdGroup vs MissileGroup
            //Debug.WriteLine("         collide:  {0} <-> {1}", m.name, this.name);

            // MissileGroup vs Columns
            GameObject pGameObj = (GameObject)Iterator.GetChild(m);

            CollisionPair.Collide(pGameObj, this);
        }
コード例 #4
0
        public Shield createShield(Shield.ShieldType mShieldType, GameObject.GameObjectName gameName, int index = 0, float mX = 0.0f, float mY = 0.0f)
        {
            Shield shield = null;

            switch (mShieldType)
            {
            case Shield.ShieldType.ShieldBrick:
                shield = new ShieldBrick(gameName, Sprite.SpriteName.ShieldBrick, index, mX, mY);
                break;

            case Shield.ShieldType.ShieldColumn:
                shield = new ShieldColumn(gameName, Sprite.SpriteName.NullObject, index, mX, mY);
                break;

            case Shield.ShieldType.ShieldUnit:
                shield = new ShieldUnit(gameName, Sprite.SpriteName.NullObject, index, mX, mY);
                break;

            case Shield.ShieldType.ShieldGrid:
                shield = new ShieldGrid(gameName, index, Sprite.SpriteName.NullObject);
                GameObjectNodeManager.add(shield, cPCSTree);
                break;

            case Shield.ShieldType.Uninitilized:
                Debug.WriteLine("Shield Type is Uninitilized");
                break;
            }

            this.cPCSTree.Insert(shield, this.cParent);
            // cSpriteBatch.addToBatch(shield.getProxySprite());
            // cSpriteBatch.addToBatch(shield.getCollisionObj().cSpriteBox);

            shield.addSpriteToBatch(this.cSpriteBatch);
            shield.addCollisionToBatch(SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Boxes));
            return(shield);
        }
コード例 #5
0
 //Shield
 public override void visitShieldGrid(ShieldGrid s)
 {
     //     Debug.WriteLine("FlippingBomb ShieldGrid");
     CollisionPair.detectCollision(this, (GameObject)s.pChild);
 }
コード例 #6
0
        //----------------------------------------------------------------------------------
        // Visit Shilds
        //----------------------------------------------------------------------------------

        public virtual void VisitShieldGrid(ShieldGrid sg)
        {
            // no differed to subcass
            Debug.WriteLine("Visit by Shield Grid not implemented");
            Debug.Assert(false);
        }
コード例 #7
0
        public ShieldCategory Create(ShieldCategory.Type type, GameObject.Name gameObjName, int index = 0, float posX = 0.0f, float posY = 0.0f)
        {
            ShieldCategory pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Root:
                pShield = new ShieldRoot(gameObjName, GameSprite.Name.NullObject, index, posX, posY);
                //pShield.SetCollisionColor(0.0f, 0.0f, 1.0f);
                //GameObjectManager.AttachTree(pShield, this.pTree);
                //pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);
                break;

            case ShieldCategory.Type.ShieldGrid:
                pShield = new ShieldGrid(gameObjName, GameSprite.Name.NullObject, index, posX, posY);
                //pShield.SetCollisionColor(1.0f, 0.0f, 0.0f);
                pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);
                break;

            case ShieldCategory.Type.ShieldColumn:
                pShield = new ShieldColumn(gameObjName, GameSprite.Name.NullObject, index, posX, posY);
                //pShield.SetCollisionColor(1.0f, 0.0f, 0.0f);
                pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);
                break;


            case ShieldCategory.Type.ShieldBrick:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrick, index, posX, posY);
                break;

            case ShieldCategory.Type.ShieldBrickLeft_Top:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrickLeft_Top, index, posX, posY);
                break;


            case ShieldCategory.Type.ShieldBrickRight_Top:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrickRight_Top, index, posX, posY);
                break;


            case ShieldCategory.Type.ShieldBrickMidLeft_Bottom:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrickMidLeft_Bottom, index, posX, posY);
                break;

            case ShieldCategory.Type.ShieldBrickMid_Bottom:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrickMid_Bottom, index, posX, posY);
                break;

            case ShieldCategory.Type.ShieldBrickMidRight_Bottom:
                pShield = new ShieldBrick(gameObjName, GameSprite.Name.ShieldBrickMidRight_Bottom, index, posX, posY);
                break;

            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }

            // add to the tree
            this.pTree.Insert(pShield, this.pParent);

            // Attached to Group
            pShield.ActivateGameSprite(this.pSpriteBatch);
            pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);

            return(pShield);
        }
コード例 #8
0
        public override void load()
        {
            Unit.level1();
            AlienFactory alienFactory = FactoryManager.getAlienFactry();
            AlienGrid    alienGrid    = (AlienGrid)alienFactory.cPCSTree.getRoot();

            alienGrid.updateDelta();
            PCSTree     pcsTree      = FactoryManager.getAlienFactry().cPCSTree;
            SpriteBatch cSpriteBatch = alienFactory.cSpriteBatch;

            for (int i = 0; i < 6; i++)
            {
                FactoryManager.getAlienFactry().setParent(alienGrid);
                Alien pColumn = (Alien)GhostManager.find(GameObject.GameObjectName.Column);
                GhostManager.remove(pColumn);

                pColumn.set(Sprite.SpriteName.NullObject, i + 1, 0, 0);
                alienFactory.activate(pColumn);
                alienFactory.setParent(pColumn);

                float x = Unit.alienPosX;
                float y = Unit.alienPosY;

                Alien alien = (Alien)GhostManager.find(GameObject.GameObjectName.Crab);
                GhostManager.remove(alien);
                alien.set(Sprite.SpriteName.Crab, i + 2, x + i * 60.0f, y);
                alienFactory.activate(alien);

                Alien alien2 = (Alien)GhostManager.find(GameObject.GameObjectName.Squid);
                GhostManager.remove(alien2);
                alien2.set(Sprite.SpriteName.Squid, i + 2, x + i * 60.0f, y - 60);
                alienFactory.activate(alien2);

                Alien alien3 = (Alien)GhostManager.find(GameObject.GameObjectName.Squid);
                GhostManager.remove(alien3);
                alien3.set(Sprite.SpriteName.Squid, i + 2, x + i * 60.0f, y - 120);
                alienFactory.activate(alien3);

                Alien alien4 = (Alien)GhostManager.find(GameObject.GameObjectName.Octopus);
                GhostManager.remove(alien4);
                alien4.set(Sprite.SpriteName.Octopus, i + 2, x + i * 60.0f, y - 180);
                alienFactory.activate(alien4);

                Alien alien5 = (Alien)GhostManager.find(GameObject.GameObjectName.Octopus);
                GhostManager.remove(alien5);
                alien5.set(Sprite.SpriteName.Octopus, i + 6, x + i * 60.0f, y - 240);
                alienFactory.activate(alien5);
            }


            ShipFactory shipFactory = FactoryManager.getShipFactry();
            ShipRoot    shipGrid    = (ShipRoot)shipFactory.cPCSTree.getRoot();

            CannonShip Ship =
                Ship = (CannonShip)GhostManager.find(GameObject.GameObjectName.CannonShip);

            GhostManager.remove(Ship);
            shipFactory.activate(Ship);
            Ship.x = Unit.shipPosX;
            Ship.y = Unit.shipPosY;

            Ship = (CannonShip)GhostManager.find(GameObject.GameObjectName.CannonShip);
            GhostManager.remove(Ship);
            shipFactory.activate(Ship);
            Ship.x = 40;
            Ship.y = 30;

            Ship = (CannonShip)GhostManager.find(GameObject.GameObjectName.CannonShip);
            GhostManager.remove(Ship);
            shipFactory.activate(Ship);
            Ship.x = 110;
            Ship.y = 30;


            //42 brics
            //7 col
            //4 bricks
            ShieldFactory shieldFactory = FactoryManager.getShieldFactry();
            ShieldGrid    shieldGrid    = (ShieldGrid)shieldFactory.cPCSTree.getRoot();

            shieldFactory.setParent(shieldGrid);
            for (int x = 0; x < 8; x = x + 2)
            {
                shieldFactory.setParent(shieldGrid);
                Shield shieldUnit = shieldFactory.createShield(Shield.ShieldType.ShieldUnit, GameObject.GameObjectName.ShieldUnit);
                shieldFactory.setParent(shieldUnit);

                Shield pColumn;
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.ShieldColumn, 0);
                shieldFactory.setParent(pColumn);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 120);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 110);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 100);

                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0);
                shieldFactory.setParent(pColumn);

                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 160);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 120);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 110);

                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0);
                shieldFactory.setParent(pColumn);

                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 170);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 160);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 120);


                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0);
                shieldFactory.setParent(pColumn);

                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 170);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 160);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 120);

                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0);
                shieldFactory.setParent(pColumn);

                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 170);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 160);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 120);

                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0);
                shieldFactory.setParent(pColumn);

                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 160);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 120);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 110);

                shieldFactory.setParent(shieldUnit);
                pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.ShieldColumn, 0);
                shieldFactory.setParent(pColumn);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 150);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 140);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 130);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 120);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 110);
                shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 100);
            }
        }
コード例 #9
0
ファイル: Visitor.cs プロジェクト: xfanw/Game
 public virtual void Visit(ShieldGrid b)
 {
 }
コード例 #10
0
        public GameObject Create(ShieldCategory.Type type, GameObject.Name gameName, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Brick:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop1, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop2:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop2, posX, posY);
                break;

            case ShieldCategory.Type.LeftBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftBottom, posX, posY);
                break;

            case ShieldCategory.Type.RightTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop1, posX, posY);
                break;

            case ShieldCategory.Type.RightTop2:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop2, posX, posY);
                break;

            case ShieldCategory.Type.RightBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightBottom, posX, posY);
                break;


            case ShieldCategory.Type.Root:
                pShield = new ShieldRoot(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(0.0f, 0.0f, 1.0f);
                Debug.Assert(false);
                break;

            case ShieldCategory.Type.Grid:
                pShield = new ShieldGrid(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(0.0f, 0.0f, 1.0f);
                break;

            case ShieldCategory.Type.Column:
                pShield = new ShieldColumn(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(1.0f, 0.0f, 0.0f);
                break;

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

            this.pTree.Add(pShield);

            pShield.ActivateGameSprite(this.pSpriteBatch);
            pShield.ActivateCollisionSprite(this.pColSpriteBatch);

            return(pShield);
        }
コード例 #11
0
ファイル: ShieldFactory.cs プロジェクト: ccaunca/Projects
        public ShieldCategory Create(ShieldType type, GameObjectName goName, float x = 0.0f, float y = 0.0f, int idx = 0)
        {
            ShieldCategory pShield = null;

            switch (type)
            {
            case ShieldType.Brick:
                pShield = new ShieldBrick(goName, SpriteBaseName.Brick, x, y, idx);
                break;

            case ShieldType.LeftTop0:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickLeftTop0, x, y, idx);
                break;

            case ShieldType.LeftTop1:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickLeftTop1, x, y, idx);
                break;

            case ShieldType.LeftBottom:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickLeftBottom, x, y, idx);
                break;

            case ShieldType.RightTop0:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickRightTop0, x, y, idx);
                break;

            case ShieldType.RightTop1:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickRightTop1, x, y, idx);
                break;

            case ShieldType.RightBottom:
                pShield = new ShieldBrick(goName, SpriteBaseName.BrickRightBottom, x, y, idx);
                break;

            case ShieldType.Root:
                pShield = new ShieldRoot(goName, SpriteBaseName.Null, x, y, idx);
                pShield.pCollisionObject.pCollisionSpriteBox.pLineColor = ColorFactory.Create(ColorName.Blue).pAzulColor;
                Debug.Assert(false);
                break;

            case ShieldType.Grid:
                pShield = new ShieldGrid(goName, SpriteBaseName.Null, x, y, idx);
                pShield.pCollisionObject.pCollisionSpriteBox.pLineColor = ColorFactory.Create(ColorName.Blue).pAzulColor;
                break;

            case ShieldType.Column:
                pShield = new ShieldColumn(goName, SpriteBaseName.Null, x, y, idx);
                pShield.pCollisionObject.pCollisionSpriteBox.pLineColor = ColorFactory.Create(ColorName.Red).pAzulColor;
                break;

            default:
                Debug.Assert(false);
                break;
            }
            this.pTree.Insert(pShield, this.pParent);
            pShield.ActivateGameSprite(this.pSpriteBatch);
            if (GameManager.GetCollisionBoxes())
            {
                pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);
            }
            return(pShield);
        }
コード例 #12
0
        public GameObject Create(ShieldCategory.Type type, GameObject.Name gameName, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Brick:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop1, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop0, posX, posY);
                break;

            case ShieldCategory.Type.LeftBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftBottom, posX, posY);
                break;

            case ShieldCategory.Type.RightTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop1, posX, posY);
                break;

            case ShieldCategory.Type.RightTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop0, posX, posY);
                break;

            case ShieldCategory.Type.RightBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightBottom, posX, posY);
                break;

            case ShieldCategory.Type.Root:
                pShield = new ShieldRoot(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.poCollisionObject.pCollisionSprite.setLineColor(1.0f, 1.0f, 1.0f);
                break;

            case ShieldCategory.Type.Grid:
                pShield = new ShieldGrid(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.poCollisionObject.pCollisionSprite.setLineColor(0.0f, 0.0f, 1.0f);
                break;

            case ShieldCategory.Type.Column:
                pShield = new ShieldColumn(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.poCollisionObject.pCollisionSprite.setLineColor(1.0f, 0.0f, 0.0f);
                break;

            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }

            // Attached to Group
            pShield.activateGameSprite(this.pSpriteBatch);
            pShield.activateCollisionSprite(this.pCollisionSpriteBatch);

            return(pShield);
        }
コード例 #13
0
 //Shields
 public virtual void visitShieldGrid(ShieldGrid s)
 {
 }
コード例 #14
0
        // strategy()
        override public void LoadContent()
        {
            AlienGroup.ResetDirection();

            TextureMan.Create(2, 1);
            ImageMan.Create(5, 2);
            GameSpriteMan.Create(4, 2);
            BoxSpriteMan.Create(3, 1);
            SpriteBatchMan.Create(3, 1);
            TimerMan.Create(3, 1);
            ProxySpriteMan.Create(10, 1);
            GameObjectMan.Create(3, 1);
            ColPairMan.Create(1, 1);
            Simulation.Create();
            GlyphMan.Create(3, 1);
            FontMan.Create(1, 1);
            //GhostSpriteBatchMan.Create(2, 1);

            //---------------------------------------------------------------------------------------------------------
            // Sound Experiment
            //---------------------------------------------------------------------------------------------------------

            // start up the engine
            sndEngine = new IrrKlang.ISoundEngine();

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

            TextureMan.Add(Texture.Name.Aliens, "newaliens.tga");
            TextureMan.Add(Texture.Name.Shields, "birds_N_shield.tga");
            Texture pTexture = TextureMan.Add(Texture.Name.Consolas20pt, "Consolas20pt.tga");

            FontMan.AddXml(Glyph.Name.Consolas20pt, "Consolas20pt.xml", Texture.Name.Consolas20pt);

            //---------------------------------------------------------------------------------------------------------
            // Load the Images
            //---------------------------------------------------------------------------------------------------------

            ImageMan.Add(Image.Name.SquidA, Texture.Name.Aliens, 547, 15, 250, 135);
            ImageMan.Add(Image.Name.CrabA, Texture.Name.Aliens, 281, 15, 250, 135);
            ImageMan.Add(Image.Name.OctopusA, Texture.Name.Aliens, 15, 15, 250, 135);

            ImageMan.Add(Image.Name.SquidB, Texture.Name.Aliens, 547, 170, 250, 135);
            ImageMan.Add(Image.Name.CrabB, Texture.Name.Aliens, 281, 170, 250, 135);
            ImageMan.Add(Image.Name.OctopusB, Texture.Name.Aliens, 15, 170, 250, 135);

            ImageMan.Add(Image.Name.MissileBombCol, Texture.Name.Aliens, 395, 480, 130, 130);
            ImageMan.Add(Image.Name.AlienDies, Texture.Name.Aliens, 550, 480, 220, 130);

            ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens, 80, 500, 230, 100);
            ImageMan.Add(Image.Name.UFODies, Texture.Name.Aliens, 15, 630, 355, 140);

            ImageMan.Add(Image.Name.Missile, Texture.Name.Aliens, 370, 795, 30, 105);
            ImageMan.Add(Image.Name.MissileBombDies, Texture.Name.Aliens, 685, 790, 110, 130);
            ImageMan.Add(Image.Name.Ship, Texture.Name.Aliens, 50, 325, 190, 125);
            ImageMan.Add(Image.Name.ShipDiesA, Texture.Name.Aliens, 280, 325, 245, 130);
            ImageMan.Add(Image.Name.ShipDiesB, Texture.Name.Aliens, 545, 325, 245, 130);

            ImageMan.Add(Image.Name.BombRoll, Texture.Name.Aliens, 445, 795, 50, 105);
            ImageMan.Add(Image.Name.BombZigZag, Texture.Name.Aliens, 560, 630, 70, 140);
            ImageMan.Add(Image.Name.BombCross, Texture.Name.Aliens, 110, 790, 50, 100);
            ImageMan.Add(Image.Name.BombFork, Texture.Name.Aliens, 520, 790, 50, 100);
            ImageMan.Add(Image.Name.BombStraight, Texture.Name.Aliens, 370, 795, 30, 105);

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

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

            GameSpriteMan.Add(GameSprite.Name.Squid, Image.Name.SquidA, 100, 600, 35, 30, 255, 255, 255, 1);
            GameSpriteMan.Add(GameSprite.Name.Crab, Image.Name.CrabA, 100, 550, 35, 30, 255, 255, 255, 1);
            GameSpriteMan.Add(GameSprite.Name.Octopus, Image.Name.OctopusA, 100, 500, 35, 30, 255, 255, 255, 1);
            GameSpriteMan.Add(GameSprite.Name.AlienDies, Image.Name.AlienDies, 0, 0, 35, 30, 255, 255, 255, 1);
            GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 100, 500, 35, 30, 255, 0, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.UFODies, Image.Name.UFODies, 0, 0, 35, 30, 255, 0, 0, 1);

            GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, 100, 200, 10, 20, 255, 255, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.MissileDies, Image.Name.MissileBombDies, 0, 0, 10, 20, 255, 255, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.MissileBombCol, Image.Name.MissileBombCol, 0, 0, 10, 20, 255, 255, 255, 1);
            GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 300, 30, 40, 20, 255, 255, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.ShipDies, Image.Name.ShipDiesA, 0, 0, 50, 25, 255, 255, 0, 1);

            GameSpriteMan.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 0, 0, 10, 20, 255, 0, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.BombRolling, Image.Name.BombRoll, 0, 0, 10, 20, 255, 0, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.BombDagger, Image.Name.BombCross, 0, 0, 10, 20, 255, 0, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 0, 0, 10, 20, 255, 0, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.BombFork, Image.Name.BombFork, 0, 0, 12, 24, 255, 0, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.BombDies, Image.Name.MissileBombDies, 0, 0, 10, 20, 255, 0, 0, 1);

            GameSpriteMan.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, 10, 5, 0, 255, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop0, Image.Name.BrickLeft_Top0, 50, 25, 10, 5, 0, 255, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, 10, 5, 0, 255, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, 10, 5, 0, 255, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightTop0, Image.Name.BrickRight_Top0, 50, 25, 10, 5, 0, 255, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, 10, 5, 0, 255, 0, 1);
            GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, 10, 5, 0, 255, 0, 1);

            SpriteBatch pSB_Aliens  = SpriteBatchMan.Add(SpriteBatch.Name.Aliens);
            SpriteBatch pSB_Box     = SpriteBatchMan.Add(SpriteBatch.Name.Boxes);
            SpriteBatch pSB_Shields = SpriteBatchMan.Add(SpriteBatch.Name.Shields);
            SpriteBatch pSB_Texts   = SpriteBatchMan.Add(SpriteBatch.Name.Texts);

            //SpriteBatch pSB_GhostAliens = GhostSpriteBatchMan.Add(SpriteBatch.Name.Aliens);
            //SpriteBatch pSB_GhostBox = GhostSpriteBatchMan.Add(SpriteBatch.Name.Boxes);
            //SpriteBatch pSB_GhostShields = GhostSpriteBatchMan.Add(SpriteBatch.Name.Shields);

            //---------------------------------------------------------------------------------------------------------
            // GameObject
            //---------------------------------------------------------------------------------------------------------

            AnimationSprite pAnimSpriteSquid   = new AnimationSprite(GameSprite.Name.Squid);
            AnimationSprite pAnimSpriteCrab    = new AnimationSprite(GameSprite.Name.Crab);
            AnimationSprite pAnimSpriteOctopus = new AnimationSprite(GameSprite.Name.Octopus);

            pAnimSpriteSquid.Attach(Image.Name.SquidB);
            pAnimSpriteSquid.Attach(Image.Name.SquidA);
            pAnimSpriteCrab.Attach(Image.Name.CrabB);
            pAnimSpriteCrab.Attach(Image.Name.CrabA);
            pAnimSpriteOctopus.Attach(Image.Name.OctopusB);
            pAnimSpriteOctopus.Attach(Image.Name.OctopusA);

            TimerMan.Add(TimerEvent.Name.SquidAnimation, pAnimSpriteSquid, pMoveRate);
            TimerMan.Add(TimerEvent.Name.CrabAnimation, pAnimSpriteCrab, pMoveRate);
            TimerMan.Add(TimerEvent.Name.OctopusAnimation, pAnimSpriteOctopus, pMoveRate);

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

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

            pWallGroup.ActivateGameSprite(pSB_Aliens);
            pWallGroup.ActivateCollisionSprite(pSB_Box);

            WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.NullObject, 336, 35, 750, 10);

            pWallBottom.ActivateCollisionSprite(pSB_Box);
            pWallGroup.Add(pWallBottom);

            WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.NullObject, 722, 384, 120, 765);

            pWallRight.ActivateCollisionSprite(pSB_Box);
            pWallGroup.Add(pWallRight);

            WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.NullObject, -45, 384, 120, 765);

            pWallLeft.ActivateCollisionSprite(pSB_Box);
            pWallGroup.Add(pWallLeft);

            WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.NullObject, 336, 685, 750, 10);

            pWallTop.ActivateCollisionSprite(pSB_Box);
            pWallGroup.Add(pWallTop);

            GameObjectMan.Attach(pWallGroup);

            //---------------------------------------------------------------------------------------------------------
            // Create Bumper
            //---------------------------------------------------------------------------------------------------------

            BumperGroup pBumperGroup = new BumperGroup(GameObject.Name.BumperGroup, GameSprite.Name.NullObject, 0.0f, 0.0f);

            pBumperGroup.ActivateGameSprite(pSB_Aliens);
            pBumperGroup.ActivateCollisionSprite(pSB_Box);

            BumperRight pBumperRight = new BumperRight(GameObject.Name.BumperRight, GameSprite.Name.NullObject, 650, 55, 15, 20);

            pBumperRight.ActivateCollisionSprite(pSB_Box);
            pBumperGroup.Add(pBumperRight);

            BumperLeft pBumperLeft = new BumperLeft(GameObject.Name.BumperLeft, GameSprite.Name.NullObject, 20, 55, 15, 20);

            pBumperLeft.ActivateCollisionSprite(pSB_Box);
            pBumperGroup.Add(pBumperLeft);

            GameObjectMan.Attach(pBumperGroup);

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

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

            pShipRoot.ActivateCollisionSprite(pSB_Box);
            GameObjectMan.Attach(pShipRoot);
            ShipMan.Create(new SndObserver(sndEngine, SndObserver.Name.ShootMissile));

            Ship pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 50, 20, null);

            pShip.ActivateCollisionSprite(pSB_Box);
            pShip.ActivateGameSprite(pSB_Aliens);
            pShipRoot.Add(pShip);

            //---------------------------------------------------------------------------------------------------------
            // Bomb
            //---------------------------------------------------------------------------------------------------------

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

            pBombRoot.ActivateCollisionSprite(pSB_Box);

            GameObjectMan.Attach(pBombRoot);

            //---------------------------------------------------------------------------------------------------------
            // Explosion
            //---------------------------------------------------------------------------------------------------------

            ExplosionFactory explosionFactory = new ExplosionFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes);
            ExplosionGroup   pExplosionGroup  = (ExplosionGroup)explosionFactory.Create(GameObject.Name.ExplosionGroup, GameSprite.Name.NullObject);

            GameObjectMan.Attach(pExplosionGroup);

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

            MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0, 0.0f, 0.0f);

            pMissileGroup.ActivateGameSprite(pSB_Aliens);
            pMissileGroup.ActivateCollisionSprite(pSB_Box);
            GameObjectMan.Attach(pMissileGroup);

            //---------------------------------------------------------------------------------------------------------
            // Create Aliens
            //---------------------------------------------------------------------------------------------------------
            AlienGroup pAlienGroup;

            if (SceneStateGame.loadGhost == false)
            {
                GameObject pGameObj;
                AlienMan.Create();

                AlienFactory alienFactory = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes);
                pAlienGroup = (AlienGroup)alienFactory.Create(GameObject.Name.AlienGroup, AlienCategory.Type.Group);

                for (int i = 0; i < 11; i++)
                {
                    float x = 100.0f + 35 * (i % 11);

                    GameObject pGameObjCol = alienFactory.Create(GameObject.Name.AlienColumn, AlienCategory.Type.Column, pAlienGroup);

                    pGameObj = alienFactory.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, pGameObjCol, x, baseY);
                    pGameObj = alienFactory.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, pGameObjCol, x, baseY - 30);
                    pGameObj = alienFactory.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, pGameObjCol, x, baseY - 30 * 2);
                    pGameObj = alienFactory.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, pGameObjCol, x, baseY - 30 * 3);
                    pGameObj = alienFactory.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, pGameObjCol, x, baseY - 30 * 4);
                }
            }
            else
            {
                GameObjectNode pGhostGameObjNode = GhostGameObjectMan.Find(GameObject.Name.AlienGroup);

                pAlienGroup = (AlienGroup)pGhostGameObjNode.pGameObj;
                ForwardIterator pFor = new ForwardIterator(pAlienGroup);

                Component pNode = pFor.First();
                while (!pFor.IsDone())
                {
                    GameObject pGameObj = (GameObject)pNode;

                    pGameObj.ActivateGameSprite(pSB_Aliens);
                    pGameObj.ActivateCollisionSprite(pSB_Box);

                    pNode = pFor.Next();
                }
                GhostGameObjectMan.Remove(pGhostGameObjNode);
            }

            GameObjectMan.Attach(pAlienGroup);

            MovementSprite pMvSprite = new MovementSprite(pAlienGroup);

            pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove4, 0.5f));
            pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove3, 0.5f));
            pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove2, 0.5f));
            pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove1, 0.5f));
            TimerMan.Add(TimerEvent.Name.AlienMovement, pMvSprite, pMoveRate);

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

            pUFORoot.ActivateCollisionSprite(pSB_Box);
            GameObjectMan.Attach(pUFORoot);
            UFOMan.Create(new SndObserver(sndEngine, SndObserver.Name.UFOFlyHigh, 0.2f, true));

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

            ShieldFactory shieldFactory = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes);
            ShieldRoot    pShieldRoot   = (ShieldRoot)shieldFactory.Create(ShieldCategory.Type.Root, GameObject.Name.NullObject);

            GameObjectMan.Attach(pShieldRoot);

            // load by column
            for (int i = 0; i < 4; i++)
            {
                int   j           = 0;
                float start_x     = 86.0f + i * 146;
                float start_y     = 100.0f;
                float off_x       = 0;
                float brickWidth  = 10.0f;
                float brickHeight = 5.0f;

                ShieldGrid pShieldGrid = (ShieldGrid)shieldFactory.Create(ShieldCategory.Type.Grid, GameObject.Name.NullObject, pShieldRoot);

                GameObject pColumn;
                pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid);

                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 2 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 3 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 4 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 5 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 6 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 7 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 8 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.LeftTop0, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 9 * brickHeight);

                pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid);

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

                pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid);

                off_x += brickWidth;
                shieldFactory.Create(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight);

                pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid);

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

                pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid);

                off_x += brickWidth;
                shieldFactory.Create(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight);

                pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid);

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

                pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid);

                off_x += brickWidth;
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 0 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 1 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight);
                shieldFactory.Create(ShieldCategory.Type.RightTop0, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight);
            }

            //---------------------------------------------------------------------------------------------------------
            // ColPair
            //---------------------------------------------------------------------------------------------------------

            // associate in a collision pair
            ColPair pColPair = ColPairMan.Add(ColPair.Name.Alien_Wall, pAlienGroup, pWallGroup);

            Debug.Assert(pColPair != null);
            pColPair.Attach(new GridObserver());
            //pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Alien_Wall));

            // Missile vs Wall
            pColPair = ColPairMan.Add(ColPair.Name.Missile_Wall, pMissileGroup, pWallGroup);
            Debug.Assert(pColPair != null);
            pColPair.Attach(new ShipReadyObserver());
            pColPair.Attach(new RemoveMissileObserver());
            pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.MissileDies, GameSprite.Name.MissileDies, pExplosionGroup, 1));


            // Bomb vs Bottom
            pColPair = ColPairMan.Add(ColPair.Name.Bomb_Wall, pBombRoot, pWallGroup);
            pColPair.Attach(new BombObserver(1));
            pColPair.Attach(new RemoveBombObserver());
            pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.BombDies, GameSprite.Name.BombDies, pExplosionGroup, 1));

            // UFO vs Wall
            pColPair = ColPairMan.Add(ColPair.Name.UFO_Wall, pUFORoot, pWallGroup);
            Debug.Assert(pColPair != null);
            pColPair.Attach(new RemoveUFOObserver());
            pColPair.Attach(new UFOReadyObserver(sndEngine));

            // Missle vs UFO
            pColPair = ColPairMan.Add(ColPair.Name.Missile_UFO, pMissileGroup, pUFORoot);
            Debug.Assert(pColPair != null);
            pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Missile_Shield));
            pColPair.Attach(new RemoveUFOObserver2());
            pColPair.Attach(new RemoveMissileObserver());
            pColPair.Attach(new UFOReadyObserver(sndEngine));
            pColPair.Attach(new ScoreObserver());
            pColPair.Attach(new ShipReadyObserver());
            pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.UFODies, GameSprite.Name.UFODies, pExplosionGroup, 2));

            // missile vs alien
            pColPair = ColPairMan.Add(ColPair.Name.Alien_Missile, pMissileGroup, pAlienGroup);
            pColPair.Attach(new ShipReadyObserver());
            pColPair.Attach(new RemoveMissileObserver());
            pColPair.Attach(new ScoreObserver());
            pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.AlienDies, GameSprite.Name.AlienDies, pExplosionGroup, 2));
            pColPair.Attach(new GridRemoveAlienObserver());
            pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Missile_Alien));
            pColPair.Attach(new AlienNumObserver(sndEngine));

            // Missile vs Shield
            pColPair = ColPairMan.Add(ColPair.Name.Misslie_Shield, pMissileGroup, pShieldRoot);
            pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Missile_Shield));
            pColPair.Attach(new RemoveMissileObserver());
            pColPair.Attach(new RemoveBrickObserver());
            pColPair.Attach(new ShipReadyObserver());
            pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.MissileDies, GameSprite.Name.MissileDies, pExplosionGroup, 1));

            // Bomb vs Shield
            pColPair = ColPairMan.Add(ColPair.Name.Bomb_Shield, pBombRoot, pShieldRoot);
            pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Bomb_Shield));
            pColPair.Attach(new BombObserver(1));
            pColPair.Attach(new RemoveBrickObserver());
            pColPair.Attach(new RemoveBombObserver());
            pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.BombDies, GameSprite.Name.BombDies, pExplosionGroup, 1));

            // Bomb vs Ship pay attention to the order
            pColPair = ColPairMan.Add(ColPair.Name.Bomb_Ship, pBombRoot, pShipRoot);
            pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Bomb_Ship));
            pColPair.Attach(new BombObserver(1));
            pColPair.Attach(new RemoveBombObserver());
            pColPair.Attach(new RemoveShipObserver());
            pColPair.Attach(new LifeObserver());
            pColPair.Attach(new AnimExplosionObserver(explosionFactory, GameObject.Name.ShipDies, GameSprite.Name.ShipDies, pExplosionGroup, 2));
            pColPair.Attach(new CreateShipObserver(sndEngine));

            // Ship vs Bumper
            pColPair = ColPairMan.Add(ColPair.Name.Ship_Bumper, pShipRoot, pBumperGroup);
            pColPair.Attach(new ShipMoveObserver());


            // Missle vs Bomb
            pColPair = ColPairMan.Add(ColPair.Name.Missile_Bomb, pMissileGroup, pBombRoot);
            Debug.Assert(pColPair != null);
            pColPair.Attach(new BombObserver(2));
            pColPair.Attach(new RemoveMissileObserver());
            pColPair.Attach(new RemoveBomb2Observer());
            pColPair.Attach(new ShipReadyObserver());
            pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.MissileBombCol, GameSprite.Name.MissileBombCol, pExplosionGroup, 1));

            //---------------------------------------------------------------------------------------------------------
            // Input
            //---------------------------------------------------------------------------------------------------------

            InputSubject pInputSubject;

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

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

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

            pInputSubject = InputMan.GetTSubject();
            pInputSubject.Attach(new ToggleObserver());

            pInputSubject = InputMan.GetRSubject();
            pInputSubject.Attach(new ToggleShieldObserver());

            Simulation.SetState(Simulation.State.Realtime);

            //---------------------------------------------------------------------------------------------------------
            // Font
            //---------------------------------------------------------------------------------------------------------
            FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "SCORE<1>", Glyph.Name.Consolas20pt, 100, 730);
            FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "HI-SCORE", Glyph.Name.Consolas20pt, 300, 730);
            FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "SCORE<2>", Glyph.Name.Consolas20pt, 500, 730);
            FontMan.Add(Font.Name.Score1, SpriteBatch.Name.Texts, score1, Glyph.Name.Consolas20pt, 100, 700);
            FontMan.Add(Font.Name.ScoreHigh, SpriteBatch.Name.Texts, scoreHigh, Glyph.Name.Consolas20pt, 300, 700);
            FontMan.Add(Font.Name.Score2, SpriteBatch.Name.Texts, score2, Glyph.Name.Consolas20pt, 500, 700);

            FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "X", Glyph.Name.Consolas20pt, 80, 17);
            FontMan.Add(Font.Name.Life, SpriteBatch.Name.Texts, GetPlayerLife(GetCurrPlayer()).ToString(), Glyph.Name.Consolas20pt, 100, 17);

            FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "Player " + currPlayer.ToString(), Glyph.Name.Consolas20pt, 480, 17);
            FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, currPlayer == 1 ? "Level " + player1Level.ToString() : "Level " + player2Level.ToString(), Glyph.Name.Consolas20pt, 570, 17);

            //---------------------------------------------------------------------------------------------------------
            // State settings
            //---------------------------------------------------------------------------------------------------------
            SceneStateGame.SetLoadGhost(false);
        }
コード例 #15
0
        public GameObject Create(ShieldCategory.Type type, GameObject.Name gameName, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pShield = null;

            switch (type)
            {
            case ShieldCategory.Type.Brick:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop1, posX, posY);
                break;

            case ShieldCategory.Type.LeftTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftTop0, posX, posY);
                break;

            case ShieldCategory.Type.LeftBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_LeftBottom, posX, posY);
                break;

            case ShieldCategory.Type.RightTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop1, posX, posY);
                break;

            case ShieldCategory.Type.RightTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightTop0, posX, posY);
                break;

            case ShieldCategory.Type.RightBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.Brick_RightBottom, posX, posY);
                break;

            case ShieldCategory.Type.Grid:
                pShield = new ShieldGrid(gameName, GameSprite.Name.NullObject, posX, posY);
                //pShield.SetCollisionColor(1.0f, 0.0f, 1.0f);
                break;

            case ShieldCategory.Type.Root:
                pShield = new ShieldRoot(gameName, GameSprite.Name.NullObject, posX, posY);
                //pShield.SetCollisionColor(1.0f, 0.0f, 1.0f);
                break;

            case ShieldCategory.Type.Column:
                pShield = new ShieldColumn(gameName, GameSprite.Name.NullObject, posX, posY);
                //pShield.SetCollisionColor(0.0f, 1.0f, 1.0f);
                break;

            default:
                Debug.WriteLine("Choose the Shield piece you want by name.");
                Debug.Assert(false);
                break;
            }

            // add to the tree
            this.pTree.Add(pShield);

            // Attached to Group
            pShield.ActivateGameSprite(this.pSpriteBatch);
            pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);

            return(pShield);
        }
コード例 #16
0
ファイル: ColVisitor.cs プロジェクト: Smybarr/space_invaders
 //-------------------------------------
 public virtual void VisitShieldGrid(ShieldGrid s)
 {
     Debug.WriteLine("Visit by ShieldGrid not implemented");
     Debug.Assert(false);
 }
コード例 #17
0
        public GameObject Create(GameObject.Name gameName, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pShield = null;

            switch (gameName)
            {
            case GameObject.Name.ShieldBrick:
                pShield = new ShieldBrick(gameName, GameSprite.Name.ShieldBrick, posX, posY);
                break;

            case GameObject.Name.ShieldBrick_LeftTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.ShieldBrick_LeftTop1, posX, posY);
                break;

            case GameObject.Name.ShieldBrick_LeftTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.ShieldBrick_LeftTop0, posX, posY);
                break;

            case GameObject.Name.ShieldBrick_LeftBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.ShieldBrick_LeftBottom, posX, posY);
                break;

            case GameObject.Name.ShieldBrick_RightTop1:
                pShield = new ShieldBrick(gameName, GameSprite.Name.ShieldBrick_RightTop1, posX, posY);
                break;

            case GameObject.Name.ShieldBrick_RightTop0:
                pShield = new ShieldBrick(gameName, GameSprite.Name.ShieldBrick_RightTop0, posX, posY);
                break;

            case GameObject.Name.ShieldBrick_RightBottom:
                pShield = new ShieldBrick(gameName, GameSprite.Name.ShieldBrick_RightBottom, posX, posY);
                break;

            case GameObject.Name.ShieldColumn:
                pShield = new ShieldColumn(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(1.0f, 0.0f, 0.0f);
                break;

            case GameObject.Name.ShieldGrid:
                pShield = new ShieldGrid(gameName, GameSprite.Name.NullObject, posX, posY);
                pShield.SetCollisionColor(0.0f, 0.0f, 1.0f);
                break;



            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }

            // add to the tree

            Debug.Assert(this.pTree != null);
            this.pTree.Add(pShield);

            // Attached to Group
            pShield.ActivateGameSprite(this.pSpriteBatch);
            pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch);

            return(pShield);
        }