void Update() { if (Input.GetButtonDown("PrimaryAction") && GameManager.AllowPlayerActions && !Health.IsFullLife) { PlayerGlobalSounds.PlayClip(gluckGluckSound); drinkAnimation.PlayAnimation(this, delegate { PlayerGlobalSounds.PlayClip(Rand.PickOne(burps)); Health.Heal(healthRestorage); Inventory.RemoveItem(item, 1); }); } }
public static IEnumerator DisplayContainer(ItemContainer item, AudioClip sound, MonoBehaviour animatedBy, Vector3 spawnPosition) { int displayCount = 0; float delayTimeForEachItem = 0.2f; float displayCountDown = 0; float itemFloatHeight = 3.33f; float itemLifeTime = 1.25f; while (displayCount < item.itemCount) { if (displayCountDown <= 0) { displayCountDown += delayTimeForEachItem; GameObject i = Object.Instantiate(item.item.RuntimeRef.gameObject); Vector3 startScale = i.transform.localScale; PlayerGlobalSounds.PlayClip(sound); Object.Destroy(i.GetComponent <SaveablePrefabRoot>()); foreach (ItemBehaviour b in i.GetComponents <ItemBehaviour>()) { b.enabled = false; } animatedBy.StartCoroutine(SmoothTransformation <Vector3> .GetStoppable(spawnPosition, spawnPosition + Vector3.up * itemFloatHeight, itemLifeTime, p => { i.transform.localPosition = p; }, (s, e, p) => { i.transform.localScale = startScale * Mathf.Cos((p / 2) * Mathf.PI); return(Vector3.Lerp(s, e, p)); }, () => Object.Destroy(i) )); displayCount++; } yield return(new WaitForFixedUpdate()); displayCountDown -= Time.deltaTime; } }
public void PlayMusic() { PlayerGlobalSounds.PlayClip(clip, 0.55f); }