local DemoFightSettingUI = class("DemoFightSettingUI", BaseUI) function DemoFightSettingUI:isFullScreen() return false end function DemoFightSettingUI:getPrefabPath() return "assets/prefabs/ui/gm/demo_fight_setting_ui.prefab" end function DemoFightSettingUI:onLoadRootComplete() self._baseRootCanvas.sortingOrder = 30001 -- 比develop面板高一点 self.atkInfo, self.defInfo = ModuleManager.DevToolManager:getCacheDemoFightInfo() self.atkInfo = self.atkInfo or {} self.defInfo = self.defInfo or {} self:_display() self:_addListeners() end function DemoFightSettingUI:_display() local uiMap = self.root:genAllChildren() uiMap["demo_fight_setting_ui.ok_btn.Text"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "开始战斗" uiMap["demo_fight_setting_ui.def_hero_node.title"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "敌方阵容" uiMap["demo_fight_setting_ui.atk_hero_node.title"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "我方阵容" uiMap["demo_fight_setting_ui.ok_btn_2.Text"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "直接使用demofight配置战斗" uiMap["demo_fight_setting_ui.clear_btn.Text"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "清除选定阵容" if not self.defCells then self.defCells = {} self.atkCells = {} for i = 1, 5 do self.defCells[i] = CellManager:addCellComp(uiMap["demo_fight_setting_ui.def_hero_node.Image_" .. i .. ".hero_cell"], GConst.TYPEOF_LUA_CLASS.HERO_CELL) self.atkCells[i] = CellManager:addCellComp(uiMap["demo_fight_setting_ui.atk_hero_node.Image_" .. i .. ".hero_cell"], GConst.TYPEOF_LUA_CLASS.HERO_CELL) end end for i = 1, 5 do if self.atkInfo[i] then if self.atkInfo[i].ishero == 1 then self.atkCells[i]:refreshWithHeroId(self.atkInfo[i].heroid, self.atkInfo[i].level, self.atkInfo[i].as or 0) else self.atkCells[i]:refreshWithMonsterId(self.atkInfo[i].heroid) end else self.atkCells[i]:refreshEmpty() end if self.defInfo[i] then if self.defInfo[i].ishero == 1 then self.defCells[i]:refreshWithHeroId(self.defInfo[i].heroid, self.defInfo[i].level, self.defInfo[i].as or 0) else self.defCells[i]:refreshWithMonsterId(self.defInfo[i].heroid) end else self.defCells[i]:refreshEmpty() end end end function DemoFightSettingUI:_addListeners() local uiMap = self.root:genAllChildren() uiMap["demo_fight_setting_ui.close_btn"]:addClickListener(function() self:closeUI() end) uiMap["demo_fight_setting_ui.ok_btn"]:addClickListener(function() ModuleManager.DevToolManager:cacheDemoFightInfo(self.atkInfo, self.defInfo) if table.nums(self.atkInfo) <= 0 or table.nums(self.defInfo) <= 0 then Logger.logError("对战双方阵容缺失") return end ModuleManager.BattleManager:playBattle(ModuleManager.BattleManager.BATTLE_TYPE.DEMO) end) uiMap["demo_fight_setting_ui.ok_btn_2"]:addClickListener(function() ModuleManager.DevToolManager:cacheDemoFightInfo(self.atkInfo, self.defInfo, true) ModuleManager.BattleManager:playBattle(ModuleManager.BattleManager.BATTLE_TYPE.DEMO) end) uiMap["demo_fight_setting_ui.clear_btn"]:addClickListener(function() self.atkInfo = {} self.defInfo = {} ModuleManager.DevToolManager:cacheDemoFightInfo(self.atkInfo, self.defInfo) self:_display() end) if self.defCells then for i, cell in ipairs(self.defCells) do cell:addClickListener(function() UIManager:showUI("app/ui/gm/hero_choose_ui", {heroInfo = clone(self.defInfo[i]), callback = function(newInfo) if newInfo.heroid <= 0 then newInfo = nil end self.defInfo[i] = newInfo self:_display() end}) end) end end if self.atkCells then for i, cell in ipairs(self.atkCells) do cell:addClickListener(function() UIManager:showUI("app/ui/gm/hero_choose_ui", {heroInfo = clone(self.atkInfo[i]), callback = function(newInfo) if newInfo.heroid <= 0 then newInfo = nil end self.atkInfo[i] = newInfo self:_display() end}) end) end end end return DemoFightSettingUI