private IEnumerator lightDamage() { while (possessedBody == null && currentHealth > 0) { float lightLevel = LightLevel.GetLightLevel(transform.position); float damage = damageFromLight.Evaluate(lightLevel) * Time.deltaTime * lightDamageMultiplier; TakeDamage(damage, transform.position, 0f); yield return(null); } }
public List <AITarget> GetSeenTargets(Vector3 position, Vector2 forward) { float effectiveSightRange = sightRange * sightRangeOverDistance.Evaluate(LightLevel.GetLightLevel(position)); List <AITarget> seenTargets = new List <AITarget>(); for (int i = 0; i < targets.Count; ++i) { Vector2 selfToTarget = targets[i].transform.position - position; if (selfToTarget.magnitude < effectiveSightRange && Mathf.Abs(Vector2.Angle(forward, selfToTarget)) < 90 && Physics2D.Raycast(position, selfToTarget).transform == targets[i].transform) { seenTargets.Add(targets[i]); } } return(seenTargets); }