public void onFoodDefenced(CalorieFoodObject foodObject) { addCombo(); showCalorie(foodObject.calorie); addScore(foodObject.calorie); showFoodImage(foodObject.imageName); CheckFoodCrash(foodObject.foodId); }
private GameObject findFoodObject(int foodId) { for (int i = 0; i < projectiles.Length; ++i) { CalorieFoodObject currentObject = projectiles[i].GetComponent <CalorieFoodObject>(); if (currentObject.foodId == foodId) { return(projectiles[i].gameObject); } } return(null); }
private void loadFoodImages() { if (_foodImageCache == null) { _foodImageCache = new Hashtable(); } foreach (Transform obj in projectiles) { CalorieFoodObject foodObject = obj.gameObject.GetComponent <CalorieFoodObject>(); string imageName = "texture/Food/" + foodObject.imageName.Replace(".png", ""); Texture2D texture = Resources.Load <Texture2D>(imageName); _foodImageCache.Add(foodObject.imageName, texture); } }