public TDAmmo(TDEntity source, TDEntity target) { this.source = source; this.CurrentLocation = new TDLocation(source.Location.X, source.Location.Y); this.target = target; this.speed = source.BulletSpeed; this.damage = source.BulletDamage; this.SplashRadius = source.SpashRadius; this.Seeking = source.SeekingMissle; this.ChainCount = source.ChainHops; this.ChainDist = source.ChainDist; this.size = 1 + (this.damage / 4); CalculateTrajectory(); // copy any effects (except waveDelay) this.Effects = new List <TDEffect>(); foreach (TDEffect e in source.Effects) { if (e.Effect == TDEffectTypes.WaveDelay) { continue; } else { this.Effects.Add(new TDEffect(e.Effect, e.Power, e.Duration, false)); } } }
private List <TDEntity> GetTowersInRange(TDLocation loc, int Radius, bool IncludeTowers, bool IncludeAttackers) { List <TDEntity> towersInRange = new List <TDEntity>(); if (IncludeAttackers) { foreach (TDAttacker a in TDSession.thisSession.CurrentLevel.Attackers) { if (TDMath.PointInRange(loc, a.Location, Radius)) { towersInRange.Add(a); } } } if (IncludeTowers) { foreach (TDTower t in TDSession.thisSession.CurrentLevel.Towers) { if (TDMath.PointInRange(loc, t.Location, Radius)) { towersInRange.Add(t); } } } return(towersInRange); }
private TDEntity GetTowerAtPoint(Point point) { if (TDSession.thisSession == null || TDSession.thisSession.CurrentLevel == null) { return(null); } TDLocation p = new TDLocation(point.X, point.Y); foreach (TDAttacker a in TDSession.thisSession.CurrentLevel.Attackers) { if (TDMath.PointOnPoint(a.Location, p, a.Size)) { return(a); } } foreach (TDTower t in TDSession.thisSession.CurrentLevel.Towers) { if (TDMath.PointOnPoint(t.Location, p, t.Size)) { return(t); } } // if not a tower or attacker, then nothing return(null); }
private void DamageRadius(TDLocation loc, int Radius) { List <TDEntity> towersInRange = GetTowersInRange(loc, Radius, false, true); for (int i = 0; i < towersInRange.Count; i++) { towersInRange[i].HPCurrent -= this.damage; } }
internal static bool Intersects(TDLocation loc1, int size1, TDLocation loc2, int size2) { bool result = false; bool Xdoes = loc1.X <loc2.X + size2 && loc1.X + size1> loc2.X; bool Ydoes = loc1.Y <loc2.Y + size2 && loc1.Y + size1> loc2.Y; result = Xdoes && Ydoes; return(result); }
public static double RangeToTarget(TDLocation center, TDLocation target) { double changeX = target.X - center.X; double changeY = target.Y - center.Y; // c^2 = a^2 + b^2 double dist = Math.Sqrt((changeX * changeX + changeY * changeY)); return(dist); }
private void MoveToward(TDLocation Location) { if (this.Seeking) { CalculateTrajectory(); } // do the actual move - adjust the location X and Y by their respect parts this.CurrentLocation.X += moveX * TDSession.SpeedFactor; this.CurrentLocation.Y += moveY * TDSession.SpeedFactor; }
public TDLocation[] GetPoints() { TDLocation[] points = new TDLocation[PathPoints.Count]; for (int i = 0; i < PathPoints.Count; i++) { points[i] = PathPoints[i].Location; } return(points); }
private void MoveToward(TDLocation tDLocation) { // get destination TDLocation nextLocation = this.Path.PathPoints[NextPoint].Location; // get raw change double changeX = nextLocation.X - (this.Location.X); double changeY = nextLocation.Y - (this.Location.Y); // calculate direction angle (rise over run) double angle = Math.Atan2(changeY, changeX); // get the X part of the speed double moveX = Math.Cos(angle) * this.SpeedCurrent; // get the Y part of the speed double moveY = Math.Sin(angle) * this.SpeedCurrent; // do the actual move - adjust the location X and Y by their respect parts this.Location.X += moveX * TDSession.SpeedFactor; this.Location.Y += moveY * TDSession.SpeedFactor; }
public static bool PointInRange(TDLocation center, TDLocation target, int range) { return(RangeToTarget(center, target) <= range + (TDMap.GridSize / 2)); }
public static bool PointOnPoint(TDLocation L1, TDLocation L2, int margin) { return((Math.Abs(L2.X - L1.X) < margin) && (Math.Abs(L2.Y - L1.Y) < margin)); }
private bool OnPoint(TDLocation L1, TDLocation L2) { return(TDMath.PointOnPoint(L1, L2, (int)Math.Max(1, this.SpeedCurrent * TDSession.SpeedFactor))); }
public TDPathPoint(int PathNodeIndex, int x, int y) { this.Index = PathNodeIndex; this.Location = new TDLocation(x, y); }
public TDExplosion(TDLocation loc, int radius) { this.Location = new TDLocation(loc.X, loc.Y); this.Radius = radius; this.Spawn = DateTime.Now; }