Example #1
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));
        }
Example #2
0
        // Factory method for creating composite type
        public static GameSprite CreateCompositeSprite(GameObject.Category cate, GameObject.CompositeType cType, float x, float y, Image.Name imgName)
        {
            Image img = ImageManager.getInstance().FindImageByName(imgName);

            Debug.Assert(img != null);

            GameSprite ret = pGameSpriteManager.AddGameSprite(cate
                                                              , GameSprite.Name.NullObject, 0f, 1.0f, 1.0f, x, y, img, 400f, 700f, 1f, 1f);

            // give it the composite type specified
            ret.pGameObject.compositeType = cType;
            ret.pGameObject.collidable    = false;
            ret.pGameObject.isComposite   = true;

            // show red box for grid
            if (cType == GameObject.CompositeType.Grid)
            {
                ret.pGameObject.colliRect.setColor(0, 255, 0);
            }
            // show green box for column
            else if (cType == GameObject.CompositeType.Column)
            {
                ret.pGameObject.colliRect.setColor(255, 0, 0);
            }

            return(ret);
        }
Example #3
0
 public FlyProxy(GameObject.Category cat, GameSprite s)
 {
     if (cat == GameObject.Category.Missile)
     {
         this.direction = 1f; // upward
     }
     else if (cat == GameObject.Category.Bomb)
     {
         this.direction = -1f; // downward
     }
     else
     {
         this.direction = 0f; // howard
     }
     this.category = Proxy.Category.FlyProxy;
     this.pSprite  = s;
 }
Example #4
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);
        }
Example #5
0
        // Factory method, create and add GameObject into actives
        public GameObject Add(GameObject.Category cate, GameSprite gSprite)
        {
            // Create a new image
            GameObject ret = (GameObject)this.PullFromReserved();

            ret.category         = cate;
            ret.pProxy           = gSprite.pProxy;
            ret.mGameSprtName    = gSprite.name;
            ret.mGameSprite      = gSprite;
            ret.colliRect        = new CollisionRect(gSprite.poRect);
            ret.colliRect.width  = gSprite.poRect.width;
            ret.colliRect.height = gSprite.poRect.height;

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

            // add this to gSprite's object reference
            gSprite.pGameObject = ret;

            return(ret);
        }
Example #6
0
        public static GameSprite CreateGameSprite(GameObject.Category cate, GameSprite.Name name, SpriteBatch.Name sbName
                                                  , float x, float y, float w, float h, Image.Name imgName)
        {
            Image img = ImageManager.getInstance().FindImageByName(imgName);

            Debug.Assert(img != null);

            GameSprite ret = pGameSpriteManager.AddGameSprite(cate, name, 0f, 1.0f, 1.0f, x, y, img, 400f, 500f, w, h);

            // Add to sprite batch
            SpriteBatch sb = SpriteBatchManager.getInstance().FindSpriteBatchByName(sbName);

            Debug.Assert(sb != null);
            sb.AddSprite(ret);
            // When Show collision box toggled on, add collision box to the batch as well
            if (GlobalConfiguration.showCollisionRect == true)
            {
                sb.AddSprite(ret.pGameObject.colliRect.box);
            }

            return(ret);
        }
Example #7
0
 public GameObject(GameObject.Category cate, GameSprite s)
 {
     this.pProxy        = s.pProxy;
     this.mGameSprtName = s.name;
     this.mGameSprite   = s;
 }