示例#1
0
 public void Initialize(Pool parentPool)
 {
     myPool         = parentPool;
     poolInterfaces = GetComponentsInChildren <IPoolable>();//GetComponents<IPoolable>();
     if (poolInterfaces.Length > 0)
     {
         usesInterface = true;
         //for (int i = 0; i < poolInterfaces.Length; i++)
         //{
         //    //poolInterfaces[i].SetusesPooling(true);
         //}
     }
 }
示例#2
0
        public static void SetupBoardPool(Board template)
        {
            if (Pool != null)
            {
            return;
            }
            Pool = new Pooling.Pool<Board> (AMT_BOARDS_NEEDED_PER_SEARCH * Environment.ProcessorCount, pool => {
            Board newBoard = new Board ();

            BoardSquare[,] squares = new BoardSquare[template.Width, template.Height];
            for (int y = 0; y < template.Height; y++)
            {
                for (int x = 0; x < template.Width; x++)
                {
                    squares [x, y] = new BoardSquare (newBoard, template.Squares [x, y].Type, new Coords () { x = x, y = y });
                }
            }
            newBoard.SetSquares (squares, template.TerritoryOf);
            return newBoard;
            },
             Pooling.LoadingMode.Eager,
             Pooling.AccessMode.FIFO);
        }