Beispiel #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;
        }
Beispiel #2
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;
            }
        }