protected bool IsEnemyVisible() { if (BotController.Character.World.IsBodyColliderVisibleFromFrustum(BotController.Character.ViewFrustum, VisibleCollider)) return true; VisibleCollider = BotController.SelectBestCollider(Enemy); return VisibleCollider != null; }
public Character GetVisibleEnemyBodyCollider(out BodyCollider collider) { foreach (Character enemy in World.BattleSystem.GetEnemiesAlive(Character)) { collider = SelectBestCollider(enemy); if (collider != null) return enemy; } collider = null; return null; }
public float? GetRayCollisionResult(Ray ray, out BodyCollider collider) { collider = null; // Simple test float? result = BoundingSphere.GetIntersectingDistance(ray); if (result == null) return null; // Precise test float? best = null; foreach (BodyCollider bodyCollider in BodyColliders) { result = bodyCollider.PrimitiveNode.GetIntersectingDistance(ray); if (result == null) continue; if (best == null || result.Value < best.Value) { best = result; collider = bodyCollider; } } return best; }
public AttackStrategy(BotController controller, Character enemy, BodyCollider visibleCollider) : base(controller, enemy, visibleCollider) { }
public bool IsBodyColliderVisibleFromFrustum(FrustumNode frustum, BodyCollider collider) { Vector3 colliderCenter = collider.PrimitiveNode.GetCenter(true); if (!frustum.Contains(colliderCenter)) return false; Vector3 delta = colliderCenter - frustum.Position; Ray ray = new Ray(frustum.Position, delta); float? buildingDistance = GetNearestIntersectingBuilding(ray); if (!buildingDistance.HasValue || delta.SquaredLength < buildingDistance.Value.Squared()) return true; return false; }
public Character FindEnemy(Character attacker, Ray ray, out BodyCollider collider, out float? intersection) { collider = null; if (BattleSystem == null) { intersection = Buildings.MinOrNull(x => x.GetIntersectingDistance(ray)); return null; } float? characterIntersection = null; Character closest = null; foreach (Character enemy in BattleSystem.GetEnemiesAlive(attacker)) { float? tempIntersection = enemy.GetRayCollisionResult(ray, out collider); if (tempIntersection == null) continue; if (characterIntersection == null || tempIntersection.Value < characterIntersection.Value) { characterIntersection = tempIntersection; closest = enemy; } } intersection = characterIntersection; if (characterIntersection == null) return null; // Determine if any buildings block the ray float? buildingIntersection = Buildings.MinOrNull(x => x.GetIntersectingDistance(ray)); if (buildingIntersection != null && buildingIntersection.Value < characterIntersection.Value) { intersection = buildingIntersection; return null; } return closest; }
public Character FindEnemy(Character attacker, Ray ray, out BodyCollider collider) { float? intersection; return FindEnemy(attacker, ray, out collider, out intersection); }
public EnemyInteractionStrategy(BotController controller, Character enemy, BodyCollider visibleCollider) : base(controller) { this.Enemy = enemy; this.VisibleCollider = visibleCollider; }
public ReactionDelayStrategy(BotController controller, Character enemy, BodyCollider visibleCollider) : base(controller, enemy, visibleCollider) { }