private void MoveEnemies(LoB lob) { foreach (var u in lob.Enemies) { u.Move(); } }
private void MoveEnemiesShells(LoB lob) { foreach (var s in lob.EnemiesShells) { s.Move(); } var removeList = new List <Shell>(); foreach (var s in lob.EnemiesShells) { var x = s.DrawOptions.Position.X; var y = s.DrawOptions.Position.Y; if (x < -100 || lob.Width + 100 < x || y < -100 || lob.Height + 100 < y) { removeList.Add(s); } } foreach (var s in removeList) { lob.EnemiesShells.Remove(s); } }
private void DrawEnemiesShells(LoB lob, RenderTarget target) { foreach (var s in lob.EnemiesShells) { s.Draw(target); } }
private void DrawNeutrals(LoB lob, RenderTarget target) { foreach (var u in lob.Neutrals) { u.Draw(target); } }
private void CalculateEnemiesShellsCollision(LoB lob) { var collidedShells = new List <Shell>(); var collidedUnits = new List <Unit>(); foreach (var s in lob.EnemiesShells) { foreach (var u in lob.Allies) { if (Vector2.Distance(s.DrawOptions.Position, u.DrawOptions.Position) < s.DrawOptions.Size + u.DrawOptions.Size) { collidedShells.Add(s); collidedUnits.Add(u); } } } foreach (var s in collidedShells) { lob.EnemiesShells.Remove(s); } foreach (var u in collidedUnits) { u.Neutralize(); lob.Neutrals.Add(u); lob.Allies.Units.Remove(u); } }
private void DrawEnemies(LoB lob, RenderTarget target) { foreach (var u in lob.Enemies) { u.Draw(target); } }
private void ShootEnemiesShells(LoB lob) { foreach (var u in lob.Enemies) { u.Shoot(); } }
private void ShootAlliesShells(LoB lob) { foreach (var u in lob.Allies.Units) { u.Shoot(); } }
/// <summary> /// Constructor of ally unit. /// </summary> /// <param name="position"></param> /// <param name="roundspersecond"></param> /// <param name="size"></param> /// <param name="color"></param> public Unit(LoB game, DrawOptions drawoptions, float roundspersecond) { Game = game; DrawOptions = drawoptions; History = new List <Vector2>(); RoundsPerSecond = roundspersecond; CoolDownTimer = 0; Faction = Faction.Ally; }
/// <summary> /// Constructor of enemy unit. /// </summary> /// <param name="position"></param> /// <param name="roundspersecond"></param> /// <param name="size"></param> /// <param name="color"></param> /// <param name="motionrule"></param> public Unit(LoB game, DrawOptions drawoptions, float roundspersecond, Func <Vector2, Vector2> motionrule) { Game = game; DrawOptions = drawoptions; History = new List <Vector2>(); RoundsPerSecond = roundspersecond; CoolDownTimer = 0; MotionRule = motionrule; Faction = Faction.Enemy; }
private void SpawnEnemy(LoB lob) { if (lob.FrameCount % 100 == 0) { var randomPosition = new Vector2(lob.Width * (float)lob.Rand.NextDouble(), lob.Height * (float)lob.Rand.NextDouble()); var drawOptions = new DrawOptions(randomPosition, 5, new RawColor4(1, 0, 0, 1)); var theta = 2 * Math.PI * lob.Rand.NextDouble(); Func <Vector2, Vector2> motionRule = pos => pos + new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)); lob.Enemies.Add(new Unit(lob, drawOptions, 1, motionRule)); } }
private void MoveAlliesShells(LoB lob) { foreach (var s in lob.AlliesShells) { s.Move(); } if (lob.AlliesShells.Any()) { for (var i = lob.AlliesShells.Count - 1; 0 <= i; i--) { var x = lob.AlliesShells[i].DrawOptions.Position.X; var y = lob.AlliesShells[i].DrawOptions.Position.Y; if (x < -100 || lob.Width + 100 < x || y < -100 || lob.Height + 100 < y) { lob.AlliesShells.RemoveAt(i); } } } }
private void MoveAllies(LoB lob) => lob.Allies.Move();
private void DrawAllies(LoB lob, RenderTarget target) => lob.Allies.Draw(target);
public AlliesLine(LoB game) { Game = game; Units = new List <Unit>(); UnitAdditionQueue = new Queue <Unit>(); }