// start the animation from the coin to the gui coin location public void CoinCollected(int coinValue, bool primaryCoin) { // don't show the animation if the camera isn't in its normal position //if (!cameraController.IsInGameTransform() || !primaryCoin) { // gameManager.CoinCollected(coinValue, primaryCoin); // return; //} CoinValueObject coin = CoinFromPool(); coin.coinValue = coinValue; coin.coinTransform.position = startPoint; activeCoins.Add(coin); }
private CoinValueObject CoinFromPool() { CoinValueObject obj; // keep a start index to prevent the constant pushing and popping from the list if (pool.Count > 0 && pool[poolIndex].coinGameObject.activeSelf == false) { obj = pool[poolIndex]; obj.coinGameObject.SetActive(true); poolIndex = (poolIndex + 1) % pool.Count; return(obj); } // No inactive objects, need to instantiate a new one obj = new CoinValueObject(GameObject.Instantiate(guiCoin) as GameObject); obj.coinTransform.parent = thisTransform; pool.Insert(poolIndex, obj); poolIndex = (poolIndex + 1) % pool.Count; return(obj); }
private CoinValueObject CoinFromPool() { CoinValueObject obj; // keep a start index to prevent the constant pushing and popping from the list if (pool.Count > 0 && pool[poolIndex].coinGameObject.activeSelf == false) { obj = pool[poolIndex]; obj.coinGameObject.SetActive(true); poolIndex = (poolIndex + 1) % pool.Count; return obj; } // No inactive objects, need to instantiate a new one obj = new CoinValueObject(GameObject.Instantiate(guiCoin) as GameObject); obj.coinTransform.parent = thisTransform; pool.Insert(poolIndex, obj); poolIndex = (poolIndex + 1) % pool.Count; return obj; }
private CoinValueObject coinFromPool() { CoinValueObject obj; // keep a start index to prevent the constant pushing and popping from the list #if UNITY_3_5 if (pool.Count > 0 && pool[poolIndex].coinGameObject.active == false) { #else if (pool.Count > 0 && pool[poolIndex].coinGameObject.activeSelf == false) { #endif obj = pool[poolIndex]; #if UNITY_3_5 obj.coinGameObject.active = true; #else obj.coinGameObject.SetActive(true); #endif poolIndex = (poolIndex + 1) % pool.Count; return obj; } // No inactive objects, need to instantiate a new one obj = new CoinValueObject(GameObject.Instantiate(guiCoin) as GameObject); obj.coinTransform.parent = thisTransform; pool.Insert(poolIndex, obj); poolIndex = (poolIndex + 1) % pool.Count; return obj; } public int getAnimatingCoins() { return activeCoins.Count; }