public override void OnClick() { base.OnClick(); // Play animation //GetComponent<Animator>().Play(""); // Drop egg if there is one if (hasEgg) { chickenObject.GetComponent <Animator>().Play("coop_" + chickenObject.name + "Yes"); AkSoundEngine.PostEvent("Chicken", gameObject); EggCoop egg = GetComponentInChildren <EggCoop>(); StartCoroutine(Coroutines.AnimatePosition(egg.gameObject, eggMark.position, 20f, () => { egg.chickenCoop = chickenCoop; egg.GetComponent <BoxCollider2D>().enabled = true; egg.PlayLandingAnimation(); })); hasEgg = false; } else { chickenObject.GetComponent <Animator>().Play("coop_" + chickenObject.name + "No"); AkSoundEngine.PostEvent("Chicken", gameObject); } }
private void Start() { // Calculate number of eggs that we need at start Data data = SaveNLoadTxt.Load(); int eggsNeeded = Pancake.eggs - data.eggQuantity; // Get all the available chickens chickens = FindObjectsOfType <ChickenControl>(); // Generate types of chicken randomly foreach (ChickenControl chicken in chickens) { int c = Random.Range(0, chickenPrefabs.Length); GameObject chickenInstance = Instantiate(chickenPrefabs[c], chicken.transform); chicken.chickenObject = chickenInstance; chicken.chickenObject.name = chickenPrefabs[c].name; } AkSoundEngine.PostEvent("CoopDoorOpen", gameObject); AkSoundEngine.SetRTPCValue("Time", 100f, null, 1350); // Place eggs randomly int eggsPlaced = 0; while (eggsPlaced < eggsNeeded && eggsPlaced < chickens.Length) { int rand = Random.Range(0, chickens.Length); if (chickens[rand].hasEgg) { continue; } // If the chicken has no egg, place one and increment eggsPlaced chickens[rand].hasEgg = true; ++eggsPlaced; } if (data.eggQuantity == Pancake.eggs) { exitButton.SetActive(true); } GetComponent <InputManager>().enabled = false; StartCoroutine(Coroutines.AnimatePosition(door, new Vector3(20f, door.transform.position.y, door.transform.position.z), 10, () => { GetComponent <InputManager>().enabled = true; AkSoundEngine.PostEvent("TapChicken", gameObject); })); }
public void Hide() { StartCoroutine(Coroutines.AnimatePosition(gameObject, initial, 20f)); }
public void Show() { StartCoroutine(Coroutines.AnimatePosition(gameObject, positionMark.position, 20f)); }