private IEnumerator IEAttack(Vector2 diraction, int value) { _go.GetComponent <BaseChar>().IsDone = false; Vector2 start = _go.transform.position; // 방향 전환 float dir = CalculateDir(start, diraction); _go.transform.localScale = new Vector3(dir, 1, 1); float delayTime = 0; // 애니메이션 _go.GetComponent <Animator>().SetTrigger("Attack"); while (delayTime < 0.5) { delayTime += Time.deltaTime; yield return(null); } BaseChar ch = GameMng.CharMng.GetChar(_tile); if (ch != null) { ch.Damage(value); GameMng.Sound.SfxPlay(_hitSound); } _go.GetComponent <BaseChar>().IsDone = true; }
private IEnumerator IEMovingObject(Tile tile) { _go.GetComponent <BaseChar>().IsDone = false; _go.GetComponent <Animator>().SetTrigger("Attack"); Vector2 curr = _go.transform.position; Vector2 target = tile.Position; _projectile.transform.position = curr; CalculateDir(curr, target); int x = (int)Mathf.Abs(curr.x - target.x); int y = (int)Mathf.Abs(curr.y - target.y); int moveCount = 0; if (x > y) { moveCount = x; } else { moveCount = y; } float elapsedTime = 0; float targetTime = 1f; while (elapsedTime < targetTime) { elapsedTime += Time.deltaTime * moveSpeed / moveCount; _projectile.transform.position = Vector2.Lerp(curr, target, elapsedTime); yield return(null); } BaseChar ch = GameMng.CharMng.GetChar(tile); if (ch != null) { ch.Damage(_damageValue); GameMng.Sound.SfxPlay(_projectile.Data._itemSound); } // Projectile Object Pool push GameMng.Pool.ItemPush(_projectile.Data._name, _projectile); //PoolMng.Instance.ItemPush(_projectile.Data._name, _projectile); _go.GetComponent <BaseChar>().IsDone = true; }