public bool RecalculateAttackPosition() { if (Target != null && TargetUnit != null && !TargetUnit.IsDead && GetDistanceTo(Target) < CollisionRadius && GetDistanceTo(TargetUnit.X, TargetUnit.Y) <= Stats.Range.Total)//If we are already where we should be, do not move. { return(false); } var objects = _game.ObjectManager.GetObjects(); List <CirclePoly> UsedPositions = new List <CirclePoly>(); var isCurrentlyOverlapping = false; var thisCollisionCircle = new CirclePoly(((Target)Target)?.GetPosition() ?? GetPosition(), CollisionRadius + 10); foreach (var gameObject in objects) { var unit = gameObject.Value as AttackableUnit; if (unit == null || unit.NetId == NetId || unit.IsDead || unit.Team != Team || unit.GetDistanceTo(TargetUnit) > DETECT_RANGE ) { continue; } var targetCollisionCircle = new CirclePoly(((Target)unit.Target)?.GetPosition() ?? unit.GetPosition(), unit.CollisionRadius + 10); if (targetCollisionCircle.CheckForOverLaps(thisCollisionCircle)) { isCurrentlyOverlapping = true; } UsedPositions.Add(targetCollisionCircle); } if (isCurrentlyOverlapping) { var targetCircle = new CirclePoly(((Target)TargetUnit.Target)?.GetPosition() ?? TargetUnit.GetPosition(), Stats.Range.Total, 72); //Find optimal position... foreach (var point in targetCircle.Points.OrderBy(x => GetDistanceTo(X, Y))) { if (_game.Map.NavGrid.IsWalkable(point)) { var positionUsed = false; foreach (var circlePoly in UsedPositions) { if (circlePoly.CheckForOverLaps(new CirclePoly(point, CollisionRadius + 10, 20))) { positionUsed = true; } } if (!positionUsed) { SetWaypoints(new List <Vector2> { GetPosition(), point }); return(true); } } } } return(false); }
//Accessors. //Overload public override void mutate(int mutationflags, float mutationstrength) { CirclePoly.mutate(mutationflags & ~cShape.MF_VERTCOUNT, mutationstrength); setAccentPoly(); int red, green, blue; //Pick bright colors that I can add 64 to and still be in range. red = Framework.randomOb.random(64, 255 - 64); green = Framework.randomOb.random(64, 255 - 64); blue = Framework.randomOb.random(64, 255 - 64); FillColor = Color.FromArgb(red, green, blue); }
internal override void UpdatePolygon() { Circle = new CirclePoly(this.EndPosition, this.SData.Radius); this.UpdatePath(); }
internal override void UpdatePolygon() { Circle = new CirclePoly(this.EndPosition, 80); this.UpdatePath(); }