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); }; }
public Array(Vector2Int size) { size.x = size.x * 2 + 4; size.y = size.y * 2 + 4; rows = new List <Bullet> [size.y]; pool.Recycle(); for (int y = 0; y < size.y; ++y) { rows[y] = pool.Get(); } columns = new List <Bullet> [size.x]; for (int x = 0; x < size.x; ++x) { columns[x] = pool.Get(); } }