public override IEnumerator PrimaryEffect(Unit caster, Vector2Int position, bool isPrimarySpell, System.Func <HashSet <Unit>, IEnumerator> then) { var projectile = Instantiate(projectilePrefab, caster.WorldPosition, Quaternion.identity); var worldTarget = new Vector3(position.x + 0.5f, position.y + 0.5f); projectile.transform.right = worldTarget - caster.WorldPosition; var progress = 0f; var distance = Vector3.Distance(caster.WorldPosition, worldTarget); while (progress < 1f) { progress += Time.deltaTime * projectileSpeed / distance; projectile.transform.position = Vector3.Lerp(caster.WorldPosition, worldTarget, progress); yield return(new WaitForEndOfFrame()); } Destroy(projectile); var target = caster.environment.GetUnit(position); if (target == null) { yield break; } Damage(target, primaryDamage.GetAmount(isPrimarySpell), caster); yield return(then(new HashSet <Unit> { target })); }
public override IEnumerator PrimaryEffect(Unit caster, Vector2Int position, bool isPrimarySpell, System.Func <HashSet <Unit>, IEnumerator> then) { // TODO make rock cone an AoE var target = caster.environment.GetUnit(position); if (target == null) { yield break; } Damage(target, primaryDamage.GetAmount(isPrimarySpell), caster); yield return(then(new HashSet <Unit> { target })); }
public override IEnumerator PrimaryEffect(Unit caster, Vector2Int position, bool isPrimarySpell, System.Func <HashSet <Unit>, IEnumerator> then) { var target = caster.environment.GetUnit(position); if (target == null) { yield break; } var targets = GetLightningTargets(target, 2, 3, null); foreach (var lightningTarget in targets) { Damage(lightningTarget, primaryDamage.GetAmount(isPrimarySpell), caster); } then(targets); }