public void UpdateIngredientsUI(string ingredientName) { bool isCollectedBefore = false; foreach (Transform collectibleTransform in _playUIIngredientsPanel.transform) { CollectibleUI collectibleUI = collectibleTransform.GetComponent <CollectibleUI> (); if (collectibleUI.collectibleName == ingredientName) { isCollectedBefore = true; collectibleUI.collectibleCount++; collectibleUI.UpdateCollectibleCountText(); break; } } if (!isCollectedBefore) { GameObject collectible = GameObject.Instantiate(_collectibleUIPrefab); collectible.transform.SetParent(_playUIIngredientsPanel.transform, false); CollectibleUI collectibleUI = collectible.GetComponent <CollectibleUI> (); collectibleUI.collectibleCount = 1; collectibleUI.collectibleName = ingredientName; collectibleUI.UpdateCollectibleCountText(); collectibleUI.UpdateCollectibleImage(); } }
IEnumerator ExecuteScoreSequence(int resultScore) { SlideInScoreUI(true); _customerPanel.GetComponent <Image> ().sprite = _customerSprites[1]; yield return(new WaitForSeconds(1.5f)); if (resultScore < 60) { _customerPanel.GetComponent <Image> ().sprite = _customerSprites[3]; } else { _customerPanel.GetComponent <Image> ().sprite = _customerSprites[2]; } yield return(new WaitForSeconds(1.5f)); // Show stars _customerPanel.GetComponent <Image> ().DOColor(new Color(107 / 255f, 107 / 255f, 107 / 255f), 0.2f); float newScoreBarWidth = (GameManager.instance.GetScore() / 100f) * _originalScoreUIScoreBarWidth; _scoreUIScoreBar.sizeDelta = new Vector2(newScoreBarWidth, _originalScoreUIScoreBarHeight); _scoreUIStarsPanel.SetActive(true); // Show ingredients collected _scoreUIIngredientsPanel.SetActive(true); foreach (KeyValuePair <string, int> ingredient in GameManager.instance.GetCollectedIngredients()) { string ingredientName = ingredient.Key; int ingredientAmount = ingredient.Value; for (int i = 0; i < ingredientAmount; i++) { GameObject collectible = GameObject.Instantiate(_collectibleUIPrefab); collectible.transform.SetParent(_scoreUIIngredientsPanel.transform, false); collectible.transform.Find("Text").gameObject.SetActive(false); collectible.name = ingredientName; CollectibleUI collectibleUI = collectible.GetComponent <CollectibleUI> (); collectibleUI.collectibleName = ingredientName; collectibleUI.UpdateCollectibleImage(); GameObject explosionParticleSystem = GameObject.Instantiate(_explosionParticleSystem); explosionParticleSystem.transform.SetParent(collectible.transform, false); explosionParticleSystem.transform.localPosition = new Vector2(0, 0); yield return(new WaitForSeconds(0.2f)); } } // Show name of the ramen you made _scoreUIRamneNamePanel.SetActive(true); yield return(new WaitForSeconds(1f)); _scoreUIAgainButton.SetActive(true); }