/// <summary>
        /// Initialises the Object Pool
        /// </summary>
        /// <param name="number">The size of the object pool (Number of objects to store)</param>
        public void Initialise(int number)
        {
            // initialise the pool
            poolSize = number;
            pooledObjects = new List<GameObject>();

            // from 0 to the size of the pool, create a new object
            for (int i = 0; i < poolSize; i++)
            {
                int randomIndex = Random.Range(0, 3);

                GameObject go = AddNewItem();
                pooledObjects.Add(go);      // add the new object to the list of pooled objects
            }

            current = this;
        }
Beispiel #2
0
		static PopupLabelGenerator()
		{
			m_labelPool = new ObjectPool<PopupLabelInfo>();
			m_labelPool.MakeFunc = () =>
			{
				var lp = Instance.LabelPrefab;
				var label = Instantiate(lp);
				label.transform.SetParent(Instance.transform);
				var labelInfo = new PopupLabelInfo
				{
					Label = label,
					MoveSpeed = new Vector2(0, 10),
					LifeTime = 2f,
					Delay = 1f,
					Free = false
				};

				return labelInfo;
			};
		}
Beispiel #3
0
		//public section
		public void Initialize(int w, int h)
		{
			print("map init w, h: " + w + ", " + h);

			m_lines = new int[w];
			m_spawnPosition.y = (Cell.Height*h) + 20f;
			m_spawnPosition.x = 0;
			Width = w;
			Height = h;
			Count = w*h;
			m_coinsPool = new ObjectPool<Coin>()
			{
				MakeFunc = () => Instantiate(coinPrefab),
				DisableFunc = (inst) =>
				{
					if (OnCoinDestroy != null && !IsBoardInit)
						OnCoinDestroy.Invoke(inst);
				}
			};

			m_matchPool = new ObjectPool<Match>()
			{
				MakeFunc = () => new Match(),
				DisableFunc = (inst) => inst.Free()
			};

			m_axisDirection = new Point[3]
			{
				null,
				new Point(1, 0),
				new Point(0, 1) 
			};

			RemoveList = new List<Coin>();

			CreateGreed();

			Fill();
		}