Beispiel #1
0
        /// <summary>
        /// This method updates all of the beams by checking for collisions with each tank
        /// </summary>
        public static void UpdateBeams()
        {
            foreach (Beam b in TheWorld.Beams.Values.ToList())
            {
                //Extra booleon to make sure that it only increments the owner shot record once
                bool shotHit = false;

                foreach (Tank t in TheWorld.Tanks.Values)
                {
                    if (!shotHit)
                    {
                        TheWorld.TankIncrementShotsHit(b.OwnerID);
                        shotHit = true;
                    }

                    if (CollisionBeamTank(b, t))
                    {
                        TheWorld.TankBeamDamage(t.ID, b.ID);
                    }
                }


                //If the beam hasn't already been around for one frame it is removved from the game.
                if (!b.Spawned)
                {
                    TheWorld.BeamSetSpawnedTrue(b.ID);
                }
                else
                {
                    TheWorld.BeamRemove(b.ID);
                    TheWorld.TankDecrementPowerUps(b.OwnerID);
                }
            }
        }