Ejemplo n.º 1
0
 /// <summary>
 /// Remove an enemy from the list of enemies
 /// </summary>
 /// <param name="index">index of the ship to remove</param>
 public void RemoveEnemy(int index)
 {
     Game.game.RandomBonus(Ships[index].Position);
     Ships.RemoveAt(index);
     UpdateBBox();
     Game.game.playerScore.CalculateScore();
 }
        public void Update(double dt, Dictionary <Guid, IShipController> controllers)
        {
            foreach (var ship in Ships)
            {
                if (!controllers.TryGetValue(ship.Uid, out var contr))
                {
                    contr = new EmptyShipController();
                }
                ship.Update(this, dt, contr);
            }

            for (int i = Ships.Count - 1; i >= 0; i--)
            {
                if (!Ships[i].Alive)
                {
                    Particles.Add(new Particle(Ships[i].Position, Ships[i].Model.ExplosionAnimation));
                    Ships[i] = Ships[Ships.Count - 1];
                    Ships.RemoveAt(Ships.Count - 1);
                }
            }

            for (int i = Particles.Count - 1; i >= 0; i--)
            {
                Particles[i].Update();
                if (Particles[i].IsFinished)
                {
                    Particles[i] = Particles[Particles.Count - 1];
                    Particles.RemoveAt(Particles.Count - 1);
                }
            }
        }
Ejemplo n.º 3
0
        AttackResult HitShip(int i)
        {
            Ships[i].Damage++;

            if (Ships[i].Damage >= Ships[i].Length)
            {
                Ships.RemoveAt(i);
                return(AttackResult.Sink);
            }
            return(AttackResult.Hit);
        }
Ejemplo n.º 4
0
        public void DestroyShip(int index)
        {
            //mark ship's tile with X and remove it from list
            Ship ship = Ships[index];

            foreach (int[] pos in ship.Position)
            {
                Board[pos[0], pos[1]] = 'X';
            }
            Ships.RemoveAt(index);
            ShipLeft = Ships.Count;
        }