private void UpdateMission() { if (_mission == null) return; var world = Globals.World.Value; var playerShip = world.GetWob<Ship>(world.GetPlayerShipID(Globals.PlayerID)); switch (_mission.State) { case MissionState.Open: if (_mission.AssignVolume.Intersects(playerShip.Pose.Location)) { _mission.Offer(); var missionDialog = new MissionDialog("MissionOfferDialog", 300); missionDialog.SetMessage(_mission.AssignMessage); missionDialog.ShowConfirmButton("Accept", _mission.Assign); missionDialog.ShowCancelButton("Refuse", _mission.Suppress); missionDialog.Show(); } break; case MissionState.Offering: break; case MissionState.Suppressed: break; case MissionState.Assigned: if (_mission.CompleteVolume.Intersects(playerShip.Pose.Location)) { _mission.Complete(); var missionDialog = new MissionDialog("MissionCompleteDialog", 300); missionDialog.SetMessage(_mission.CompleteMessage); missionDialog.ShowConfirmButton("OK", () => { }); missionDialog.Show(); } break; case MissionState.Completed: break; default: throw new NotImplementedException(); } }
private void SyncWithServerLoop() { try { while (!_exiting) SyncWithServer(); } catch (Exception e) { var errorDialog = new MessageDialog("Communication error", 600); errorDialog.SetMessage("An error occurred when communicating with the server.\n" + e.Message); errorDialog.ShowConfirmButton("OK, too bad!", () => { }); errorDialog.Show(); } }