/// <summary> /// Send player commands to server. /// </summary> /// <param name="cmd"></param> static void SendPlayerCommand(PilotCommandType cmd) { PilotCommand pcmd = new PilotCommand(); pcmd.command = cmd; _client.PilotRequest(pcmd); }
public override string Command(PilotCommand command, List <string> args) { AISeaUnitSpawn shipSpawn = (AISeaUnitSpawn)unitSpawn; switch (command) { case PilotCommand.North: waypoint.GetTransform().position = actor.transform.position + new Vector3(0, 0, 2000); shipSpawn.MoveTo(waypoint); return("Ship moving 2k North."); case PilotCommand.East: waypoint.GetTransform().position = actor.transform.position + new Vector3(2000, 0, 0); shipSpawn.MoveTo(waypoint); return("Ship moving 2k East."); case PilotCommand.South: waypoint.GetTransform().position = actor.transform.position + new Vector3(0, 0, -2000); shipSpawn.MoveTo(waypoint); return("Ship moving 2k South."); case PilotCommand.West: waypoint.GetTransform().position = actor.transform.position + new Vector3(-2000, 0, 0); shipSpawn.MoveTo(waypoint); return("Ship moving 2k West."); default: return(base.Command(command, args)); } }
public override string Command(PilotCommand command, List <string> args) { GroundUnitSpawn groundSpawn = (GroundUnitSpawn)unitSpawn; switch (command) { case PilotCommand.North: waypoint.GetTransform().position = actor.transform.position + new Vector3(0, 0, 500); groundSpawn.MoveTo(waypoint); return("Tank moving 500m North!"); case PilotCommand.East: waypoint.GetTransform().position = actor.transform.position + new Vector3(500, 0, 0); groundSpawn.MoveTo(waypoint); return("Tank moving 500m East!"); case PilotCommand.South: waypoint.GetTransform().position = actor.transform.position + new Vector3(0, 0, -500); groundSpawn.MoveTo(waypoint); return("Tank moving 500m South!"); case PilotCommand.West: waypoint.GetTransform().position = actor.transform.position + new Vector3(-500, 0, 0); groundSpawn.MoveTo(waypoint); return("Tank moving 500m West!"); case PilotCommand.Stop: groundSpawn.ParkNow(); return("Tank stopping."); default: return(base.Command(command, args)); } }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Callback Dispatch Comments: PWB: Callbacks to the controller from the JetterCommManager MUST be delgated to the WPF thread // that handles the UI for the _game_stage - otherwise the WPF game_stage objects are not accessable // the program will crash. So we use a pattern that bundles up the arguments and has // the WPF engine call a "dispatch method" with the arguments on the UI thread. // MSDN BeginInvoke exanple info: http://msdn.microsoft.com/en-us/library/ms741870.aspx // Also intresting: http://stackoverflow.com/questions/1207832/wpf-dispatcher-begininvoke-and-ui-background-threads /////////////////////////////////////////////////////////////////////// public void PilotRequest(string from_pilot, PilotCommand pilot_command) { // NOTE: See "Callback Dispatch Comments" for explanation of the dispatch pattern and why it is needed. // Bundle up the arguments. PilotRequest_DispatchDelegateArgs args = new PilotRequest_DispatchDelegateArgs(from_pilot, pilot_command); // Delegate the work such that the UI thread of the game_stage calls the XXX_Dispatch() method // to do the actual work. _game_stage.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new PilotRequest_DispatchDelegate(PilotRequest_Dispatch), this, new object[] { args }); }
public void Should_Add_Command_If_Provided(PilotCommand command) { // Given var fixture = new FastlanePilotFixture(); fixture.Settings.Command = command; // When var result = fixture.Run(); // Then Assert.Equal($"pilot {command.ToString().ToLower()}", result.Args); }
public override string Command(PilotCommand command, List <string> args) { AIDroneCarrierSpawn carrierSpawn = (AIDroneCarrierSpawn)unitSpawn; switch (command) { case PilotCommand.LaunchAll: carrierSpawn.LaunchDrones(); return("Launching all drones!"); default: return(base.Command(command, args)); } }
public override string Command(PilotCommand command, List <string> args) { AICarrierSpawn carrierSpawn = (AICarrierSpawn)unitSpawn; switch (command) { case PilotCommand.LaunchAll: carrierSpawn.LaunchAllAircraft(); return("Scrambling all aircraft!"); default: return(base.Command(command, args)); } }
public virtual string Command(PilotCommand command, List <string> args) { switch (command) { case PilotCommand.Engage: unitSpawn.SetEngageEnemies(true); return("Engaging!"); case PilotCommand.Disengage: unitSpawn.SetEngageEnemies(false); return("Disengaging!"); default: return("This vehicle doesnt support that command."); } }
public override string Command(PilotCommand command, List <string> args) { ArtilleryUnitSpawn artySpawn = (ArtilleryUnitSpawn)unitSpawn; switch (command) { case PilotCommand.Attack: artySpawn.ParkNow(); Actor target = GetActor(args[0]); if (target != null) { waypoint.GetTransform().position = target.position; artySpawn.FireOnWaypoint(waypoint, 1); return("Attacking " + target.name + "!"); } else { return("No such target " + args[0] + " exists."); } default: return(base.Command(command, args)); } }
public PilotRequest_DispatchDelegateArgs(string from_pilot_, PilotCommand pilot_command_) { from_pilot = from_pilot_; pilot_command = pilot_command_; }
public override string Command(PilotCommand command, List <string> args) { AIAircraftSpawn aircraftSpawn = (AIAircraftSpawn)unitSpawn; switch (command) { case PilotCommand.Attack: Actor target = GetActor(args[0]); if (target != null) { aircraftSpawn.AttackTarget(GetUnitReference(target)); return("Attacking " + target.name + "!"); } else { return("No such target " + args[0] + " exists."); } case PilotCommand.Cancel: aircraftSpawn.CancelAttackTarget(); return("Canceling attack."); case PilotCommand.Orbit: Actor target2 = GetActor(args[0]); if (target2 != null) { waypoint.GetTransform().position = target2.position; aircraftSpawn.SetOrbitNow(waypoint, 5000, 5000); return("Orbiting " + target2.name + "!"); } else { return("No such target " + args[0] + " exists."); } case PilotCommand.Formation: Actor target3 = GetActor(args[0]); if (target3 != null) { aircraftSpawn.FormOnPilot(GetUnitReference(target3)); return("Following " + target3.name + "!"); } else { return("No such target " + args[0] + " exists."); } case PilotCommand.TakeOff: aircraftSpawn.TakeOff(); return("Taking off!"); case PilotCommand.RTB: aircraftSpawn.RearmAt(new AirportReference(args[0])); return("Landing!"); case PilotCommand.A2ARefuel: RefuelPlane rp = FindRefuelTanker(); if (rp != null) { aircraftSpawn.RefuelWithUnit(GetUnitReference(rp.actor)); return("Refueling!"); } else { return("Found no refuel plane."); } case PilotCommand.Bomb: Actor target4 = GetActor(args[0]); if (target4 != null) { waypoint.GetTransform().position = target4.position; aircraftSpawn.BombWaypoint(waypoint, UnityEngine.Random.Range(0f, 360f), 5, aircraftSpawn.aiPilot.defaultAltitude); return("Bombing " + target4.name + "!"); } else { return("No such target " + args[0] + " exists."); } case PilotCommand.CM: aircraftSpawn.CountermeasureProgram(true, true, 3, 0.2f); return("Deploying CMs!"); case PilotCommand.Flare: aircraftSpawn.CountermeasureProgram(true, false, 3, 0.2f); return("Deploying flares!"); case PilotCommand.Chaff: aircraftSpawn.CountermeasureProgram(false, true, 3, 0.2f); return("Deploying chaff!"); case PilotCommand.JetisonEmpty: wm.MarkEmptyToJettison(); wm.JettisonMarkedItems(); return("Jettisoning empty!"); case PilotCommand.JetisonFuel: wm.MarkDroptanksToJettison(); wm.JettisonMarkedItems(); return("Jettisoning droptanks!"); case PilotCommand.Jetison: wm.MarkAllJettison(); wm.JettisonMarkedItems(); return("Jettisoning all weapons!"); case PilotCommand.Eject: actor.health.Kill(); return("Punch out!"); case PilotCommand.Kamikaze: Actor target5 = GetActor(args[0]); if (target5 != null) { if (target5.role == Actor.Roles.Ground || target5.role == Actor.Roles.GroundArmor || target5.role == Actor.Roles.Ship) { aircraftSpawn.aiPilot.gunRunMinAltitude = float.MinValue; aircraftSpawn.aiPilot.gunGroundMaxRange = 50; aircraftSpawn.aiPilot.minAltClimbThresh = float.MinValue; aircraftSpawn.aiPilot.minAltitude = float.MinValue; aircraftSpawn.aiPilot.obstacleCheckAheadTime = 0; wm.MarkAllJettison(); wm.JettisonMarkedItems(); aircraftSpawn.AttackTarget(GetUnitReference(target5)); return("BANZAI!"); } else { return("Can only kamikaze ground targets."); } } else { return("No such target " + args[0] + " exists."); } default: return(base.Command(command, args)); } }