Пример #1
0
        private static void Init()
        {
            resources = "Tank Resources".LoadAsset <TankResources>();

            var pool = new SystemObjectPool <List <Tank> >(list => list.Clear());

            BattleField.awake += () =>
            {
                var size = "STAGE".GetValue <Stage>().size;
                size.x = size.x * 2 + 4;
                size.y = size.y * 2 + 4;
                var _array = new List <Tank> [size.x][];
                var a      = new ReadOnlyArray <IReadOnlyList <Tank> > [size.x];
                pool.Recycle();
                for (int x = 0; x < size.x; ++x)
                {
                    a[x] = new ReadOnlyArray <IReadOnlyList <Tank> >(_array[x] = new List <Tank> [size.y]);
                    for (int y = 0; y < size.y; ++y)
                    {
                        _array[x][y] = pool.Get();
                    }
                }
                array = new ReadOnlyArray <ReadOnlyArray <IReadOnlyList <Tank> > >(a);
            };
        }