public override bool RayCast(ref RayCastInput input, ref Transform transform, int childIndex, out RayCastOutput output) { Debug.Assert(childIndex < Vertices.Count); int i1 = childIndex; int i2 = childIndex + 1; if (i2 == Vertices.Count) { i2 = 0; } Vector2 v1 = Vertices[i1]; Vector2 v2 = Vertices[i2]; return(RayCastHelper.RayCastEdge(ref v1, ref v2, ref input, ref transform, out output)); }
private IEnumerable <IPlayer> RayCast(Vector2 start, Vector2 end) { if (HasDamage(TurretDamage.SensorDamaged)) { foreach (var result in RayCastHelper.Players(start, end)) { yield return(Game.GetPlayer(result.ObjectID)); } } else { foreach (var result in RayCastHelper.Players(start, end, true, Team, Owner)) { yield return(Game.GetPlayer(result.ObjectID)); } } }
private void Update() { Vector3 dir = new Vector3(0f, 0.5f, -1.25f); Quaternion rotation = Quaternion.Euler(yRot, xRot, 0); if (this.cameraState == CameraState.ZoomedIn) { Vector3 offset = new Vector3(2.75f, 0.5f, -3.5f); this.dollyPosition = this.target.position + rotation * offset; this.transform.rotation = rotation; } else { this.dollyPosition = this.target.position + rotation * dir * this.distance; } Vector3 point; bool hit = RayCastHelper.ShootLine(this.target.transform.position, this.dollyPosition, out point); if (hit) { this.dollyPosition = point; } transform.position = this.dollyPosition; if (this.cameraState == CameraState.Normal) { this.transform.LookAt(this.target.transform.position); } if (Input.GetMouseButton(1) || this.cameraState == CameraState.ZoomedIn) { xRot += Input.GetAxis("Mouse X") * cameraSettings.sensitivty; yRot -= Input.GetAxis("Mouse Y") * cameraSettings.sensitivty; yRot = Mathf.Clamp(yRot, -40f, 45f); } else if (!Input.GetMouseButton(1) && this.cameraState == CameraState.Normal) { xRot += Input.GetAxis("Horizontal"); yRot = Mathf.Lerp(yRot, this.yStart, 0.25f); } }
private bool HasTargetToCharge() { var los = GetLineOfSight(); var lineStart = los[0]; var lineEnd = los[1]; foreach (var result in RayCastHelper.Players(lineStart, lineEnd)) { var player = Game.GetPlayer(result.ObjectID); var inMinimumRange = ScriptHelper.IntersectCircle( player.GetAABB(), Actor.Position, ChargeMinimumRange); if (!inMinimumRange && !player.IsDead && !player.IsInMidAir && !ScriptHelper.SameTeam(player, Player)) { return(true); } } return(false); }
public bool AvoidWalls() { bool backward = RayCastHelper.ShootRay(this.transform.position, -this.transform.forward, 1f); bool left = RayCastHelper.ShootRay(this.transform.position, -this.transform.right, 1f); bool right = RayCastHelper.ShootRay(this.transform.position, this.transform.right, 1f); Vector3 destination = Vector3.zero; if (backward || right) { destination = this.transform.position - (this.transform.right * 1.5f); this.ChangeDestination(destination); return(true); } else if (left) { destination = this.transform.position + this.transform.right * 1.5f; this.ChangeDestination(destination); return(true); } return(false); }
// Update is called once per frame public void Awake() { Instance = this; }
public override bool RayCast(ref RayCastInput input, ref Transform transform, int childIndex, out RayCastOutput output) { return(RayCastHelper.RayCastPolygon(_vertices, _normals, ref input, ref transform, out output)); }
public bool IsTargetVisible() { return(RayCastHelper.ShootLine(this.transform.position, this.target.position)); }
public override bool RayCast(ref RayCastInput input, ref Transform transform, int childIndex, out RayCastOutput output) { return(RayCastHelper.RayCastEdge(ref _vertex1, ref _vertex2, ref input, ref transform, out output)); }
public override bool RayCast(ref RayCastInput input, ref Transform transform, int childIndex, out RayCastOutput output) { return(RayCastHelper.RayCastCircle(ref _position, Radius, ref input, ref transform, out output)); }
private bool ShouldBuildTurretHere() { if (!CanBuildTurretNow) { return(false); } if (!Actor.CanBuildTurretHere()) { return(false); } m_availableDirection = AvailableTurretDirection.None; var prioritizedDirection = Player.FacingDirection == 1 ? AvailableTurretDirection.Right : AvailableTurretDirection.Left; for (var i = 0; i < ScanLines.Count; i++) { var scanLine = ScanLines[i]; Game.DrawLine(scanLine[0], scanLine[1], Color.Yellow); if (RayCastHelper.ImpassableObjects(scanLine[0], scanLine[1]).Count() == 0) { m_availableDirection = i == 0 ? AvailableTurretDirection.Right : AvailableTurretDirection.Left; if (m_availableDirection == prioritizedDirection) { break; } } } if (m_availableDirection == AvailableTurretDirection.None) { return(false); } // Uncomment if Engineer is too OP // foreach (var bot in BotManager.GetBots<EngineerBot>()) // { // if (bot.IsBuilding) return false; // } // Don't build turret when enemies are nearby foreach (var bot in BotManager.GetBots()) { if (!ScriptHelper.SameTeam(Player, bot.Player)) { if (DangerArea.Intersects(bot.Player.GetAABB())) { return(false); } } } foreach (var turret in WeaponManager.GetWeapons <Turret>()) { if (turret.Broken) { continue; } var area = new Area( turret.Position + Vector2.UnitX * 32 * turret.Direction + Vector2.UnitY * 7, turret.Position - Vector2.UnitX * 20 * turret.Direction - Vector2.UnitY * 14); area.Normalize(); Game.DrawArea(area); //ScriptHelper.LogDebug(area, area.Intersects(player.GetAABB())); if (area.Intersects(Player.GetAABB())) { return(false); } if (ScriptHelper.IntersectCircle(Actor.Position, turret.Position, 275, turret.MinAngle, turret.MaxAngle)) { return(false); } } return(true); }