示例#1
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);
        }
示例#2
0
 //----------------------------------------------------------------------------------
 // Constructor
 //----------------------------------------------------------------------------------
 public ExplosionSpriteObserver(GameSprite.Name spriteName, float delay = 0.2f)
 {
     this.pTargetObj       = null;
     this.pExplosionSprite = null;
     this.name             = spriteName;
     this.timeDelay        = delay;
 }
 public Missile(GameObject.Name name, GameSprite.Name spriteName, float posX, float posY)
     : base(name, spriteName)
 {
     this.x     = posX;
     this.y     = posY;
     this.delta = 15.0f;
 }
示例#4
0
 //---------------------------------------------------------------------------------------------------------
 // Constructor
 //---------------------------------------------------------------------------------------------------------
 public Composite(GameObject.Name gameName, GameSprite.Name spriteName)
     : base(gameName, spriteName)
 {
     this.poHead = null;
     this.poLast = null;
     this.holder = Container.Composite;
 }
示例#5
0
 public PlayerExplosion(GameObject.Name gameObjectname, GameSprite.Name gameSpriteName, float posX, float posY)
     : base(gameObjectname, gameSpriteName)
 {
     this.x = posX;
     this.y = posY;
     this.pProxySprite.pSprite.SwapColor(1.0f, 1.0f, 1.0f);
 }
示例#6
0
        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------

        //public Composite()
        //{
        //    this.poHead = null;
        //    this.holder = Container.COMPOSITE;
        //}

        public Composite(GameObject.Name gameObjName, GameSprite.Name gameSpriteName)
            : base(gameObjName, gameSpriteName)
        {
            this.poHead = null;
            this.poTail = null;
            this.holder = Container.COMPOSITE;
        }
示例#7
0
 public RedAlien(GameObject.Name name, GameSprite.Name spriteName, float posX, float posY)
     : base(name, spriteName)
 {
     this.x       = posX;
     this.y       = posY;
     this.nPoints = 10;
 }
示例#8
0
 public AnimationSprite(GameSprite.Name spriteName)
 {
     this.pSprite = GameSpriteMan.Find(spriteName);
     Debug.Assert(this.pSprite != null);
     this.pCurrImage  = null;
     this.poHeadImage = null;
 }
示例#9
0
        public static GameSprite Create(GameObject.Category cate, GameSprite.Name name, float x, float y, Image.Name imgName)
        {
            Image img = ImageManager.getInstance().FindImageByName(imgName);

            Debug.Assert(img != null);

            float w;
            float h;

            // For missile and bomb, we don't need a square
            if (cate == GameObject.Category.Missile)
            {
                w = 2.5f;
                h = 10.0f;
            }
            else if (cate == GameObject.Category.Bomb)
            {
                w = 5f;
                h = 20f;
            }
            else if (cate == GameObject.Category.Wall)
            {
                w = 896f;
                h = 1f;
            }
            else
            {
                w = 50f;
                h = 50f;
            }


            return(pGameSpriteManager.AddGameSprite(cate, name, 0f, 1.0f, 1.0f, x, y, img, 400f, 500f, w, h));
        }
示例#10
0
 //----------------------------------------------------------------------------------
 // Constructor
 //----------------------------------------------------------------------------------
 public Missile(GameObject.Name gameObjName, GameSprite.Name spriteName, float px, float py, float delta = 12.0f)
     : base(gameObjName, spriteName, MissileCategory.Type.Missile)
 {
     this.x     = px;
     this.y     = py;
     this.delta = delta;
 }
示例#11
0
        public Bomb ActivateBomb(Random rnd)
        {
            //Random rnd = new Random();
            int number = rnd.Next(0, 3);

            GameSprite.Name name = GameSprite.Name.BombStraight + number;


            Bomb pBomb = null;

            switch (name)
            {
            case GameSprite.Name.BombStraight:
                pBomb = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombStraight, new FallStraight(), this.x, this.y - (float)0.5 * this.poColObj.poColRect.height);
                break;

            case GameSprite.Name.BombDagger:
                pBomb = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombDagger, new FallDagger(), this.x, this.y - (float)0.5 * this.poColObj.poColRect.height);
                break;

            case GameSprite.Name.BombZigZag:
                pBomb = new Bomb(GameObject.Name.Bomb, GameSprite.Name.BombZigZag, new FallZigZag(), this.x, this.y - (float)0.5 * this.poColObj.poColRect.height);
                break;

            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }
            this.bomb = pBomb;

            return(pBomb);
        }
示例#12
0
 public LeftUFO(GameObject.Name name, GameSprite.Name spriteName, float posX, float posY)
     : base(name, spriteName)
 {
     this.x     = posX;
     this.y     = posY;
     this.delta = -2.0f;
 }
示例#13
0
 //--------------------------------------------------------------------------------------------
 // Constructor
 //--------------------------------------------------------------------------------------------
 public Composite(GameObject.Name gameObjectName, GameSprite.Name gameSpriteName)
     : base(gameObjectName, gameSpriteName)
 {
     this.poHead = null;
     this.poLast = null;
     this.type   = Component.Container.COMPOSITE;
 }
示例#14
0
 public Missile(GameSprite.Name spriteName, GameObject.Name name, float posX, float posY) : base(spriteName, name)
 {
     this.x    = posX;
     this.y    = posY;
     this.orgY = posY;
     this.bHit = false;
 }
示例#15
0
文件: Missile.cs 项目: wangjo22/Final
 public Missile(GameObject.Name gameObjectname, GameSprite.Name gameSpriteName, float posX, float posY)
     : base(gameObjectname, gameSpriteName)
 {
     this.x        = posX;
     this.y        = posY;
     this.isFlying = false;
 }
示例#16
0
 public UFO(GameObject.Name gOName, GameSprite.Name gSeName, float x, float y, SndObserver pSndObs)
     : base(gOName, gSeName, UFOCategory.Type.UFO)
 {
     this.SetXY(x, y);
     this.pSnd  = pSndObs;
     this.state = new UFOStateEnd();
 }
示例#17
0
        //---------------------------------------------------------------------------------------------------------
        // Methods
        //---------------------------------------------------------------------------------------------------------
        public void Set(GameSprite.Name name, Image pImage, float x, float y, float width, float height, Azul.Color pColor)
        {
            Debug.Assert(pImage != null);
            Debug.Assert(this.poScreenRect != null);
            Debug.Assert(this.poAzulSprite != null);

            this.poScreenRect.Set(x, y, width, height);
            this.pImage = pImage;
            this.name   = name;

            if (pColor == null)
            {
                Debug.Assert(GameSprite.psTmpColor != null);
                GameSprite.psTmpColor.Set(1, 1, 1);

                this.poAzulColor.Set(psTmpColor);
            }
            else
            {
                this.poAzulColor.Set(pColor);
            }

            this.poAzulSprite.Swap(pImage.GetAzulTexture(), pImage.GetAzulRect(), this.poScreenRect, this.poAzulColor);

            this.x     = poAzulSprite.x;
            this.y     = poAzulSprite.y;
            this.sx    = poAzulSprite.sx;
            this.sy    = poAzulSprite.sy;
            this.angle = poAzulSprite.angle;
        }
示例#18
0
 protected AlienCategory(GameObject.Name gameObjectName, GameSprite.Name gameSpriteName, int _Index, float _ori_X, float _ori_Y)
     : base(gameObjectName, gameSpriteName)
 {
     this.index   = _Index;
     this.originX = _ori_X;
     this.originY = _ori_Y;
 }
示例#19
0
        //----------------------------------------------------------------------------------
        // Data
        //----------------------------------------------------------------------------------


        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------
        public WallGroup(GameObject.Name gameName, GameSprite.Name spriteName, float px, float py)
            : base(gameName, spriteName)
        {
            this.x = px;
            this.y = py;
            this.poCollObj.pCollSprite.SetLineColor(1.0f, 1.0f, 1.0f);
        }
示例#20
0
 public ShieldBrick(GameObject.Name gameObjectname, GameSprite.Name gameSpriteName, int _Index, float posX, float posY)
     : base(gameObjectname, gameSpriteName)
 {
     this.x     = posX;
     this.y     = posY;
     this.index = _Index;
 }
示例#21
0
 public BombGroup(GameObject.Name gameObjectname, GameSprite.Name gameSpriteName, float posX, float posY)
     : base(gameObjectname, gameSpriteName)
 {
     this.x = posX;
     this.y = posY;
     this.pColObject.pBoxSprite.SetColor(0.0f, 1.0f, 0.0f);
 }
示例#22
0
文件: Player.cs 项目: wangjo22/Final
 public Player(GameObject.Name gameObjectname, GameSprite.Name gameSpriteName, float posX, float posY)
     : base(gameObjectname, gameSpriteName)
 {
     this.x = posX;
     this.y = posY;
     this.pProxySprite.pSprite.SwapColor(0.7f, 0.0f, 0.3f);
 }
示例#23
0
 public GreenBird(GameSprite.Name spriteName, GameObject.Name name, float posX, float posY)
     : base(spriteName, name)
 {
     this.x     = posX;
     this.y     = posY;
     this.speed = 1.0f;
 }
示例#24
0
        public SpriteNode Attach(GameSprite.Name name)
        {
            SpriteNode spriteNode = (SpriteNode)baseAdd();

            spriteNode.Initialize(name);
            return(spriteNode);
        }
示例#25
0
        public void Set(GameSprite.Name myName, Image pImage, float mx, float my, float w, float h, Azul.Color pColor)
        {
            Debug.Assert(pImage != null);
            Debug.Assert(this.poAzulColor != null);
            Debug.Assert(this.poAzulSprite != null);

            this.name   = myName;
            this.pImage = pImage;
            this.poScreenRect.Set(mx, my, w, h);


            if (pColor == null)
            {
                Debug.Assert(psTempColor != null);
                GameSprite.psTempColor.Set(1, 1, 1);
                this.poAzulColor.Set(psTempColor);
            }
            else
            {
                this.poAzulColor.Set(pColor);
            }

            Debug.Assert(this.poAzulSprite != null);
            this.poAzulSprite.Swap(pImage.GetAzulTexture(), pImage.GetAzulRect(), this.poScreenRect, this.poAzulColor);

            //grab data from the Azul Sprite, then update/sync
            this.x     = poAzulSprite.x;
            this.y     = poAzulSprite.y;
            this.sx    = poAzulSprite.sx;
            this.sy    = poAzulSprite.sy;
            this.angle = poAzulSprite.angle;
        }
示例#26
0
 public ExplosionGroup(GameObject.Name gameObjectname, GameSprite.Name gameSpriteName, float posX, float posY)
     : base(gameObjectname, gameSpriteName)
 {
     this.x = posX;
     this.y = posY;
     this.pColObject.pBoxSprite.SetColor(0, 1, 0);
 }
示例#27
0
 public ExplosionSpriteObserver(ExplosionSpriteObserver pObserver)
 {
     this.pTargetObj       = pObserver.pTargetObj;
     this.pExplosionSprite = pObserver.pExplosionSprite;
     this.name             = pObserver.name;
     this.timeDelay        = pObserver.timeDelay;
 }
示例#28
0
        //----------------------------------------------------------------------------------
        // Data
        //----------------------------------------------------------------------------------


        //----------------------------------------------------------------------------------
        // Constructor
        //----------------------------------------------------------------------------------
        public ShieldGrid(GameObject.Name name, GameSprite.Name spriteName, float posX, float posY)
            : base(name, spriteName)
        {
            this.x = posX;
            this.y = posY;
            this.poCollObj.pCollSprite.SetLineColor(1.0f, 0.0f, 1.0f);
        }
示例#29
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);
        }
示例#30
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);
        }