public unsafe bool HandlePacket(ENetPeer *peer, byte[] data, Game game) { //Builds team info var screenInfo = new LoadScreenInfo(game.getPlayers()); bool pInfo = PacketHandlerManager.getInstace().sendPacket(peer, screenInfo, Channel.CHL_LOADING_SCREEN); //For all players send this info bool bOk = false; foreach (var player in game.getPlayers()) { var loadName = new LoadScreenPlayerName(player); var loadChampion = new LoadScreenPlayerChampion(player); bool pName = PacketHandlerManager.getInstace().sendPacket(peer, loadName, Channel.CHL_LOADING_SCREEN); bool pHero = PacketHandlerManager.getInstace().sendPacket(peer, loadChampion, Channel.CHL_LOADING_SCREEN); bOk = (pName && pHero); if (!bOk) { break; } } return(pInfo && bOk); }
public override bool HandlePacket(Peer peer, byte[] data) { // Builds team info e.g. first UserId set on Blue has PlayerId 0 // increment by 1 for each added player var screenInfo = new LoadScreenInfo(_playerManager.GetPlayers()); bool pInfo = _game.PacketHandlerManager.sendPacket(peer, screenInfo, Channel.CHL_LOADING_SCREEN); // Distributes each players info by UserId bool bOk = false; foreach (var player in _playerManager.GetPlayers()) { // Giving the UserId in loading screen a name var loadName = new LoadScreenPlayerName(player); // Giving the UserId in loading screen a champion var loadChampion = new LoadScreenPlayerChampion(player); bool pName = _game.PacketHandlerManager.sendPacket(peer, loadName, Channel.CHL_LOADING_SCREEN); bool pHero = _game.PacketHandlerManager.sendPacket(peer, loadChampion, Channel.CHL_LOADING_SCREEN); bOk = (pName && pHero); if (!bOk) { break; } } return(pInfo && bOk); }
public bool HandlePacket(Peer peer, byte[] data) { //Builds team info var screenInfo = new LoadScreenInfo(_playerManager.GetPlayers()); bool pInfo = _game.PacketHandlerManager.sendPacket(peer, screenInfo, Channel.CHL_LOADING_SCREEN); //For all players send this info bool bOk = false; foreach (var player in _playerManager.GetPlayers()) { var loadName = new LoadScreenPlayerName(player); var loadChampion = new LoadScreenPlayerChampion(player); bool pName = _game.PacketHandlerManager.sendPacket(peer, loadName, Channel.CHL_LOADING_SCREEN); bool pHero = _game.PacketHandlerManager.sendPacket(peer, loadChampion, Channel.CHL_LOADING_SCREEN); bOk = (pName && pHero); if (!bOk) { break; } } return(pInfo && bOk); }
public void NotifyLoadScreenInfo(int userId, List <Pair <uint, ClientInfo> > players) { var screenInfo = new LoadScreenInfo(players); _packetHandlerManager.SendPacket(userId, screenInfo, Channel.CHL_LOADING_SCREEN); }
private void UpdateLoadUnfo(LoadScreeResutType _result, LevelModules _module, float _progress) { if (loadScreenInfo == null) { loadScreenInfo = new LoadScreenInfo(gameControllers.SceneController.CurrentScreen, ScreenType); } if (IsInitComplite) { Console.LogWarningFormat(ConsoleFilter.GameController, "Incorrect call UpdateLoadUnfo, IsInitComplite = true: {0}, {1}, {2}", _result, _module, _progress); return; } loadScreenInfo.UpdateInfo(_result, _module, _progress); gameControllers.SwichScreenController.CallBackForMainMenuScreen(_result, _module, _progress); switch (_module) { case LevelModules.UI: if (_result == LoadScreeResutType.Done) { UI = gameControllers.MainUI.ScreenUI as IGameUI; if (UI == null) { Console.LogError(ConsoleFilter.MainController, "Fail Get IMainMenuUI"); break; } UI.SetGameControoler(this); UI.EventCreatingTurret -= SelectObject.CreatingTurret; UI.EventCancelCreateTurret -= SelectObject.CancelCreatingTurret; UI.CreateRobotRequest -= CreateRobotRequest; UI.CreateTurretRequest -= CreateTurretRequest; UI.RemoveBuildObjRequest -= RemoveBuildObjRequest; UI.EventCreatingTurret += SelectObject.CreatingTurret; UI.EventCancelCreateTurret += SelectObject.CancelCreatingTurret; UI.CreateRobotRequest += CreateRobotRequest; UI.CreateTurretRequest += CreateTurretRequest; UI.RemoveBuildObjRequest += RemoveBuildObjRequest; SelectObject.SelectPlatformForTurret -= UI.SelectPlatformForTurret; SelectObject.CancelSelectPlatformForTurret -= UI.CancelCreateTurret; SelectObject.SelectPlatformForTurret += UI.SelectPlatformForTurret; SelectObject.CancelSelectPlatformForTurret -= UI.CancelCreateTurret; } break; case LevelModules.Resouces: commandQueue.Enqueue(() => { InstansingResource(); }); break; default: break; } if (IsInitComplite) { ulong timeActionId = gameControllers.TimeActionContoller.AddTimeAction((obj) => { WaitStartValues(); return(true); }, null, 1.0f); } }
/* * This scans the loading screen image untill it finds a pixel which is not black. Then it * starts from the middle of the image (that is, the middle height wise) and works upwards until it finds * a black pixel, denoting a safe bottom point of the champion image. * * Then, starting from the safe bottom point, it starts upwards again untill it finds a pixel that is non-black * and notes the location of the pixel in the y frame. * * It then captures that area with a rectangle using the start point and the known bottom point. */ public void parseLoadingScreen() { try { Image b = form.windowImage; loadScreenInfo = new LoadScreenInfo(); LoadScreenInfo lsi = loadScreenInfo; lsi.minX = b.Width - 1; lsi.maxX = 0; lsi.minXBot = b.Width - 1; lsi.maxXBot = 0; bool foundNonBlack = false; for (int x = 5; x < b.Width - 5; x++) { var c = ((Bitmap)b).GetPixel(x, b.Height / 4); if (c.B != 0 || c.R != 0 || c.G != 0) { if (x < lsi.minX) lsi.minX = x; if (x > lsi.maxX) lsi.maxX = x; foundNonBlack = true; } c = ((Bitmap)b).GetPixel(x, 3 * b.Height / 4); if (c.B != 0 || c.R != 0 || c.G != 0) { if (x < lsi.minXBot) lsi.minXBot = x; if (x > lsi.maxXBot) lsi.maxXBot = x; } } if (lsi.minX >= lsi.maxX || lsi.minXBot >= lsi.maxXBot || !foundNonBlack) { loadScreenInfo = null; return; } //find a safe bottom point int bot = b.Height / 2; for (int y = b.Height / 2; y >= 0; y--) { var c = ((Bitmap)b).GetPixel(lsi.minX + 20, y); if (c.B == 0 && c.R == 0 && c.G == 0) { bot = y; break; } } //get the champion heights lsi.minY = b.Height - 1; lsi.maxY = 0; for (int y = 5; y < bot; y++) { var c = ((Bitmap)b).GetPixel(lsi.minX + 20, y); if (c.B != 0 || c.R != 0 || c.G != 0) { if (y < lsi.minY) lsi.minY = y; if (y > lsi.maxY) lsi.maxY = y; } } if (lsi.minY >= lsi.maxY) { loadScreenInfo = null; return; } lsi.scale = (lsi.maxY - lsi.minY) / 341.0; lsi.topChampionCount = (int)((lsi.maxX - lsi.minX) / (185 * lsi.scale - 5)); lsi.botChampionCount = (int)((lsi.maxXBot - lsi.minXBot) / (185 * lsi.scale - 5)); if (lsi.topChampionCount <= 0 || lsi.botChampionCount <= 0) { loadScreenInfo = null; return; } lsi.championWidth = (int)Math.Round(190 * lsi.scale); lsi.championHeight = (int)Math.Round(341 * lsi.scale); lsi.xpadding = (int)Math.Round(10 * lsi.scale); lsi.topPadding = lsi.minY; //System.Diagnostics.Debug.WriteLine("Top champions:" + lsi.topChampionCount); //System.Diagnostics.Debug.WriteLine("Bottom champions:" + lsi.botChampionCount); summonerInfo[0] = new SummonerInfo[lsi.topChampionCount]; summonerInfo[1] = new SummonerInfo[lsi.botChampionCount]; form.scriptControl.log("LoadScreen: " + lsi.topChampionCount + " (top) " + lsi.topChampionCount + " (bot)"); } catch (Exception e) { sc.log("[ERROR] (" + e.Source + "): " + e.Message + "\n" + e.StackTrace); throw; } }