public IEnumerator Destroy() { status = Status.Destroy; if (home != null) { home.RemoveResident(this); } if (job != null) { job.RemoveWorker(this); } float t = 0f; while (t < 1f) { t += Time.deltaTime * 5f; float v = Mathf.Sin(Mathf.PI * t / 2f); transform.localScale = Vector3.one * Mathf.Lerp(1f, 1.25f, v); yield return(null); } t = 0f; while (t < 1f) { t += Time.deltaTime * 3f; float v = Mathf.Sin(Mathf.PI * (1 - t) / 2f); transform.localScale = Vector3.one * Mathf.Lerp(0f, 1.25f, v); yield return(null); } Destroy(this.gameObject); }
protected void MoveOut() { Home.RemoveResident(this); }