public async Task ScanShipLocationForLoot(AuthorizationTokenContainer tokenContainer, SelectedShipContainer selectedShipContainer) { GetPlayerByAccessTokenResponse playerByAccessTokenResponse = _authService.GetPlayerByAccessToken(tokenContainer.Token); if (playerByAccessTokenResponse.Success && playerByAccessTokenResponse.Player.IsAdmin == true) { GetShipsByPlayerIdResponse serviceResult = _gameService.GetShipByPlayerId(playerByAccessTokenResponse.Player.Id, selectedShipContainer.ShipId); if (serviceResult.Success) { Ship ship = serviceResult.Ships.First(); List <SpaceLoot> loot = _lootService.GetAllSpaceLoot(ship.X, ship.Y, ship.Z); LootScanResponse scanResponse = new LootScanResponse(); scanResponse.X = ship.X; scanResponse.Y = ship.Y; scanResponse.Z = ship.Z; if (loot.Count > 0) { scanResponse.SpaceLoots = loot; } else { scanResponse.SpaceLoots = null; } Clients.Caller.ReceiveLootScanResponse(scanResponse); } else { await Clients.Caller.ReceiveError(new ErrorFromServer("Could not retrieve the ship you are piloting for object placement or selection purposes.")); } } else { await Clients.Caller.ReceiveError(new ErrorFromServer("Loot spawning is is only available to administrators.")); } }
private static void DisplayLootScanResults(LootScanResponse lootScanResponse) { var scanResultWindow = new ScanResultWindow(MainConsole.Width / 2, MainConsole.Height / 2, MainConsole); MainConsole.Children.Add(scanResultWindow); scanResultWindow.TitleAlignment = HorizontalAlignment.Center; scanResultWindow.Title = "Loot scan results"; scanResultWindow.CanDrag = true; scanResultWindow.IsVisible = true; scanResultWindow.UseKeyboard = true; scanResultWindow.CenterWithinParent(); scanResultWindow.SetLoot(lootScanResponse); }
public void SetLoot(LootScanResponse lootScanResponse) { if (lootScanResponse.SpaceLoots != null && lootScanResponse.SpaceLoots.Count > 0) { ListBox lootList = new ListBox(_scanResultConsole.Width - 4, _scanResultConsole.Height - 4); lootList.Position = new Point(2, 2); lootList.IsVisible = true; lootList.IsScrollBarVisible = true; foreach (var item in lootScanResponse.SpaceLoots) { foreach (var shipmodule in item.ShipModules) { lootList.Items.Add(shipmodule); } } _scanResultConsole.Add(lootList); lootList.MouseButtonClicked += LootList_MouseButtonClicked; _scanResultConsole.AddTakeAllButton(); } else { _scanResultConsole.Print(2, 2, "Scans did not reveal anything useful."); } }