private void OnDestroy() { if (m_commandsPanel != null) { m_commandsPanel.Move -= OnMove; m_commandsPanel.Attack -= OnAttack; m_commandsPanel.Cancel -= OnCancel; m_commandsPanel.Auto -= OnAuto; m_commandsPanel.Wall -= OnWall; m_commandsPanel.Bomb -= OnBomb; m_commandsPanel.Spawner -= OnSpawner; m_commandsPanel.Split -= OnSplit; m_commandsPanel.Split4 -= OnSplit4; m_commandsPanel.Grow -= OnGrow; m_commandsPanel.Diminish -= OnDiminish; // m_commandsPanel.Closed -= OnClosed; } if (m_playersBot != null) { m_playersBot.Reset(); } }
private void ProcessRequest(ClientRequest request, Action <ClientRequest> callback) { Cmd cmd = request.Cmd; if (cmd != null) { if (cmd.Code == CmdCode.GrantBotCtrl) { m_bots = new IBotController[m_game.PlayersCount]; for (int i = 0; i < m_bots.Length; ++i) { Player player = m_game.GetPlayer(i); if (player.IsActiveBot) { IBotController bot = MatchFactoryCli.CreateBotController(player, m_taskEngines[i], new DefaultStrategy()); bot.Init(); m_bots[i] = bot; } } callback(request); } else if (cmd.Code == CmdCode.DenyBotCtrl) { m_bots = new IBotController[m_game.PlayersCount]; for (int i = 0; i < m_bots.Length; ++i) { IBotController bot = m_bots[i]; if (bot != null) { bot.Reset(); } } m_bots = null; callback(request); } else { IVoxelDataController dc = m_game.GetVoxelDataController(request.PlayerIndex, cmd.UnitIndex); if (cmd.Code != CmdCode.Move || dc == null) { if (dc == null) { request.Cmd.ErrorCode = CmdResultCode.Fail_NoUnit; } else { request.Cmd.ErrorCode = CmdResultCode.Fail_NotSupported; } SubmitResponse(request); } else { CoordinateCmd coordinateCmd = (CoordinateCmd)cmd; Debug.Assert(coordinateCmd.Coordinates.Length > 1); IPathFinder pathFinder = m_pathFinders[request.PlayerIndex]; #warning PathFinder should igore dataController.ControlledVoxelData pathFinder.Find(cmd.UnitIndex, -1, dc.Clone(), coordinateCmd.Coordinates, (unitIndex, path) => { coordinateCmd.Coordinates = path; request.Cmd = coordinateCmd; callback(request); }, null); } } } }