/// <summary> /// This method will create a projectile object or beam object /// </summary> /// <param name="cc"></param> /// <param name="tank"></param> private void ProjectileCreation(ControlCommand cc, Tank tank) { //figure out what kind of weapon String fireStatus = cc.GetFire(); //Get aim direction Vector2D turretDirection = cc.GetTurretDirection(); if (fireStatus == "main")// Normal attack { //Check fire cooldown if (!tank.HasFired) { //Create the new projectile in a thread safe manner lock (serverWorld.Projectiles) { Projectile proj = new Projectile(tank.GetID(), tank.Location, turretDirection, tank.GetID()); //Tank has fired so begin cooldown tank.HasFired = true; serverWorld.Projectiles[proj.getID()] = proj; } } } //This is a beam attack else if (fireStatus == "alt") { //Check if a tank has picked up a powerup if (tank.PowerUpNumber > 0) { //Create a new beam Beam beam = new Beam(tank.Location, turretDirection, tank.GetID(), tank.GetID()); //Decrement tanks powerup number tank.UsePowerup(); //Add beam to world to send message to clients lock (serverWorld.Beams) { serverWorld.Beams.Add(beam.GetID(), beam); } //Check if the beam kills any tanks lock (serverWorld.Tanks) { foreach (Tank t in serverWorld.Tanks.Values) { if (Intersects(beam.Origin, beam.Direction, t.Location, 30)) { t.HealthLevel = 0; t.HasDied = true; //increment player score serverWorld.Tanks[beam.GetOwner()].Score++; } } } } } }