---创建房间View对象 local GameListView = import(".GameListView") local CreateRoomView = {} local M = CreateRoomView function CreateRoomView.new(index) setmetatable(M, { __index = BaseWindow }) local self = setmetatable({}, { __index = M }) self.class = "CreateRoomView" self._animation = false --self._full = true self._scale = true self._full_offset = false self._modeMap = {} self.selectedIndex = index self._close_destroy = true self._put_map = false self._new_hide = false self._queue = false -- self:init("ui://Lobby/Win_CreateRoom") self:init("ui://Lobby/CreatePlay") return self end function M:init(url) BaseWindow.init(self, url) self.gl_view = GameListView.new(self._view, 1, 1, nil, function(mode_data) self:OnCreateRoom(mode_data) end, true, { _lobby_create = true }) --self.gl_view.IsHallGame=true end local tuoguanTimeList = { 10, 30, 60, 120, 180, 240, 300 } -- 显示玩法体力值配置 function M:OnCreateRoom(mode_data) if mode_data.type == 0 then local tex_times = self._view:GetChild("tex_times") -- 通用设置 local com_editSetting = self.gl_view:GetModeData().data._config:GetChild("com_editSetting") self.cGps = com_editSetting:GetController("cGps") self.cTuoguan = com_editSetting:GetController("cTuoguan") self.cJiesan = com_editSetting:GetController("cJiesan") self.cGongneng = com_editSetting:GetController("cGongneng") self.cChat = com_editSetting:GetController("cChat") self.cMisslie = com_editSetting:GetController("cMisslie") self.hpData = {} local mode = mode_data.data --点击建房按钮后保存当前游戏的config local btn_ok = self._view:GetChild("btn_ok") local _data = mode:SelectedConfigData() _data.game_id = mode.game_data.game_id _data.isNonnegative = 0 _data.hp_no_limit = 0 _data.tuoguan = true _data.tuoguan_active_timeIndex = 0 _data.tuoguan_result_type = 0 _data.isHidden = 0 _data.isvip = 0 -- GPS设置 local dis = 0 if self.cGps.selectedIndex == 0 then dis = 100 elseif self.cGps.selectedIndex == 1 then dis = 500 elseif self.cGps.selectedIndex == 2 then dis = 0 end _data.GPSDetection = dis -- 托管 local time = 0 if self.cTuoguan.selectedIndex == 1 then time = 30 elseif self.cTuoguan.selectedIndex == 2 then time = 60 elseif self.cTuoguan.selectedIndex == 3 then time = 120 end _data.tuoguan_active_time = time -- 解散 self.hpData.JieShan = self.cJiesan.selectedIndex + 1 -- 功能 self.hpData.GongNeng = self.cGongneng.selectedIndex + 1 -- 开启聊天 self.hpData.BanChat = self.cChat.selectedIndex -- 开启表情互动 self.hpData.BanMissile = self.cMisslie.selectedIndex local hpType = mode.game_data.hpType self.hpData.limitInRoom = 0 self.hpData.limitPlay = 0 self.hpData.limitloot = 0 self.hpData.robot_room = 0 self.hpData.type = self._type self.hpData.limitPump = self._limitPump local hpOnOff = 0 if hpType > 1 and hpOnOff == 1 then if self.hpData.limitInRoom < self.hpData.limitPlay then ViewUtil.ErrorMsg(self._root_view, -9, "进入限制必须大于等于退出限制") return end if self.hpData.limitPlay == 0 then ViewUtil.ErrorMsg(self._root_view, -9, "退出房间限制不能为0") return end end local times = tonumber(tex_times.text) self.hpData.times = ad2d(tonumber(times)) self.hpData.tex_times_room = 1 self.hpData.basePump = 0 self.hpData.rewards_list = {} self.hpData.rewards_type = 1 self.hpData.rewardValueType = 1 self.hpData.xipai_rewardType = 1 self.hpData.xipai_rewardValueType = 1 self.hpData.anchou_rewardType = 1 self.hpData.anchou_rewardValueType = 1 if self.hpData.rewardValueType == 1 then self.hpData.rewards_val = 100 else self.hpData.rewards_val = ad2d(10000) end if self.hpData.xipai_rewardValueType == 1 then self.hpData.xipai_rewards_val = 100 else self.hpData.xipai_rewards_val = ad2d(10000) end if self.hpData.anchou_rewardValueType == 1 then self.hpData.anchou_rewards_val = 100 else self.hpData.anchou_rewards_val = ad2d(10000) end local com_editSetting = self._view:GetChild("tex_name") local tex_name = self._view:GetChild("tex_name") local name = " " -- print("jefe:") pt(self.hpData) ---- print("OnCreateRoom================") --pt(_data) if not _data["stamina"] then _data["stamina"] = 0 end local user_id = DataManager.SelfUser.account_id local config_data = {} local game_id = mode.game_data.game_id config_data["game_id"] = game_id config_data["version"] = mode.game_data.version config_data["config"] = _data Utils.SaveLocalFile(user_id, json.encode(config_data)) local loddyCtr = ControllerManager.GetController(LoddyController) -- 对强制开启gps的玩法进行判断 if not DataManager.SelfUser.location then DataManager.SelfUser.location = Location.new() end if _data["GPSDetection"] and _data["GPSDetection"] > 0 and DataManager.SelfUser.location:Location2String() == "" then ViewUtil.ErrorTip(nil, "正在获取GPS定位,请稍候重试。") get_gps() return end ViewUtil.ShowModalWait(self._root_view, "正在创建房间...") loddyCtr:CreateRoom(game_id, { _data = _data, hpData = self.hpData, name = name }, function(res) self:__OnCreateRoomAction(res) end) end end function M:__OnCreateRoomAction(response) ViewUtil.CloseModalWait() if (response.ReturnCode == -2) then return end if (response.ReturnCode ~= 0) then ViewUtil.ErrorTip(response.ReturnCode, "创建房间失败") return end self:Destroy() if self.onCeateRoom then self.onCeateRoom() end end function M:Destroy() self.gl_view:Destroy() BaseWindow.Destroy(self) end return M