Exemplo n.º 1
0
        public static void InitializeBomb(float x, float y)
        {
            // get Bomb Group
            BombCol BCol = (BombCol)GameObjectMan.Find(0, 10).GameObj;

            // if bullet is in the object pool
            if (BCol.Reservedchildren.GetHead() != null)
            {
                _BombMan.Bomb = (BombLeaf)BCol.Reservedchildren.GetHead();
                BCol.Reservedchildren.Remove(_BombMan.Bomb);
                UpdateBombPos(x, y);
                _BombMan.Bomb.ResetStrategy();
                // next line is necessary
                PlayBatchMan.Find(BatchName.Box).Add(GetBomb().CollisionObj.Box);
                PlayBatchMan.Find(BatchName.Box).Add(BCol.CollisionObj.Box);
            }
            else    // if bullet is not in the object pool. create new Bullet Obj
            {
                GetRandomBomb();
                UpdateBombPos(x, y);
            }


            BCol.Add(GetBomb());
        }
Exemplo n.º 2
0
        public static void KillAll()
        {
            DLinkedNode Child = GetGrid().GetFirstChild();

            while (Child != null)
            {
                // Kill all Child
                DLinkedNode NextChild = Child.Next;

                // Kill all grand Child
                DLinkedNode GrandChild = ((AliensCol)Child).GetFirstChild();
                while (GrandChild != null)
                {
                    DLinkedNode NextGrandChild = GrandChild.Next;
                    AlienLeaf   tempGrandChild = ((AlienLeaf)GrandChild);
                    ((AliensCol)Child).Remove(tempGrandChild);

                    // Remove ProxySprite add Box Obj
                    PlayBatchMan.Find(BatchName.Aliens).Remove(((AlienLeaf)GrandChild).GetProxy());
                    PlayBatchMan.Find(BatchName.Box).Remove(((AlienLeaf)GrandChild).CollisionObj.Box);
                    GrandChild = NextGrandChild;
                }

                GetGrid().Remove((AliensCol)Child);
                // Remove Box Obj
                PlayBatchMan.Find(BatchName.Box).Remove(((AliensCol)Child).CollisionObj.Box);
                Child = NextChild;
            }
        }
Exemplo n.º 3
0
        public static void InitializeGrid()
        {
            // get Alien Grid From ReservedChildren Group
            AliensGrid Grid = (AliensGrid)GameObjectMan.Find(0, 0).GameObj;

            //if Grid has Child in the object pool
            DLinkedNode Col = Grid.Reservedchildren.GetHead();

            if (Col != null)
            {
                ResetGrid(Grid);

                // Update xs and ys of the whole grid
                UpdateGridPos(60, 530 - 30 * Nums.Level);

                // next line is necessary
                PlayBatchMan.Find(BatchName.Box).Add(GetGrid().CollisionObj.Box);
            }
            else
            {   // if Aliens Grid is not in the object pool. create new Grid Obj
                for (int j = 1; j <= 11; j++)
                {
                    Composite col = AlienObjectFactory.CreatComposite(j);
                    Grid.Add(col);
                }
            }
            _AlienGridMan._AlienGrid = Grid;
        }
Exemplo n.º 4
0
 private static PlayBatchMan GetInstance(int t = 4, int d = 1)
 {
     if (_batchManager == null)
     {
         _batchManager = new PlayBatchMan(t, d);
     }
     return(_batchManager);
 }
Exemplo n.º 5
0
 public ShipCol(int lx, int ly)
 {
     CollisionObj = new CollisionObject();
     CollisionObj.Box.SetColor(1, 1, 0, 1);
     PlayBatchMan.Find(BatchName.Box).Add(CollisionObj.Box);
     locationX = lx;
     locationY = ly;
 }
Exemplo n.º 6
0
 public WallLeaf(int x, int y, int w, int h, int lx, int ly)
 {
     CollisionObj = new CollisionObject();
     CollisionObj.UpdateCollisionObject(new CollisionRect(new Azul.Rect(x, y, w, h)));
     CollisionObj.Box.SetColor(1, 1, 1, 1);
     PlayBatchMan.Find(BatchName.Box).Add(CollisionObj.Box);
     locationX = lx;
     locationY = ly;
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 public ShipBulletLeaf(GameSpriteName spname, 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;
     locationX = lx;
     locationY = ly;
 }
Exemplo n.º 9
0
        public ShieldBrick(GameSpriteName spname, 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);

            // set obj Green
            proxySprite.GetSprite().SetColor(0, 1, 0);
            this.x    = x;
            this.y    = y;
            locationX = lx;
            locationY = ly;
        }
Exemplo n.º 10
0
        public static void KillAll()
        {
            BombCol     BCol  = (BombCol)GameObjectMan.Find(0, 10).GameObj;
            DLinkedNode Child = BCol.GetFirstChild();

            while (Child != null)
            {
                // Kill all Child
                DLinkedNode NextChild = Child.Next;

                BCol.Remove((BombLeaf)Child);
                // Remove Box Obj
                PlayBatchMan.Find(BatchName.Box).Remove(((BombLeaf)Child).CollisionObj.Box);
                PlayBatchMan.Find(BatchName.Bombs).Remove(((BombLeaf)Child).GetProxy());
                Child = NextChild;
            }
        }
Exemplo n.º 11
0
Arquivo: UFOMan.cs Projeto: xfanw/Game
        public static void InitialUFO()
        {
            UFOCol UCol = (UFOCol)GameObjectMan.Find(50, 50).GameObj;

            if (UCol.Reservedchildren.GetHead() != null)
            {
                _UFOMan.UFO = (UFOLeaf)UCol.Reservedchildren.GetHead();
                UCol.Reservedchildren.Remove(GetUFO());
                UpdateUFOPos();
                PlayBatchMan.Find(BatchName.Box).Add(GetUFO().CollisionObj.Box);
                PlayBatchMan.Find(BatchName.Box).Add(UCol.CollisionObj.Box);
            }
            else
            {
                _UFOMan.UFO = new UFOLeaf(GameSpriteName.UFO, 400, 200, 50, 6);
                UpdateUFOPos();
            }
            UCol.Add(_UFOMan.UFO);
        }
Exemplo n.º 12
0
        private static void UpdateGridPos(float x, float y)
        {
            for (DLinkedNode Child = (AliensCol)GetGrid().GetFirstChild(); Child != null; Child = Child.Next)
            {
                // Alien Col do not have to update position, Since they will be updated By GameObjMan.Update()
                // Only add Box Obj to Box batch
                PlayBatchMan.Find(BatchName.Box).Add(((AliensCol)Child).CollisionObj.Box);

                // Alien leaf can be updated by their relative location
                for (DLinkedNode GrandChild = ((AliensCol)Child).GetFirstChild(); GrandChild != null; GrandChild = GrandChild.Next)
                {
                    AlienLeaf tempGrandChild = ((AlienLeaf)GrandChild);
                    tempGrandChild.x = x + 40 * tempGrandChild.locationX;
                    tempGrandChild.y = y - 30 * tempGrandChild.locationY;

                    tempGrandChild.CollisionObj.UpdatePos(tempGrandChild.x, tempGrandChild.y);

                    // Update ProxySprite add Box Obj to  batch
                    PlayBatchMan.Find(BatchName.Aliens).Add(((AlienLeaf)GrandChild).GetProxy());
                    PlayBatchMan.Find(BatchName.Box).Add(((AlienLeaf)GrandChild).CollisionObj.Box);
                }
            }
        }
Exemplo n.º 13
0
        public static void InitializeBullet()
        {
            // get Bullet Group
            ShipBulletCol BulletCol = (ShipBulletCol)GameObjectMan.Find(200, 100).GameObj;

            // if bullet is in the object pool
            if (BulletCol.Reservedchildren.GetHead() != null)
            {
                _ShipMan.BulletLeaf = (ShipBulletLeaf)BulletCol.Reservedchildren.GetHead();
                BulletCol.Reservedchildren.Remove(_ShipMan.BulletLeaf);
                UpdateBulletPos();
                // next line is necessary
                PlayBatchMan.Find(BatchName.Box).Add(GetShipBulletLeaf().CollisionObj.Box);
                PlayBatchMan.Find(BatchName.Box).Add(BulletCol.CollisionObj.Box);
            }
            else    // if bullet is not in the object pool. create new Bullet Obj
            {
                _ShipMan.BulletLeaf = new ShipBulletLeaf(GameSpriteName.ShipBullet, 400, 100, 200, 101);
                UpdateBulletPos();
            }

            BulletCol.Add(GetShipBulletLeaf());
        }
Exemplo n.º 14
0
        public static void InitializeShip()
        {
            // get Ship Group
            ShipCol ShipC = (ShipCol)GameObjectMan.Find(200, 200).GameObj;

            // if Ship is in the object pool
            if (ShipC.Reservedchildren.GetHead() != null)
            {
                _ShipMan.Ship = (ShipLeaf)ShipC.Reservedchildren.GetHead();
                ShipC.Reservedchildren.Remove(GetShip());
                UpdateShipPos();
                // next line is necessary
                PlayBatchMan.Find(BatchName.Box).Add(GetShip().CollisionObj.Box);
                PlayBatchMan.Find(BatchName.Box).Add(ShipC.CollisionObj.Box);
            }
            else    // if Ship is not in the object pool. create new Bullet Obj
            {
                _ShipMan.Ship = new ShipLeaf(GameSpriteName.Ship, 400, 100, 200, 201);
                UpdateShipPos();
            }
            GetShip().SetState(StateName.Ready);
            ShipC.Add(GetShip());
        }
Exemplo n.º 15
0
        //-----------------------------------------------------------------------------
        // Game::LoadContent()
        //		Allows you to load all content needed for your engine,
        //	    such as objects, graphics, etc.
        //-----------------------------------------------------------------------------
        public override void LoadContent()
        {
            //---------------------------------------------------------------------------------------------------------
            // Initialize managers
            //---------------------------------------------------------------------------------------------------------
            // Initialize and Add All Texture
            TextureMan.Initialize();
            TextureMan.AddAll();

            // Initialize and Add All image
            ImageMan.Initialize();
            ImageMan.AddAll();

            // Initialize and Add All Sprites
            GameSpriteMan.Initialize();
            GameSpriteMan.AddAll();

            // Initialize and Add All Sounds
            SoundMan.Initialize();
            SoundMan.AddAll();

            // Initialize Input and Output
            GlyphMan.Initialize();
            GlyphMan.AddXml(GlyphName.Consolas36pt, "Consolas36pt.xml", TextureName.Consolas);
            FontMan.Initialize();
            InputMan.Initialize();

            // Initialize TimerEvents
            TimerMan.Initialize();

            // Initialize GameObj and Collision
            PlayBatchMan.Initialize();

            // ***** Scene *****
            SceneContext.Initialize();
        }
Exemplo n.º 16
0
 private static void UpdateBombPos(float x, float y)
 {
     PlayBatchMan.Find(BatchName.Bombs).Add(GetBomb().GetProxy());
     GetBomb().SetPos(x, y);
     GetBomb().CollisionObj.UpdatePos(x, y);
 }
Exemplo n.º 17
0
 public static void Initialize()
 {
     _batchManager = GetInstance();
 }
Exemplo n.º 18
0
 private static void UpdateBulletPos()
 {
     PlayBatchMan.Find(BatchName.ShipBullet).Add(GetShipBulletLeaf().GetProxy());
     GetShipBulletLeaf().SetPos(GetShip().x, GetShip().y + 20);
     GetShipBulletLeaf().CollisionObj.UpdatePos(GetShip().x, GetShip().y + 20);
 }
Exemplo n.º 19
0
 private static void UpdateShipPos()
 {
     PlayBatchMan.Find(BatchName.Ship).Add(GetShip().GetProxy());
     GetShip().SetPos(400, 100);
     GetShip().CollisionObj.UpdatePos(400, 100);
 }
Exemplo n.º 20
0
Arquivo: UFOMan.cs Projeto: xfanw/Game
 private static void UpdateUFOPos()
 {
     PlayBatchMan.Find(BatchName.UFO).Add(GetUFO().GetProxy());
     GetUFO().SetPos(100, 200);
     GetUFO().CollisionObj.UpdatePos(100, 200);
 }