コード例 #1
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);
        }
コード例 #2
0
ファイル: BombMan.cs プロジェクト: xfanw/Game
 private static BombMan GetInstance()
 {
     if (_BombMan == null)
     {
         _BombMan = new BombMan();
     }
     return(_BombMan);
 }
コード例 #3
0
        public override void dropBomb(AlienCategory pAlien)
        {
            Bomb pBomb = BombMan.ActiveBomb();

            pBomb.setPos(pAlien.x + 5, pAlien.y - 40);
            pBomb.setShooter(pAlien);

            // switch states
            this.handle(pAlien);
        }
コード例 #4
0
        //---------------------------------------------------------
        // Static methods
        //---------------------------------------------------------
        public static void Create()
        {
            Debug.Assert(pInstance == null);

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

            Debug.Assert(pInstance != null);
        }
コード例 #5
0
        public void Shoot()
        {
            AliensCol shootingCol = (AliensCol)Iterator.GetChild(this);
            int       size        = children.Size();
            int       col         = Rand.GetNext(1, size);

            if (Iterator.GetSibling(shootingCol) != null)
            {
                for (int i = 0; i < col; i++)
                {
                    shootingCol = (AliensCol)Iterator.GetSibling(shootingCol);
                }
                BombMan.InitializeBomb(shootingCol.x, shootingCol.y - shootingCol.CollisionObj.Rect.height / 2 - 10);
            }
        }
コード例 #6
0
ファイル: BombMan.cs プロジェクト: xfanw/Game
 public static void Initialize()
 {
     _BombMan = GetInstance();
 }
コード例 #7
0
ファイル: UFO.cs プロジェクト: AlfredYan/Space_Invaders
        public void dropBomb()
        {
            Bomb pBomb = BombMan.ActiveBomb();

            pBomb.setPos(this.x + 5, this.y - 40);
        }
コード例 #8
0
        //-------------------------------------------------------------------------------
        // Methods
        //-------------------------------------------------------------------------------
        public void create(Manager.Name managerName, int reserveNum = 3, int growNum = 1)
        {
            switch (managerName)
            {
            case Manager.Name.TextureMan:
                TextureMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.ImageMan:
                ImageMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.GameSpriteMan:
                GameSpriteMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.BoxSpriteMan:
                BoxSpriteMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.SpriteBatchMan:
                SpriteBatchMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.TimerMan:
                TimerMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.ProxySpriteMan:
                ProxySpriteMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.GameObjectMan:
                GameObjectMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.CollisionPairMan:
                CollisionPairMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.GlyphMan:
                GlyphMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.FontMan:
                FontMan.Create(reserveNum, growNum);
                break;

            case Manager.Name.ShipMan:
                ShipMan.Create();
                break;

            case Manager.Name.BombMan:
                BombMan.Create();
                break;

            case Manager.Name.SoundMan:
                SoundMan.Create();
                break;

            case Manager.Name.AlienMan:
                AlienMan.Create();
                break;

            case Manager.Name.UFOMan:
                UFOMan.Create();
                break;

            case Manager.Name.SceneMan:
                SceneMan.Create();
                break;

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