Esempio n. 1
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;
        }
Esempio n. 2
0
        // Aliens
        public override void VisitAlienGrid(AliensGrid g)
        {
            // MissileGroup vs AliensGrid
            Debug.WriteLine("         collide:  {0} <-> {1}", g.GetName(), this.GetName());

            // Missile vs AliensCol
            ColPair.Collide((GameObject)g.GetFirstChild(), (GameObject)this.GetFirstChild());
        }
Esempio n. 3
0
        public static AliensGrid GetGrid()
        {
            AliensGrid temp = _AlienGridMan._AlienGrid;

            if (temp == null || temp.GetFirstChild() == null)
            {
                InitializeGrid();
            }
            return(_AlienGridMan._AlienGrid);
        }
Esempio n. 4
0
        public GameObject Create(GameObject.Name name, AlienCategory.Type type, float posX = 0.0f, float posY = 0.0f)
        {
            GameObject pGameObj = null;

            switch (type)
            {
            case AlienCategory.Type.Squid:
                pGameObj = new Alien(GameSprite.Name.Sprite_Squid, name, posX, posY);
                break;

            case AlienCategory.Type.Crab:
                pGameObj = new Alien(GameSprite.Name.Sprite_Crab, name, posX, posY);
                break;

            case AlienCategory.Type.Octopus:
                pGameObj = new Alien(GameSprite.Name.Sprite_Octopus, name, posX, posY);
                break;

            case AlienCategory.Type.Grid:
                pGameObj = new AliensGrid(name);
                break;

            case AlienCategory.Type.Column:
                pGameObj = new AliensColumn(name);

                break;

            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }

            // add it to the gameObjectManager
            Debug.Assert(pGameObj != null);
            // GameObjectMan.Attach(pGameObj);

            // Attached to Group
            pGameObj.ActivateGameSprite(this.pSpriteBatch);
            pGameObj.ActivateCollisionSprite(pBoxBatch);

            return(pGameObj);
        }
Esempio n. 5
0
        // private methods ---------->>>for recycling Aliens
        private static void ResetGrid(AliensGrid Grid)
        {
            DLinkedNode Col = Grid.Reservedchildren.GetHead();

            while (Col != null)
            {
                DLinkedNode NextCol = Col.Next;
                // Active Col
                Grid.Add((AliensCol)Col);

                // Active Leaf
                DLinkedNode Leaf = ((AliensCol)Col).Reservedchildren.GetHead();
                while (Leaf != null)
                {
                    DLinkedNode NextLeaf = Leaf.Next;
                    ((AliensCol)Col).Add((AlienLeaf)Leaf);
                    ((AliensCol)Col).Reservedchildren.Remove((AlienLeaf)Leaf);
                    Leaf = NextLeaf;
                }
                Grid.Reservedchildren.Remove((AliensCol)Col);
                Col = NextCol;
            }
        }
Esempio n. 6
0
 public virtual void VisitAlienGrid(AliensGrid g)
 {
     // no differed to subcass
     Debug.WriteLine("Visit by Aliens not implemented");
     Debug.Assert(false);
 }
Esempio n. 7
0
 public virtual void Visit(AliensGrid b)
 {
 }