public sealed override IEnumerator Dead() { Dispose(false); GameManager.Instance.MessageSystem.Publish(MonsterDeadEvent.Create(this, UnitPosition)); UnitAnimator.SetBool("dead", true); yield return(new WaitForSeconds(0.2f)); GameManager.Instance.EffectSystem.CreateEffect("DeathStandard", this.gameObject.transform.position + new Vector3(0, 0.1f, -0.1f), new Vector3(0.25f, 0.25f, 0.25f), Quaternion.Euler(new Vector3(-90, 0, 0)), 2); SoundManager.Instance.PlaySfx("Weird0" + Random.Range(1, 5), 0.1f); yield return(new WaitForSeconds(0.1f)); float alpha = spriteRenderer.material.color.a; for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / 1) { Color newColor = new Color(1, 1, 1, Mathf.Lerp(alpha, 0, t)); spriteRenderer.material.color = newColor; yield return(null); } UnitAnimator.SetBool("dead", false); FieldObjectManager.Instance.ReleaseUnit(unitName, this); }
protected void SetPath() { // 다음 노드로 이동 if (pathList.Count > 1) { pathList.RemoveAt(0); direction = ((Vector3)pathList[0] - UnitPosition).normalized; if (UnitPosition.x <= pathList[0].x) { spriteRenderer.flipX = true; } else { spriteRenderer.flipX = false; } currentState = MonsterUnitState.Walk; } else { Dispose(true); GameManager.Instance.MessageSystem.Publish(MonsterDeadEvent.Create(this, UnitPosition)); } }