// Start is called before the first frame update void Start() { audioSource = GetComponent <AudioSource>(); particleSystem = GetComponent <ParticleSystem>(); this._isInitialized = true; OnScriptInitialized?.Invoke(this); }
void Start() { tagToPoolObjectDictionary = new Dictionary <string, Pool>(); objectToTagDictionary = new Dictionary <GameObject, string>(); tagToPoolQueueDictionary = new Dictionary <string, Queue <GameObject> >(); foreach (Pool pool in pools) { tagToPoolObjectDictionary[pool.tag] = pool; // create a Q for each pool Queue <GameObject> objectPool = new Queue <GameObject>(); // populate Q with `size` objects for (int i = 0; i < pool.size; i++) { GameObject obj = Instantiate(pool.prefab); obj.SetActive(false); //not yet in the game IPooledObject pooledObj = obj.GetComponent <IPooledObject>(); if (pooledObj != null) { pooledObj.OnObjectInitiate(pool.spriteManager); } objectPool.Enqueue(obj); objectToTagDictionary[obj] = pool.tag; } tagToPoolQueueDictionary.Add(pool.tag, objectPool); } this._isInitialized = true; OnScriptInitialized?.Invoke(this); }
// Start is called before the first frame update void Start() { rigTransform = this.transform.parent; gameManager.OnNewPlayer += OnNewPlayer; this._isInitialized = true; OnScriptInitialized?.Invoke(this); }
public virtual void InitSpriteManager() { gameManager = GameManager.Instance; gameManager.OnGameStart += OnGameStart; gameManager.OnGameOver += OnGameOver; gameManager.OnNewPlayer += OnNewPlayer; gameManager.OnNewGameSpeed += OnNewGameSpeed; objectPooler = ObjectPooler.Instance; sprites = new List <GameObject>(); InitSpawnLocations(); OnScriptInitialized?.Invoke(this); }