/// <summary> /// Crea una lista con todos los ingredientes en la escena que no estén en el caldero /// </summary> public override void OnStart() { sqrMagnitude = magnitude.Value * magnitude.Value; //Si la lista de objetos no está vacía al inicio, se limpia if (objects != null) { objects.Clear(); } //Se crea la lista nueva else { objects = new List <GameObject>(); } //Se obtienen todos los objetos que tienen el componente de ingrediente CauldronIngredient[] ingredients = Object.FindObjectsOfType <CauldronIngredient>(); //Random int k = Random.Range(0, ingredients.Length); for (int i = 0; i < ingredients.Length; ++i) { int randomI = (i + k) % ingredients.Length; //Variable auxiliar para obtener un ingrediente CauldronIngredient cauldronIngredient = ingredients[randomI]; //Añadimos solamente los objetos que no están aún en el caldero y que forman parte de la misión(pluma, calabaza y filete) if (!IsThisIngredientIn(cauldronIngredient.IngredientType) && (cauldronIngredient.IngredientType == "feather" || cauldronIngredient.IngredientType == "pumpkin" || cauldronIngredient.IngredientType == "meat")) { objects.Add(ingredients[randomI].gameObject); } } }
void OnTriggerEnter(Collider other) { CauldronIngredient ingredient = other.attachedRigidbody.GetComponentInChildren <CauldronIngredient>(); Vector3 contactPosition = other.attachedRigidbody.gameObject.transform.position; contactPosition.y = gameObject.transform.position.y; SplashEffect.transform.position = contactPosition; SFXPlayer.Instance.PlaySFX(SplashClips[Random.Range(0, SplashClips.Length)], contactPosition, new SFXPlayer.PlayParameters() { Pitch = Random.Range(0.8f, 1.2f), SourceID = 17624, Volume = 1.0f }, 0.2f, true); splashVFX.Play(); RespawnableObject respawnableObject = ingredient; if (ingredient != null) { m_CurrentIngredientsIn.Add(ingredient.IngredientType); } else { //added an object that is not an ingredient, it will make automatically fail any recipe m_CurrentIngredientsIn.Add("INVALID"); respawnableObject = other.attachedRigidbody.GetComponentInChildren <RespawnableObject>(); } if (respawnableObject != null) { respawnableObject.Respawn(); } else { Destroy(other.attachedRigidbody.gameObject, 0.5f); } }
public void IngridientSelected(CauldronIngredient obj) { GameState.Ingridients obj_ingr = (GameState.Ingridients) System.Enum.Parse (typeof(GameState.Ingridients), obj.name, true); if (ingridient_is_correct (obj_ingr, GameState.HadDrink, GameState.Fumes)) { dialog.ShowText ("Mmm! Let's drink this baby now!"); LevelComplete = true; } else { dialog.ShowText ("Don't try this at home, kids!"); room.Death (); } }