Ejemplo n.º 1
0
        public void RecycleAllActive()
        {
            SpriteBatchNode current = (SpriteBatchNode)this.poActiveHead;
            SpriteBatchNode pOld;

            while (current != null)
            {
                if (current.pSprite.pGameObject != null)
                {
                    GameObjectManager.getInstance().Remove(current.pSprite.pGameObject.Wash());
                }

                if (current.pSprite.GetType() == typeof(GameSprite))
                {
                    GameSpriteManager.getInstance().Remove(current.pSprite.Wash());
                }
                else if (current.pSprite.GetType() == typeof(BoxSprite))
                {
                    BoxSpriteManager.getInstance().Remove(current.pSprite.Wash());
                }

                pOld    = current;
                current = (SpriteBatchNode)current.pNext;
                this.Remove(pOld);
            }
        }
Ejemplo n.º 2
0
        // PA2 Factory method, create node and add to the list
        public GameSprite AddGameSprite(GameObject.Category category, GameSprite.Name name, float ag, float sx, float sy, float x, float y, Image img
                                        , float posx, float posy, float w, float h)
        {
            // pull one reserved node
            GameSprite ret = (GameSprite)this.PullFromReserved();

            // Modify the field
            ret.name   = name;
            ret.pImage = img;

            // Add first image to queue
            ret.addImage(img);

            ret.poRect             = new Azul.Rect(posx, posy, w, h);
            ret.poAzulSprite       = new Azul.Sprite(img.pAzulTexture, img.poRect, ret.poRect);
            ret.poAzulSprite.angle = ag;
            ret.poAzulSprite.sx    = sx;
            ret.poAzulSprite.sy    = sy;
            ret.poAzulSprite.x     = x;
            ret.poAzulSprite.y     = y;

            // for projectile sprite, add flyproxy
            if (category == GameObject.Category.Missile || category == GameObject.Category.Bomb)
            {
                ret.pProxy = new FlyProxy(category, ret);
            }
            else if (category == GameObject.Category.UFO)
            {
                ret.pProxy = new UFOProxy(ret);
            }
            else
            {
                ret.pProxy = new MoveProxy(ret);
            }

            // Add to the active list
            this.Add(ret);

            // Create and Add GameObject to GameObjectManager
            GameObjectManager.getInstance().Add(category, ret);

            return(ret);
        }
Ejemplo n.º 3
0
        // Visitor logic
        // TODO: can be simplified using strategy
        public override void Accept(Visitor v)
        {
            if (this.category == Category.Wall)
            {
                if (this.mGameSprtName == GameSprite.Name.LeftWall)
                {
                    v.VisitLeftWall();
                }
                else if (this.mGameSprtName == GameSprite.Name.RightWall)
                {
                    v.VisitRightWall();
                }
                else
                {
                    v.VisitWall();
                }
            }
            else if (this.category == Category.Alien)
            {
                v.VisitAlien();
            }
            else if (this.category == Category.Shield)
            {
                v.VisitShield();
            }
            else if (this.category == Category.Missile)
            {
                if (ProjectileTracker.MissileFlying)
                {
                    v.VisitMissile();

                    // Reset location
                    this.pProxy.x = 0f;
                    this.pProxy.y = -10f;
                    this.pProxy.Update();
                    // Flip Missile Handle
                    ProjectileTracker.MissileHandle();
                }
            }
            else if (this.category == Category.Ship)
            {
                v.VisitShip();
            }

            // If hit by missile, start self-destruction process
            if (((GameObject)v).category == Category.Missile || (((GameObject)v).category == Category.Bomb && this.category != Category.Missile))
            {
                // Play explosion animation
                Debug.Print(this.category + " hit by" + ((GameObject)v).category);

                // If ship, trigger next round
                if (this.category == Category.Ship)
                {
                    SoundUtility.getInstance().playExplosion();
                    SpaceInvaders.currentState.Handle();
                    return;
                }

                // If Alien, incremente score
                if (this.mGameSprtName == GameSprite.Name.Octopus)
                {
                    GlobalPlayerStats.incrementScore(10);
                }
                else if (this.mGameSprtName == GameSprite.Name.Crab)
                {
                    GlobalPlayerStats.incrementScore(20);
                }
                else if (this.mGameSprtName == GameSprite.Name.Squid)
                {
                    GlobalPlayerStats.incrementScore(20);
                }

                // set itself as not collidable, if it's not wall
                if (this.category != Category.Wall)
                {
                    if (this.category == Category.Alien)
                    {
                        SoundUtility.getInstance().killed();
                        this.mGameSprite.ShowExplosion();
                    }
                    else if (this.category == Category.UFO)
                    {
                        SoundUtility.getInstance().killed();
                        ((UFOProxy)this.pProxy).reset();
                        GlobalPlayerStats.incrementScore(300);
                        return;
                    }
                    else
                    {
                        SoundUtility.getInstance().playExplosion();
                    }



                    this.collidable = false;
                    // Remove itself from active
                    GameObjectManager.getInstance().Remove(this);
                }
            }
        }