예제 #1
0
        override public void Execute(float deltaTime)
        {
            int pFreq = pRandom.Next(1, 10) / this.nCurrLevel;

            AlienGrid     pGrid  = (AlienGrid)GameObjectMan.Find(GameObject.Name.AlienGrid);
            AlienCategory pAlien = pGrid.GetRandomAlien();

            // HACK don't crash pleease
            if (pAlien == null)
            {
                TimerMan.Add(TimeEvent.Name.BombSpawn, this, pFreq);
                return;
            }

            int          type          = pRandom.Next(0, 2);
            FallStrategy pFallStrategy = null;

            switch (type)
            {
            case (0):
                pFallStrategy = new FallZigZag();
                break;

            case (1):
                pFallStrategy = new FallDagger();
                break;

            case (2):
                pFallStrategy = new FallStraight();
                break;
            }
            type = pRandom.Next(0, 2);
            GameSprite.Name pGameSpriteName = GameSprite.Name.Uninitialized;
            switch (type)
            {
            case (0):
                pGameSpriteName = GameSprite.Name.BombZigZag;
                break;

            case (1):
                pGameSpriteName = GameSprite.Name.BombDagger;
                break;

            case (2):
                pGameSpriteName = GameSprite.Name.BombStraight;
                break;
            }

            Bomb pBomb = new Bomb(GameObject.Name.Bomb, pGameSpriteName, pFallStrategy, pAlien.x, pAlien.y);

            pBomb.ActivateCollisionSprite(this.pSB_Boxes);
            pBomb.ActivateGameSprite(this.pSB_Bombs);

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

            Debug.Assert(pBombRoot != null);

            pBombRoot.Add(pBomb);
            TimerMan.Add(TimeEvent.Name.BombSpawn, this, pFreq);
        }
예제 #2
0
        private FallStrategy chooseFallStrategy(GameSprite.Name spriteName)
        {
            FallStrategy pFallStrategy = null;

            switch (spriteName)
            {
            case GameSprite.Name.BombDagger:
                pFallStrategy = new FallDagger();
                break;

            case GameSprite.Name.BombStraight:
                pFallStrategy = new FallStraight();
                break;

            case GameSprite.Name.BombZigZag:
                pFallStrategy = new FallZigZag();
                break;

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

            return(pFallStrategy);
        }
예제 #3
0
        private void SpawnBomb()
        {
            int    random  = this.pGrid.pRandom.Next(0, pGrid.colCount);
            Column pColumn = pGrid.GetColumn(random);

            //Debug.WriteLine("Firing from Column{0}", random);
            if (pColumn != null)
            {
                PCSTree        pTree  = GameObjectManager.GetRootTree();
                SpriteBaseName sName  = SpriteBaseName.Null;
                FallStrategy   pStrat = null;
                switch (pGrid.pRandom.Next(0, 3))
                {
                case 0:
                    sName  = SpriteBaseName.BombStraight;
                    pStrat = new FallStraight();
                    break;

                case 1:
                    sName  = SpriteBaseName.BombDagger;
                    pStrat = new FallDagger();
                    break;

                case 2:
                default:
                    sName  = SpriteBaseName.BombZigZag;
                    pStrat = new FallZigZag();
                    break;
                }
                Bomb pBomb = new Bomb(GameObjectName.Bomb, sName, pStrat, pColumn.x, pColumn.pCollisionObject.pCollisionRect.minY, 0);
                pBomb.ActivateCollisionSprite(this.sbBoxes);
                pBomb.ActivateGameSprite(this.sbAliens);
                pTree.Insert(pBomb, this.pBombRoot);
            }
        }
예제 #4
0
        public static Bomb ActiveBomb()
        {
            //ensure call Create() first
            BombMan pMan = BombMan.GetInstance();

            Debug.Assert(pMan != null);

            GameSprite.Name spriteName    = GameSprite.Name.BombDagger + pMan.randNum.Next(3);
            FallStrategy    pFallStrategy = pMan.chooseFallStrategy(spriteName);

            Debug.Assert(pFallStrategy != null);

            // create Bomb
            Bomb pBomb = new Bomb(GameObject.Name.Bomb, spriteName, pFallStrategy, 100, 100);

            // activate collision sprite and game sprite
            pBomb.activateGameSprite(SpriteBatchMan.Find(SpriteBatch.Name.Bombs));
            pBomb.activateCollisionSprite(SpriteBatchMan.Find(SpriteBatch.Name.Boxes));

            //attach Bomb to BombGroup
            GameObject pBombGroup = GameObjectMan.Find(GameObject.Name.BombGroup);

            Debug.Assert(pBombGroup != null);

            // add to GameObject
            pBombGroup.add(pBomb);

            return(pBomb);
        }
예제 #5
0
파일: BombLeaf.cs 프로젝트: xfanw/Game
 public BombLeaf(GameSpriteName spname, FallStrategy strategy, float x, float y, int lx, int ly)
 {
     proxySprite  = new ProxySprite(spname, x, y);
     CollisionObj = new CollisionObject(proxySprite);
     PlayBatchMan.Find(BatchName.Box).Add(CollisionObj.Box);
     this.x    = x;
     this.y    = y;
     _Strategy = strategy;
     _Strategy.Reset(this.y);
 }
예제 #6
0
파일: Bomb.cs 프로젝트: ccaunca/Projects
 public Bomb(GameObjectName goName, SpriteBaseName sName, FallStrategy strat, float x, float y, int idx)
     : base(goName, sName, BombType.Bomb, idx)
 {
     this.x     = x;
     this.y     = y;
     this.speed = 5.0f;
     Debug.Assert(strat != null);
     this.fallStrategy = strat;
     this.fallStrategy.Reset(this.y);
     this.pCollisionObject.pCollisionSpriteBox.pLineColor = ColorFactory.Create(ColorName.Orange).pAzulColor;
 }
예제 #7
0
        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------
        public Bomb(GameObject.Name name, GameSprite.Name spriteName, FallStrategy strategy, float posX, float posY)
            : base(name, spriteName, BombCategory.Type.Bomb)
        {
            this.x     = posX;
            this.y     = posY;
            this.delta = 1.5f;

            Debug.Assert(strategy != null);
            this.pStrategy = strategy;

            this.pStrategy.Reset(posY);
            this.poCollObj.pCollSprite.SetLineColor(1.0f, 1.0f, 0.0f);
        }
예제 #8
0
        public Bomb(GameObject.Name name, Sprite.Name spriteName, FallStrategy strategy, float posX, float posY)
            : base(name, spriteName)
        {
            this.x     = posX;
            this.y     = posY;
            this.delta = 4.0f;

            Debug.Assert(strategy != null);
            this.pStrategy = strategy;

            this.pStrategy.Reset(this.y);

            this.SetCollisionObjectLineColor(1, 1, 0);
        }
예제 #9
0
        //---------------------------------------------------------------------------------------------------------
        // Constructor
        //---------------------------------------------------------------------------------------------------------
        public Bomb(GameObject.Name name, GameSprite.Name spriteName, FallStrategy strategy, float posX, float posY)
            : base(name, spriteName, BombCategory.Type.Bomb)
        {
            this.x     = posX;
            this.y     = posY;
            this.delta = 5.0f;

            Debug.Assert(strategy != null);
            this.pStrategy = strategy;

            this.pStrategy.reset(this.y);

            this.poCollisionObject.pCollisionSprite.setLineColor(1, 1, 0);
        }
예제 #10
0
        public Bomb(GameObject.Name name, GameSprite.Name spriteName, FallStrategy strategy, float posX, float posY, GameObject pGameObj)
            : base(name, spriteName, BombCategory.Type.Bomb)
        {
            this.x      = posX;
            this.y      = posY;
            this.delta  = 4.0f;
            this.enable = false;

            Debug.Assert(strategy != null);
            this.pStrategy = strategy;

            this.pStrategy.Reset(this.y);

            this.poColObj.pColSprite.SetLineColor(1, 1, 0);
            this.owned = pGameObj;
        }
예제 #11
0
        public Bomb(GameObject.Name name, GameSprite.Name spriteName, FallStrategy strategy, GameObject owner, float posX, float posY)
            : base(name, spriteName, BombCategory.Type.Bomb)
        {
            this.x         = posX;
            this.y         = posY;
            this.deltaMove = 4.0f;

            Debug.Assert(strategy != null);
            this.pStrategy = strategy;

            this.pOwner = owner;

            this.pStrategy.Reset(this.y);

            this.GetColObject().pColSprite.SetLineColor(1, 1, 0);
        }
예제 #12
0
        public Bomb(AlienColumn pOwner)
            : base(GameObject.Name.Bomb, GameSprite.Name.NullObject)
        {
            this.x     = pOwner.x;
            this.y     = pOwner.GetBottom();
            this.delta = 0.0f;

            this.pOwner = pOwner;

            this.pDaggers  = new FallDagger();
            this.pZigZag   = new FallZigZag();
            this.pStraight = new FallStraight();
            this.pStrategy = null;

            this.poColObj.pColSprite.SetLineColor(1, 1, 0);
        }
예제 #13
0
        public override void Execute(float deltaTime)
        {
            Composite pFlyingSaucerRoot = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.FlyingSaucerRoot);

            // If Flying Saucer is on screen
            if (pFlyingSaucerRoot.GetFirstChild() != null)
            {
                Composite pBombRoot = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.BombRoot);

                // Identify random Column + starting location
                int          randomColIndex = r.Next(0, pFlyingSaucerRoot.GetNumOfChildren());
                FlyingSaucer pFlyingSaucer  = (FlyingSaucer)pFlyingSaucerRoot.GetFirstChild();
                Azul.Rect    pFlyingSaucerColCollisionRect = pFlyingSaucer.GetCollisionObject().GetCollisionRect();

                float xPos = (pFlyingSaucerColCollisionRect.x + (pFlyingSaucerColCollisionRect.width / 2.0f));
                float yPos = (pFlyingSaucerColCollisionRect.y - (pFlyingSaucerColCollisionRect.height / 2.0f));

                // Identify random Bomb Type and create bomb
                FallStrategy bombStrategy = null;
                int          bombType     = r.Next(0, 3);

                if (bombType == 0)
                {
                    bombType     = (int)Sprite.Name.BombStraight;
                    bombStrategy = new FallStraight();
                }
                else if (bombType == 1)
                {
                    bombType     = (int)Sprite.Name.BombZigZag;
                    bombStrategy = new FallZigZag();
                }
                else
                {
                    bombType     = (int)Sprite.Name.BombCross;
                    bombStrategy = new FallDagger();
                }

                // TODO refactor to use Object Pool
                FlyingSaucerBomb pBomb = new FlyingSaucerBomb(GameObject.Name.FlyingSaucerBomb, (Sprite.Name)bombType, bombStrategy, xPos, yPos);

                // Attach to BombRoot, SpriteBatches, and any related managers
                GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.BombRoot).Add(pBomb);
                GameStateManager.GetGame().GetStateGameObjectManager().Attach(pBomb);
                pBomb.ActivateCollisionSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox));
                pBomb.ActivateSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.Bomb));
            }
        }
예제 #14
0
 public FlyingSaucerBomb(GameObject.Name name, Sprite.Name spriteName, FallStrategy strategy, float posX, float posY)
     : base(name, spriteName, strategy, posX, posY)
 {
     // Do nothing at this layer
 }
예제 #15
0
 public void SetStrategy(FallStrategy pStrategy)
 {
     Debug.Assert(pStrategy != null);
     this.pFallStrategy = pStrategy;
 }