示例#1
0
 private void MoveEnemies(LoB lob)
 {
     foreach (var u in lob.Enemies)
     {
         u.Move();
     }
 }
示例#2
0
        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);
            }
        }
示例#3
0
 private void DrawEnemiesShells(LoB lob, RenderTarget target)
 {
     foreach (var s in lob.EnemiesShells)
     {
         s.Draw(target);
     }
 }
示例#4
0
 private void DrawNeutrals(LoB lob, RenderTarget target)
 {
     foreach (var u in lob.Neutrals)
     {
         u.Draw(target);
     }
 }
示例#5
0
        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);
            }
        }
示例#6
0
 private void DrawEnemies(LoB lob, RenderTarget target)
 {
     foreach (var u in lob.Enemies)
     {
         u.Draw(target);
     }
 }
示例#7
0
 private void ShootEnemiesShells(LoB lob)
 {
     foreach (var u in lob.Enemies)
     {
         u.Shoot();
     }
 }
示例#8
0
 private void ShootAlliesShells(LoB lob)
 {
     foreach (var u in lob.Allies.Units)
     {
         u.Shoot();
     }
 }
示例#9
0
 /// <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;
 }
示例#10
0
 /// <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;
 }
示例#11
0
 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));
     }
 }
示例#12
0
        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);
                    }
                }
            }
        }
示例#13
0
 private void MoveAllies(LoB lob)
 => lob.Allies.Move();
示例#14
0
 private void DrawAllies(LoB lob, RenderTarget target)
 => lob.Allies.Draw(target);
示例#15
0
 public AlliesLine(LoB game)
 {
     Game              = game;
     Units             = new List <Unit>();
     UnitAdditionQueue = new Queue <Unit>();
 }