public void applyBlink(float elapsedTime, Player player, Vector3 move) { BoundingBox playerBoundingBox = player.getBoundingBox(); Vector3 cent = center(playerBoundingBox); //fix the move with a hitscan HitScan hs = hitscan(cent, Vector3.Normalize(move), null); if (hs != null && hs.Distance() < Math.Sqrt(Vector3.Dot(move, move))) { move = Vector3.Normalize(move) * hs.Distance() + hs.collisionFace.plane.getNormal() * 70; } Vector3 offset = center(playerBoundingBox) - player.getPosition(); Vector3 playerRadius = size(playerBoundingBox) * 0.5f; Vector3 basePoint = toESpace(playerRadius, cent); Vector3 evelocity = toESpace(playerRadius, move); Vector3 pos = collideWithWorld(playerRadius, basePoint, evelocity, 0, player); player.setPosition(toWorldSpace(playerRadius, pos) - offset); }
public void splashDamage(Vector3 position, float size, float damage) { foreach (Agent a in core.allAgents()) { if (a.spawnTime > 0) { continue; } BoundingBox bb = a.getBoundingBox(); Vector3 cent = bb.Min + (bb.Max - bb.Min) * 0.5f; float dist = Vector3.Distance(cent, position); if (dist < size) { //do hitscan check HitScan hs = hitscan(position, cent - position, null); if (hs == null || hs.Distance() > dist) { a.health -= (int)Math.Ceiling(damage * Math.Pow(1 - dist / size, 0.5)); } } } }