private Vector3 getRandPosition(float minR, float maxR) { double minNormalized = IzakoUtil.fromRangeToRange(0, maxR, 0, 1, minR); Vector3 normalizedArea = UnityEngine.Random.insideUnitSphere; if (Math.Abs(normalizedArea.x) < minNormalized) { normalizedArea.x *= 2; } if (Math.Abs(normalizedArea.z) < minNormalized) { normalizedArea.z *= 2; } Vector3 randomDirection = normalizedArea * maxR; randomDirection += gameObject.transform.position; NavMeshHit hit; NavMesh.SamplePosition(randomDirection, out hit, maxR, 1); Vector3 finalPosition = hit.position; return(finalPosition); }
public override TaskStatus OnUpdate() { EntityStats stats = gameObject.GetComponent <EntityManager>().getStats(); Stat health = stats.getStat("health"); double healthPercentage = IzakoUtil.fromRangeToRange(0, health.maxValue, 0, 100, health.value); return(healthPercentage <= percentage ? TaskStatus.COMPLETED : TaskStatus.FAILED); }