diff --git a/lua_probject/base_project/Game/Controller/LoginController.lua b/lua_probject/base_project/Game/Controller/LoginController.lua index 8b47f46e..49fd8bc3 100644 --- a/lua_probject/base_project/Game/Controller/LoginController.lua +++ b/lua_probject/base_project/Game/Controller/LoginController.lua @@ -18,6 +18,7 @@ local _LocalConfigAllGame = { -- 22, 66,90 ,91 + ,92 } local FilterGame = function(games) diff --git a/lua_probject/base_project/Game/Controller/RoomController.lua b/lua_probject/base_project/Game/Controller/RoomController.lua index 4d6f29b4..b7dd0ec4 100644 --- a/lua_probject/base_project/Game/Controller/RoomController.lua +++ b/lua_probject/base_project/Game/Controller/RoomController.lua @@ -126,9 +126,20 @@ end local join_room_frame = 0 -function M:PublicJoinRoom(cmd, roomid, tem, callback, group_id, pid) - printlog("公共进入房间接口=============PublicJoinRoom") - print("test,亲友圈ID是:", group_id) +-- function M:PublicJoinRoom(cmd, roomid, tem, callback, group_id, pid) + +function M:PublicJoinRoom(data, callback) + data = data or {} + local cmd = data.cmd + local roomid = data.roomid + local is_null = data.is_null or false + local group_id = data.group_id + local pid = data.pid + local selectSeat = data.selectSeat + if not cmd or not group_id then + ViewUtil:ErrorTip("加入房间方法调用失败") + return + end -- 同一帧不重复调用 local last_frame = join_room_frame join_room_frame = Time.frameCount @@ -140,7 +151,7 @@ function M:PublicJoinRoom(cmd, roomid, tem, callback, group_id, pid) local _data = {} if cmd == Protocol.WEB_FG_MATCH_ROOM then - _data["is_null"] = tem + _data["is_null"] = is_null --获得玩法配置定位信息,如果开启了配置则必须强制有定位才能进入房间 local play = DataManager.groups:get(group_id):getPlay(pid) local pos = "" @@ -151,7 +162,14 @@ function M:PublicJoinRoom(cmd, roomid, tem, callback, group_id, pid) get_gps(nil, { _callback_lad = function(flag) if flag then - self:PublicJoinRoom(cmd, roomid, tem, callback, group_id, pid) + self:PublicJoinRoom({ + cmd = cmd, + roomid = roomid, + is_null = is_null, + group_id = group_id, + pid = pid, + selectSeat = selectSeat + }, callback) return end ViewUtil.ErrorMsg(nil, 55, "未开启gps定位,不能创建gps定位房") @@ -189,7 +207,14 @@ function M:PublicJoinRoom(cmd, roomid, tem, callback, group_id, pid) -- res.ReturnCode = -2 -- callback(res) - self:PublicJoinRoom(Protocol.WEB_FG_JOIN_ROOM, json["room_id"], tem, callback, group_id, pid) + self:PublicJoinRoom({ + cmd = Protocol.WEB_FG_JOIN_ROOM, + roomid = json["room_id"], + is_null = is_null, + group_id = group_id, + pid = pid, + selectSeat = selectSeat + }, callback) end) return end @@ -224,6 +249,7 @@ function M:PublicJoinRoom(cmd, roomid, tem, callback, group_id, pid) DataManager.SelfUser.location = Location.new() end j_data["pos"] = DataManager.SelfUser.location:Location2String() + j_data.selectSeat = selectSeat printlog("++++++++++++++++++++++++++++++++++++++++++") __ConntectGameServer(Protocol.GAME_JOIN_ROOM, room, room.server_host, j_data, function(res1) printlog("===============================-------------") diff --git a/lua_probject/base_project/Game/View/Common/BaseWindow.lua b/lua_probject/base_project/Game/View/Common/BaseWindow.lua index e654134c..3aca60e8 100644 --- a/lua_probject/base_project/Game/View/Common/BaseWindow.lua +++ b/lua_probject/base_project/Game/View/Common/BaseWindow.lua @@ -26,7 +26,7 @@ BaseWindow = { --全屏偏移 _full_offset = true, --新窗口隐藏队列 - _new_hide = true, + _new_hide = false, --模糊组件对象 _put_map = true } diff --git a/lua_probject/base_project/Game/View/FamilyViewZuo.lua b/lua_probject/base_project/Game/View/FamilyViewZuo.lua index 10b60eaf..d111f980 100644 --- a/lua_probject/base_project/Game/View/FamilyViewZuo.lua +++ b/lua_probject/base_project/Game/View/FamilyViewZuo.lua @@ -33,6 +33,7 @@ function M:init(url) --亲友圈列表 self._viewList_familyList = view:GetChild('familyList') self._viewList_familyList.itemRenderer = handler(self, self.FamilyListRenderer) + self._viewList_familyList.onClickItem:Set(handler(self,self.ClickFamilyList)) view:GetController('showList').onChanged:Set(function(context) if context.sender.selectedIndex == 0 then @@ -71,12 +72,12 @@ function M:init(url) --管理页面 view:GetChild('btn_manager').onClick:Set(function() - FamilyManagerView.new({pageType=1}) + FamilyManagerView.new({ pageType = 1 }) end) --成员页面 view:GetChild('btn_menber').onClick:Set(function() - FamilyManagerView.new({pageType=2}) + FamilyManagerView.new({ pageType = 2 }) end) --新玩法管理 @@ -111,7 +112,7 @@ function M:FamilyTableRenderer(index, obj) local head = obj:GetChild(string.format("head%s", i)) head:GetChild('btn_head').icon = "" head.onClick:Set(function(context) - self:ClickMachRoom(context, tmp) + self:ClickMachRoom(context, tmp, i) end) end obj:GetChild('icon').onClick:Set(function(context) @@ -120,6 +121,9 @@ function M:FamilyTableRenderer(index, obj) if self._view:GetController('showPlayDetail').selectedIndex == 1 then self:ClickTableShowDetail({ type = 1, info = tmp, index = index }) end + obj:GetChild('text_roundNum').text = string.format("(0/%s)", + ExtendManager.GetExtendConfig(tmp.gameId):GetGameInfo():LoadConfigOneInfo(tmp.config, tmp.hpData, "maxRound") or + 0) elseif index - #playList < #roomList then --存在的桌子 local roomInfo = roomList[index - #playList + 1] tmp = self._group:getPlay(roomInfo.pid) @@ -135,7 +139,7 @@ function M:FamilyTableRenderer(index, obj) btn:GetController('zuo').selectedIndex = 0 btn:GetChild("btn_head").icon = "ui://Family/icon_luozuo" btn.onClick:Set(function(context) - self:ClickJoinRoom(context, roomInfo) + self:ClickJoinRoom(context, roomInfo, i) end) end end @@ -145,15 +149,19 @@ function M:FamilyTableRenderer(index, obj) if self._view:GetController('showPlayDetail').selectedIndex == 1 then self:ClickTableShowDetail({ type = 2, info = roomInfo, index = index }) end + obj:GetChild('text_roundNum').text = string.format("(%s/%s)", roomInfo.round, roomInfo.times) end obj:GetController('playerNum').selectedIndex = tmp.maxPlayers - 2 obj:GetChild('text_playName').text = tmp.name - obj:GetChild('text_roundNum').text = string.format("(0/%s)", - ExtendManager.GetExtendConfig(tmp.gameId):GetGameInfo():LoadConfigOneInfo(tmp.config, tmp.hpData, "maxRound") or - 0) obj.icon = string.format("ui://Family/icon_table%s", (self.localTextDesk[tmp.gameId] or 0) + 1) end +--点击切换亲友圈 +function M:ClickFamilyList(context) + local index = context.sender.selectedIndex + self:EnterFamily(index+1) +end + --进入亲友圈 function M:EnterFamily(index_family, only) local groups = DataManager.groups.groupList @@ -192,13 +200,17 @@ function M:UpdateRoom() end --点击玩法创建桌子 -function M:ClickMachRoom(context, playinfo) +function M:ClickMachRoom(context, playinfo, selectSeat) local group = DataManager.CurrenGroup local roomCtr = ControllerManager.GetController(RoomController) - roomCtr:PublicJoinRoom( - Protocol.WEB_FG_MATCH_ROOM, - "", - true, + roomCtr:PublicJoinRoom({ + cmd = Protocol.WEB_FG_MATCH_ROOM, + roomid = "", + is_null = true, + group_id = group.id, + pid = playinfo.id, + selectSeat = selectSeat + }, function(response) if (response.ReturnCode == -1) then ViewUtil.CloseModalWait2() @@ -221,9 +233,9 @@ function M:ClickMachRoom(context, playinfo) { _flag_showTip = true }) ViewUtil.CloseModalWait2() end - end, - group.id, - playinfo.id + end + + ) end @@ -240,11 +252,11 @@ function M:ClickTableShowDetail(data) local playinfo = data.info detailView:GetChild('btn_createRoom').onClick:Set(function(context) - self:ClickMachRoom(context, data.info) + self:ClickMachRoom(context, data.info, 0) end) detailView:GetChild('btn_joinRoom').onClick:Set(function(context) - self:ClickJoinRoom(context, data.info) + self:ClickJoinRoom(context, data.info, 0) end) detailView:GetChild('btn_inviteRoom').onClick:Set(function(context) @@ -303,13 +315,19 @@ function M:JieSanRomm(groupId, roomId) end --点击桌子进入游戏 -function M:ClickJoinRoom(context, room) +function M:ClickJoinRoom(context, room, selectSeat) local group = DataManager.CurrenGroup local roomCtr = ControllerManager.GetController(RoomController) roomCtr:PublicJoinRoom( - Protocol.WEB_FG_JOIN_ROOM, - room.id, - true, + { + cmd = Protocol.WEB_FG_JOIN_ROOM, + roomid = room.id, + is_null = true, + group_id = group.id, + pid = room.pid, + selectSeat = selectSeat + }, + function(response) if (response.ReturnCode == -1) then ViewUtil.CloseModalWait2() @@ -329,9 +347,7 @@ function M:ClickJoinRoom(context, room) { _flag_showTip = true }) ViewUtil.CloseModalWait2() end - end, - group.id, - room.pid + end ) end diff --git a/lua_probject/base_project/Game/View/FamilyZuo/FamilyChooseTimeView.lua b/lua_probject/base_project/Game/View/FamilyZuo/FamilyChooseTimeView.lua new file mode 100644 index 00000000..902ad4c4 --- /dev/null +++ b/lua_probject/base_project/Game/View/FamilyZuo/FamilyChooseTimeView.lua @@ -0,0 +1,121 @@ +local FamilyChooseTimeView = {} + +local M = FamilyChooseTimeView + +function FamilyChooseTimeView.new(data, callback) + setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) + self.class = "FamilyChooseTimeView" + self._data = data + self._callback = callback + self._close_destroy = true + self:init("ui://Family/FamilyChooseTime") + return self +end + +function M:init(url) + getmetatable(M).__index.init(self, url) + + local view = self._view + self._viewList = view:GetChild('list') + self._viewList:SetVirtual() + self._viewList.itemRenderer = handler(self, self.ListRenderer) + self._viewList.onClickItem:Set(handler(self, self.ClickListItem)) + + view:GetChild('btn_confirm').onClick:Set(function() + self._callback(self._data_times[self._left_Index], self._data_times[self._right_Index]) + self:Destroy() + end) + + view:GetChild('btn_cancel').onClick:Set(function() + self:Destroy() + end) + + self:FillData() +end + +function M:InitTime() + local dataTable = os.date("*t") + dataTable.hour = 0 + dataTable.min = 0 + dataTable.sec = 0 + local timeStasmp = os.time(dataTable) + return timeStasmp +end + +function M:ClickListItem(context) + local item = context.data + local index = self._viewList:GetChildIndex(item) + 1 + if index > self._selectedIndex then + self._left_Index = self._selectedIndex + self._right_Index = index + else + self._right_Index = self._selectedIndex + self._left_Index = index + end + self._selectedIndex = index + self._viewList:RefreshVirtualList() +end + +function M:ListRenderer(index, obj) + if index >= self._left_Index - 1 and index < self._right_Index then + obj.selected = true + else + obj.selected = false + end + if index == 0 then + obj.text = "今天" + return + end + if index == 1 then + obj.text = "昨天" + return + end + obj.text = os.date("%d", self._data_times[index + 1]) +end + +function M:FillData() + local data = self._data + local days = data.days or 7 + self._data_times = {} + local dataTable = os.date("*t") + dataTable.hour = 0 + dataTable.min = 0 + dataTable.sec = 0 + local timeStasmp = os.time(dataTable) + local leftTime = data.left or timeStasmp + local rightTime = data.right or timeStasmp + for i = 1, days do + local thisTimeStamp = timeStasmp - (i - 1) * 86400 + if leftTime == thisTimeStamp then + self._left_Index = i + end + if rightTime == thisTimeStamp then + self._right_Index = i + end + table.insert(self._data_times, thisTimeStamp) + end + self._selectedIndex = self._left_Index + self._viewList.numItems = days + + + self:Show() +end + +-- 打开窗口 +function M:Show() + getmetatable(M).__index.Show(self) +end + +-- 关闭窗口 +function M:Close() + getmetatable(M).__index.Close(self) +end + +-- 销毁窗口 +function M:Destroy() + + getmetatable(M).__index.Destroy(self) +end + +return M diff --git a/lua_probject/base_project/Game/View/FamilyZuo/FamilyDissolveByRoomView.lua b/lua_probject/base_project/Game/View/FamilyZuo/FamilyDissolveByRoomView.lua new file mode 100644 index 00000000..1270b5a1 --- /dev/null +++ b/lua_probject/base_project/Game/View/FamilyZuo/FamilyDissolveByRoomView.lua @@ -0,0 +1,113 @@ +local FamilyUtilInput = import(".FamilyUtilInput") + +local FamilyDissolveByRoomView = {} + +local M = FamilyDissolveByRoomView + +function FamilyDissolveByRoomView.new(data, callback) + setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) + self.class = "FamilyDissolveByRoomView" + self._data = data + self._callback = callback + self._close_destroy = true + self:init("ui://Family/FamilyDissolveByRoom") + return self +end + +function M:init(url) + getmetatable(M).__index.init(self, url) + + local view = self._view + + self._input = view:GetChild('input_text') + FamilyUtilInput:init(self._input, view:GetChild('comp_input')) + + self._ctr_page = view:GetController('page') + view:GetChild('btn_search').onClick:Set(handler(self, self.ClickSearch)) + + view:GetChild('btn_returnPage0').onClick:Set(handler(self,self.ClickReturnPage0)) + + view:GetChild('btn_confirmDissolve').onClick:Set(handler(self, self.ClickDissolve)) + self:FillData() +end + +function M:ClickDissolve() + local _curren_msg = + MsgWindow.new( + self._root_view, + '确定要解散该房间吗?', + MsgWindow.MsgMode.OkAndCancel + ) + _curren_msg.onOk:Add( + function() + ViewUtil.ShowModalWait2(self._root_view) + local fgCtr = ControllerManager.GetController(NewGroupController) + + fgCtr:FG_RemoveRoom( + DataManager.CurrenGroup.id, + self._searchRoom.id, + function(res) + ViewUtil.CloseModalWait2() + if res.ReturnCode ~= 0 then + ViewUtil.ErrorTip(res.ReturnCode, '删除房间失败!') + return + else + ViewUtil:ErrorTip('删除房间成功!') + self:ClickReturnPage0() + end + end + ) + end + ) + _curren_msg:Show() +end + +function M:ClickSearch() + local group = DataManager.CurrenGroup + local view = self._view + for i, v in ipairs(group.rooms) do + if v.id == self._input.text then + local playInfo = group:getPlay(v.pid) + self._searchRoom = v + self._ctr_page.selectedIndex = 1 + view:GetChild('text_roomType').text = string.format("%s/%s局", v.round, v.times) + view:GetChild('text_roomName').text = playInfo.name + view:GetChild('list_player'):RemoveChildrenToPool() + for i, v1 in ipairs(v.plist) do + local obj = view:GetChild('list_player'):AddItemFromPool() + obj:GetChild('text_name').text = v1.nick + ImageLoad.Load(v1.portrait, obj:GetChild('btn_head')._iconObject) + end + return + end + end + ViewUtil:ErrorTip("没有该房间号。") +end + +function M:ClickReturnPage0() + self._searchRoom = nil + self._input.text = "" + self._ctr_page.selectedIndex = 0 +end + +function M:FillData() + self:Show() +end + +-- 打开窗口 +function M:Show() + getmetatable(M).__index.Show(self) +end + +-- 关闭窗口 +function M:Close() + getmetatable(M).__index.Close(self) +end + +-- 销毁窗口 +function M:Destroy() + getmetatable(M).__index.Destroy(self) +end + +return M diff --git a/lua_probject/base_project/Game/View/FamilyZuo/FamilyEventView.lua b/lua_probject/base_project/Game/View/FamilyZuo/FamilyEventView.lua new file mode 100644 index 00000000..a867fcc4 --- /dev/null +++ b/lua_probject/base_project/Game/View/FamilyZuo/FamilyEventView.lua @@ -0,0 +1,448 @@ +local FamilyEventView = {} + +local M = FamilyEventView + +function FamilyEventView.new(root) + setmetatable(M, { __index = root }) + local self = setmetatable({}, { __index = M }) + return self +end + +function M:AddListener() + local mgr_ctr = self._mgr_ctr + mgr_ctr._cacheEvent:Clear() + mgr_ctr:AddEventListener(GroupMgrEvent.AddPlay, handler(self, self._evtAddPlay)) + mgr_ctr:AddEventListener(GroupMgrEvent.DelPlay, handler(self, self._evtDelPlay)) + mgr_ctr:AddEventListener(GroupMgrEvent.UpdatePlay, handler(self, self._evtUpdatePlay)) + mgr_ctr:AddEventListener(GroupMgrEvent.AddRoom, handler(self, self._evtAddRoom)) + mgr_ctr:AddEventListener(GroupMgrEvent.DelRoom, handler(self, self._evtDelRoom)) + mgr_ctr:AddEventListener(GroupMgrEvent.UpdateRoom, handler(self, self._evtUpdateRoom)) + mgr_ctr:AddEventListener(GroupMgrEvent.UpdatePlayerInfo, handler(self, self._evtUpdatePlayerInfo)) + --mgr_ctr:AddEventListener(GroupMgrEvent.BeInvited, handler(self, self._evtInvited)) + mgr_ctr:AddEventListener(GroupMgrEvent.UpdateGroup, handler(self, self._evtUpdateGroup)) + mgr_ctr:AddEventListener(GroupMgrEvent.NewMailTip, handler(self, self._evtNewMailTip)) + mgr_ctr:AddEventListener(GroupMgrEvent.InviteResponse, handler(self, self._evtInviteResponse)) + mgr_ctr:AddEventListener(GroupMgrEvent.IsOpenChatRoom, handler(self, self._evtIsOpenChatRoom)) + mgr_ctr:AddEventListener(GroupMgrEvent.ChatRoomData, handler(self, self._evtChatRoomData)) + mgr_ctr:AddEventListener(GroupMgrEvent.OnNewApply, handler(self, self._evtOnNewApply)) + mgr_ctr:AddEventListener(GroupMgrEvent.OnNewRecord, handler(self, self._evtOnNewRecord)) + mgr_ctr:AddEventListener(GroupMgrEvent.Onpush_assistant, handler(self, self._evtOnPush_assistant)) + mgr_ctr:AddEventListener(GroupMgrEvent.OnMemberState, handler(self, self._evtOnMemberState)) + mgr_ctr:AddEventListener(GroupMgrEvent.OnFamilyReflash, handler(self, self._evtOnFamilyReflash)) + mgr_ctr:AddEventListener(GroupMgrEvent.OnFamilyRoomReflash, handler(self, self._evtOnFamilyRoomReflash)) + mgr_ctr:AddEventListener(GroupMgrEvent.OnFamilyMemberOut, handler(self, self._evtOnFamilyMemberOut)) + mgr_ctr:AddEventListener(GroupMgrEvent.OnRefShowStartRoom, handler(self, self._evtOnRefShowStartRoom)) + mgr_ctr:AddEventListener(GroupMgrEvent.OnRefNotice, handler(self, self._evtOnRefNotice)) + print("家族添加监听") +end + +function M:RemoveAll() + local mgr_ctr = self._mgr_ctr + mgr_ctr:RemoveEventListener(GroupMgrEvent.AddPlay, handler(self, self._evtAddPlay)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.DelPlay, handler(self, self._evtDelPlay)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.UpdatePlay, handler(self, self._evtUpdatePlay)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.AddRoom, handler(self, self._evtAddRoom)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.DelRoom, handler(self, self._evtDelRoom)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.UpdateRoom, handler(self, self._evtUpdateRoom)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.UpdatePlayerInfo, handler(self, self._evtUpdatePlayerInfo)) + --mgr_ctr:RemoveEventListener(GroupMgrEvent.BeInvited, handler(self, self._evtInvited)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.UpdateGroup, handler(self, self._evtUpdateGroup)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.NewMailTip, handler(self, self._evtNewMailTip)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.InviteResponse, handler(self, self._evtInviteResponse)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.IsOpenChatRoom, handler(self, self._evtIsOpenChatRoom)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.ChatRoomData, handler(self, self._evtChatRoomData)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.OnNewApply, handler(self, self._evtOnNewApply)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.OnNewRecord, handler(self, self._evtOnNewRecord)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.Onpush_assistant, handler(self, self._evtOnPush_assistant)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.OnMemberState, handler(self, self._evtOnMemberState)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.OnFamilyRoomReflash, handler(self, self._evtOnFamilyRoomReflash)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.OnFamilyMemberOut, handler(self, self._evtOnFamilyMemberOut)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.OnRefNotice, handler(self, self._evtOnRefShowStartRoom)) + mgr_ctr:RemoveEventListener(GroupMgrEvent.OnRefNotice, handler(self, self._evtOnRefNotice)) + + + print("家族去除监听") +end + +function M:_evtAddPlay(...) + local arg = { ... } + print("family event _evtAddPlay") + + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + + view:UpdateFamilyRoom(nil, view._group.id) +end + +function M:_evtDelPlay(...) + local arg = { ... } + + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + + view:UpdateFamilyRoom(nil, view._group.id) +end + +function M:_evtUpdatePlay(...) + local arg = { ... } + print("family event _evtUpdatePlay") + + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + + view:UpdateFamilyRoom(nil, view._group.id) +end + +function M:_evtAddRoom(...) + local arg = { ... } + print("family event _evtAddRoom") +end + +function M:_evtDelRoom(...) + local arg = { ... } + print("family event _evtDelRoom") +end + +function M:_evtUpdateRoom(...) + local arg = { ... } + print("family event _evtUpdateRoom") +end + +function M:_evtUpdatePlayerInfo(...) + local arg = { ... } + print("family event _evtUpdatePlayerInfo") +end + +function M:_evtInvited(...) + local arg = { ... } + print("family event _evtInvited") +end + +function M:_evtUpdateGroup(...) + local arg = { ... } + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + + -- 刷新名字 + view:ReflashFamilyList() + + -- 刷新打烊 + view:ReflashBan() + print("family event _evtUpdateGroup") +end + +function M:_evtNewMailTip(...) + local arg = { ... } + print("family event _evtNewMailTip") +end + +function M:_evtOnNewApply(...) + print("_evtOnNewApply") + local arg = { ... } + pt(arg) + + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + view:ChangeOther() + + local AuditNumber = BaseView.FindView("FamilyAuditNumber") + + if AuditNumber then + AuditNumber:OnNewApply(arg) + end +end + +function M:_evtInviteResponse(...) + local arg = { ... } + local evt_data = arg[1] + local invite_id = evt_data.invite_id + local nik = evt_data.nik + local g_name = evt_data.g_name + local roomid = evt_data.roomid + local pid = evt_data.pid + local groupid = evt_data.groupId + local playInfo = evt_data.pinfo + local roomCtr = ControllerManager.GetController(RoomController) + UIPackage.AddPackage('base/newgroup/ui/FGAssist') + local imv = + FGInvitedMsgView.new( + self._root_view, + groupid, + playInfo, + nik, + function() + roomCtr:PublicJoinRoom( + Protocol.WEB_FG_JOIN_ROOM, + roomid, + groupid, + function(response) + if (response.ReturnCode == -1) then + ViewUtil.ErrorMsg(self._root_view, response.ReturnCode, 'response.ReturnCode == -1') + -- RestartGame() + return + end + + if response.ReturnCode ~= 0 then + ViewUtil.ErrorMsg(self._root_view, response.ReturnCode, '进入房间失败') + -- ViewManager.ChangeView(ViewManager.View_Lobby) + return + else + UpdateBeat:Remove(self.OnUpdate, self) + ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id, + { _flag_showTip = true }) + end + end, + groupid, + pid + ) + end + ) + -- imv:FillData(data) + imv:Show() +end + +function M:_evtIsOpenChatRoom(...) + local arg = { ... } + self:ReflashChatRoomBtn() + print("_evtIsOpenChatRoom") + pt(arg) +end + +function M:_evtChatRoomData(...) + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + view.com_FamilyChatRoom:Refalsh() + ViewUtil.CloseModalWait2() +end + +function M:_evtOnNewRecord(...) + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + local arg = { ... } + view.com_FamilyChatRoom:OnNewChatRefalsh(arg[1]) + view:ReflashChatRoomRedPoint() +end + +function M:_evtOnMemberState(...) + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + view:ReflashMember(...) + --[[ + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + local arg = { ... } + local group = DataManager.groups:get(view._group.id) + + for _, player in pairs(arg[1].offlineUserId) do + group.memberMap[player].online = 0 + end + + for _, player in pairs(arg[1].onlineUserId) do + group.memberMap[player].online = 0 + end + + for _, player in pairs(arg[1].playingUserId) do + group.memberMap[player].playing = "startPlaying" + end + ]] +end + +function M:_evtOnPush_assistant(...) + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + + local arg = { ... } + local groupId = arg[1].id + local lev = arg[1].lev + + if view._group == nil or groupId ~= view._group.id then + return + end + + view:ChangeOther() +end + +-- reflashType == "joinFamily" 成功加入了亲友圈 +-- reflashType == "outFamily" 成员退出了亲友圈 +-- reflashType == "kickoutFamily" 成员被踢出了亲友圈 +-- reflashType == "changeJoins" 修改了申请信息 +function M:_evtOnFamilyReflash(...) + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + + local gMgr = ControllerManager.GetController(GroupMgrController) + local group = DataManager.groups:get(gMgr.groupId) + + local arg = { ... } + local reflashType = arg[1].reflashType + + if reflashType == "joinFamily" then + local uid = arg[1].uid + + if DataManager.SelfUser.account_id == uid then + group.lev = 3 + view:Reflash() + local tips = "成功加入【%s(%s)】" + tips = string.format(tips, arg[1].name, arg[1].groupId) + local win = MsgWindow.new(view._view, tips, MsgWindow.MsgMode.OnlyOk) + win:Show() + return + end + + --新加入的成员没带权限 + arg[1].usersDetail.lev = 3 + group:addMember(arg[1].usersDetail) + + Broadcast.Send(Broadcast.OnMemberChange) + end + + if reflashType == "outFamily" then + --local player = DataManager. + + --local tips = "成员 【%s(%s)】退出了【%s(%s)】亲友圈" + --string.format(tips, ) + + --MsgWindow.new(self._root_view, "确定要点过吗?") + end + + if reflashType == "changeJoins" then + local uid = arg[1].uid + local joins = arg[1].joins + + group.joins = joins + + if not group.joinsData or #group.joinsData < 1 then + return + end + + for _, data in pairs(group.joinsData) do + if data.id == uid then + table.remove(group.joinsData, _) + end + end + + Broadcast.Send(BroadcastEvent.OnJoinsChange) + --[[ + view:ChangeOther() + local win = BaseWindow.FindWindow("FamilyAuditNumber") + if win then + win:Reflash() + end + ]] + end +end + +-- 刷新房间和成员 +function M:_evtOnFamilyRoomReflash(...) + local arg = { ... } + print("_evtOnFamilyRoomReflash") + pt(arg) + local groupId = arg[1] + + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + + if view._group == nil or groupId ~= view._group.id then + return + end + + view:UpdateFamilyRoom(nil, groupId) + view:ReflashMember() +end + +function M:_evtOnFamilyMemberOut(...) + local arg = { ... } + local arg = arg[1] + + local uid = arg.uid + local groupId = arg.groupId + local name = arg.name + local reflashType = arg.reflashType + + local group = DataManager.groups:get(groupId) + + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" or not group then + return + end + local tips = "" + + if name == group.name then + tips = "【%s(%s)】亲友圈已解散" + tips = string.format(tips, group.name, groupId) + else + tips = "成员 【%s(%s)】退出了【%s(%s)】亲友圈" + tips = string.format(tips, DataManager.SelfUser.nick_name, DataManager.SelfUser.account_id, group.name, groupId) + end + if uid == DataManager.SelfUser.account_id then + DataManager.groups:del(groupId) + if #DataManager.groups.groupList == 0 then + view._close_destroy = true + ViewManager.ChangeView(ViewManager.View_Lobby) + else + if view._group.id == groupId then + view:Reflash() + end + end + end + local win = MsgWindow.new(view._view, tips, MsgWindow.MsgMode.OnlyOk) + win:Show() +end + +function M:_evtOnRefShowStartRoom(...) + local arg = { ... } + + local evt_data = arg[1] + + -- local view = ViewManager.GetCurrenView() + -- if view.class ~= "FamilyMainView" then + -- return + -- end + printlog("lingmeng _evtOnRefShowStartRoom", self._group.id, evt_data.groupId) + if self._group.id == nil or evt_data.groupId ~= self._group.id then + return + end + self:UpdateFamilyRoom(nil, self._group.id) +end + +function M:_evtOnRefNotice(...) + local arg = { ... } + + local evt_data = arg[1] + + local view = ViewManager.GetCurrenView() + if view.class ~= "FamilyMainView" then + return + end + printlog("lingmeng _evtOnRefShowStartRoom", self._group.id, evt_data.groupId) + if self._group.id == nil or evt_data.groupId ~= self._group.id then + return + end + self:RefNotice(self._group.id) +end + +return M diff --git a/lua_probject/base_project/Game/View/FamilyZuo/FamilyManagerTable.lua b/lua_probject/base_project/Game/View/FamilyZuo/FamilyManagerTable.lua index 485c1364..a810be28 100644 --- a/lua_probject/base_project/Game/View/FamilyZuo/FamilyManagerTable.lua +++ b/lua_probject/base_project/Game/View/FamilyZuo/FamilyManagerTable.lua @@ -2,6 +2,9 @@ local ManagerChild_GamePlayView = import(".ManagerChild_GamePlayView") local ManagerChild_PlayerView = import(".ManagerChild_PlayerView") local ManagerChild_SettingView = import(".ManagerChild_SettingView") +local ManagerChild_BlackView = import(".ManagerChild_BlackView") +local ManagerChild_ForbidSameTableView = import(".ManagerChild_ForbidSameTableView") +local ManagerChild_RecordView = import(".ManagerChild_RecordView") --成员 local ManagerMenberChild_PlayerView = import(".ManagerMenberChild_PlayerView") local ManagerMenberChild_JoinsView = import(".ManagerMenberChild_JoinsView") @@ -17,6 +20,9 @@ M.ManagerTable = { { id = 1, title = "基本设置", view = ManagerChild_SettingView }, { id = 2, title = "成员管理", view = ManagerChild_PlayerView }, { id = 3, title = "快速组局", view = ManagerChild_GamePlayView }, + { id = 4, title = "小黑屋管理", view = ManagerChild_BlackView }, + { id = 4, title = "禁止同桌", view = ManagerChild_ForbidSameTableView}, + { id = 4, title = "战绩统计", view = ManagerChild_RecordView}, --成员管理页面 { id = 4, title = "成员列表", view = ManagerMenberChild_PlayerView }, { id = 5, title = "进驻申请", view = ManagerMenberChild_JoinsView }, @@ -26,13 +32,13 @@ M.ManagerTable = { } M.ManagerShow = { - { 1,2, 3 }, --群主 + { 1,2, 3,4,5,6}, --群主 {}, --代理 {} --用户 } M.ManagerMenberShow = { - { 3,4,5,6,7 }, --群主 + { 6,6,7,8,9 }, --群主 {}, --代理 {} --用户 } diff --git a/lua_probject/base_project/Game/View/FamilyZuo/FamilyMenberManagerDisDetailView.lua b/lua_probject/base_project/Game/View/FamilyZuo/FamilyMenberManagerDisDetailView.lua index ad8c2c81..357a055a 100644 --- a/lua_probject/base_project/Game/View/FamilyZuo/FamilyMenberManagerDisDetailView.lua +++ b/lua_probject/base_project/Game/View/FamilyZuo/FamilyMenberManagerDisDetailView.lua @@ -17,15 +17,16 @@ end function M:init(url) getmetatable(M).__index.init(self, url) - self._data.type = self._data.type or 1 + self._data.type = self._data.type or 0 local view = self._view self._viewList_player = view:GetChild('list_player') + self._viewList_player:SetVirtual() self._viewList_player.itemRenderer = handler(self, self.PlayerRenderer) self._viewText_search = self._view:GetChild('input_search') - view:GetChild('btn_search').onClick:Set(handler(self,self.ClickSearch)) - view:GetChild('btn_return').onClick:Set(handler(self,self.ShowAllMenber)) + view:GetChild('btn_search').onClick:Set(handler(self, self.ClickSearch)) + view:GetChild('btn_return').onClick:Set(handler(self, self.ShowAllMenber)) self:FillData() end @@ -33,12 +34,12 @@ function M:ClickSearch() local text = self._viewText_search.text local tmpTable = self._fillData local searchData = {} - for i,v in ipairs(tmpTable) do - if v.uid == tonumber(text) or string.find(v.nick,text) then - table.insert(searchData,v) + for i, v in ipairs(tmpTable) do + if v.uid == tonumber(text) or string.find(v.nick, text) then + table.insert(searchData, v) end end - self._fillData= searchData + self._fillData = searchData self._viewList_player.numItems = #self._fillData self._view:GetController('search').selectedIndex = 1 end @@ -49,14 +50,24 @@ function M:PlayerRenderer(index, obj) ImageLoad.Load(info.portrait, obj:GetChild('btn_head')._iconObject) obj:GetChild('text_name').text = info.nick obj:GetChild('text_id').text = string.format("标识:%s", info.uid) - obj:GetChild('btn_add').onClick:Set(function() - ViewUtil:ErrorTip("暂时还未开放此功能。") - end) + --根据不同type决定控制器的显示和添加按钮的功能 + if self._data.type == 2 then + local uidData = self._data.uidData or {} + obj:GetController('added').selectedIndex = info._flag_add or 0 + obj:GetChild('btn_add').onClick:Set(function() + table.insert(uidData, info.uid) + self._callback(uidData) + obj:GetController('added').selectedIndex = 1 + if #uidData == 1 then + self:Destroy() + end + end) + end end function M:ShowAllMenber() self._viewText_search.text = "" - self._fillData = DataManager.CurrenGroup.members + self._fillData = self._data.menberTable or DataManager.CurrenGroup.members self._viewList_player.numItems = #self._fillData end diff --git a/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_BlackView.lua b/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_BlackView.lua new file mode 100644 index 00000000..8d058356 --- /dev/null +++ b/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_BlackView.lua @@ -0,0 +1,45 @@ +local ManagerChild_BlackView = {} + +local M = ManagerChild_BlackView + +function ManagerChild_BlackView.new(data, callback) + local self = setmetatable({}, { __index = M }) + self.class = "ManagerChild_BlackView" + self._data = data or {} + self._callback = callback + self:init("ui://Family/ManagerChild_Black") + return self +end + +function M:init(url) + local root = self._data.root + if not root then + ViewUtil:ErrorTip("点击太快,请重新打开页面") + return + end + local page = root._view:GetChild('page') + ViewUtil.LoadPage(page, url, function(view) + self._view = view + end) +end + +function M:FillData() + +end + +-- 打开窗口 +function M:Show() + getmetatable(M).__index.Show(self) +end + +-- 关闭窗口 +function M:Close() + getmetatable(M).__index.Close(self) +end + +-- 销毁窗口 +function M:Destroy() + getmetatable(M).__index.Destroy(self) +end + +return M diff --git a/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_ForbidSameTableView.lua b/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_ForbidSameTableView.lua new file mode 100644 index 00000000..fd2670d2 --- /dev/null +++ b/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_ForbidSameTableView.lua @@ -0,0 +1,168 @@ +local FamilyMenberManagerDisDetailView = import(".FamilyMenberManagerDisDetailView") + +local ManagerChild_ForbidSameTableView = {} + +local M = ManagerChild_ForbidSameTableView + +function ManagerChild_ForbidSameTableView.new(data, callback) + local self = setmetatable({}, { __index = M }) + self.class = "ManagerChild_ForbidSameTableView" + self._data = data or {} + self._callback = callback + self:init("ui://Family/ManagerChild_ForbidSameTable") + return self +end + +function M:init(url) + local root = self._data.root + if not root then + ViewUtil:ErrorTip("点击太快,请重新打开页面") + return + end + local page = root._view:GetChild('page') + ViewUtil.LoadPage(page, url, function(view) + self._view = view + + self._viewList_list = view:GetChild('list_menber') + self._viewList_list:SetVirtual() + self._viewList_list.itemRenderer = handler(self, self.ListRenderer) + + self:FillData() + end) +end + +function M:ListRenderer(index, obj) + obj.text = string.format("限制组(%s)", index + 1) + local list = obj:GetChild('list') + list:RemoveChildrenToPool() + local uidData = {} + local uidMap = {} + local deskId = -1 + if index < #self._resList then + deskId = self._resList[index + 1].deskId + for i, v in ipairs(self._resList[index + 1].deskList) do + local obj1 = list:AddItemFromPool() + obj1:GetController('head').selectedIndex = 1 + ImageLoad.Load(v.portrait, obj1._iconObject) + obj1:GetChild('text_name').text = v.nick + obj1:GetChild('text_id').text = v.uid + table.insert(uidData, v.uid) + uidMap[v.uid] = 1 + obj1:GetChild('btn_remove').onClick:Set(function() + for i = 1, #uidData do + table.remove(uidData, i) + self:SetForbid(deskId, uidData, obj.text) + return + end + end) + end + end + local obj1 = list:AddItemFromPool() + obj1:GetChild('btn_add').onClick:Set(function() + if #uidData > 0 then + self:GetAllMember(function() + local tempMenbers = {} + for i, v in ipairs(DataManager.CurrenGroup.members) do + local tempMenber = {} + for k, v in pairs(v) do + tempMenber[k] = v + end + tempMenber._flag_add = uidMap[v.uid] or 0 + table.insert(tempMenbers, tempMenber) + end + FamilyMenberManagerDisDetailView.new({ menberTable = tempMenbers, type = 2, uidData = uidData }, + function(uidData) + self:SetForbid(deskId, uidData, obj.text) + end) + end) + else + FamilyMenberManagerDisDetailView.new({ type = 2 }, function(uidData) + self:SetForbid(deskId, uidData, obj.text) + end) + end + end) + obj1:GetController('head').selectedIndex = 0 + list:ResizeToFit(list.numItems) + obj:GetChild('btn_delete').onClick:Set(function() + if deskId == -1 then + ViewUtil:ErrorTip("该限制组不能删除") + else + self:SetForbid(deskId, {}, obj.text) + end + end) +end + +function M:SetForbid(id, banList, name) + ViewUtil.ShowModalWait2() + local fgCtr = ControllerManager.GetController(NewGroupController) + fgCtr:FG_SetBanTable1(DataManager.CurrenGroup.id, id, banList, name, function(res) + ViewUtil.CloseModalWait2() + if res.ReturnCode ~= 0 then + ViewUtil:ErrorTip(res.ReturnCode, "禁止同桌设置失败") + else + self:GetForbidSameDesk() + end + end) +end + +function M:GetForbidSameDesk() + local fgCtr = ControllerManager.GetController(NewGroupController) + + ViewUtil.ShowModalWait2() + + fgCtr:FG_GetBanTable1(DataManager.CurrenGroup.id, function(res) + ViewUtil.CloseModalWait2() + if res.ReturnCode ~= 0 then + ViewUtil.ErrorTip(res.ReturnCode, "获取禁止同桌列表") + return + end + self._resList = res.Data.ban_list or {} + if self._viewList_list.numItems == #self._resList + 1 then + self._viewList_list:RefreshVirtualList() + else + self._viewList_list.numItems = #self._resList + 1 + end + end) +end + +function M:GetAllMember(callback) + local group = DataManager.CurrenGroup + if #group.members == 0 then + local fgCtr = ControllerManager.GetController(NewGroupController) + fgCtr:FG_GroupMembers(group.id, 0, group.total_member_num, false, 1, function(res) + if res.ReturnCode ~= 0 then + ViewUtil.ErrorTip(res.ReturnCode, "获取成员列表失败") + return + end + if callback then + callback() + end + end) + return + end + if callback then + callback() + end +end + +function M:FillData() + self:GetForbidSameDesk() + self:GetAllMember() +end + +-- 打开窗口 +function M:Show() + getmetatable(M).__index.Show(self) +end + +-- 关闭窗口 +function M:Close() + getmetatable(M).__index.Close(self) +end + +-- 销毁窗口 +function M:Destroy() + getmetatable(M).__index.Destroy(self) +end + +return M diff --git a/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_RecordOperationView.lua b/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_RecordOperationView.lua new file mode 100644 index 00000000..94d0fa82 --- /dev/null +++ b/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_RecordOperationView.lua @@ -0,0 +1,45 @@ +local ManagerChild_RecordOperationView = {} + +local M = ManagerChild_RecordOperationView + +function ManagerChild_RecordOperationView.new(data, callback) + local self = setmetatable({}, { __index = M }) + self.class = "ManagerChild_RecordOperationView" + self._data = data or {} + self._callback = callback + self:init("ui://Family/ManagerChild_RecordOperation") + return self +end + +function M:init(url) + local root = self._data.root + if not root then + ViewUtil:ErrorTip("点击太快,请重新打开页面") + return + end + local page = root._view:GetChild('page') + ViewUtil.LoadPage(page, url, function(view) + self._view = view + end) +end + +function M:FillData() + +end + +-- 打开窗口 +function M:Show() + getmetatable(M).__index.Show(self) +end + +-- 关闭窗口 +function M:Close() + getmetatable(M).__index.Close(self) +end + +-- 销毁窗口 +function M:Destroy() + getmetatable(M).__index.Destroy(self) +end + +return M diff --git a/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_RecordView.lua b/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_RecordView.lua new file mode 100644 index 00000000..ee97d33d --- /dev/null +++ b/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_RecordView.lua @@ -0,0 +1,85 @@ +local FamilyUtilInput = import(".FamilyUtilInput") +local FamilyChooseTimeView = import(".FamilyChooseTimeView") + +local ManagerChild_RecordView = {} + +local M = ManagerChild_RecordView + +function ManagerChild_RecordView.new(data, callback) + local self = setmetatable({}, { __index = M }) + self.class = "ManagerChild_RecordView" + self._data = data or {} + self._callback = callback + self:init("ui://Family/ManagerChild_Record") + return self +end + +function M:init(url) + local root = self._data.root + if not root then + ViewUtil:ErrorTip("点击太快,请重新打开页面") + return + end + local page = root._view:GetChild('page') + ViewUtil.LoadPage(page, url, function(view) + self._view = view + + self._ctr_serch = view:GetController('search') + view:GetChild('btn_search').onClick:Set(function() + self._ctr_serch.selectedIndex = 1 + end) + + self._viewInput = view:GetChild('input_id') + FamilyUtilInput:init(self._viewInput, view:GetChild('comp_input')) + view:GetChild('btn_find').onClick:Set(handler(self, self.ClickFind)) + + view:GetChild('btn_time').onClick:Set(function() + FamilyChooseTimeView.new({left=self._left_time,right=self._right_time}, function(lef, rig) + self._left_time = lef + self._right_time = rig + self:RefenTime() + end) + end) + + self:FillData() + end) +end + +function M:ClickFind() + if #self._viewInput.text == 0 then + ViewUtil:ErrorTip("请输出标识id") + return + end + ViewUtil:ErrorTip("此id暂无战绩") +end + +function M:RefenTime() + self._view:GetChild('btn_time').text = string.format("%s-%s", os.date("%m月%d号", self._right_time), + os.date("%m月%d号", self._left_time)) +end + +function M:FillData() + local view = self._view + + local timeStamp = FamilyChooseTimeView:InitTime() + self._left_time = timeStamp + self._right_time = timeStamp + self:RefenTime() +end + +-- 打开窗口 +function M:Show() + getmetatable(M).__index.Show(self) +end + +-- 关闭窗口 +function M:Close() + getmetatable(M).__index.Close(self) +end + +-- 销毁窗口 +function M:Destroy() + getmetatable(M).__index.Destroy(self) +end + +return M diff --git a/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_SettingView.lua b/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_SettingView.lua index a1518be9..ac988222 100644 --- a/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_SettingView.lua +++ b/lua_probject/base_project/Game/View/FamilyZuo/ManagerChild_SettingView.lua @@ -1,3 +1,5 @@ +local FamilyDissolveByRoomView = import(".FamilyDissolveByRoomView") + local FamilyRoomCardView = import(".FamilyRoomCardView") local ManagerChild_SettingView = {} @@ -24,7 +26,7 @@ function M:init(url) self._view = view view:GetChild('btn_dissolveRoom').onClick:Set(function() - + FamilyDissolveByRoomView.new() end) view:GetChild('btn_add').onClick:Set(function() @@ -32,9 +34,12 @@ function M:init(url) end) view:GetChild('btn_record').onClick:Set(function() - + ViewUtil:ErrorTip("页面缺失") + end) + view:GetChild('btn_copy').onClick:Set(function() + ViewUtil:ErrorTip("复制成功") + GameApplication.Instance:CopyToClipboard(view:GetChild('text_id').text) end) - view:GetChild('btn_dissolveRoomDetail').onClick:Set(handler(self, self.ClickDissolveDetail)) view:GetChild('btn_witness').onClick:Set(handler(self, self.ClickWitnessDetail)) @@ -56,13 +61,13 @@ function M:ClickWitnessDetail() end -function M:ClickCheckHideDesk() +function M:ClickCheckHideDesk(context) local mgr_ctr = ControllerManager.GetController(GroupMgrController) - mgr_ctr:FG_SetShowStartRoom(DataManager.CurrenGroup.id, self._viewCheck_hideDesk.selected and 1 or 0, function(res) + mgr_ctr:FG_SetShowStartRoom(DataManager.CurrenGroup.id, context.sender.selected and 1 or 0, function(res) --因为没有回调,这边先把值设置好 if res.ReturnCode ~= 0 then - ViewUtil.ErrorTip(res.ReturnCode,"设置失败") - self._viewCheck_hideDesk.selected = not self._viewCheck_hideDesk.selected + ViewUtil.ErrorTip(res.ReturnCode, "设置失败") + context.sender.selected = not context.sender.selected return else ViewUtil:ErrorTip("设置成功") @@ -70,12 +75,22 @@ function M:ClickCheckHideDesk() end) end -function M:ClickCheckDissolveRoom() - +function M:ClickCheckDissolveRoom(context) + ViewUtil:ErrorTip("协议缺失") + context.sender.selected = not context.sender.selected end -function M:ClickCheckWitness() - +function M:ClickCheckWitness(context) + local fgCtr = ControllerManager.GetController(NewGroupController) + fgCtr:SetCanWatch(DataManager.CurrenGroup.id, context.sender.selected and 1 or 0, function(res) + if res.ReturnCode ~= 0 then + ViewUtil.ErrorTip(res.ReturnCode) + context.sender.selected = not context.sender.selected + return + else + ViewUtil:ErrorTip("设置成功") + end + end) end function M:FillData() @@ -87,8 +102,8 @@ function M:FillData() view:GetChild('text_id').text = group.id view:GetChild('text_fangka').text = group.groupDiamo - self._viewCheck_hideDesk.selected = group.isOpenStartRoom == 1 - self._viewCheck_witness.selected = group.isWatch == 1 + self._viewCheck_hideDesk.selected = group.isOpenStartRoom == 1 + self._viewCheck_witness.selected = group.isWatch == 1 end -- 打开窗口 diff --git a/lua_probject/base_project/Game/View/LobbyView.lua b/lua_probject/base_project/Game/View/LobbyView.lua index 64a6ccb5..7930f85d 100644 --- a/lua_probject/base_project/Game/View/LobbyView.lua +++ b/lua_probject/base_project/Game/View/LobbyView.lua @@ -419,9 +419,14 @@ function M:ReconnectRoom(groupId) if roomId and #roomId > 0 then local roomCtr = ControllerManager.GetController(RoomController) roomCtr:PublicJoinRoom( - Protocol.WEB_FG_JOIN_ROOM, - roomId, - false, + { + cmd = Protocol.WEB_FG_JOIN_ROOM, + roomid = roomId, + is_null = false, + group_id = groupId, + pid = 0, + selectSeat = 0 + }, function(response) if (response.ReturnCode == -1) then ViewUtil.ErrorMsg(self._root_view, response.ReturnCode, 'response.ReturnCode == -1') @@ -439,8 +444,7 @@ function M:ReconnectRoom(groupId) DataManager.SelfUser.room_id = "" ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id) end - end, - groupId + end ) end end diff --git a/lua_probject/base_project/Game/View/LoginView.lua b/lua_probject/base_project/Game/View/LoginView.lua index 08f0194f..f8179dee 100644 --- a/lua_probject/base_project/Game/View/LoginView.lua +++ b/lua_probject/base_project/Game/View/LoginView.lua @@ -333,9 +333,13 @@ function M:ReconnectRoom(groupId, times) if roomId and #roomId > 0 then local roomCtr = ControllerManager.GetController(RoomController) roomCtr:PublicJoinRoom( - Protocol.WEB_FG_JOIN_ROOM, - roomId, - false, + { + cmd = Protocol.WEB_FG_JOIN_ROOM, + roomid = roomId, + is_null = false, + group_id = groupId, + selectSeat = 0 + }, function(response) if (response.ReturnCode == -1) then ViewUtil.CloseModalWait2() @@ -370,8 +374,7 @@ function M:ReconnectRoom(groupId, times) end) ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id) end - end, - groupId + end ) end end diff --git a/lua_probject/base_project/Game/View/MainView.lua b/lua_probject/base_project/Game/View/MainView.lua index 5b3cdf02..24acf16d 100644 --- a/lua_probject/base_project/Game/View/MainView.lua +++ b/lua_probject/base_project/Game/View/MainView.lua @@ -18,13 +18,15 @@ end local function RefalshBtnClose(self) local btn_close = self._view:GetChild("btn_closeRoom") - local btn_close_cSytle = btn_close:GetController("cStyle") - local roomOwner = self._room.player_list[1].self_user.account_id + if btn_close then + local btn_close_cSytle = btn_close:GetController("cStyle") + local roomOwner = self._room.player_list[1].self_user.account_id - if roomOwner == DataManager.SelfUser.account_id then - btn_close_cSytle.selectedIndex = 0 - else - btn_close_cSytle.selectedIndex = 1 + if roomOwner == DataManager.SelfUser.account_id then + btn_close_cSytle.selectedIndex = 0 + else + btn_close_cSytle.selectedIndex = 1 + end end end @@ -544,7 +546,11 @@ function M:InitView(url, isHideIpAdds) end end--]] -------------------------lingmeng--------------------------- - _view:GetChild('text_roomId').text = string.format("房间:%s", self._room.room_id) + local text_roomId = _view:GetChild('text_roomId') + if text_roomId then + text_roomId.text = string.format("房间:%s", self._room.room_id) + end + local btn_inviteFamily = self._view:GetChild('btn_inviteFamily') if btn_inviteFamily then diff --git a/lua_probject/base_project/Game/View/ViewUtil.lua b/lua_probject/base_project/Game/View/ViewUtil.lua index 9223c876..ac2e0a3b 100644 --- a/lua_probject/base_project/Game/View/ViewUtil.lua +++ b/lua_probject/base_project/Game/View/ViewUtil.lua @@ -445,3 +445,52 @@ function ViewUtil.LoadPage(loader, url, callback) end, 1):Start() end end + +local function RecursionBinarySearch(table, num, type, left, right) + if not table then + return nil + end + if #table == 0 then + return 1 + end + left = left or 1 + right = right or #table + if left == right then + if type == 0 then + return num >= table[left] and left + 1 or left + else + return num <= table[left] and left + 1 or left + end + end + + + if type == 0 then + local index = math.ceil((left + right) / 2) + + if num >= table[index] then + left = index + else + right = index - 1 + end + else + local index = math.floor((left + right) / 2) + + if num <= table[index] then + left = index + 1 + else + right = index + + end + end + + return RecursionBinarySearch(table, num, type or 0, left, right) +end + +---comment 二分法查找下标 +---@param table 查询表 +---@param num 当前值 +---@param type 类型 0为升序,1为降序 +---@return integer|nil +function ViewUtil.BinarySearch(table, num, type) + return RecursionBinarySearch(table, num, type) +end diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/CS_Win_Type.lua b/lua_probject/extend_project/extend/majiang/hongzhong/CS_Win_Type.lua new file mode 100644 index 00000000..fc00cbf2 --- /dev/null +++ b/lua_probject/extend_project/extend/majiang/hongzhong/CS_Win_Type.lua @@ -0,0 +1,47 @@ +local CS_Win_Type = { + "点炮", + "自摸", + "十三烂", + "七星十三烂", + "碰碰胡", + "碰碰胡清一色", + "碰碰胡字一色", + "七小对", + "七小对清一色", + "七小对字一色", + "清一色真胡", + "清一色假胡", + "字一色真胡", + "字一色假胡", + "天胡", + "地胡", + "平胡", + "抢杠胡", + "杠上花", + "烧庄", + "四归一", + "八归一", + "十二归一", + "清一色假胡四归一", + "清一色真胡四归一", + "清一色假胡八归一", + "清一色真胡八归一", + "清一色假胡十二归一", + "清一色真胡十二归一", + "字一色假胡四归一", + "字一色真胡四归一", + "字一色假胡八归一", + "字一色真胡八归一", + "字一色假胡十二归一", + "字一色真胡十二归一", + "清一色七对四归一", + "清一色七对八归一", + "清一色七对十二归一", + "字一色七对四归一", + "字一色七对八归一", + "字一色七对十二归一", + "七对四归一", + "七对八归一", + "七对十二归一" +} +return CS_Win_Type diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/CardCheck.lua b/lua_probject/extend_project/extend/majiang/hongzhong/CardCheck.lua index c22ab3a8..0d52848a 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/CardCheck.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/CardCheck.lua @@ -1,11 +1,11 @@ -- 检测牌是否存在 -local function checkCard(eventCard,cardList,num) +local function checkCard(eventCard, cardList, num) num = num == nil and 1 or num local result = 0 - for i = 1,#cardList do + for i = 1, #cardList do if (cardList[i] == eventCard) then result = result + 1 - if(result ==num) then + if (result == num) then return true end end @@ -14,24 +14,24 @@ local function checkCard(eventCard,cardList,num) end -- 移除指定数量的牌 -local function removeCard(cardList, card,count) - for i=1,count do - list_remove(cardList,card) +local function removeCard(cardList, card, count) + for i = 1, count do + list_remove(cardList, card) end end -local function checkCardAndRomve(eventCard,cardList,num) - if(checkCard(eventCard,cardList,num)) then - removeCard(cardList,eventCard,num) +local function checkCardAndRomve(eventCard, cardList, num) + if (checkCard(eventCard, cardList, num)) then + removeCard(cardList, eventCard, num) return true end return false end -- 获取列表中牌数量 -local function cardNum(eventCard,cardList) +local function cardNum(eventCard, cardList) local result = 0 - for i=1,#cardList do + for i = 1, #cardList do local card = cardList[i] if (card == eventCard) then result = result + 1 @@ -40,7 +40,7 @@ local function cardNum(eventCard,cardList) return result end -local zhongid = 412 +local zhongid = 0 local M = { @@ -54,16 +54,16 @@ local M = { } -function M:push(cardGroup) - self.stack[#self.stack+1] = cardGroup +function M:push(cardGroup) + self.stack[#self.stack + 1] = cardGroup end function M:rollBack() local cardGroup = self.stack[#self.stack] - table.remove(self.stack,#self.stack) - for _,card in ipairs(cardGroup) do + table.remove(self.stack, #self.stack) + for _, card in ipairs(cardGroup) do if (card == zhongid) then - self.zhong_count = self.zhong_count +1 + self.zhong_count = self.zhong_count + 1 else self.cardList[#self.cardList + 1] = card end @@ -71,36 +71,75 @@ function M:rollBack() table.sort(self.cardList) end -function M:tryShunzi(card) - if (card < 400 and card % 100 > 7) then +function M:tryShunzi(card) + if card > 400 or card % 100 > 7 then return false end - if (checkCard(card + 1, self.cardList) and checkCard(card + 2, self.cardList)) then + if (checkCard(card + 1, self.cardList) and checkCard(card + 2, self.cardList)) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 1, 1) removeCard(self.cardList, card + 2, 1) - local cardGroup = {card,card+1,card+2} + local cardGroup = { card, card + 1, card + 2 } self:push(cardGroup) return true end return false end -function M:tryKezi(card) +--特殊牌,风牌也就是东南西北的成顺逻辑,中发白逻辑在普通顺子里 +function M:tryFengShunzi(card) + --只有牌里有东南风的时候才能成顺,401东风,402南方 + if self._flag_zikechengshun ~= 0 then + return false + end + local canShunziFeng = { 401, 402 } + for i = 1, #canShunziFeng do + if card == canShunziFeng[i] then + local tempFengList = {} + for j = 1, 4 - i do + if checkCard(405 - j, self.cardList) then + table.insert(tempFengList, 405 - j) + end + end + if #tempFengList >= 2 then + removeCard(self.cardList, card, 1) + removeCard(self.cardList, tempFengList[1], 1) + removeCard(self.cardList, tempFengList[2], 1) + local cardGroup = { card, tempFengList[1], tempFengList[2] } + self:push(cardGroup) + return true + end + end + end + if card < 500 then + return false + end + if (checkCard(card + 1, self.cardList) and checkCard(card + 2, self.cardList)) then + removeCard(self.cardList, card, 1) + removeCard(self.cardList, card + 1, 1) + removeCard(self.cardList, card + 2, 1) + local cardGroup = { card, card + 1, card + 2 } + self:push(cardGroup) + return true + end + return false +end + +function M:tryKezi(card) if (checkCardAndRomve(card, self.cardList, 3)) then - local cardGroup = {card,card,card} + local cardGroup = { card, card, card } self:push(cardGroup) return true end return false end -function M:tryPair(card) +function M:tryPair(card) if (self.pair_count > 0) then return false end if (checkCardAndRomve(card, self.cardList, 2)) then - local cardGroup = {card,card} + local cardGroup = { card, card } self:push(cardGroup) self.pair_count = 1 return true @@ -108,28 +147,27 @@ function M:tryPair(card) return false end - -function M:tryKezi1Zhong(card) - if (self.zhong_count >= 1 and checkCardAndRomve(card, self.cardList,2)) then - local cardGroup = {card,card,zhongid} +function M:tryKezi1Zhong(card) + if (self.zhong_count >= 1 and checkCardAndRomve(card, self.cardList, 2)) then + local cardGroup = { card, card, zhongid } self:push(cardGroup) - self.zhong_count = self.zhong_count -1 - return true - end - return false -end - -function M:tryKezi2Zhong(card) - if (self.zhong_count >= 2 and checkCardAndRomve(card, self.cardList,1)) then - local cardGroup = {card,zhongid,zhongid} - self:push(cardGroup) - self.zhong_count = self.zhong_count -2 + self.zhong_count = self.zhong_count - 1 return true end return false end -function M:tryShunzi1Zhong(card) +function M:tryKezi2Zhong(card) + if (self.zhong_count >= 2 and checkCardAndRomve(card, self.cardList, 1)) then + local cardGroup = { card, zhongid, zhongid } + self:push(cardGroup) + self.zhong_count = self.zhong_count - 2 + return true + end + return false +end + +function M:tryShunzi1Zhong(card) if (card % 100 > 8) then return false end @@ -141,8 +179,8 @@ function M:tryShunzi1Zhong(card) if (checkCard(card + 1, self.cardList)) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 1, 1) - self.zhong_count = self.zhong_count -1 - local cardGroup = {card,card+1,zhongid} + self.zhong_count = self.zhong_count - 1 + local cardGroup = { card, card + 1, zhongid } self:push(cardGroup) return true end @@ -150,15 +188,15 @@ function M:tryShunzi1Zhong(card) if (checkCard(card + 2, self.cardList) and ((card + 1) % 100 ~= 0)) then removeCard(self.cardList, card, 1) removeCard(self.cardList, card + 2, 1) - self.zhong_count = self.zhong_count -1 - local cardGroup = {card,zhongid,card+2} + self.zhong_count = self.zhong_count - 1 + local cardGroup = { card, zhongid, card + 2 } self:push(cardGroup) return true end return false end -function M:tryPair1Zhong(card) +function M:tryPair1Zhong(card) if (self.pair_count > 0) then return false end @@ -166,28 +204,28 @@ function M:tryPair1Zhong(card) return false end removeCard(self.cardList, card, 1) - local cardGroup = {card,zhongid} + local cardGroup = { card, zhongid } self:push(cardGroup) - self.zhong_count = self.zhong_count -1 + self.zhong_count = self.zhong_count - 1 self.pair_count = 1 return true end -function M:tryPair2Zhong() +function M:tryPair2Zhong() if (self.pair_count > 0) then return false end if (self.zhong_count < 2) then return false end - local cardGroup = {zhongid,zhongid} + local cardGroup = { zhongid, zhongid } self:push(cardGroup) - self.zhong_count = self.zhong_count -2 + self.zhong_count = self.zhong_count - 2 self.pair_count = 1 return true end -function M:tryWin() +function M:tryWin() if (self.zhong_count == 4 and not self.eight_laizi) or (self.zhong_count == 8 and self.eight_laizi) then return true end @@ -225,6 +263,13 @@ function M:tryWin() self:rollBack() end + if (self:tryFengShunzi(activeCard)) then + if (self:tryWin()) then + return true + end + self:rollBack() + end + if (self:tryKezi1Zhong(activeCard)) then if (self:tryWin()) then return true @@ -233,7 +278,6 @@ function M:tryWin() end if (self:tryKezi2Zhong(activeCard)) then - if (self:tryWin()) then return true end @@ -257,7 +301,7 @@ function M:tryWin() return false end -function M:checkQidui() +function M:checkQidui() if (not self.qidui) then return false end @@ -270,17 +314,17 @@ function M:checkQidui() return self:isQdPari(cardList) end -function M:isQdPari(cardList) - if(self.qidui_pari_count == 7) then +function M:isQdPari(cardList) + if (self.qidui_pari_count == 7) then return true end - if (#cardList== 0) then + if (#cardList == 0) then return true end local card = cardList[1] if (cardNum(card, cardList) >= 2) then removeCard(cardList, card, 2) - self.qidui_pari_count = self.qidui_pari_count +1 + self.qidui_pari_count = self.qidui_pari_count + 1 if (self:isQdPari(cardList)) then return true end @@ -289,7 +333,7 @@ function M:isQdPari(cardList) if (self.hongzhong_count > 0) then removeCard(cardList, card, 1) self.hongzhong_count = self.hongzhong_count - 1 - self.qidui_pari_count = self.qidui_pari_count +1 + self.qidui_pari_count = self.qidui_pari_count + 1 if (self:isQdPari(cardList)) then return true end @@ -297,37 +341,110 @@ function M:isQdPari(cardList) return false end -local function init(self,cardInhand,addCard,isZhong,qidui,eightLaizi) +function M:checkshisanlan() + if (not self.shisanlan) then + return false + end + if ((#self.cardList + self.zhong_count) ~= 14) then + return false + end + local cardList = membe_clone(self.cardList) + self.hongzhong_count = self.zhong_count + return self:isShiSanLan(cardList, table.remove(cardList, 1)) +end + +function M:isShiSanLan(cardList, card) + if (#cardList == 0) then + return true + end + if card < 400 then + if not (checkCard(card, cardList) or checkCard(card + 1, cardList) or checkCard(card + 2, cardList)) then + return self:isShiSanLan(cardList, table.remove(cardList, 1)) + end + else + if not checkCard(card, cardList) then + return self:isShiSanLan(cardList, table.remove(cardList, 1)) + end + end + return false +end + +--._flag_haveLaizi, data._hu_qidui, data._data_laizi +local function init(self, cardInhand, addCard, data) self.stack = {} self.pair_count = 0 self.cardList = membe_clone(cardInhand) - self.qidui = qidui - self.eight_laizi = eightLaizi - self.cardList[#self.cardList+1] = addCard - if (isZhong) then + self.qidui = data._hu_qidui + self.shisanlan = data._hu_shisanlan + self.eight_laizi = nil + self.cardList[#self.cardList + 1] = addCard + if (data._flag_haveLaizi) then self.zhong_count = cardNum(zhongid, self.cardList) removeCard(self.cardList, zhongid, self.zhong_count) end table.sort(self.cardList) - return self:checkQidui() or self:tryWin() + --printlog("添加排序====>>>") + --pt(self.cardList) + return self:checkQidui() or self:checkshisanlan() or self:tryWin() end -function M.tingPai(cardInhand,isZhong,qidui,eightLaizi) - local self = setmetatable({}, {__index = M}) +local specialCardList = { 401, 402, 403, 404, 501, 502, 503 } +function M.tingPai(cardInhand, data) + data = data or {} + local self = setmetatable({}, { __index = M }) local tingList = {} if not cardInhand or #cardInhand == 0 then return tingList end - for k=100,300,100 do - for i=1,9 do + for k = 100, 300, 100 do + for i = 1, 9 do local tem = k + i - local result = init(self,cardInhand,tem,isZhong,qidui,eightLaizi) - if(result) then - tingList[#tingList + 1] = tem + local result = init(self, cardInhand, tem, data) + --printlog("返回结果为===>>>",result) + if (result) then + tingList[#tingList + 1] = tem end end end + + for j = 1, #specialCardList do + local tem = specialCardList[j] + local result = init(self, cardInhand, tem, data) + if (result) then + tingList[#tingList + 1] = tem + end + end + return tingList end -return M \ No newline at end of file +function M.MuiltiplteCaculateTingPai(cardInhand, isZhong, qidui, eightLaizi) + local room = DataManager.CurrenRoom + + if room.laiziInfo and #room.laiziInfo > 0 then + zhongid = room.laiziInfo[1] + local tempTingList2 = {} + local tempTingList1 = M.tingPai(cardInhand, isZhong, qidui, eightLaizi) + if room.laiziInfo[2] then + zhongid = room.laiziInfo[2] + tempTingList2 = M.tingPai(cardInhand, isZhong, qidui, eightLaizi) + zhongid = room.laiziInfo[1] + end + local currentTingList = {} + if #tempTingList1 > 0 and #tempTingList2 > 0 then + currentTingList = CombineDictionaryAndRemoveSomeItem(tempTingList1, tempTingList2) + elseif #tempTingList1 > 0 then + currentTingList = tempTingList1 + elseif #tempTingList2 > 0 then + currentTingList = tempTingList2 + end + + return currentTingList + else + M._flag_zikechengshun = room.room_config.config.zikechengshun or 0 + zhongid = 0 + return M.tingPai(cardInhand, isZhong, qidui, eightLaizi) + end +end + +return M diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/EXClearingView.lua b/lua_probject/extend_project/extend/majiang/hongzhong/EXClearingView.lua index 8f76efea..a18ae6ff 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/EXClearingView.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/EXClearingView.lua @@ -1,385 +1,496 @@ require("Game.View.ResultView") +local Hu_Type_Name = import(".CS_Win_Type") local EXClearingView = {} local M = EXClearingView -function EXClearingView.new(blur_view) - setmetatable(M, {__index = ResultView}) - local self = setmetatable({}, {__index = M}) - self._full = true - ResultView.init(self, "ui://Main_Majiang/clearing") +function EXClearingView.new(root, data) + setmetatable(M, { __index = ResultView }) + local self = setmetatable({}, { __index = M }) + self._full = true + ResultView.init(self, "ui://Main_Majiang/clearing") - self._currenIndex = 0 - self._blur_view = blur_view - self._close_zone = false - self.xiPaiCtr=self._view:GetController("xipai") - - self:InitMaPai() - return self -end + self._root_view:GetChild("win_mode").visible = false - -function M:InitMaPai() - self.maPaiCtr=self._view:GetController("mapai") - self.maPaiCtr.selectedIndex=0 - - self.maPaiList={} - - for i=1,10 do - local tempMP=self._view:GetChild("niao"..i) - table.insert(self.maPaiList,tempMP) - end - -end - - -function M:IsMapaiShow(niao,isShow) - if niao then - niao.visible=isShow - end -end - - -function M:SetMaPaiValue(niao,value) - if niao then - niao.icon='ui://Main_Majiang/' ..get_majiang_prefix(DataManager.CurrenRoom.game_id).."201_"..value - end -end - -function M:SetMaPaiColor(niao,num) - niao:GetController("color").selectedIndex=num -end - -function M:HideAllMapai() - for i=1,#self.maPaiList do - self:IsMapaiShow(self.maPaiList[i],false) - self:SetMaPaiColor(self.maPaiList[i],0) - end -end - - - -function M:ShowSelectMaPai(niaoList) - printlog("ccccccccccccccccccaaaaaaaaaaaaaa00") - pt(niaoList) - if niaoList and #niaoList>0 then - self.maPaiCtr.selectedIndex=1 - self:HideAllMapai() - for i=1,#niaoList do - self:IsMapaiShow(self.maPaiList[i],true) - self:SetMaPaiValue(self.maPaiList[i],niaoList[i].card) - if niaoList[i].score>0 then - self:SetMaPaiColor(self.maPaiList[i],2) - end - end - else - self.maPaiCtr.selectedIndex=0 - end -end - - -function M:InitData(over, room, result, total_result, callback) - self._callback = callback - local _overCtr = self._view:GetController("over") - local btn_confirm = self._view:GetChild("btn_confirm") - local btn_result = self._view:GetChild("btn_showResult") - local btn_close = self._view:GetChild("big_result"):GetChild("btn_close") - local _btnCtr = self._view:GetController("button") - local _sdkCtr = self._view:GetController("sdk") - local ctr_type = self._view:GetController("type") - self._view:GetChild("tex_roominfo").text = string.format("房号%s 局%s/%s %s", room.room_id, room.curren_round, room.room_config.round, os.date("%Y-%m-%d %H:%M:%S", os.time())) - self._view:GetChild("tex_gameinfo").text = string.gsub(room.room_config:GetDes(), "\r", "") - - local paixingxiangqing=self._view:GetChild("btn_detal") - paixingxiangqing.visible=false - - local fanhuipaixing=self._view:GetChild("btn_fanhuipaixing") - fanhuipaixing.visible=false - - - local round=DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig=DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig and round>1 then - self.xiPaiCtr.selectedIndex=1 - else - self.xiPaiCtr.selectedIndex=0 - end - - - if result then - self:ShowSelectMaPai(result.niao) - end - - if over ~= 2 then - local xipai=self._view:GetChild("btn_xipai") - xipai.touchable=true - xipai.onClick:Add(function() - local xiPaiCallBack=function () - xipai.touchable=false - self.xiPaiCtr.selectedIndex=0 - ViewUtil.ErrorTip(1000000,"申请洗牌成功") - end - local _gamectr = ControllerManager.GetController(GameController) - _gamectr:SendXiPaiAction(xiPaiCallBack) - end) - if result and result.xipai_score then - --xipai.text="洗牌 积分x"..result.xipai_score - end - - if result.liuju then - ctr_type.selectedIndex = 3 - else - local info_list = result.info_list - for i = 1, #info_list do - local is_win = info_list[i].is_win - if is_win then - if info_list[i].seat == room.self_player.seat then - ctr_type.selectedIndex = 1 - else - ctr_type.selectedIndex = 2 - end - end - end - end - if over == 0 then - _btnCtr.selectedIndex = 0 - _sdkCtr.selectedIndex = 1 - btn_confirm.onClick:Add(function() - local _gamectr = ControllerManager.GetController(GameController) - _gamectr:PlayerReady() - self:DestroyWithCallback() - end) - self:AddClearItem(room, result.info_list, nil, over, result.niao, result.active_player) - elseif over == 1 then - self.xiPaiCtr.selectedIndex=0 - _btnCtr.selectedIndex = 1 - _sdkCtr.selectedIndex = 1 - btn_result.onClick:Add(function() - _overCtr.selectedIndex = 1 - _btnCtr.selectedIndex = 0 - _sdkCtr.selectedIndex = 0 - self.maPaiCtr.selectedIndex=0 - if self._qsinfo_view then - self._qsinfo_view:Dispose() - end - end) - btn_close.onClick:Add(function() - ViewManager.ChangeView(ViewManager.View_Lobby) - end) - self:AddClearItem(room, result.info_list, total_result.info_list, over, result.niao, result.active_player) - end - else - _overCtr.selectedIndex = 1 - self.xiPaiCtr.selectedIndex=0 - self.maPaiCtr.selectedIndex=0 - btn_close.onClick:Add(function() - ViewManager.ChangeView(ViewManager.View_Lobby) - end) - self:AddClearItem(room, nil, total_result.info_list, over) - end -end - -function M:AddClearItem(room, data, total_data,over, niao, active_player) - local n = over + 1 - local list_view1 = self._view:GetChild("player_list_1") - local list_view2 = self._view:GetChild("player_list_2") - if 0 == over or 1 == over then - table.sort(data, function(a,b) return a.seat > b.seat end) - list_view1:RemoveChildrenToPool() - for i=1,#data do - local item = list_view1:AddItemFromPool() - self:FillItemData(room, data[i], item, active_player, niao) - end - if #data == 3 then - list_view1.lineGap = 54 - elseif #data == 2 then - list_view1.lineGap = 108 - end - if 1 == over then - self:FillItemData2(room, total_data, list_view2) - end - elseif 2 == over then - self:FillItemData2(room, total_data, list_view2) - end -end - -function M:FillItemData(room, data, item, active_player, niao) - local _gamectr = ControllerManager.GetController(GameController) - local p = room:GetPlayerBySeat(data["seat"]) - item:GetChild("playerName").text = p.self_user.nick_name - - -- 手牌 - local hand_cards = data["hand_card"] - table.sort( hand_cards, ViewUtil.HandCardSort) - local hand_list_view = item:GetChild("hand_card_list") - hand_list_view:RemoveChildrenToPool() - for i=1,#hand_cards do - local card = hand_list_view:AddItemFromPool() - card.icon = "ui://Main_Majiang/b202_"..hand_cards[i] - end - hand_list_view.width = 52 * #hand_cards - - local fz_card = p.fz_list - local fz_card_list = item:GetChild("fz_card_list") - fz_card_list.width = 157 * #fz_card * 0.8 - fz_card_list:RemoveChildrenToPool() - for i=1,#fz_card do - if fz_card[i].type == FZType.Peng then - local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_3") - for j=1,3 do - local card = item:GetChild("card_" .. j) - card.icon = "ui://Main_Majiang/b202_"..fz_card[i].card - end - elseif fz_card[i].type == FZType.Gang or fz_card[i].type == FZType.Gang_An or fz_card[i].type == FZType.Gang_Peng then - local item = fz_card_list:AddItemFromPool("ui://Main_Majiang/clearing_fz_4") - for j=1,4 do - local card = item:GetChild("card_" .. j) - if fz_card[i].type == FZType.Gang_An and j == 4 then - card.icon = "ui://Main_Majiang/b202_00" - else - card.icon = "ui://Main_Majiang/b202_"..fz_card[i].card - end - end - end - end - - local huadd = data["hu_score"] - local gangadd = data["gang_score"] - local birdadd = data["niao_score"] - local total = data["round_score"] - local sp = " " - local str = "胡:"..huadd.."分" - str = str..sp.."杠:"..gangadd.."分" - str = str..sp.."扎鸟:"..birdadd.."分" - if data["piao_niao_score"] then - str = str..sp.."飘鸟:"..data["piao_niao_score"].."分" - end - item:GetChild("score1").text = str - -- local total_score = data["total_score"] - if total >= 0 then - item:GetChild("score2").text = "+"..total - item:GetChild("score2").grayed = false - else - item:GetChild("score2").text = total - item:GetChild("score2").grayed = true - end - - local hp_nonnegative = room:checkHpNonnegative() - item:GetController("nonnegative").selectedIndex = hp_nonnegative and 1 or 0 - if hp_nonnegative then - local hp_info = data.hp_info - local ctr_hp_limit = item:GetController("hp_limit") - local hp = d2ad(hp_info.round_actual_hp) - if hp >= 0 then hp = "+" .. tostring(hp) end - item:GetChild("tex_hp").text = hp - ctr_hp_limit.selectedIndex = hp_info.upper_limit and 1 or 0 - end - - local is_win = data["is_win"] or false - item:GetController("win").selectedIndex = is_win and 0 or 1 - if p.self_user.account_id == active_player and is_win == false and total < 0 then - item:GetController("win").selectedIndex = 2 - end - local win_card = item:GetChild("win_card") - if is_win then - win_card.icon = "ui://Main_Majiang/b202_"..data["win_card"] - local lst_niao = item:GetChild("list_niao") - lst_niao:RemoveChildrenToPool() - for i = 1, #niao do - if niao[i].score > 0 then - local card_niao = lst_niao:AddItemFromPool() - card_niao.icon = "ui://Main_Majiang/b202_" .. niao[i].card - end - end - end - if p.seat == room.banker_seat then - item:GetController("bank").selectedIndex = 1 - end -end - -function M:FillItemData2(room, data, list) - -- 赋值result_info,聊天室分享需要 - local player_list = {} - for i = 1, #data do - player_list[i] = {} - local user = room:GetPlayerBySeat(data[i].seat).self_user - player_list[i].id = user.account_id - player_list[i].hp_info = data[i].hp_info - player_list[i].score = data[i].total_score - player_list[i].house = room.owner_id == player_list[i].id and 1 or 0 - player_list[i].nick = user.nick_name - player_list[i].head_url = user.head_url - - local settle_log = data[i].settle_log - player_list[i].param = {} - player_list[i].param[1]={} - player_list[i].param[1].key = "自摸次数:" - player_list[i].param[1].value = tostring(data[i].settle_log.zimo) - player_list[i].param[2]={} - player_list[i].param[2].key = "接炮次数:" - player_list[i].param[2].value = tostring(data[i].settle_log.jie_pao) - player_list[i].param[3]={} - player_list[i].param[3].key = "点炮次数:" - player_list[i].param[3].value = tostring(data[i].settle_log.dian_pao) - player_list[i].param[4]={} - player_list[i].param[4].key = "暗杠次数:" - player_list[i].param[4].value = tostring(data[i].settle_log.an_kong) - player_list[i].param[5]={} - player_list[i].param[5].key = "明杠次数:" - player_list[i].param[5].value = tostring(data[i].settle_log.ming_kong) + self._currenIndex = 0 + self._root = root + self._close_zone = false + if data then + self.flag_back = data.flag_back end - local round = room.room_config.round - self:GenerateRoomResultInfo(round, room.room_config:GetGameName(), room.room_id, room.create_time, player_list) - local big_result = self._view:GetChild("big_result") - big_result:GetChild("txt_room_info").text = string.format("%s 房号%s 局%s/%s", os.date("%Y/%m/%d", os.time()), room.room_id, room.curren_round, room.room_config.round) - local lst_p = big_result:GetChild("player_list") - if #player_list == 3 then - lst_p.columnGap = 108 - elseif #player_list == 2 then - lst_p.columnGap = 208 - end - self:InitBigResult(room, 30) - local show_detail = room.hpOnOff == 1 - for i = 1, lst_p.numChildren do - local com_p = lst_p:GetChildAt(i - 1) - local list_param = com_p:GetChild("list_param") - for j = 1, list_param.numChildren do - local tem = list_param:GetChildAt(j - 1) - tem:GetChild("txt_value").textFormat.size = 30 - end - if show_detail then - local score = 0 - if com_p:GetController("pn").selectedIndex == 0 then - score = com_p:GetChild("txt_navigate").text - else - score = com_p:GetChild("txt_positive").text - end - score = score / room.score_times - com_p:GetChild("tex_detail_score").text = string.format("%s × %s倍", score, room.score_times) - end + -- self:InitMaPai() + + return self +end + +-- function M:InitMaPai() +-- self.maPaiCtr = self._view:GetController("mapai") +-- self.maPaiCtr.selectedIndex = 0 + +-- self.maPaiList = {} + +-- for i = 1, 8 do +-- local tempMP = self._view:GetChild("niao" .. i) +-- table.insert(self.maPaiList, tempMP) +-- end +-- end + +function M:InitData(over, room, result, total_result, callback, isWitness, witnessCallbak) + -- print("===============================InitData===========================", over, room, result, total_result) + -- pt(room) + -- pt(result) + -- Pt(total_result) + self._callback = callback + self._witnessCallbak = witnessCallbak + local showClearMainBtn = self._view:GetChild("btn_showClearMain") + local nextRoundBtn = self._view:GetChild("btn_nextRound") + local nextRoundBtn2 = self._view:GetChild("Btn_NextRound2") + local endRound = self._view:GetChild("Btn_EndRound") + local _overCtr = self._view:GetController("over") + local mainCtr = self._view:GetController("main") + local playerNum = self._view:GetController("playerNum") + local showBtnTypeCtr = self._view:GetController("showType") + local Text_BoJing = self._view:GetChild('Text_BoJing') + + Text_BoJing.visible = false + + if self.flag_back then + mainCtr.selectedIndex = 1 + nextRoundBtn2.touchable = false + end + + if result then + if result.cardList then + result.cardList = json.decode(result.cardList) + else + result.cardList = {} + end + end + self.list_lastCard = self._view:GetChild('list_lastCard') + + self.list_lastCard:SetVirtual() + self.list_lastCard.itemRenderer = function(index, obj) + self:RemindCardRender(result.cardList[index + 1], obj) + end + + local peopleNum = room.room_config.people_num + + playerNum.selectedIndex = peopleNum - 2 + + showClearMainBtn.onClick:Set(function() + mainCtr.selectedIndex = 1 + end) + + nextRoundBtn.onClick:Set(function() + if self._callback_jiangma then + self._callback_jiangma() + end + if isWitness and isWitness == 1 then + if self._witnessCallbak then + self._witnessCallbak() + end + self:DestroyWithCallback() + else + if over == 0 then + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:PlayerReady() + self:DestroyWithCallback() + else + mainCtr.selectedIndex = 1 + _overCtr.selectedIndex = 1 + end + end + end) + + endRound.onClick:Set(function() + if room._flag_lobby then + ViewManager.ChangeView(ViewManager.View_Lobby) + else + ViewManager.ChangeView(ViewManager.View_Family) + end + end) + + local Btn_Share = self._view:GetChild('Btn_Share') + if Btn_Share then + Btn_Share.onClick:Set(function() + self:SaveRenderTextureToPNG() + end) + end + + local Btn_Copy = self._view:GetChild('Btn_Copy') + if Btn_Copy then + Btn_Copy.onClick:Set(function() + local resultStr = "" + if room.group_id ~= 0 then + local group = DataManager.groups:get(room.group_id) + resultStr = string.format("【%s】俱乐部,", group.name) + end + resultStr = string.format("%s%s\n", resultStr, room.game_info.name) + for i = 1, peopleNum do + local totalInfoList = total_result.info_list[i] + local playInfo = room:GetPlayerBySeat(totalInfoList.seat) + resultStr = string.format("%s%s\nID:%s【%s】\n", resultStr, playInfo.self_user.nick_name, + playInfo.self_user.account_id, + totalInfoList.total_score) + end + resultStr = string.format("%s房号:%s 局数:%s/%s局\n结束时间:%s", resultStr, room.room_id, room.curren_round, + room.room_config.round, os.date("%Y-%m-%d %H:%M:%S", os.time())) + ViewUtil.__openWx() + GameApplication.Instance:CopyToClipboard(resultStr) + end) + end + + if over == 0 then + showBtnTypeCtr.selectedIndex = 0 + _overCtr.selectedIndex = 0 + self:fillResult0(room, peopleNum, result) + nextRoundBtn2.onClick:Set(function() + if self._callback_jiangma then + self._callback_jiangma() + end + if isWitness and isWitness == 1 then + if self._witnessCallbak then + self._witnessCallbak() + end + self:DestroyWithCallback() + else + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:PlayerReady() + self:DestroyWithCallback() + end + end) + elseif over == 1 then + self:fillResult1(room, peopleNum, total_result) + if result then + _overCtr.selectedIndex = 0 + self:fillResult0(room, peopleNum, result) + nextRoundBtn2.onClick:Set(function() + _overCtr.selectedIndex = 1 + end) + else + showBtnTypeCtr.selectedIndex = 1 + _overCtr.selectedIndex = 1 + end + else --解散房间如果没有开局直接退出不显示结算界面,over=2 + if room.curren_round > 0 then + mainCtr.selectedIndex = 1 + _overCtr.selectedIndex = 1 + showBtnTypeCtr.selectedIndex = 1 + self:fillResult1(room, peopleNum, total_result) + else + if room._flag_lobby then + ViewManager.ChangeView(ViewManager.View_Lobby) + else + ViewManager.ChangeView(ViewManager.View_Family) + end + end + end +end + +function M:fillResult0(room, peopleNum, result) + local config = ExtendManager.GetExtendConfig(room.game_id) + local mode = config:GetGameInfo() + local gamePlay = mode:LoadConfigToDetail(json.encode(room.room_config.config), json.encode(room.room_config.hpData)) + self._view:GetChild("Label_GamePlay").title = string.format("第%s/%s局,%s", room.curren_round, + room.room_config.round, gamePlay) + self.list_lastCard.numItems = #result.cardList + self._view:GetChild('n147').text = string.format("剩余%d张未显示", #result.cardList) + for i = 1, peopleNum do + local playerInfoComp = self._view:GetChild(string.format("Comp_Player%d", i)) + + local allCardsList = playerInfoComp:GetChild("list_allCards") + local huCardBtn = playerInfoComp:GetChild("Btn_Card_Hu") + local jiangMaList = playerInfoComp:GetChild("list_JiangMa") + local ziMoCtr = playerInfoComp:GetController("isZiMo") + local dianPaoCtr = playerInfoComp:GetController("isPao") + local isMeCtr = playerInfoComp:GetController("IsMe") + local isZhuang = playerInfoComp:GetController("zhuang") + + local infoList = result.info_list[i] + local infoJiangma = result.niao + local playInfo = room:GetPlayerBySeat(infoList.seat) + local fzCardInfo = playInfo.fz_list + local fzInfoNum = #fzCardInfo + local handInfoNum = #infoList.hand_card + + self:fillHead(playInfo.self_user.head_url, playerInfoComp) + + infoList.jing_score = infoList.jing_score or 0 + infoList.gang_score = infoList.gang_score or 0 + infoList.hu_score = infoList.hu_score or 0 + infoList.round_score = infoList.round_score or 0 + + playerInfoComp:GetChild("Text_BoJing").visible = false + + playerInfoComp:GetChild("text_name").text = playInfo.self_user.nick_name + playerInfoComp:GetChild("Text_BoJing").text = infoList.jing_score >= 0 and + string.format("+%d", infoList.jing_score) or infoList.jing_score + playerInfoComp:GetChild("Text_Gang").text = infoList.gang_score >= 0 and + string.format("+%d", infoList.gang_score) or infoList.gang_score + playerInfoComp:GetChild("Text_Hu").text = infoList.hu_score >= 0 and string.format("+%d", infoList.hu_score) or + infoList.hu_score + playerInfoComp:GetChild("Text_Tatal").text = infoList.round_score >= 0 and + string.format("+%d", infoList.round_score) or infoList.round_score + + for j = 1, fzInfoNum do + if fzCardInfo[j].type == FZType.Peng then + local item = allCardsList:AddItemFromPool("ui://Main_Majiang/Comp_Clearing_FZ_3") + for l = 1, 3 do + local card = item:GetChild(string.format("Btn_Card%d", l)) + card.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), fzCardInfo[j].card) + print("===============================FZType.Peng", room.jing, fzCardInfo[j].card) + if room.jing == fzCardInfo[j].card then + card:GetController('jing').selectedIndex = 1 + else + card:GetController('jing').selectedIndex = 0 + end + end + elseif fzCardInfo[j].type == FZType.Chi then + local item = allCardsList:AddItemFromPool("ui://Main_Majiang/Comp_Clearing_FZ_3") + for l = 1, 3 do + local card = item:GetChild(string.format("Btn_Card%d", l)) + card.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), fzCardInfo[j].opcard + [l]) + print("===============================FZType.Chi", room.jing, fzCardInfo[j].opcard[l]) + + if room.jing == fzCardInfo[j].opcard[l] then + card:GetController('jing').selectedIndex = 1 + else + card:GetController('jing').selectedIndex = 0 + end + end + elseif fzCardInfo[j].type == FZType.Gang or fzCardInfo[j].type == FZType.Gang_An or fzCardInfo[j].type == FZType.Gang_Peng then + local item = allCardsList:AddItemFromPool("ui://Main_Majiang/Comp_Clearing_FZ_4") + for l = 1, 4 do + local card = item:GetChild(string.format("Btn_Card%d", l)) + if fzCardInfo[j].type == FZType.Gang_An and j == 4 then + card.icon = "ui://Main_Majiang/b202_00" + else + card.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), fzCardInfo[j].card) + print("===============================FZType.Gang", room.jing, fzCardInfo[j].card) + + if room.jing == fzCardInfo[j].card then + card:GetController('jing').selectedIndex = 1 + else + card:GetController('jing').selectedIndex = 0 + end + end + end + end + end + + local handCardItem = allCardsList:AddItemFromPool("ui://Main_Majiang/Comp_HandCard") + local handCardList = handCardItem:GetChild("list") + --手牌排序 + table.sort(infoList.hand_card, self.HandCardSortAndJing) + handCardList:SetVirtual() + handCardList.itemRenderer = function(index, obj) + obj.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), infoList.hand_card[index + 1]) + if room.jing == infoList.hand_card[index + 1] then + obj:GetController('jing').selectedIndex = 1 + else + obj:GetController('jing').selectedIndex = 0 + end + end + handCardList.numItems = handInfoNum + --拿取实际的子项大小 + local handCard = 78 + local hangColumGrap = -4 + local fzCard = 234 + local fzColumGrap = 36 + handCard = handCardList:GetChildAt(handInfoNum - 1).width + hangColumGrap = handCard + handCardList.columnGap + if fzInfoNum > 0 then + fzCard = allCardsList:GetChildAt(0).width + fzColumGrap = allCardsList.columnGap + end + allCardsList.width = fzCard * fzInfoNum + handCard + (handInfoNum - 1) * hangColumGrap + + fzColumGrap * (fzInfoNum) + + if infoList.seat == room.self_player.seat then + isMeCtr.selectedIndex = 1 + end + + if infoList.seat == room.self_player.seat then + isMeCtr.selectedIndex = 1 + end + + if infoList.seat == room.banker_seat then + isZhuang.selectedIndex = 1 + end + + if infoList.is_win then + local winInfo = "" + for j = 1, #infoList.win_list do + winInfo = string.format("%s,%s", winInfo, Hu_Type_Name[infoList.win_list[j].type]) + end + winInfo = string.sub(winInfo, 2, -1) + playerInfoComp:GetChild("text_huShow").text = winInfo + + if room.isZiMoHu then + ziMoCtr.selectedIndex = 1 + end + + + huCardBtn.icon = string.format("ui://Main_Majiang/b202_%d", infoList.win_card) + if room.jing == infoList.win_card then + huCardBtn:GetController('jing').selectedIndex = 1 + else + huCardBtn:GetController('jing').selectedIndex = 0 + end + huCardBtn.visible = true + + jiangMaList.visible = true + jiangMaList:SetVirtual() + jiangMaList.itemRenderer = function(index, obj) + obj.icon = string.format("ui://Main_Majiang/b202_%d", infoJiangma[index + 1].card) + obj:GetController('bg').selectedIndex = infoJiangma[index + 1].score + obj:GetController('jing').selectedIndex = infoJiangma[index + 1].card == room.jing and 1 or 0 + end + jiangMaList.numItems = #infoJiangma + -- jiangMaList.columnCount = #infoJiangma / 2 + else + playerInfoComp:GetChild("text_huShow").text = "" + if not room.isZiMoHu and playInfo.self_user.account_id == result.active_player then + dianPaoCtr.selectedIndex = 1 + end + + huCardBtn.visible = false + jiangMaList.visible = false + end + end +end + +function M:fillResult1(room, peopleNum, total_result) + local gameNameAndRoomIDText = self._view:GetChild("Text_GameNameAndRoomID") + local familyIDText = self._view:GetChild("Text_FamilyID") + print("lingmeng fillResult1") + pt(room) + --初始化大赢家和最佳炮手 + local bigWin = { seat = -1, score = 0 } + local bestPao = { seat = -1, times = 0 } + --循环数据得出分数最大的大赢家,以及点炮次数最多的最佳炮手 + for i = 1, #total_result.info_list do + if total_result.info_list[i].total_score > bigWin.score then + bigWin = { seat = total_result.info_list[i].seat, score = total_result.info_list[i].total_score } + end + if total_result.info_list[i].settle_log.fangpao and total_result.info_list[i].settle_log.fangpao > bestPao.times then + bestPao = { seat = total_result.info_list[i].seat, times = total_result.info_list[i].settle_log.fangpao } + end + end + for i, v in pairs(DataManager.SelfUser.games) do + if v.game_id == room.game_id then + gameNameAndRoomIDText.text = string.format("%s 房号:%s", v.name, room.room_id) + end + end + if #gameNameAndRoomIDText.text <= 0 then + gameNameAndRoomIDText.text = string.format("房号:%s", room.room_id) end if room.group_id ~= 0 then - big_result:GetController("group").selectedIndex = 1 + familyIDText.text = string.format("俱乐部:%s", room.group_id) + else + familyIDText.visible = false + self._view:GetChild('n148').visible = false + end + self._view:GetChild("Text_RoundNum").text = string.format("局数:%s/%s", room.curren_round, room.room_config.round) + self._view:GetChild("Text_Time").text = os.date("%Y-%m-%d %H:%M:%S", os.time()) + + for i = 1, peopleNum do + local resultInfoComp = self._view:GetChild(string.format("Comp_ResultInfo%d", i)) + local totalInfoList = total_result.info_list[i] + local playInfo = room:GetPlayerBySeat(totalInfoList.seat) + + self:fillHead(playInfo.self_user.head_url, resultInfoComp) + + resultInfoComp:GetChild('Text_Name').text = playInfo.self_user.nick_name + resultInfoComp:GetChild('Text_ID').text = string.format("ID:%s", playInfo.self_user.account_id) + resultInfoComp:GetChild('Text_TotalScore').text = totalInfoList.total_score >= 0 and + string.format("+%s", totalInfoList.total_score) or totalInfoList.total_score + resultInfoComp:GetChild('Text_ZiMo').text = string.format("自摸 %d次", totalInfoList.settle_log.zimo or 0) + resultInfoComp:GetChild('Text_JiePao').text = string.format("接炮 %d次", totalInfoList.settle_log.jiepao or 0) + resultInfoComp:GetChild('Text_FangPao').text = string.format("放炮 %d次", totalInfoList.settle_log.fangpao or 0) + resultInfoComp:GetChild('Text_AnGang').text = string.format("暗杠 %d次", totalInfoList.settle_log.an_kong or 0) + resultInfoComp:GetChild('Text_MingGang').text = string.format("明杠 %d次", + totalInfoList.settle_log.ming_kong or 0) + resultInfoComp:GetChild('Text_FangGang').text = string.format("放杠 %d次", + totalInfoList.settle_log.fanggang or 0) + + resultInfoComp:GetController("win").selectedIndex = totalInfoList.total_score >= 0 and 1 or 0 + if totalInfoList.seat == bigWin.seat then + resultInfoComp:GetController("bigWin").selectedIndex = 1 + -- else + -- resultInfoComp:GetController("bigWin").selectedIndex = 0 + end + if totalInfoList.seat == bestPao.seat then + resultInfoComp:GetController("fangPao").selectedIndex = 1 + -- else + -- resultInfoComp:GetController("fangPao").selectedIndex = 0 + end end - DataManager.CurrenRoom = nil end -function M:LoadHead(p, room) - local btn_head = self._view:GetChild("btn_head") - for i = 1, #room.player_list do - local player = room.player_list[i] - if p.seat == player.seat and player.self_user.head_url ~= "" then - ImageLoad.Load(player.self_user.head_url, btn_head.icon) - end - end +function M:fillHead(url, view) + ImageLoad.Load(url, view:GetChild("Btn_Head")._iconObject) end -function M:DestroyWithCallback() - if self._callback then - self._callback() - end - self:Destroy() +function M:RemindCardRender(data, obj) + local room = DataManager.CurrenRoom + obj.icon = string.format("ui://Main_Majiang/%s202_%d", self:GetPrefix(), data) + if room.jing == data then + obj:GetController('jing').selectedIndex = 1 + else + obj:GetController('jing').selectedIndex = 0 + end end -return M \ No newline at end of file +function M.HandCardSortAndJing(a, b) + local jing = DataManager.CurrenRoom.jing + if a == jing or b == jing then + if a == b then + return a < b + end + return a == jing + else + if a < 200 then + a = a + 1000 + elseif a < 300 then + a = a + 3000 + elseif a < 400 then + a = a + 2000 + else + a = a + 4000 + end + if b < 200 then + b = b + 1000 + elseif b < 300 then + b = b + 3000 + elseif b < 400 then + b = b + 2000 + else + b = b + 4000 + end + return a < b + end +end + +local prefix +function M:GetPrefix() + -- if not prefix then + prefix = get_majiang_prefix(10) + -- end + return prefix +end + +function M:SetJiangMaCallback(fct) + self._callback_jiangma = fct +end + +function M:DestroyWithCallback() + if self._callback then + self._callback() + end + self:Destroy() +end + +return M diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/EXGameController.lua b/lua_probject/extend_project/extend/majiang/hongzhong/EXGameController.lua index 2d68c53e..1a3d8539 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/EXGameController.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/EXGameController.lua @@ -33,6 +33,12 @@ function M:init(name) self._eventmap[TX_Protocol.GAME_EVT_NIAO] = self.OnEventNiao self._eventmap[TX_Protocol.GAME_EVT_PIAOTIP] = self.OnEventPiaoTip self._eventmap[TX_Protocol.GAME_EVT_PIAO] = self.OnEventPiao + + self._eventmap[TX_Protocol.GAME_EVT_GANGZI] = self.OnEventGangCards + self._eventmap[TX_Protocol.GAME_EVT_BUGANG] = self.OnEventBuGang + + self._eventmap[TX_Protocol.GAME_EVT_RESIDUE_CARD] = self.OnEventResidueCard + self._eventmap[TX_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai self._eventmap[TX_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim @@ -82,33 +88,76 @@ end local __pre_delete_card = false -- 发送出牌指令到服务器 -function M:SendOutCard(card, callback) - local _room = self._room - local p = _room.self_player - + +-------------------------展示牌--------------------------- +function M:SendNextCard(card) local _data = {} - _data["card"] = card - _data["card_list"] = p.card_list - if p.outcard_list and #p.outcard_list>0 then - _data["outcard_list"] = p.outcard_list - end - - local _client = ControllerManager.GameNetClinet + _data["card"] = tonumber(card) + local _client = ControllerManager.GameNetClinet + _client:send(TX_Protocol.GAME_NEXT_CARD, _data) +end + +function M:ReqResidueCard() + local _data = {} + _data["card"] = 0 + local _client = ControllerManager.GameNetClinet + _client:send(TX_Protocol.GAME_RESIDUE_CARD, _data) +end + +------------------------------------------------------------ + +function M:SendOutCard(data, callback) + local _data = {} + _data["card"] = data.card + _data["isTip"] = data.isTip + local _room = self._room + local _client = ControllerManager.GameNetClinet _client:send(TX_Protocol.GAME_DIS_CARD, _data) -- 进行预删牌处理 local p = _room.self_player _room.curren_outcard_seat = -1 - list_remove(p.card_list,card) - table.sort(p.card_list, ViewUtil.HandCardSort) + list_remove(p.card_list, data.card) + + table.sort(p.card_list, self.HandCardSortAndJing) + + p.hand_left_count = p.hand_left_count - 1 if not p.outcard_list then p.outcard_list = {} end - p.outcard_list[#p.outcard_list+1] = card + p.outcard_list[#p.outcard_list + 1] = data.card __pre_delete_card = true callback() end +function M:SendGangCard(card) + local _data = {} + _data["card"] = card + local _client = ControllerManager.GameNetClinet + _client:send(TX_Protocol.GAME_EVT_DOGANG, _data) +end + +function M:OnEventGangCards(evt_data) + printlog("OnEventGangCards") + pt(evt_data) + DispatchEvent(self._dispatcher, TX_GameEvent.SendGangZi, evt_data["gangzi1"], evt_data["gangzi2"], + evt_data["gangnum"], true) +end + +function M:OnEventBuGang(evt_data) + printlog("OnEventBuGang") + pt(evt_data) + DispatchEvent(self._dispatcher, TX_GameEvent.EventBuGang, evt_data["info"], true) +end + +function M:OnEventResidueCard(evt_data) + printlog("OnEventResidueCard") + pt(evt_data) + if evt_data.seat ~= DataManager.CurrenRoom.self_player.seat then + return + end + DispatchEvent(self._dispatcher, TX_GameEvent.EventResidueCard, evt_data["residueCard"]) +end -- 发送放子选择到服务器 function M:SendAction(id) @@ -124,18 +173,32 @@ function M:OnEventSendCards(evt_data) return end - local _room = self._room - --if not _room.room_config.piao_niao or _room.self_player.entrust then - -- _room.curren_round = _room.curren_round + 1 - --end - _room.curren_round = evt_data["round"] - + local _room = self._room + if not _room.room_config.piao_niao or _room.self_player.entrust then + _room.curren_round = _room.curren_round + 1 + end if _room.curren_round > 0 then _room.playing = true end + printlog("开始发牌===========>>>") + pt(evt_data) + + local room = DataManager.CurrenRoom + --printlog(evt_data.laiziCard) + --printlog(evt_data.laiziCard2) + --printlog(evt_data.laiziCardBefore) + --printlog(evt_data.laiziCard2Before) + + + DispatchEvent(self._dispatcher, TX_GameEvent.SendGangZi, 102, 103, 0, true) + + + -- _room.SelfPlayer.AutoOutCard = false local handcards = evt_data["card_list"] local p = _room.self_player local seat = evt_data["bank_seat"] + local jing = evt_data["jing"] + _room.jing = jing self._cacheEvent:Enqueue(function() _room.banker_seat = seat for i=1,#_room.player_list do @@ -144,10 +207,11 @@ function M:OnEventSendCards(evt_data) _room.player_list[i].card_list = {} end p.card_list = handcards - self._room.self_player.hand_left_count = #handcards - table.sort( handcards, ViewUtil.HandCardSort ) - DispatchEvent(self._dispatcher,TX_GameEvent.SendCards, p) - end) + self._room.self_player.hand_left_count = #handcards + + table.sort(handcards, self.HandCardSortAndJing) + DispatchEvent(self._dispatcher, TX_GameEvent.SendCards, p) + end) end function M:OnEventOutCard(evt_data) @@ -163,7 +227,8 @@ function M:OnEventOutCard(evt_data) else if seat == _room.self_player.seat then list_remove(p.card_list, card) - table.sort(p.card_list, ViewUtil.HandCardSort) + + table.sort(p.card_list, self.HandCardSortAndJing) end p.hand_left_count = p.hand_left_count - 1 if not p.outcard_list then p.outcard_list = {} end @@ -183,8 +248,9 @@ function M:OnEventTakeCard(evt_data) self._cacheEvent:Enqueue(function() p.hand_left_count = p.hand_left_count +1 if (seat == _room.self_player.seat) then - _room.self_player.card_list[#_room.self_player.card_list+1] = card - -- table.sort( _room.self_player.card_list, ViewUtil.HandCardSort ) + _room.self_player.card_list[#_room.self_player.card_list + 1] = card + + -- table.sort( _room.self_player.card_list, self.HandCardSortAndJing ) end DispatchEvent(self._dispatcher,TX_GameEvent.GetCard, seat, card, left_count) end) @@ -217,6 +283,8 @@ function M:OnEventFzTips(evt_data) tip.weight = dtip["weight"] tip.card = dtip["card"] tip.type = dtip["type"] + tip.opcard = dtip["opcard"] + -- if (dtip["opcard"]) then -- local opcard = dtip["opcard"] -- tip.OpCard = opcard @@ -225,7 +293,11 @@ function M:OnEventFzTips(evt_data) -- end tiplist:AddTip(tip) end - DispatchEvent(self._dispatcher,TX_GameEvent.FZTips, tiplist, weight) + --排序规则,胡杠碰 + tiplist:SortList(function(a, b) + return a.type < b.type + end) + DispatchEvent(self._dispatcher, TX_GameEvent.FZTips, tiplist, weight) end) end @@ -256,12 +328,19 @@ function M:OnEventFzAction(evt_data) end end end + fz = {} + fz.card = card + fz.type = type + fz.active_card = actice_card if (index == -1) then - fz = {} - fz.card = card - fz.type = type - fz.active_card = actice_card - p.fz_list[#p.fz_list+1] = fz + if (ftype == FZType.Chi) then + local data = {} + data[1] = opcard[1] + data[2] = card + data[3] = opcard[2] + fz.opcard = data + end + p.fz_list[#p.fz_list + 1] = fz end fz.from_seat = from_seat local remove_num = #opcard @@ -273,7 +352,7 @@ function M:OnEventFzAction(evt_data) end p.hand_left_count = p.hand_left_count - remove_num - if from_seat ~= p.seat then + if from_seat ~= p.seat and ftype ~= FZType.Gang_Peng then -- if (fz.Type == FZType.Chi) then card = actice_card end local fp = _room:GetPlayerBySeat(from_seat) table.remove(fp.outcard_list,#fp.outcard_list) @@ -287,21 +366,28 @@ function M:OnEventHu(evt_data) local cards = evt_data["card"] local win_p = self._room:GetPlayerBySeat(evt_data["seat"]) local lose_p = self._room:GetPlayerBySeat(evt_data["from_seat"]) - local hu_card = evt_data["win_card"] - table.sort(cards, ViewUtil.HandCardSort) - cards[#cards +1] = hu_card - + local win_card = evt_data["win_card"] + local win_list = evt_data["win_list"] + local scoreData = evt_data["result"].info_list + self._cacheEvent:Enqueue(function() win_p.card_list = cards - DispatchEvent(self._dispatcher,TX_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], cards, hu_card) + table.sort(win_p.card_list, self.HandCardSortAndJing) + DispatchEvent(self._dispatcher, TX_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], win_card, cards, + win_list, scoreData) end) end function M:OneventResult1(evt_data) local over = evt_data.type + printlog("OneventResult1") + pt(evt_data) --0:小结算 1:小大结算 2:大结算 self._room._reload_flag = false self._room.playing = false + if evt_data.result then + evt_data.result.cardList = evt_data.cardList + end if 0 == over then local result = evt_data.result self._cacheEvent:Enqueue(function() @@ -392,4 +478,34 @@ function M:Discard(card) _client:send(Protocol.Game_Da, _data) end +function M.HandCardSortAndJing(a, b) + local jing = DataManager.CurrenRoom.jing + if a == jing or b == jing then + if a == b then + return a < b + end + return a == jing + else + if a < 200 then + a = a + 1000 + elseif a < 300 then + a = a + 3000 + elseif a < 400 then + a = a + 2000 + else + a = a + 4000 + end + if b < 200 then + b = b + 1000 + elseif b < 300 then + b = b + 3000 + elseif b < 400 then + b = b + 2000 + else + b = b + 4000 + end + return a < b + end +end + return M \ No newline at end of file diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/EXGameInfo.lua b/lua_probject/extend_project/extend/majiang/hongzhong/EXGameInfo.lua index 2ee052c4..5f9b0d3a 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/EXGameInfo.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/EXGameInfo.lua @@ -2,307 +2,285 @@ local EXGameInfo = {} local M = EXGameInfo + function EXGameInfo.new(blur_view) - setmetatable(M, {__index = IGameInfo}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = IGameInfo }) + local self = setmetatable({}, { __index = M }) self.class = "EXGameInfo" - UIPackage.AddPackage("extend/majiang/hongzhong/ui/Info_MJ_HongZhong") + UIPackage.AddPackage("extend/majiang/fuzhou/ui/Info_MJ_FuZhou") return self end function M:FillData() - self._maxPlayer = 4 -- 默认玩家人数 - self._roundChoice = 4 -- 回合选项数 - - if oldGameVersion==1 then - self._config = UIPackage.CreateObjectFromURL("ui://Info_MJ_HongZhong/Cgm_create_room") - else - self._config = UIPackage.CreateObjectFromURL("ui://Info_MJ_HongZhong/Cgm_create_room_yueyang") - end - - if oldGameVersion==2 then - self._config:GetController("xipai").selectedIndex=0 - - self.xipaiValueText=self._config:GetChild('xipaifen') - self.xipaiValue=1 + self._maxPlayer = 4 -- 默认玩家人数 + self._roundChoice = 3 -- 回合选项数 + self._config = UIPackage.CreateObjectFromURL("ui://Info_MJ_FuZhou/Label_Detail_83") - self.anchouValueText=self._config:GetChild('anchoufen') - self.anchouValueText.text=1 - self.anchouValue=1 - - local btn_cr = self._config:GetChild('sdsrbtn') - btn_cr.onClick:Set( - function() - - local gniv = GroupNumberInputView_Game.new(nil, function(num) + local jiangmaSlider = self._config:GetChild("n92") + jiangmaSlider.onChanged:Set(function() + self._config:GetChild("n93").text = string.format("奖%s马", Mathf.Round(jiangmaSlider.value) * 2) + end) - local value = limit - if otype == 1 then - value = value + ad2d(num) - elseif otype == - 1 then - value = value - ad2d(num) - else - value = ad2d(num) - end - - if value < 0 then - ViewUtil.ErrorTip(1,"输入数据异常!") - end - - self.xipaiValueText.text=value/1000 - self.xipaiValue=value/1000 - - end, 3, nil) - gniv:Show() - - - end - ) + local com_editSetting = self._config:GetChild("com_editSetting") + com_editSetting:GetController("cGps").selectedIndex = 2 + local ctr_round = self._config:GetController("round") + if ctr_round.selectedIndex == 0 then + com_editSetting:GetController("oneRound").selectedIndex = 1 + else + com_editSetting:GetController("oneRound").selectedIndex = 0 + end + self._config:GetController("round").onChanged:Set(function() + if ctr_round.selectedIndex == 0 then + com_editSetting:GetController("oneRound").selectedIndex = 1 + else + com_editSetting:GetController("oneRound").selectedIndex = 0 + end + end) +end - local btn_cr2 = self._config:GetChild('anchoubtn') - btn_cr2.onClick:Set( - function() - - local gniv = GroupNumberInputView_Game.new(nil, function(num) +function M:FillDataNew() + self._maxPlayer = 4 -- 默认玩家人数 + self._roundChoice = 3 -- 回合选项数 + self._config = UIPackage.CreateObjectFromURL("ui://Info_MJ_FuZhou/Label_Detail_83") - local value = limit - if otype == 1 then - value = value + ad2d(num) - elseif otype == - 1 then - value = value - ad2d(num) - else - value = ad2d(num) - end - - if value < 0 then - ViewUtil.ErrorTip(1,"输入数据异常!") - end - - self.anchouValueText.text=value/1000 - self.anchouValue=value/1000 - - end, 3, nil) - gniv:Show() - - - end - ) - - end - -end + local jiangmaSlider = self._config:GetChild("n92") + jiangmaSlider.onChanged:Set(function() + self._config:GetChild("n93").text = string.format("奖%s马", Mathf.Round(jiangmaSlider.value) * 2) + end) -local _help_url= "ui://Info_MJ_HongZhong/Com_help" + local com_editSetting = self._config:GetChild("com_editSetting") + + com_editSetting:GetController("cGps").selectedIndex = 2 + + local ctr_round = self._config:GetController("round") + if ctr_round.selectedIndex == 0 then + com_editSetting:GetController("oneRound").selectedIndex = 1 + else + com_editSetting:GetController("oneRound").selectedIndex = 0 + end + self._config:GetController("round").onChanged:Set(function() + if ctr_round.selectedIndex == 0 then + com_editSetting:GetController("oneRound").selectedIndex = 1 + else + com_editSetting:GetController("oneRound").selectedIndex = 0 + end + end) +end + +local _help_url = "ui://Info_MJ_FuZhou/Com_help" function M:GetHelpUrl() return _help_url end -local _icon_url = "ui://Info_MJ_HongZhong/icon" +local _icon_url = "ui://Info_MJ_FuZhou/icon" function M:GetIconUrl() - return _icon_url + return "ui://Lobby/fuzhoumajiang2", "ui://Lobby/fuzhoumajiang1" end -local _icon_url1 = "ui://Info_MJ_HongZhong/icon1" +local _icon_url1 = "ui://Info_MJ_FuZhou/icon1" function M:GetIconUrl1() return _icon_url1 end -local _play_list = {}--{"红中麻将","三人红中","二人红中"} +local _play_list = {} function M:GetPlayList() return _play_list end +function M:GetPageURL() + return "ui://Info_MJ_FuZhou/Label_Detail_83" +end + function M:SelectedConfigData() local _config = self._config local round = _config:GetController("round").selectedIndex + 1 - local people = _config:GetController("play_list").selectedIndex+2 - local qiangkong = _config:GetChild("btn_qgh").selected and true or false - local qiangkong_niao = _config:GetChild("btn_qghjm").selected and true or false - local seven_pair = _config:GetChild("btn_qidui").selected and true or false - local niao_type = _config:GetController("NiaoType").selectedIndex + 1 - local zha_ma = _config:GetController("zha").selectedIndex + 1 - local wo_niao = _config:GetController("wowoniao").selectedIndex + 1 - local laizi = _config:GetChild("btn_laizi").selected and true or false - local aa = _config:GetController("Cost").selectedIndex - -- local zhuangxian = _config:GetChild("btn_zhuangxian").selected and true or false - local piao_niao = _config:GetChild("btn_piao_niao").selected - local jiangma = _config:GetController("jiangma").selectedIndex - local wuguizhuopaojiabei = _config:GetChild("btn_wuhongzhongzuobaofanbei").selected - - ---------- - local piao_niao1=0 - if _config:GetController('piao') then - piao_niao1=_config:GetController('piao').selectedIndex - end - local piao1=false - local piao2=false - local piao3=false - local piao_niao_opt=0 - if piao_niao1==2 then - piao_niao_opt=_config:GetController("piaofen").selectedIndex - end - - - local laizi4_hu = false - if _config:GetChild("btn_sihongzhong") then - laizi4_hu = _config:GetChild("btn_sihongzhong").selected - end - - local hz_hu =false - if _config:GetChild("btn_wuhongzhong") then - hz_hu = _config:GetChild("btn_wuhongzhong").selected - end - - local wuguijiabei =false - if _config:GetChild("btn_wuhongzhongzimo") then - wuguijiabei = _config:GetChild("btn_wuhongzhongzimo").selected - end - - local di_fen=false - if _config:GetController('difen') then - di_fen=_config:GetController('difen').selectedIndex - end - - local xi_pai=false - if _config:GetChild("xipai") then - xi_pai=_config:GetChild("xipai").selected - end - - local fengding_score=0 - if _config:GetController("fengding") then - fengding_score=_config:GetController("fengding").selectedIndex - end - ---------- + local people = _config:GetController("peopleNum").selectedIndex + 2 + local zimo = _config:GetController("ZiMo").selectedIndex + local shaozhuang = _config:GetController("ShaoZhuang").selectedIndex + local fengding = _config:GetController("FengDing").selectedIndex + local Tiandihu = _config:GetController("TianDiHu").selectedIndex + local zikechengshun = _config:GetController("ZiKeChengShun").selectedIndex + local zhuangfenfanbei = _config:GetController('ZhuangFenFanBei').selectedIndex + + local jiangma = Mathf.Round(_config:GetChild("n92").value) + + local xi_pai = false + local xi_paifen = 0 + if _config:GetChild("xipai") then + xi_pai = _config:GetChild("xipai").selected + end + + + + ------ local _data = {} _data["opt"] = round _data["maxPlayers"] = people - -- _data["maxPlayers"] = 2 - -- _data["zhuangxian"] = zhuangxian - _data["qidui"] = seven_pair - _data["qiangkong"] = qiangkong - _data["qiangkong_niao"] = not qiangkong and false or qiangkong_niao - _data["niao"] = niao_type - if oldGameVersion==1 then - _data["niao_opt"] = niao_type == 2 and 1 or (niao_type == 3 and wo_niao or zha_ma) - else - _data["niao_opt"] = niao_type == 2 and 1 or (niao_type == 3 and wo_niao or zha_ma) - end - - _data["niao_opt_score"] = wo_niao - - - _data["laizi8"] = laizi - _data["AA"] = aa - if oldGameVersion==1 then - _data["piao_niao"] = piao_niao - else - _data["piao_niao"] = piao_niao1 - end - + + _data["zimo"] = zimo + _data["shaozhuang"] = shaozhuang + _data["fengding"] = fengding + _data["Tiandihu"] = Tiandihu + _data["zikechengshun"] = zikechengshun + _data["zhuangfenfanbei"] = zhuangfenfanbei + + _data["jiangma"] = jiangma - - _data['piao1'] = piao1 - _data['piao2'] = piao2 - _data['piao3'] = piao3 - _data['laizi4_hu'] = laizi4_hu - _data['hz_hu'] = hz_hu - _data['wuguijiabei'] = wuguijiabei - _data['di_fen'] = di_fen - _data['xi_pai'] = xi_pai - - auto_piao=false - if piao_niao==2 then - if piao1 or piao2 or piao3 then - auto_piao=true - end - end - _data['auto_piao'] = auto_piao - _data['piao_niao_opt'] = piao_niao_opt - - local xi_pai_score=0 - local an_chou_score=0 - if oldGameVersion==2 then - xi_pai_score=self.xipaiValue - an_chou_score=self.anchouValue - end - - _data['xi_pai_score'] = xi_pai_score*1000 - _data['an_chou_score'] = an_chou_score*1000 - - _data["fengding_score"] = fengding_score - _data["wuguizhuopaojiabei"] = wuguizhuopaojiabei - + _data['xi_pai'] = xi_pai + + local xi_pai_score = 0 + local an_chou_score = 0 + -- if oldGameVersion == 2 then + -- xi_pai_score = self.xipaiValue + -- an_chou_score = self.anchouValue + -- end + + _data['xi_pai_score'] = xi_pai_score * 1000 + _data['an_chou_score'] = an_chou_score * 1000 + return _data -end +end function M:LoadConfigData(data) - local _config = self._config - _config:GetController("round").selectedIndex = data.opt-1 - _config:GetController("play_list").selectedIndex = data.maxPlayers-2 - _config:GetChild("btn_qgh").selected = data.qiangkong - _config:GetChild("btn_qghjm").selected = data.qiangkong_niao - _config:GetChild("btn_qidui").selected = data.qidui - -- _config:GetChild("btn_zhuangxian").selected = data.zhuangxian - _config:GetController("NiaoType").selectedIndex = data.niao - 1 - if data.niao == 1 then - _config:GetController("zha").selectedIndex = data.niao_opt - 1 - elseif data.niao == 3 then - _config:GetController("wowoniao").selectedIndex = data.niao_opt - 1 - end - _config:GetController("wowoniao").selectedIndex = data.niao_opt_score - 1 - - _config:GetChild("btn_laizi").selected = data.laizi8 - _config:GetController("Cost").selectedIndex = data.AA or 0 - if oldGameVersion==1 then - _config:GetChild("btn_piao_niao").selected = data.piao_niao - end - _config:GetController("jiangma").selectedIndex = data.jiangma - - - if _config:GetController("piao") then - _config:GetController("piao").selectedIndex=data.piao_niao - _config:GetChild('pf1').selected=data.piao1 - _config:GetChild('pf2').selected=data.piao2 - _config:GetChild('pf3').selected=data.piao3 - end - - if _config:GetChild("btn_sihongzhong") then - _config:GetChild("btn_sihongzhong").selected=data.laizi4_hu - _config:GetChild("btn_wuhongzhong").selected=data.hz_hu - _config:GetChild("btn_wuhongzhongzimo").selected=data.wuguijiabei - end - - if _config:GetController("difen") then - _config:GetController("difen").selectedIndex=data.di_fen - end - - if _config:GetChild("xipai") then - _config:GetChild("xipai").selected=data.xi_pai - end - - if _config:GetController("piaofen") then - _config:GetController("piaofen").selectedIndex=data.piao_niao_opt - end - - if oldGameVersion==2 then - self.xipaiValueText.text=data.xi_pai_score/1000 - self.xipaiValue=data.xi_pai_score/1000 + --printlog("加载房间配置=========>>>") + --pt(data) + local _config = self._config + _config:GetController("round").selectedIndex = data.opt - 1 + _config:GetController("peopleNum").selectedIndex = data.maxPlayers - 2 - self.anchouValueText.text=data.an_chou_score/1000 - self.anchouValue=data.an_chou_score/1000 - end - - if _config:GetController("fengding") then - _config:GetController("fengding").selectedIndex=data.fengding_score - end - - _config:GetChild("btn_wuhongzhongzuobaofanbei").selected=data.wuguizhuopaojiabei - - end - -return M - \ No newline at end of file + _config:GetController("ZiMo").selectedIndex = data.zimo + _config:GetController("ShaoZhuang").selectedIndex = data.shaozhuang + _config:GetController("FengDing").selectedIndex = data.fengding + _config:GetController("TianDiHu").selectedIndex = data.Tiandihu + _config:GetController("ZiKeChengShun").selectedIndex = data.zikechengshun + _config:GetController('ZhuangFenFanBei').selectedIndex = data.zhuangfenfanbei + + _config:GetChild("n92").value = data.jiangma + self._config:GetChild("n93").text = string.format("奖%s马", data.jiangma * 2) +end + +function M:LoadConfigToDetailOnlyPlay(data, hpdata) + local configData = data + if type(data) == 'string' then + configData = json.decode(data) + end + + local hpData = configData.hpData or hpdata + if type(hpData) == 'string' then + if hpData == "null" then + hpData = nil + else + hpData = json.decode(hpData) + end + end + + local returnString = "" + if hpData then + returnString = string.format("%s倍", hpData.times / 1000) + end + + returnString = string.format("%s人数%s人", returnString, configData.maxPlayers) + + if hpData then + returnString = string.format("%s %s局", returnString, hpData.maxRound) + end + + if configData.zimo then + returnString = string.format("%s,%s", returnString, configData.zimo == 0 and "可点炮,可自摸" or "必须自摸") + end + if configData.shaozhuang then + returnString = string.format("%s%s", returnString, configData.shaozhuang == 0 and ",不烧庄" or ",烧庄") + end + if configData.fengding then + local matString = "%s%s" + if configData.fengding == 0 then + returnString = string.format(matString, returnString, ",封顶20炮") + else + returnString = string.format(matString, returnString, ",不封顶") + end + end + if configData.TianDiHu then + returnString = string.format("%s%s", returnString, configData.TianDiHu == 0 and ",天地胡玩法" or ",没有天地胡") + end + if configData.jiangma then + returnString = string.format("%s,%s马", returnString, + configData.jiangma == 0 and "不奖" or string.format("奖%s", configData.jiangma * 2)) + end + if configData.zikechengshun then + returnString = string.format("%s%s", returnString, configData.zikechengshun == 0 and ",字可成顺" or ",字不可成顺") + end + if configData.zhuangfenfanbei then + returnString = string.format("%s%s", returnString, configData.zhuangfenfanbei == 0 and ",庄家积分翻倍" or ",庄家积分不翻倍") + end + + if hpData then + if hpData.BanChat then + returnString = string.format("%s%s", returnString, hpData.BanChat == 1 and ",不允许快捷聊天" or "") + end + end + return returnString +end + +function M:LoadConfigToDetail(data, hpdata) + local configData = data + if type(data) == 'string' then + configData = json.decode(data) + end + + local hpData = configData.hpData or hpdata + if type(hpData) == 'string' then + if hpData == "null" then + hpData = nil + else + hpData = json.decode(hpData) + end + end + + local returnString = "" + if hpData then + returnString = string.format("%s倍,", hpData.times / 1000) + end + + returnString = string.format("%s人数%s人", returnString, configData.maxPlayers) + + if hpData then + returnString = string.format("%s %s局", returnString, hpData.maxRound) + end + if configData.zimo then + returnString = string.format("%s,%s", returnString, configData.zimo == 0 and "可点炮,可自摸" or "必须自摸") + end + if configData.shaozhuang then + returnString = string.format("%s%s", returnString, configData.shaozhuang == 0 and ",不烧庄" or ",烧庄") + end + if configData.fengding then + local matString = "%s%s" + if configData.fengding == 0 then + returnString = string.format(matString, returnString, ",封顶20炮") + else + returnString = string.format(matString, returnString, ",不封顶") + end + end + if configData.TianDiHu then + returnString = string.format("%s%s", returnString, configData.TianDiHu == 0 and ",天地胡玩法" or ",没有天地胡") + end + if configData.jiangma then + returnString = string.format("%s,%s马", returnString, + configData.jiangma == 0 and "不奖" or string.format("奖%s", configData.jiangma * 2)) + end + if configData.zikechengshun then + returnString = string.format("%s%s", returnString, configData.zikechengshun == 0 and ",字可成顺" or ",字不可成顺") + end + if configData.zhuangfenfanbei then + returnString = string.format("%s%s", returnString, configData.zhuangfenfanbei == 0 and ",庄家积分翻倍" or ",庄家积分不翻倍") + end + + returnString = returnString .. IGameInfo.LoadConfigToDetail(self, configData, hpData) + + return returnString +end + +return M diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/EXMainView.lua b/lua_probject/extend_project/extend/majiang/hongzhong/EXMainView.lua index b005af4a..8cedc495 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/EXMainView.lua @@ -1,21 +1,32 @@ local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local MJMainView = require("main.majiang.MJMainView") +local TableBG = require("Game.Data.TableBG") local EXClearingView = import(".EXClearingView") local TX_GameEvent = import(".GameEvent") local HuTipView = import("main.majiang.HuTipView") -local SettingView = import("main.majiang.MJSettingViewNew") +local SettingView = import(".EXSettingView") local PlayerInfoView = import(".EXPlayerInfoView") +local HuCardImg = import(".HuCardImg") local M = {} --- Create a new ZZ_MainView + + function M.new() - setmetatable(M,{__index = MJMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MJMainView }) + local self = setmetatable({}, { __index = M }) + + self.EXClearingViewClass = EXClearingView + + self.HuCardImg = setmetatable(HuCardImg, { __index = self.HuCardImg }) + self.class = "MainView" - self.asset_group = "HongZhong_MJ" + self.asset_group = "FuZhou_MJ" + self.HuCardImg_path = "ui://Extend_MJ_FuZhou/" + self.Sound_path = "extend/majiang/fuzhou/sound/" self:init() - ViewUtil.PlayMuisc(self.asset_group, "extend/majiang/hongzhong/sound/bg.mp3") + --ViewUtil.PlayMuisc(self.asset_group, "extend/majiang/fuzhou/sound/bg.mp3") return self end @@ -23,110 +34,229 @@ function M:InitView(url) local room = self._room self._style = 1 self._gps_style = 1 - self._full = true - UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") - MJMainView.InitView(self,"ui://Main_Majiang/Main_"..room.room_config.people_num .. "_s2") + --self._full = true + self._scale = true + UIPackage.AddPackage("extend/majiang/fuzhou/ui/Extend_MJ_FuZhou") + -- if self._room.room_config.people_num == 2 then + -- MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num) + -- else + -- MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") + -- end + MJMainView.InitView(self, string.format("ui://Main_Majiang/Main_new_%d_jiangxi", room.room_config.people_num), + true, nil) self._hu_tip = HuTipView.new(self) - self._view:GetChild('wanfa_text').text =room.room_config.people_num .. '人红中 ' .. room.score_times .. '倍' - - self.LaiziBG=self._view:GetChild('n103') - self.LaiziBG.text="鬼牌" - self.LaiziBG.visible=false - self.selectLaiziBtn=self._view:GetChild('selectlaizi') - self.Laizi1Btn=self._view:GetChild('selectlaizi1') - self.Laizi2Btn=self._view:GetChild('selectlaizi2') - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - - self:PlayerChangeLineState() + self.selectLaiziBtn = self._view:GetChild('selectlaizi') + self.Laizi1Btn = self._view:GetChild('selectgang1') + self.Laizi2Btn = self._view:GetChild('selectgang2') + self._view:GetChild("n108").visible = true + self.Laizi1Btn.visible = true + self.Laizi2Btn.visible = true + self.bugangnum = self._view:GetChild("bugangnum") - if room.playing or room.curren_round > 0 then + self.com_logocType.selectedIndex = 0 + --lingmeng + --[[ + MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num) + --]] + + self.jing = self._view:GetChild('jing') + + self._state.onChanged:Add(function() + self:UpdatePlayerInfoView() + end) + + self.showNextCtr = self._view:GetController('showNext') + self.showNextList = self._view:GetChild('list_showNext') + self._view:GetChild('btn_showNext').onClick:Set(function() + if self._flag_getRemindCard then + self.showNextCtr.selectedIndex = 1 + self.showNextList:SetVirtual() + self.showNextList.itemRenderer = function(index, obj) + local card = self.cardSet[index + 1] + self:FillShowCards(obj, card, self.cardMap[card]) + obj.data = { card = card } + end + self.showNextList.numItems = #self.cardSet + else + self:reqResidueCard() + end + end) + self._view:GetChild('btn_closeShow').onClick:Set(function() + self.showNextCtr.selectedIndex = 0 + self.showNextList.selectedIndex = -1 + self._showNextName = nil + end) + self.showNextList.onClickItem:Set(function(context) + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:SendNextCard(context.data.data.card) + self.showNextCtr.selectedIndex = 0 + self.showNextList.selectedIndex = -1 + self._showNextName = nil + end) + + -------- + self:PlayerChangeLineState() + + if room.playing or room.curren_round > 0 then self:ReloadRoom() end end +function M:__BuGang(cardInfo, callback) + local _gang_tip_choice = UIPackage.CreateObject("Extend_MJ_FuZhou", "Gang_tip_choice") + _gang_tip_choice.visible = true + + local list_card = _gang_tip_choice:GetChild("list_card") + list_card:SetVirtual() + list_card.itemRenderer = function(index, obj) + obj.icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_" .. cardInfo[index + 1]) + end + list_card.numItems = #cardInfo + list_card.onClickItem:Set(function(context) + local item = context.data + local index = list_card:GetChildIndex(item) + callback(cardInfo[index + 1]) + end) + + + _gang_tip_choice.xy = Vector2((self._view.width - _gang_tip_choice.width) / 2, + (self._view.height - _gang_tip_choice.height) / 2) + self._view:AddChild(_gang_tip_choice) + self._gang_tip_choice = _gang_tip_choice +end + +function M:SetShowGangZiProcess(currentLaizi1ID, currentLaizi2ID, bugangnum, isShowAnim) + --zhongid=currentLaizi1ID + if isShowAnim == nil then isShowAnim = false end + + self:SetGangZiCard(self.Laizi1Btn, currentLaizi1ID) + -- self:SetGangZiCard(self.Laizi2Btn, currentLaizi2ID) + self:IsShowGangZi(self.Laizi1Btn, true) + -- self:IsShowGangZi(self.Laizi2Btn, true) + self.bugangnum.text = "当前 " .. bugangnum .. " 杠" +end + +function M:HideAllGangZiCard() + self.Laizi1Btn.visible = false + -- self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + --self.LaiziBG.visible=false +end + +function M:SetGangZiCard(btn, cardId) + btn.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. cardId +end + +function M:IsShowGangZi(btn, isShow) + btn.visible = isShow +end + function M:UpdateRound() - local currRD=self._room.curren_round - if self._room.curren_round==0 then - currRD=1 - end - - self._view:GetChild("tex_round1").text = currRD - self._view:GetChild("tex_round2").text = self._room.room_config.round + self._view:GetChild("text_round").text = string.format("局数:%d/%d", self._room.curren_round, + self._room.room_config.round) end function M:InitPlayerInfoView() - self._player_info = {} + self._player_info = {} local _player_info = self._player_info for i = 1, self._room.room_config.people_num do - local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) + local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1)) + _player_info[i] = PlayerInfoView.new(tem, self) tem.visible = false end end -function M:NewMJPlayerCardInfoView(view,index) - if index == 1 then - return MJPlayerSelfCardInfoView.new(view,self) +function M:UpdatePlayerInfoView() + self._player_info = {} + local _player_info = self._player_info + local list = self._room.player_list + + for i = 1, #list do + local seat = self:GetPos(list[i].seat) + local tem = self._view:GetChild(string.format("player_info%d_%d", seat, (self._state.selectedIndex % 2) + 1)) + _player_info[seat] = PlayerInfoView.new(tem, self) + _player_info[seat]:FillData(list[i]) + printlog("lingmeng _player_info", tem, seat, list[i].self_user.nick_name) end - return MJPlayerCardInfoView.new(view,self) +end + +function M:NewMJPlayerCardInfoView(view, index) + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self, nil, "S") + end + return MJMainView.NewMJPlayerCardInfoView(self, view, index) end function M:EventInit() - -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") - MainView.EventInit(self) + -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") + MainView.EventInit(self) local _room = self._room local _view = self._view local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard") local _player_info = self._player_info - local _gamectr = self._gamectr - - _gamectr:AddEventListener(TX_GameEvent.EventXiPai,function( ... ) - local arg = {...} - local currentPlayer1=arg[1] - local currentPlayer2=arg[2] - self._popEvent = false - if ( currentPlayer1 ) then - - local xipaiCB=function () - self._popEvent = true - end - self:PlayXiPai(xipaiCB) - - end - - - if ( currentPlayer2 ) then - --self._popEvent = false - local xipaiCB2=function () - self._popEvent = true - end - self:PlayXiPai1(xipaiCB2) - end - - - end) - - _gamectr:AddEventListener(TX_GameEvent.SendCards,function( ... ) + local _gamectr = self._gamectr + + + + _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) + local arg = { ... } + self:SetShowLaiZiProcess(arg[1], arg[2], arg[3], arg[4]) + end) + + _gamectr:AddEventListener(TX_GameEvent.SendGangZi, function(...) + local arg = { ... } + self:SetShowGangZiProcess(arg[1], arg[2], arg[3], arg[4]) + end) + + _gamectr:AddEventListener(TX_GameEvent.EventBuGang, function(...) + local arg = { ... } + _gamectr:SendGangCard(arg[1][1]) + -- self:__BuGang(arg[1], + -- function(id) + -- printlog(id) + -- _gamectr:SendGangCard(id) + -- self:__CloseGangTip() + -- end) + end) + + + + _gamectr:AddEventListener(TX_GameEvent.SendCards, function(...) -- self:ShowHuTip() + --self._viewText_testName.text = 0 self:UpdateRound() + self:RemoveCursor() + self:reqResidueCard() self._state.selectedIndex = 1 + self:ShowJing() + if self._niao_View then + self._niao_View:RemoveFromParent() + self._niao_View:Dispose() + end + -- self._laiziMove:Play() local list = _room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:UpdateHandCard() + card_info:Clear() + card_info:UpdateHandCard() + card_info._view_handCardList.touchable = true + card_info._view_getCard.touchable = true + if _room.curren_round == 1 then + self._touxiangMove:Play() + end end end) - _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) - local arg = {...} - self._left_time = 15 + _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) + local arg = { ... } + if not self._left_time or self._left_time <= 15 then + self._left_time = 15 + end local seat = arg[1] self:UpdateCardBox(self:GetPos(seat)) -- if seat == self._room.self_player.seat then @@ -136,14 +266,14 @@ function M:EventInit() _gamectr:AddEventListener(TX_GameEvent.OutHint, function(...) local info = self._player_card_info[self:GetPos(_room.self_player.seat)] + --self._viewText_testName.text = tonumber(self._viewText_testName.text) + 1 info:UpdateHandCard(true) end) - local _gcm_outcard_url ="ui://Main_Majiang/Gcm_OutCard" + local _gcm_outcard_url = "ui://Main_Majiang/Gcm_OutCard" _gamectr:AddEventListener(TX_GameEvent.OutCard, function(...) self:__CloseTip() - self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local card = arg[2] local seat = p.seat @@ -152,48 +282,62 @@ function M:EventInit() info:UpdateHandCard() local outcard = UIPackage.CreateObjectFromURL(_gcm_outcard_url) info:UpdateOutCardList(outcard, card, self._cursor) - self:PlaySound("HongZhong_MJ", p.self_user.sex, tostring(card)) + self._player_card_info[1]._ctr_tip.selectedIndex = 0 + self._player_card_info[1]._ctr_showGuoHu.selectedIndex = 0 self:PlayMJSound("chupai.mp3") + self:PlaySound("FuZhou_MJ", p.self_user.sex, tostring(card)) if seat == _room.self_player.seat then _room.curren_outcard_seat = -1 end end) _gamectr:AddEventListener(TX_GameEvent.GetCard, function(...) self:__CloseTip() - local arg = {...} + self:reqResidueCard() + local arg = { ... } local seat = arg[1] local card = arg[2] -- self._tex_leftTime.text = arg[3] - self._tex_LeftCard.text = arg[3] + self._tex_LeftCard.text = string.format("余%d张", arg[3]) -- self:UpdateRoomInfo() local info = self._player_card_info[self:GetPos(seat)] info:UpdateHandCard(true) + if self:GetPos(seat) == 1 then + info:ShowHuTip() + self._btn_selectTing.visible = false + info._ctr_tip.selectedIndex = 0 + info._ctr_showGuoHu.selectedIndex = 0 + end end) _gamectr:AddEventListener(TX_GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] local weight = arg[2] self:__FangziTip(_tip, weight) end) - _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self,self.OnFangziAction)) + _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) + MJMainView.OnHuCard(self, ...) + --[[ self._left_time = 0 self:UpdateCardBox(0) self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local win_seat = arg[1] local lose_seat = arg[2] - local cards = arg[3] - local win_card = arg[4] - local info = self._player_card_info[self:GetPos(win_seat)] + local win_card = arg[3] + local cards = arg[4] + local win_list = arg[5] + local index = self:GetPos(win_seat) + local info = self._player_card_info[index] self:RemoveCursor() - info:UpdateHandCard(true, true) + --info:UpdateHandCard(false, false) + info:ShowHuCard(win_card) - local obj_win_card = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Btn_Card") + local obj_win_card = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Btn_Card_jiangxi") obj_win_card.icon = "ui://Main_Majiang/b202_" .. win_card obj_win_card:GetController("bg").selectedIndex = 1 info._view:AddChild(obj_win_card) @@ -203,7 +347,7 @@ function M:EventInit() local player = _room:GetPlayerBySeat(win_seat) if win_seat ~= _room.self_player.seat then url = "ui://Main_Majiang/别人胡" - pNode = info._mask_liangpai + pNode = info._view elseif win_seat == _room.self_player.seat then url = "ui://Main_Majiang/自己胡牌" pNode = self._view @@ -211,102 +355,147 @@ function M:EventInit() if win_seat == lose_seat then url = "ui://Main_Majiang/eff_zimo" end - local hu_sound = win_seat == lose_seat and "zimo" or "hu" - self:PlaySound("HongZhong_MJ", player.self_user.sex, hu_sound .. math.random(1, 2)) + local he = UIPackage.CreateObjectFromURL(url) pNode:AddChild(he) he:GetTransition("t2"):Play() - if win_seat == _room.self_player.seat then - he:Center() + he:Center() + if _room.room_config.people_num == 2 then + if win_seat ~= _room.self_player.seat then + he.scaleY = 0.4 + he.scaleX = 0.4 + he.x = he.width * 0.4 * 0.5 * -1 + he.y = he.height * 0.4 * 0.5 * -1 + end + end + + if win_seat == _room.self_player.seat then + printlog("自己位置=====") + he:Center() elseif url == "ui://Main_Majiang/eff_zimo" then + printlog("自摸地址==========") he.scaleY = 0.4 he.scaleX = 0.4 he.x = he.width * 0.4 * 0.5 * -1 he.y = he.height * 0.4 * 0.5 * -1 end + + + + --- + local isZiMo = win_seat == lose_seat + DataManager.CurrenRoom.isZiMoHu = isZiMo + local hu_sound = isZiMo and ("zimo") or ("hu") + printlog("声音====>>>", hu_sound) + self:PlaySound("LiChuan_MJ", player.self_user.sex, hu_sound) + + local pNode = info._view + local url = "eff_list1" + local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_LiChuan/" .. url) + he_list.touchable = false + pNode:AddChild(he_list) + he_list:Center() + coroutine.start(function() + for i = 1, #win_list do + local tem = win_list[i] + if tem.type > 0 and tem.type < 32 then + local com_name = "he" .. tem.type + printlog("声音====>>>", com_name) + ViewUtil.PlaySound("LiChuan_MJ", + string.format("extend/majiang/lichuan/sound/%s/%s.mp3", ViewUtil.Sex_Chat[player.self_user.sex], + com_name)) + local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_LiChuan/" .. com_name) + coroutine.wait(0.3) + end + end + coroutine.wait(2) obj_win_card:Dispose() he:Dispose() + he_list:Dispose() self._popEvent = true - end) + end)]] end) _gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...) - local arg = {...} + local arg = { ... } self._popEvent = false local list = arg[1] local start_seat = arg[2] - ViewUtil.PlaySound("HongZhong_MJ", "extend/majiang/hongzhong/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao,self,list, start_seat) + -- ViewUtil.PlaySound("FuZhou_MJ", "extend/majiang/chaozhou/sound/zhuaniao.mp3") + coroutine.start(self.RunNiao, self, list, start_seat) end) _gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...) + MJMainView.OnResult1(self, ...) + --[[ self._popEvent = false self:__CloseTip() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } self:ShowHand(arg) local result = arg[1] local liuju = result.liuju local data = result.info_list local niao = result.niao - if liuju then - local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu") - self._view:AddChild(le) - le:Center() - le:GetTransition("t0"):Play() - coroutine.start(function() - coroutine.wait(1) - le:Dispose() - end) - end + -- if liuju then + -- local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu") + -- self._view:AddChild(le) + -- le:Center() + -- le:GetTransition("t0"):Play() + -- coroutine.start(function() + -- coroutine.wait(1) + -- le:Dispose() + -- end) + -- end self:RemoveCursor() if self._clearingView == nil then self._clearingView = EXClearingView.new(self._root_view) - coroutine.start(function() + coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() self._popEvent = true - end) + end) end - if _room.curren_round ~= _room.room_config.round then -- if #niao == 0 then self._view:GetChild("n13").visible = false end self._clearingView:InitData(0, _room, result, nil, function(...) for i = 1, #data do local p = _room:GetPlayerBySeat(data[i].seat) - p.total_score = data[i].total_score - local card_info = self._player_card_info[self:GetPos(p.seat)] - local info = self._player_info[self:GetPos(p.seat)] - card_info:Clear() - card_info:ResetCardType() - if _room:checkHpNonnegative() then - p.cur_hp = data[i].hp_info.cur_hp - end - info:UpdateScore() - info._view:GetChild("zhanji").visible = true - local num = data[i].hp_info.total_score - if num > 0 then - info._view:GetController("text_color").selectedIndex = 0 - info._view:GetChild("text_jifen").text = "+" .. num --d2ad(num) - else - info._view:GetController("text_color").selectedIndex = 1 - info._view:GetChild("text_jifen").text = num --d2ad(num) - end + if p then + p.total_score = data[i].total_score + local card_info = self._player_card_info[self:GetPos(p.seat)] + local info = self._player_info[self:GetPos(p.seat)] + card_info:Clear() + card_info:ResetCardType() + if _room:checkHpNonnegative() then + p.cur_hp = data[i].total_score + end + -- info:UpdateScore() + info._view:GetChild("zhanji").visible = true + local num = data[i].total_score + if num >= 0 then + info._view:GetController("text_color").selectedIndex = 0 + info._view:GetChild("text_jifen").text = "+" .. num + else + info._view:GetController("text_color").selectedIndex = 1 + info._view:GetChild("text_jifen").text = num + end - info._view:GetChild("mask_piao").title = "" - info._view:GetController("piao_niao").selectedIndex = 0 - p.fz_list = {} + info._view:GetChild("mask_piao").title = "" + info._view:GetController("piao_niao").selectedIndex = 0 + p.fz_list = {} + end end DataManager.CurrenRoom.self_player.card_list = {} self._state.selectedIndex = 2 self._clearingView = nil end) end - self._player_card_info[1]:ShowHuTip() + -- self._player_card_info[1]:ShowHuTip()]] end) _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) @@ -314,120 +503,260 @@ function M:EventInit() self._left_time = 0 self:UpdateCardBox(0) self._ctr_cardbox.selectedIndex = 0 - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] - self._clearingView = EXClearingView.new() + if self.dismissWin ~= nil then + self.dismissWin:Destroy() + end + self.dismissWin = nil + self._player_card_info[1]._ctr_tip.selectedIndex = 0 + self._player_card_info[1]._ctr_showGuoHu.selectedIndex = 0 + if over == 2 then + if _room.curren_round > 0 then + self:PlayMJMusic("gameover.mp3") + end + else + -- self:ShowHand(arg) + self:PlayMJMusic("gameover.mp3") + end + local liuju = result and result.liuju or nil coroutine.start(function() + if liuju then + self:PlayMJSound("liuju.mp3") + coroutine.wait(3) + self:PlayMJSound("end_music.mp3") + else + if over ~= 2 then + self:PlayMJSound("end_music.mp3") + end + end + -- 扣分动画 + if result then + for _, pScore in pairs(result.info_list) do + local infoView = self._player_info[self:GetPos(pScore.seat)] + infoView:UpdateScore(pScore.total_score, true) + end + end + coroutine.wait(0.3) + coroutine.wait(0.5) self._clearingView:Show() - end) + self._popEvent = true + end) + self._clearingView = EXClearingView.new() + + -- if over < 2 or _room.curren_round > 0 then + -- self:PlayMJSound("end_music.mp3") + -- end self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) _gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function() self:UpdateRound() - self._tex_LeftCard.text = "0" - self._state.selectedIndex = 1 - self:__PiaoNiaoTip() - --if oldGameVersion==1 then - -- self:__PiaoNiaoTip() - --else - -- self:__PiaoNiaoTip1() - --end + self._tex_LeftCard.text = "剩余0张牌" + self._state.selectedIndex = 1 + self:__PiaoNiaoTip() end) _gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local num = arg[2] if num > 0 then local head_info = self._player_info[self:GetPos(seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. num head_info._view:GetController("piao_niao").selectedIndex = 1 - end + end if seat == _room.self_player.seat then - if self._com_piao and _room.self_player.entrust then + if self._com_piao and _room.self_player.entrust then self._com_piao:Dispose() self._com_piao = nil _room.curren_round = _room.curren_round - 1 end end end) + + _gamectr:AddEventListener(TX_GameEvent.EventResidueCard, function(...) + local arg = { ... } + local residueCard = arg[1] + self.cardMap = {} + self.cardSet = {} + for i = 1, #residueCard do + local cardNum = residueCard[i] + if not self.cardMap[cardNum] then + self.cardMap[cardNum] = 1 + table.insert(self.cardSet, cardNum) + else + self.cardMap[cardNum] = self.cardMap[cardNum] + 1 + end + end + table.sort(self.cardSet) + self._flag_getRemindCard = true + end) + + --替换mianview的事件 + _gamectr:AddEventListener( + GameEvent.PlayerState, + function(...) + printlog("lingmeng OnEventOnlineState") + local arg = { ... } + local p = arg[1] + local info = self._player_info[self:GetPos(p.seat)] + info._ctr_offline.selectedIndex = p.line_state == 0 and 1 or 0 + end + ) end function M:OutCard(card) - --if card ~= 412 then + if card ~= 0 then + printlog("当前出牌为===>>>" .. card) local _gamectr = ControllerManager.GetController(GameController) self._room.curren_outcard_seat = -1 - _gamectr:SendOutCard(card, function() - local info = self._player_card_info[1] - self:RemoveCursor() - info:UpdateHandCard() - - info:UpdateOutCardList(nil, card, self._cursor) - self:PlaySound("HongZhong_MJ", self._room.self_player.self_user.sex,tostring(card)) - self:PlayMJSound("chupai.mp3") - -- self:ShowHuTip() - end) - -- end + _gamectr:SendOutCard( + { + card = card, + isTip = self._player_card_info[1]._ctr_tip.selectedIndex == 1 or + self._player_card_info[1]._ctr_showGuoHu.selectedIndex == 1 + }, function() + local info = self._player_card_info[1] + self:RemoveCursor() + info:UpdateHandCard() + info._ctr_tip.selectedIndex = 0 + info._ctr_showGuoHu.selectedIndex = 0 + info:UpdateOutCardList(nil, card, self._cursor) + info:ShowHuTip() + if #info:GetTingList(DataManager.CurrenRoom.self_player.card_list) > 0 then + self._btn_selectTing.visible = true + else + self._btn_selectTing.visible = false + end + self:markOutCards(false, card) + self:PlaySound("FuZhou_MJ", self._room.self_player.self_user.sex, tostring(card)) + self:PlayMJSound("chupai.mp3") + end) + else + printlog("鬼牌不能出===>>>" .. card) + end end +-- function M:__FangziTip(tip, weight) +-- printlog("__FangziTip") +-- local _gamectr = self._gamectr +-- local _chipeng_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips") +-- _chipeng_tip:GetController("hide_bg").selectedIndex = 1 +-- self._chipeng_tip = _chipeng_tip +-- local p = self._room.self_player +-- -- self._player_card_info[self:GetPos(p.seat)] + +-- local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi") +-- _lit_fanzi:RemoveChildrenToPool() +-- local _tlist = table.keys(tip.tip_map_type) +-- printlog(tip.tip_map_type) +-- pt(_tlist) +-- local tip_hu = false +-- local count = #_tlist +-- table.sort(_tlist) +-- local isHu = false +-- for k = 1, #_tlist do +-- local td = tip.tip_map_type[_tlist[k]][1] +-- local url = "ui://Main_Majiang/Btn_fztip" +-- local td_weight = td.weight +-- if td_weight == 16 then td_weight = 8 end +-- if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end +-- local btn_t = _lit_fanzi:AddItemFromPool(url) +-- btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight +-- btn_t.data = { tip, td } +-- btn_t.onClick:Add(self.__TipAction, self) +-- end + +-- -- if not (tonumber(weight) >= 16) then +-- local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") +-- -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") +-- _btn_pass.onClick:Set(function() +-- if tonumber(weight) >= 8 then +-- local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) +-- guo_msg.onOk:Add(function() +-- _gamectr:SendAction(0) +-- _chipeng_tip:Dispose() +-- self._chipeng_tip = nil +-- guo_msg:Close() +-- end) +-- guo_msg:Show() +-- else +-- _gamectr:SendAction(0) +-- _chipeng_tip:Dispose() +-- self._chipeng_tip = nil +-- end +-- end) +-- -- end + +-- self._view:AddChild(_chipeng_tip) +-- _chipeng_tip:Center() +-- end + function M:__FangziTip(tip, weight) + printlog("__FangziTip") local _gamectr = self._gamectr - local _chipeng_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips") - _chipeng_tip:GetController("hide_bg").selectedIndex = 1 - self._chipeng_tip = _chipeng_tip - local p = self._room.self_player - -- self._player_card_info[self:GetPos(p.seat)] + local info = self._player_card_info[1] + local _chipeng_tip = info._view_FZTips + local _ctr_tips = info._ctr_tip - local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi") - _lit_fanzi:RemoveChildrenToPool() - local _tlist = table.keys(tip.tip_map_type) - - local tip_hu = false - local count = #_tlist - for k=1,#_tlist do - local td = tip.tip_map_type[_tlist[k]][1] - local url = "ui://Main_Majiang/Btn_fztip" - local td_weight = td.weight - if td_weight == 16 then td_weight = 8 end - if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end - local btn_t = _lit_fanzi:AddItemFromPool(url) - if url == "ui://Main_Majiang/Btn_hu" then - btn_t:GetChild("hupai").icon="ui://Main_Majiang/b202_" .. td.card - btn_t:GetController("hupai").selectedIndex=1 - end - btn_t.icon = "ui://Main_Majiang/fztip_"..td_weight - btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) - end - - -- if not (tonumber(weight) >= 16) then - local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") - -- local _btn_pass = _chipeng_tip:GetChild("btn_pass") - _btn_pass.onClick:Set(function() - if tonumber(weight) >= 8 then - local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) - guo_msg.onOk:Add(function() + local _lit_fanzi = _chipeng_tip:GetChild("list") + --_lit_fanzi:SetVirtual() + local _tlist = tip.tip_sortList + _lit_fanzi.itemRenderer = function(index, obj) + local type = obj:GetController('type') + if index == tip.tip_num then + type.selectedIndex = 0 + obj.onClick:Set(function() + _ctr_tips.selectedIndex = 0 + if tip.is_hu then + info._ctr_showGuoHu.selectedIndex = 1 + info._viewBtn_guoHu.onClick:Set(function() + _gamectr:SendAction(0) + end) + else _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - guo_msg:Close() - end) - guo_msg:Show() + end + end) + else + index = index + 1 + if _tlist[index].type == FZType.HU then + type.selectedIndex = 4 + obj:GetChild('btn_Card1').icon = string.format('ui://Main_Majiang/b202_%d', _tlist[index].card) + elseif _tlist[index].type == FZType.Chi then + type.selectedIndex = FZType.Chi + for i = 1, 3 do + obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/b202_%d', + _tlist[index].opcard[i]) + end + elseif _tlist[index].type == FZType.Peng then + type.selectedIndex = FZType.Peng + for i = 1, 3 do + obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/b202_%d', + _tlist[index].card) + end else - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil + for i = 1, 4 do + obj:GetChild(string.format('btn_Card%d', i)).icon = string.format('ui://Main_Majiang/b202_%d', + _tlist[index].card) + end + type.selectedIndex = FZType.Gang + if _tlist[index].type == FZType.Gang_An then + obj:GetChild('btn_Card4').icon = 'ui://Main_Majiang/b202_00' + end end - end) - -- end - - self._view:AddChild(_chipeng_tip) - _chipeng_tip:Center() + obj.onClick:Set(function() + _gamectr:SendAction(_tlist[index].id) + _ctr_tips.selectedIndex = 0 + end) + end + end + _ctr_tips.selectedIndex = 1 + _lit_fanzi.numItems = tip.tip_num + 1 end function M:__TipAction(context) @@ -436,6 +765,8 @@ function M:__TipAction(context) local tip = data[1] local td = data[2] local list = tip.tip_map_type[td.weight] + printlog("__TipAction") + pt(list) if (#list > 1) then self:_ChiView(list, function(id) _gamectr:SendAction(id) @@ -453,105 +784,88 @@ end function M:_ChiView(tiplist, callback) self._chipeng_tip.visible = false - local _pop_tip_choice = UIPackage.CreateObject("Main_Majiang", "Pop_tip_choice") - local list_choose = _pop_tip_choice:GetChild("Lst_choose") + printlog("_ChiView") + pt(tiplist) + local _pop_tip_choice = UIPackage.CreateObject("Extend_MJ_FuZhou", "Pop_tip_choice") + local list_choose1 = _pop_tip_choice:GetChild("Lst_choose") + local list_choose2 = _pop_tip_choice:GetChild("Lst_choose2") local crossCtr = _pop_tip_choice:GetController("state") - crossCtr.selectedIndex = #tiplist == 3 and 0 or 1 + crossCtr.selectedIndex = #tiplist == 3 and 0 or + (#tiplist == 2 and 1 or (#tiplist == 4 and 2 or (#tiplist == 5 and 3 or 4))) _pop_tip_choice:GetChild("Btn_cross").onClick:Add(function() _pop_tip_choice:Dispose() self._chipeng_tip.visible = true end) - list_choose:RemoveChildrenToPool() + list_choose1:RemoveChildrenToPool() + list_choose2:RemoveChildrenToPool() for i = 1, #tiplist do + local list_choose = i <= 3 and list_choose1 or list_choose2 local item_choose = list_choose:AddItemFromPool() - item_choose:GetController("type").selectedIndex = 0 - for j = 1, 4 do - item_choose:GetChild("card"..j).icon = UIPackage.GetItemURL("Main_Majiang", "202_"..tiplist[i].card) + item_choose:GetController("type").selectedIndex = (1 == tiplist[i].weight or 2 == tiplist[i].weight) and 1 or 0 + if tiplist[i].weight ~= 1 then + for j = 1, 4 do + item_choose:GetChild("card" .. j).icon = UIPackage.GetItemURL("Main_Majiang", + self:GetPrefix() .. "202_" .. tiplist[i].card) + end + else + local tem = {} + table.insert(tem, tiplist[i].opcard[1]) + table.insert(tem, tiplist[i].opcard[2]) + local tcard = tiplist[i].card + table.insert(tem, tcard) + table.sort(tem, function(a, b) + return a < b + end) + item_choose:GetChild("card1").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_" .. + tem[1]) + item_choose:GetChild("card2").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_" .. + tem[2]) + item_choose:GetChild("card4").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_" .. + tem[3]) + local cardpos = tem[2] > tcard and 1 or (tem[2] < tcard and 4 or 2) + item_choose:GetChild("card" .. cardpos):GetController("color").selectedIndex = 1 end item_choose.onClick:Add(function() callback(tiplist[i].id) end) end - _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width)/2, (self._view.height - _pop_tip_choice.height)/2) + _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, + (self._view.height - _pop_tip_choice.height) / 2) self._view:AddChild(_pop_tip_choice) self._pop_tip_choice = _pop_tip_choice end -function M:OnFangziAction(...) - self._popEvent = false - self:__CloseTip() - local arg = {...} - local _player_card_info = self._player_card_info - local fz = arg[1] - local player = arg[2] - local index = arg[3] - - local info = _player_card_info[self:GetPos(player.seat)] - local pNode = info._mask_liangpai - local effect = UIPackage.CreateObject("Extend_MJ_HongZhong", "FzEffect") - if fz.type == FZType.Peng then - self:PlaySound("HongZhong_MJ", player.self_user.sex,"peng"..math.random(1, 3)) - effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "碰") - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "碰") - -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框") - else - self:PlaySound("HongZhong_MJ", player.self_user.sex,"gang"..math.random(1, 2)) - effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") - -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") - end - effect.touchable = false - effect:GetTransition("t2"):Play() - pNode:AddChild(effect) - - coroutine.start(function() - coroutine.wait(0.2) - self._popEvent = true - end) - - coroutine.start(function() - coroutine.wait(1.5) - effect:Dispose() - end) - - self:RemoveCursor() - if (player.seat ~= fz.from_seat) then - local fs_info = _player_card_info[self:GetPos(fz.from_seat)] - fs_info:UpdateOutCardList() - end - info:UpdateFzList(fz, index, true) - local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi - info:UpdateHandCard(getcard) - self:__CloseTip() -end - function M:RunNiao(list, start_seat) local _room = self._room --local _niao_View = self._niao_View - self._niao_View = UIPackage.CreateObject("Extend_MJ_HongZhong","Panel_Birds") - self._view:AddChild(self._niao_View) + self._niao_View = UIPackage.CreateObject("Extend_MJ_FuZhou", "Panel_Birds") + self._view:GetChild('jiangma_show'):AddChild(self._niao_View) self._niao_View:Center() local _niao_View = self._niao_View local list_niao_card = self._niao_View:GetChild("Lst_birds") list_niao_card:RemoveChildrenToPool() - for i = 1, #list do - --添加背面的麻將 - local item = list_niao_card:AddItemFromPool() - item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") - item:GetChild("tex_score").text = "+" .. list[i].score - end + -- for i = 1, #list do + -- --添加背面的麻將 + -- local item = list_niao_card:AddItemFromPool() + -- item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") + -- item:GetChild("tex_score").text = "+" .. list[i].score + -- end for i = 1, #list do --顯示正面 - local item = list_niao_card:GetChildAt(i - 1) + local item = list_niao_card:AddItemFromPool() local card = list[i].card - coroutine.wait(0.3) - item:GetTransition("appear"):Play() - item.icon = UIPackage.GetItemURL("Main_Majiang", "201_"..card) - if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end + item.icon = UIPackage.GetItemURL("Main_Majiang", "b202_" .. card) + if list[i].score > 0 then + item:GetController("select").selectedIndex = 1 + else + item:GetController("select").selectedIndex = 0 + end + coroutine.wait(2 / #list) + -- item:GetTransition("appear"):Play() end coroutine.start(function() - coroutine.wait(1) - _niao_View:Dispose() + coroutine.wait(0.3) + -- _niao_View:Dispose() self._popEvent = true end) end @@ -570,63 +884,18 @@ end -- end -- end - function M:__PiaoNiaoTip() - local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") - self._view:AddChild(obj_piao) - obj_piao.x = (self._view.width - obj_piao.width) * 0.5 - obj_piao.y = self._view.height * 0.6 - local piaoState=obj_piao:GetController('piao') - piaoState.selectedIndex=1 - for i = 1, 4 do - obj_piao:GetChild("btn_" .. i).onClick:Add(function() - self._gamectr:SendAction(i - 1) - obj_piao:Dispose() - end) - end - self._com_piao = obj_piao -end - - -function M:__PiaoNiaoTip1() - local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") - self._view:AddChild(obj_piao) - obj_piao.x = (self._view.width - obj_piao.width) * 0.5 - obj_piao.y = self._view.height * 0.6 - local piaoState=obj_piao:GetController('piao') - - local tconfig=DataManager.CurrenRoom.room_config.config - - - - local piaoList={} - - for i = 1, 4 do - local piaoT=obj_piao:GetChild("btn_" .. i) - table.insert(piaoList,piaoT) - piaoT.onClick:Add(function() - self._gamectr:SendAction(i - 1) - obj_piao:Dispose() - end) - - end - self._com_piao = obj_piao - - - - if tconfig.piao_niao<2 then - for i=1,#piaoList do - piaoList[i].visible=true - end - piaoState.selectedIndex=1 - else - piaoList[1].visible=false - for i=2,#piaoList do - piaoList[i].visible=tconfig["piao"..(i-1)] - end - piaoState.selectedIndex=2 - end - + local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") + self._view:AddChild(obj_piao) + obj_piao.x = (self._view.width - obj_piao.width) * 0.5 + obj_piao.y = self._view.height * 0.6 + for i = 1, 4 do + obj_piao:GetChild("btn_" .. i).onClick:Add(function() + self._gamectr:SendAction(i - 1) + obj_piao:Dispose() + end) + end + self._com_piao = obj_piao end function M:ReloadRoom(bskip) @@ -639,36 +908,44 @@ function M:ReloadRoom(bskip) -- end if bskip == nil or bskip == false then - if not room.playing then - self._state.selectedIndex = 2 - else - self._state.selectedIndex = 1 - self._room._reload_flag = true - end + if not room.playing then + self._state.selectedIndex = 2 + self._ctr_action.selectedIndex = 1 + else + self._state.selectedIndex = 1 + self._ctr_action.selectedIndex = 0 + self._room._reload_flag = true + end end - + self:reqResidueCard() + self:ShowJing() for i = 1, #room.player_list do local p = room.player_list[i] local info = self._player_card_info[self:GetPos(p.seat)] for i = 1, #p.fz_list do info:UpdateFzList(p.fz_list[i], -1) end - info:UpdateHandCard() + info:UpdateHandCard() local head_info = self._player_info[self:GetPos(p.seat)] - head_info:UpdateScore() + -- head_info:UpdateScore() head_info._view:GetChild('zhanji').visible = true - local num = p.total_score or 0 - if num > 0 then - head_info._view:GetController('text_color').selectedIndex = 0 - head_info._view:GetChild('text_jifen').text = "+" .. num --d2ad(num) - else - head_info._view:GetController('text_color').selectedIndex = 1 - head_info._view:GetChild('text_jifen').text = num --d2ad(num) - end + local num = p.total_score or 0 + if num > 0 then + head_info._view:GetController('text_color').selectedIndex = 0 + head_info._view:GetChild('text_jifen').text = "+" .. num --d2ad(num) + else + head_info._view:GetController('text_color').selectedIndex = 1 + head_info._view:GetChild('text_jifen').text = num --d2ad(num) + end if p.seat == room.last_outcard_seat then local card = p.outcard_list[#p.outcard_list] - info:UpdateOutCardList(nil,card, self._cursor) + info:UpdateOutCardList(nil, card, self._cursor) + if self:GetPos(p.seat) == 1 and #info:GetTingList(DataManager.CurrenRoom.self_player.card_list) > 0 then + self._btn_selectTing.visible = true + else + self._btn_selectTing.visible = false + end elseif p.seat == room.curren_outcard_seat then info:UpdateHandCard(true) info:UpdateOutCardList() @@ -682,47 +959,97 @@ function M:ReloadRoom(bskip) -- self._player_info[self:GetPos(p.seat)]:Ready(true) -- end if bskip == nil or bskip == false then - if p.ready and room.playing == false then - self._player_info[self:GetPos(p.seat)]:Ready(true) - end - end - if p.piao_niao~=nil and p.piao_niao > 0 then + if p.ready and room.playing == false then + self._player_info[self:GetPos(p.seat)]:Ready(true) + if room.self_player.seat == p.seat then + self._ctr_action.selectedIndex = 0 + end + end + end + if p.piao_niao ~= nil and p.piao_niao > 0 then local head_info = self._player_info[self:GetPos(p.seat)] head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao head_info._view:GetController("piao_niao").selectedIndex = 1 end end -- self:ShowHuTip() - + if bskip == nil or bskip == false then self:UpdateCardBox(self:GetPos(room.curren_outcard_seat)) - self._tex_LeftCard.text = room.left_count + self._tex_LeftCard.text = string.format("余%d张", room.left_count) self:UpdateRound() - end + end end function M:PlayerChangeLineState() - -- local isOutCard = true - -- local str = "玩家 " - -- for _ , player in ipairs(self._room.player_list) do - -- if player.line_state == 0 then - -- isOutCard = false - -- end - -- end - -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard + -- local isOutCard = true + -- local str = "玩家 " + -- for _ , player in ipairs(self._room.player_list) do + -- if player.line_state == 0 then + -- isOutCard = false + -- end + -- end + -- self._player_card_info[1]._area_handcard_list.touchable = isOutCard end function M:UpdateCardBox(seat) - local index = seat + local index = seat - 1 local people_num = self._room.room_config.people_num if people_num == 2 and seat == 2 then - index = 3 - elseif people_num == 3 and seat == 3 then - index = 4 + index = 2 end self._ctr_cardbox.selectedIndex = index end +-----------------------展示牌---------------------------- + +function M:reqResidueCard() + self._flag_getRemindCard = false + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:ReqResidueCard() +end + +function M:SendShowNext(ShowNextConfrimCtr) + if not self._showNextName then + ViewUtil.ErrorTip(nil, "请先选择一个麻将牌") + return + end + ShowNextConfrimCtr.selectedIndex = 1 +end + +function M:ClickShowNext(context, ShowNextConfrimCtr) + if self._showNextName == context.data.name then + self:SendShowNext(ShowNextConfrimCtr) + return + end + self._showNextName = context.data.name +end + +function M:FillShowCards(obj, card, num) + if DataManager.CurrenRoom.jing and obj:GetController('jing') then + if DataManager.CurrenRoom.jing and obj:GetController('jing') then + if card == DataManager.CurrenRoom.jing then + obj:GetController('jing').selectedIndex = 1 + else + obj:GetController('jing').selectedIndex = 0 + end + end + end + if obj.icon then + obj.icon = 'ui://Main_Majiang/b201_' .. card + else + obj:GetChild("icon").url = 'ui://Main_Majiang/b201_' .. card + end + if obj.title then + obj.title = string.format("%d张", num) + else + obj:GetChild("title").text = string.format("%d张", num) + end +end + +----------------------------------------------------------- + + function M:__CloseTip() if self._chipeng_tip then self._chipeng_tip:Dispose() @@ -734,13 +1061,20 @@ function M:__CloseTip() end end +function M:__CloseGangTip() + if self._gang_tip_choice then + self._gang_tip_choice:Dispose() + self._gang_tip_choice = nil + end +end + function M:closeTipOnTuoguan() self:__CloseTip() end function M:Destroy() MJMainView.Destroy(self) - UIPackage.RemovePackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") + UIPackage.RemovePackage("extend/majiang/fuzhou/ui/Extend_MJ_FuZhou") end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/EXPlayBackView.lua b/lua_probject/extend_project/extend/majiang/hongzhong/EXPlayBackView.lua index c66e33d1..8b645ed9 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/EXPlayBackView.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/EXPlayBackView.lua @@ -1,33 +1,43 @@ local MJPlayBackView = require("main.majiang.MJPlayBackView") local EXRoomConfig = import(".EXRoomConfig") local EXClearingView = import(".EXClearingView") +local HuCardImg = import(".HuCardImg") +local FZTipList = require("main.majiang.FZData") +local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") + local Record_Event = import(".RecordEvent") local M = {} ---- Create a new +--- Create a new function M.new() - setmetatable(M,{__index = MJPlayBackView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MJPlayBackView }) + local self = setmetatable({}, { __index = M }) self.class = "PlayBackView" self:init() return self end - function M:InitView(url) - local room = self._room - UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") - MJPlayBackView.InitView(self,"ui://Main_Majiang/Main_"..room.room_config.people_num) - local _cardbox = self._view:GetChild("cardbox") - --self._view:GetChild("panel_record"):GetChild("btn_LastStep").enabled = false + local room = self._room + UIPackage.AddPackage("extend/majiang/fuzhou/ui/Extend_MJ_FuZhou") + MJPlayBackView.InitView(self, string.format("ui://Main_Majiang/Main_new_%d_jiangxi", room.room_config.people_num)) + local _cardbox = self._view:GetChild("cardbox") + --self._view:GetChild("panel_record"):GetChild("btn_LastStep").enabled = false self._ctr_cardbox = _cardbox:GetController("c1") self._tex_round = self._view:GetChild("tex_round") self._tex_LeftCard = self._view:GetChild("remaining_card") self._anchor = self._view:GetChild("mask_tips") + self.jing = self._view:GetChild('jing') + + self.HuCardImg = setmetatable(HuCardImg, { __index = self.HuCardImg }) + self.asset_group = "FuZhou_MJ" + self.HuCardImg_path = "ui://Extend_MJ_FuZhou/" + self.Sound_path = "extend/majiang/fuzhou/sound/" + self._eventmap = {} self._cmdmap = {} @@ -38,36 +48,44 @@ function M:InitView(url) self._cmdmap[Record_Event.Evt_Niao] = self.CmdNiao self._cmdmap[Record_Event.Evt_Piao] = self.CmdPiao self._cmdmap[Record_Event.Evt_Result] = self.CmdResult + self._cmdmap[Record_Event.Evt_FZTip] = self.CmdFZTip + self._cmdmap[Record_Event.Evt_GangScore] = self.GangScore + + self.com_logocType.selectedIndex = 0 end function M:FillRoomData(data) - MJPlayBackView.FillRoomData(self) - if self._win_pic then self._win_pic:Dispose() end - if self._niao then self._niao:Dispose() end - self._currentStep = 0 - local room = DataManager.CurrenRoom - local _player_card_info = self._player_card_info - local left_count = data.info.left_card - self:UpdateLeftCard(left_count) - local round = data.info.round - self:UpdateRound(round) - - local roominfo_panel = self._view:GetChild("roominfo_panel1") - roominfo_panel:GetChild("tex_roomid").text = room.room_id - roominfo_panel:GetChild("tex_gametype").text = room.room_config:GetGameName() + MJPlayBackView.FillRoomData(self) + if self._win_pic then self._win_pic:Dispose() end + if self._niao then self._niao:Dispose() end + self._currentStep = 0 + local room = DataManager.CurrenRoom + local _player_card_info = self._player_card_info + local left_count = data.info.left_card + self:UpdateLeftCard(left_count) + local round = data.info.round + self:UpdateRound(round) + self:ShowJing() - for i = 1, #room.player_list do - local p = room.player_list[i] - local card_info = _player_card_info[self:GetPos(p.seat)] - card_info:Clear() - table.sort(p.card_list, ViewUtil.HandCardSort) - card_info:UpdateHandCard(false, true) - self._player_info[i]._view:GetController("piao_niao").selectedIndex = 0 - end + local roominfo_panel = self._view:GetChild("roominfo_panel1") + roominfo_panel:GetChild("tex_roomid").text = room.room_id + roominfo_panel:GetChild("tex_gametype").text = room.room_config:GetGameName() - self:GenerateAllStepData(data) - self:UpdateStep(1) - -- self:ShowStep(0) + for i = 1, #room.player_list do + local p = room.player_list[i] + local card_info = _player_card_info[self:GetPos(p.seat)] + card_info:Clear() + table.sort(p.card_list, self.HandCardSortAndJing) + card_info:UpdateHandCard(false, true) + self._player_info[i]._view:GetController("piao_niao").selectedIndex = 0 + end + + self:GenerateAllStepData(data) + self:UpdateStep(1) + self:Play() + self._laiziMove:Play() + self._touxiangMove:Play() + -- self:ShowStep(0) end function M:ShowStep(index) @@ -86,76 +104,348 @@ function M:ShowStep(index) p.outcard_list = step.player_card_data[i].outcard_list p.fz_list = step.player_card_data[i].fz_list p.hand_left_count = #p.card_list - info:Clear() - info:ResetFzList() + -- info:Clear() + -- info:ResetFzList() p.piao_niao = step.player_card_data[i].piao_niao local head_info = self._player_info[self:GetPos(i)] if p.piao_niao and p.piao_niao > 0 then head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao head_info._view:GetController("piao_niao").selectedIndex = 1 else - head_info._view:GetController("piao_niao").selectedIndex = 0 + head_info._view:GetController("piao_niao").selectedIndex = 0 end if step.cmd == Record_Event.Evt_OutCard and i == step.last_out_seat then local card = p.outcard_list[#p.outcard_list] - info:UpdateOutCardList(nil, nil, self._cursor) + info:UpdateOutCardList(nil, card, self._cursor) + self:PlayMJSound("chupai.mp3") + self:PlaySound("FuZhou_MJ", p.self_user.sex, tostring(card)) else info:UpdateOutCardList() end - if step.cmd == Record_Event.Evt_GetCard and p.seat == step.current_out_seat then - info:UpdateHandCard(true, true) + ---显示提示按钮 + local _ctr_tips = info._view:GetController('tip2') + local _lit_fanzi = info._view:GetChild("Comp_Back_FZTips") + local _flag_tipGetCard = false + if step.cmd == Record_Event.Evt_FZTip then + if p.seat == step.seat then + local tip = step.tiplist + local _tlist = tip.tip_sortList + _lit_fanzi.itemRenderer = function(index, obj) + local type = obj:GetController('type') + if index == tip.tip_num then + type.selectedIndex = 0 + else + index = index + 1 + if _tlist[index].type == FZType.HU then + type.selectedIndex = 4 + obj:GetChild('btn_Card1').icon = string.format('ui://Main_Majiang/b202_%d', + _tlist[index].card) + _flag_tipGetCard = self.last_get_seat ~= step.seat + elseif _tlist[index].type == FZType.Chi then + type.selectedIndex = FZType.Chi + for i = 1, 3 do + obj:GetChild(string.format('btn_Card%d', i)).icon = string.format( + 'ui://Main_Majiang/b202_%d', + _tlist[index].opcard[i]) + end + elseif _tlist[index].type == FZType.Peng then + type.selectedIndex = FZType.Peng + for i = 1, 3 do + obj:GetChild(string.format('btn_Card%d', i)).icon = string.format( + 'ui://Main_Majiang/b202_%d', + _tlist[index].card) + end + else + for i = 1, 4 do + obj:GetChild(string.format('btn_Card%d', i)).icon = string.format( + 'ui://Main_Majiang/b202_%d', + _tlist[index].card) + end + type.selectedIndex = FZType.Gang + if _tlist[index].type == FZType.Gang_An then + obj:GetChild('btn_Card4').icon = 'ui://Main_Majiang/b202_00' + end + _flag_tipGetCard = true + end + end + end + _ctr_tips.selectedIndex = 1 + _lit_fanzi.numItems = tip.tip_num + 1 + end else - info:UpdateHandCard(false, true) + _ctr_tips.selectedIndex = 0 + _lit_fanzi.numItems = 0 + end + ----多人胡的时候,同时显示胡 + if step.cmd == Record_Event.Evt_Result then + --所有都显示胡吧,暂时没做胡和自摸的判断 + if not self.result then + if step.result_data.info_list[i].is_win then + local info2 = self._player_card_info[self:GetPos(step.result_data.info_list[i].seat)] + local loader_HuEffect = info2._viewLoader_selfHuCardEffect + local isZiMo = false + DataManager.CurrenRoom.isZiMoHu = isZiMo + local hu_sound = isZiMo and ("zimo") or ("hu") + printlog("声音====>>>", hu_sound) + self:PlaySound(self.asset_group, p.self_user.sex, hu_sound) + + local effects = isZiMo and ("tile_zimo") or ("tile_hu") + loader_HuEffect.visible = true + loader_HuEffect.url = "ui://Main_Majiang/" .. effects + loader_HuEffect:SetScale(2, 2) + local hu_tween = loader_HuEffect:TweenScale(Vector2(1, 1), 0.3) + hu_tween:SetEase(EaseType.QuartOut) + hu_tween:OnComplete(function() + loader_HuEffect.visible = false + end) + end + end + end + if step.cmd ~= Record_Event.Evt_OutCard and step.cmd ~= Record_Event.Evt_GangScore and step.cmd ~= Record_Event.Evt_Win and step.cmd ~= Record_Event.Evt_Niao and p.seat == step.current_out_seat or step.cmd == Record_Event.Evt_Result then + if step.cmd == Record_Event.Evt_Action then + pt("lingmeng step ", step) + local fz = step.fz + local info = self._player_card_info[self:GetPos(i)] + local loader_HuEffect = info._viewClip_Peng_Gang + local effects = "" + if fz.type == FZType.Peng then + self:PlaySound("Main_Majiang", p.self_user.sex, "peng") + effects = "clip_peng" + elseif fz.type == FZType.Chi then + + else + self:PlaySound("Main_Majiang", p.self_user.sex, "gang") + effects = "clip_gang" + end + local clip = UIPackage.CreateObjectFromURL(string.format("ui://Main_Majiang/%s", effects)) + clip:SetSize(loader_HuEffect.width, loader_HuEffect.height) + loader_HuEffect:AddChild(clip) + clip:SetPlaySettings(0, -1, 1, -1) + clip.onPlayEnd:Add(function() + if clip.parent then + clip.parent:RemoveChild(clip) + end + clip:Dispose() + end) + clip.playing = true + info:UpdateFzList(fz, index, true, self:GetPos(fz.from_seat)) + end + printlog("lingmeng UpdateHandCard", step.cmd, p.seat, step.fz and step.fz.type or -1, FZType.Peng, + _flag_tipGetCard) + if step.cmd == Record_Event.Evt_Action and step.fz.type ~= FZType.Peng then + info:UpdateHandCard(false, true) + elseif step.cmd == Record_Event.Evt_FZTip and not _flag_tipGetCard then + info:UpdateHandCard(false, true) + elseif step.cmd == Record_Event.Evt_Result then + local _flag_result = false + for i = 1, #step.result_data.info_list do + printlog("lingmeng UpdateHandCard3", step.result_data.info_list[i].is_win, + step.result_data.info_list[i].seat) + + if step.result_data.info_list[i].is_win and p.seat == step.result_data.info_list[i].seat then + _flag_result = true + end + end + printlog("lingmeng UpdateHandCard3", _flag_result) + info:UpdateHandCard(_flag_result, true) + else + info:UpdateHandCard(true, true) + end + else + if step.cmd == Record_Event.Evt_Win or step.cmd == Record_Event.Evt_Niao then + else + info:UpdateHandCard(false, true) + end end end + + --统一在大结算时显示 if step.cmd == Record_Event.Evt_Win then - self._win_pic = UIPackage.CreateObjectFromURL("ui://Main_Majiang/胡") - local info = self._player_card_info[self:GetPos(step.win)] - info._mask_liangpai:AddChild(self._win_pic) - self._win_pic:Center() else if self._win_pic then self._win_pic:Dispose() end end + --统一在大结算时显示 if step.cmd == Record_Event.Evt_Niao then local niao_list = step.niao - self._niao = UIPackage.CreateObjectFromURL("ui://Extend_MJ_HongZhong/Panel_Birds") - local list = self._niao:GetChild("Lst_birds") - list:RemoveChildrenToPool() - for i = 1, #niao_list do - local item = list:AddItemFromPool() - item.icon = UIPackage.GetItemURL("Main_Majiang", "201_"..niao_list[i].card) - if niao_list[i].score > 0 then - item:GetController("bg").selectedIndex = 2 - end - end - self._view:AddChild(self._niao) - self._view:AddChild(self._view:GetChild("panel_record")) - self._niao:Center() else - if self._niao then - self._niao:Dispose() - end end if step.cmd == Record_Event.Evt_Result then + print("lingmeng playerback", self.result) if not self.result then - self.result = EXClearingView.new(self._root_view, true) - self.result:InitData(0, self._room, step.result_data) + local result = step.result_data + result.cardList = step.residual_card + self.result = EXClearingView.new(self, { flag_back = true }) + self.result:InitData(0, self._room, result) self.result._view.x = (GRoot.inst.width - self.result._view.width) * -0.5 self.result._view.width = GRoot.inst.width self.result._view.height = GRoot.inst.height - self.result._view:GetChild("btn_confirm").visible = false self._anchor:AddChild(self.result._view) + self.result._view.visible = false self.result._view.x = self._anchor.x * -1 self.result._view.y = self._anchor.y * -1 + + local liuju = result and result.liuju or nil + coroutine.start(function() + coroutine.wait(0.3) + + --逐个显示胡的特效 + for i = 1, #result.info_list do + local hu_info = result.info_list[i] + local player = self._room:GetPlayerBySeat(hu_info.seat) + local info = self._player_card_info[self:GetPos(hu_info.seat)] + + if hu_info.is_win then + local win_list = hu_info.win_list + + local list_HuCardEffect = info._viewList_HuEffect + local Effects = {} + --先循环一遍把杠上开花放在最前面 + for i = 1, #win_list do + local HuMsg = win_list[i] + if HuMsg.type > 2 and HuMsg.type < 60 then + if self.HuCardImg[HuMsg.type][1] == "tile_cs_gangshanghua" then + local imgPath = "ui://Main_Majiang/tile_cs_gangshanghua" + local imgObj = list_HuCardEffect:AddItemFromPool() + local imgLoader = imgObj:GetChild("loader_img") + imgLoader.url = imgPath + imgObj.visible = false + Effects[#Effects + 1] = imgObj + table.remove(win_list, i) + break + end + end + end + + for i = 1, #win_list do + local HuMsg = win_list[i] + + -- ↓↓↓先排列好特效图片 + if HuMsg.type > 2 and HuMsg.type < 60 then + local sound_name = string.format(self.Sound_path .. "%s/%s.mp3", + ViewUtil.Sex_Chat[player.self_user.sex], + "he" .. HuMsg.type) + ViewUtil.PlaySound(self.asset_group, sound_name) + + local imgList = self.HuCardImg[HuMsg.type] + for _, img in pairs(imgList) do + local imgPath = "ui://Main_Majiang/" .. img + local imgObj = list_HuCardEffect:AddItemFromPool() + local imgLoader = imgObj:GetChild("loader_img") + imgLoader.url = imgPath + imgObj.visible = false + Effects[#Effects + 1] = imgObj + end + end + end + + --小于四个字段时动态调整胡特效 + if info._viewText_cardInfo["huEffet_columnGap"] and #Effects < 4 then + list_HuCardEffect.columnGap = tonumber(info._viewText_cardInfo["huEffet_columnGap"]) + else + list_HuCardEffect.columnGap = 0 + end + + -- ↓↓↓播放动画 + for _, imgObj in pairs(Effects) do + imgObj.visible = true + + local effect_xingxing = imgObj:GetChild("effect_xingxing") + effect_xingxing:SetPlaySettings(0, -1, 1, -1); + effect_xingxing.visible = true + effect_xingxing.playing = true + effect_xingxing.onPlayEnd:Set(function() + effect_xingxing.visible = false + end) + + local imgLoader = imgObj:GetChild("loader_img") + imgLoader:SetScale(2, 2) + imgLoader:Center() + imgLoader:TweenScale(Vector2(1, 1), 0.3) + coroutine.wait(0.5) + end + + coroutine.wait(0.3) + list_HuCardEffect:RemoveChildrenToPool() + end + end + + --展示摸鸟 + local niao_list = result.niao + self._niao = UIPackage.CreateObject("Extend_MJ_FuZhou", "Panel_Birds") + self._view:GetChild('jiangma_show'):AddChild(self._niao) + self._niao:Center() + local list_niao_card = self._niao:GetChild("Lst_birds") + list_niao_card:RemoveChildrenToPool() + for i = 1, #niao_list do + --顯示正面 + local item = list_niao_card:AddItemFromPool() + local card = niao_list[i].card + item.icon = UIPackage.GetItemURL("Main_Majiang", "b202_" .. card) + if niao_list[i].score > 0 then + item:GetController("select").selectedIndex = 1 + else + item:GetController("select").selectedIndex = 0 + end + coroutine.wait(2 / #niao_list) + end + coroutine.wait(0.3) + self._niao:Dispose() + + --统一显示弹出分数 + for i = 1, #result.info_list do + local hu_info = result.info_list[i] + local head_info = self._player_info[self:GetPos(hu_info.seat)] + + -- 扣分动画 + head_info:UpdateScore(hu_info.total_score, true) + end + coroutine.wait(0.3) + + if liuju then + self:PlayMJSound("liuju.mp3") + coroutine.wait(3) + self:PlayMJSound("end_music.mp3") + else + self:PlayMJSound("end_music.mp3") + end + coroutine.wait(0.5) + self.result._view.visible = true + end) else - self.result._view.visible = true + -- self.result._view.visible = true end - -- self.result._view:Center() - else - if self.result then - self.result._view.visible = false + end + --显示杠分 + if step.cmd == Record_Event.Evt_GangScore then + local totalScoreList = step.totalScoreList + local playerList = step.playerList + local addScoreList = step.addScoreList + local scoreData = {} + for i = 1, #totalScoreList do + local p = {} + + p.totalScore = totalScoreList[i] + p.player = playerList[i] + p.addScore = addScoreList[i] + + scoreData[#scoreData + 1] = p + end + + for _, p in pairs(scoreData) do + local player = self._room:GetPlayerById(p.player) + local infoView = self._player_info[self:GetPos(player.seat)] + player.cur_hp = p.totalScore + + if p.addScore ~= 0 then + infoView:ScoreAnimation(p.addScore) + if player.cur_hp >= 0 then + infoView._view:GetChild("text_jifen").text = "+" .. player.cur_hp + else + infoView._view:GetChild("text_jifen").text = player.cur_hp + end + end end end end @@ -167,10 +457,12 @@ function M:GenerateAllStepData(data) local info = data.info step.cmd = "" step.left_card = info.left_card + step.last_get_seat = 0 step.last_out_seat = 0 step.current_out_seat = 1 step.win = 0 step.niao = 0 + step.residual_card = info.residual_card step.player_card_data = {} for i = 1, #self._room.player_list do @@ -192,10 +484,11 @@ function M:GenerateAllStepData(data) end end -function M:CmdGetCard(cmd, index) +function M:CmdGetCard(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd data.current_out_seat = cmd.seat + data.last_get_seat = cmd.seat data.left_card = cmd.data.left_count local u = data.player_card_data[cmd.seat] u.card_list[#u.card_list + 1] = cmd.data.card @@ -207,7 +500,7 @@ function M:CmdOutCard(cmd, index) data.last_out_seat = cmd.seat local u = data.player_card_data[cmd.seat] list_remove(u.card_list, cmd.data.card) - table.sort(u.card_list, ViewUtil.HandCardSort) + table.sort(u.card_list, self.HandCardSortAndJing) u.outcard_list[#u.outcard_list + 1] = cmd.data.card end @@ -217,26 +510,43 @@ function M:CmdAction(cmd, index) data.last_out_seat = 0 data.current_out_seat = cmd.seat local u = data.player_card_data[cmd.seat] - for i = 1, #cmd.data.opcard do - list_remove(u.card_list, cmd.data.opcard[i]) - end - local fz = {} - fz.type = cmd.data.type - fz.card = cmd.data.card - fz.opcard = cmd.data.opcard - local uf = data.player_card_data[cmd.data.from_seat] - if fz.type ~= FZType.Gang_An and fz.type ~= FZType.Gang_Peng then - table.remove(uf.outcard_list, #uf.outcard_list) - end - if fz.type ~= FZType.Gang_Peng then - u.fz_list[#u.fz_list + 1] = fz - else + local fz = nil + local index = -1 + local ftype = cmd.data.type + if (ftype == FZType.Gang_Peng) then for i = 1, #u.fz_list do - if u.fz_list[i].type == FZType.Peng and u.fz_list[i].card == fz.card then - u.fz_list[i].type = FZType.Gang_Peng + if (u.fz_list[i].card == cmd.data.card) then + u.fz_list[i].card = cmd.data.card + fz = u.fz_list[i] + fz.type = cmd.data.type + index = i - 1 + break end end end + fz = {} + fz.card = cmd.data.card + fz.type = cmd.data.type + if (index == -1) then + u.fz_list[#u.fz_list + 1] = fz + end + fz.from_seat = cmd.data.from_seat + local remove_num = #cmd.data.opcard + + for i = 1, remove_num do + if ftype == FZType.Gang_Peng then + list_remove(u.card_list, cmd.data.card) + else + list_remove(u.card_list, cmd.data.opcard[i]) + end + end + + u.hand_left_count = u.hand_left_count - remove_num + if cmd.data.from_seat ~= u.seat and ftype ~= FZType.Gang_Peng then + local u = data.player_card_data[cmd.data.from_seat] + table.remove(u.outcard_list, #u.outcard_list) + end + data.fz = fz end function M:CmdWin(cmd, index) @@ -257,10 +567,56 @@ function M:CmdPiao(cmd, index) data.player_card_data[cmd.seat].piao_niao = cmd.data.num end +function M:CmdFZTip(cmd, index) + local data = self:CopyLastStep(index) + data.cmd = cmd.cmd + data.seat = cmd.seat + local tiplist = FZTipList.new() + local list = cmd.data.tip_list + for i = 1, #list do + local dtip = list[i] + local tip = {} + tip.id = dtip["id"] + tip.weight = dtip["weight"] + tip.card = dtip["card"] + tip.type = dtip["type"] + tip.opcard = dtip["opcard"] + tiplist:AddTip(tip) + end + --排序规则,胡杠碰 + tiplist:SortList(function(a, b) + return a.type < b.type + end) + data.tiplist = tiplist + data.weight = cmd.data.weight +end + +function M:GangScore(cmd, index) + local data = self:CopyLastStep(index) + data.cmd = cmd.cmd + data.seat = cmd.seat + data.totalScoreList = cmd.data.totalScoreList + data.playerList = cmd.data.playerList + data.addScoreList = cmd.data.addScoreList +end + function M:CmdResult(cmd, index) local data = self:CopyLastStep(index) data.cmd = cmd.cmd + data.seat = 0 data.result_data = cmd.data + if not data._flag_result then + for i = 1, #cmd.data.info_list do + local info = cmd.data.info_list[i] + if info.is_win and info.seat ~= data.current_out_seat then + local u = data.player_card_data[info.seat] + u.card_list[#u.card_list + 1] = info.win_card + local u = data.player_card_data[data.last_out_seat] + table.remove(u.outcard_list, #u.outcard_list) + end + end + end + data._flag_result = true end function M:CopyLastStep(index) @@ -273,7 +629,7 @@ function M:CopyLastStep(index) end function M:UpdateLeftCard(num) - self._tex_LeftCard.text = "剩余 "..num.." 张牌" + self._tex_LeftCard.text = "余" .. num .. "张" end function M:UpdateCardBox(seat) @@ -287,12 +643,53 @@ function M:UpdateCardBox(seat) self._ctr_cardbox.selectedIndex = index end -function M:UpdateRound(round) - self._tex_round.text = "第 "..round.."/"..self._room.room_config.round.." 局" +function M:UpdateRound() + self._view:GetChild("text_round").text = string.format("局数:%d /%d", self._room.curren_round, + self._room.room_config.round) +end + +function M:ShowJing() + print("lingmeng jing ", self._room.jing) + if self._room.jing then + self.jing.visible = true + MJPlayerCardInfoView.fillCard2(self, self.jing, "b202_", self._room.jing) + else + self.jing.visible = false + end end function M:UpdateStep(step) self._record:GetChild("tex_step").text = "第 " .. step .. " / " .. #self._step .. "步" end -return M \ No newline at end of file +function M.HandCardSortAndJing(a, b) + local jing = DataManager.CurrenRoom.jing + if a == jing or b == jing then + if a == b then + return a < b + end + return a == jing + else + if a < 200 then + a = a + 1000 + elseif a < 300 then + a = a + 3000 + elseif a < 400 then + a = a + 2000 + else + a = a + 4000 + end + if b < 200 then + b = b + 1000 + elseif b < 300 then + b = b + 3000 + elseif b < 400 then + b = b + 2000 + else + b = b + 4000 + end + return a < b + end +end + +return M diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/majiang/hongzhong/EXPlayerInfoView.lua index f8a5fd69..3a8b3a84 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/EXPlayerInfoView.lua @@ -1,27 +1,25 @@ local PlayerInfoView = require("Game.View.PlayerInfoView") +local PlayerInfoView2 = require("Game.View.PlayerInfoView2") local M = {} -function M.new(view, mainView) - setmetatable(M, {__index = PlayerInfoView}) - local self = setmetatable({}, {__index = M}) +function M.new(view, mainView,flag_witness) + setmetatable(M, { __index = PlayerInfoView2 }) + local self = setmetatable({}, { __index = M }) self._view = view self._main_view = mainView - self:init() + self:init(flag_witness) return self end -function M:init() - PlayerInfoView.init(self) - self._tex_score = self._view:GetChild("info"):GetChild("tex_score1") - self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2") - self._ct_score = self._view:GetChild("info"):GetController("score") +function M:init(flag_witness) + PlayerInfoView2.init(self,flag_witness) end -function M:ShowInteraction(type,str) +function M:ShowInteraction(type, str) if type == 3 then Voice.DownLoad(str, function(clip) - if (clip ) then + if (clip) then self:ShowMaskVoice(clip.length) GameApplication.Instance:PlayVoice(clip) end @@ -30,47 +28,25 @@ function M:ShowInteraction(type,str) self:SetChat(str) elseif type == 2 then local chat_index = tonumber(str) - self._main_view:PlayChatSound(self._player.self_user.sex,chat_index) + self._main_view:PlayChatSound(self._player.self_user.sex, chat_index) local language, index = self._main_view:GetChatMsgLanguage(chat_index) self:SetChat(self._main_view.Fix_Msg_Chat[index]) elseif type == 1 then - self:SetBiaoqing("ui://Chat/"..str) + self:SetBiaoqing("ui://Chat/" .. str) end end function M:UpdateRemainCard(card_num, hide) if hide then - self._view:GetController("show_remain").selectedIndex = 0 + self._view:GetController("show_remain").selectedIndex = 0 else - self._view:GetController("show_remain").selectedIndex = 1 + self._view:GetController("show_remain").selectedIndex = 1 end self._view:GetChild("com_remain"):GetChild("tex_remain").text = card_num end function M:FillData(player) - PlayerInfoView.FillData(self, player) - self:UpdateScore(player.total_score) -end - -function M:UpdateScore() - local score = self._player.total_score - local room = DataManager.CurrenRoom - if room:checkHpNonnegative() then - score = d2ad(self._player.cur_hp) - end - if not score then - score = 0 - end - if score < 0 then - self._ct_score.selectedIndex = 1 - self._tex_score2.text = score - else - self._ct_score.selectedIndex = 0 - if not room:checkHpNonnegative() then - score = "+" .. score - end - self._tex_score.text = score - end + PlayerInfoView2.FillData(self, player) end return M diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/EXSettingView.lua b/lua_probject/extend_project/extend/majiang/hongzhong/EXSettingView.lua new file mode 100644 index 00000000..28640424 --- /dev/null +++ b/lua_probject/extend_project/extend/majiang/hongzhong/EXSettingView.lua @@ -0,0 +1,113 @@ +--设置窗口对象 +local MJSettingViewNew = require("main.majiang.MJSettingViewNew") + +local EXSettingView = {} + +function EXSettingView.new(main_view, flag_witness) + local self = setmetatable({}, { __index = MJSettingViewNew }) + self.class = 'EXSettingView' + self._close_destroy = true + self._mainView = main_view + self._flag_witness = flag_witness + MJSettingViewNew.new(main_view, flag_witness) + --self:init('ui://Main_Majiang/Setting') + return self +end + +--[[ +local EXSettingView = {} + +local M = EXSettingView +setmetatable(M, { __index = BaseWindow }) + +function EXSettingView:Show(room) + self._room = room + + -- 房主,第一个进房间的人 + local roomOwner = self._room.player_list[1].self_user.account_id + + if roomOwner == DataManager.SelfUser.account_id then + self.cBtn.selectedIndex = 1 + else + self.cBtn.selectedIndex = 0 + end + + BaseWindow.Show(self) +end + +function EXSettingView.new(main_view, flag_witness) + local self = setmetatable({}, { __index = M }) + self.class = 'EXSettingView' + self._close_destroy = true + self._mainView = main_view + self._flag_witness = flag_witness + self:init('ui://Main_Majiang/Setting') + return self +end + +function M:init(url) + BaseWindow.init(self, url) + + local view = self._view + local slider_sound = view:GetChild('slider_vedio_sound') + local slider_music = view:GetChild('slider_vedio_music') + local btn_music = view:GetChild('btn_vedio_music') + local btn_sound = view:GetChild('btn_vedio_sound') + + self.cBtn = self._view:GetController('cBtn') + + slider_sound.value = GameApplication.Instance.SoundValue + slider_music.value = GameApplication.Instance.MusicValue + + slider_music.onChanged:Add(function() + GameApplication.Instance.MusicValue = slider_music.value + btn_music.selected = false + GameApplication.Instance.MusicMute = false; + end) + + slider_sound.onChanged:Add(function() + GameApplication.Instance.SoundValue = slider_sound.value + btn_sound.selected = false + GameApplication.Instance.SoundMute = false; + end) + + btn_sound.onClick:Add(function() + GameApplication.Instance.SoundMute = btn_sound.selected; + end) + + btn_music.onClick:Add(function() + GameApplication.Instance.MusicMute = btn_music.selected; + end) + + local _btn_logout = self._view:GetChild('btn_cancelRoom') + _btn_logout.onClick:Set(function() + if self._flag_witness then + local _room = DataManager.CurrenRoom + pt(_room) + self._mainView._gamectr:ExitWitnessGame(_room.play_id, _room.game_id, + _room.room_id) + ViewManager.ChangeView(ViewManager.View_Family) + else + if self._mainView.dismiss_room_cd_time > 0 then + ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") + else + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:AskDismissRoom() + end + end + end) + + self._view:GetChild("btn_closeRoom").onClick:Set(function() + local _gamectr = ControllerManager.GetController(GameController) + _gamectr:LevelRoom(function(res) + print("退出房间") + if res.ReturnCode ~= 0 then + ViewUtil.ErrorTip(res.ReturnCode) + return + end + ViewManager.ChangeView(ViewManager.View_Family) + end) + end) +end +]] +return EXSettingView diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/EXWitnessView.lua b/lua_probject/extend_project/extend/majiang/hongzhong/EXWitnessView.lua new file mode 100644 index 00000000..089e0610 --- /dev/null +++ b/lua_probject/extend_project/extend/majiang/hongzhong/EXWitnessView.lua @@ -0,0 +1,520 @@ +local EXRoomConfig = import(".EXRoomConfig") +local EXClearingView = import(".EXClearingView") +local TX_GameEvent = import(".GameEvent") +local PlayerInfoView = import(".EXPlayerInfoView") +local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") +local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") +local SettingView = import(".EXSettingView") +local TableBG = require("Game.Data.TableBG") +local WitnessView = require("main.majiang.MJWitnessView") +local MJMainView = require("main.majiang.MJMainView") +local HuCardImg = import(".HuCardImg") + + +local Record_Event = import(".RecordEvent") + +local M = {} + +--- Create a new +function M.new() + setmetatable(M, { __index = WitnessView }) + local self = setmetatable({}, { __index = M }) + self.class = "EXMJWitness" + self:init() + + return self +end + +function M:init() + getmetatable(M).__index.init(self) +end + +function M:InitView() + local room = self._room + getmetatable(M).__index.InitView(self) + UIPackage.AddPackage("extend/majiang/fuzhou/ui/Extend_MJ_FuZhou") + self:EventInit() + UpdateBeat:Add(self.OnUpdate, self) + + self.HuCardImg = setmetatable(HuCardImg, { __index = self.HuCardImg }) + self.Sound_path = "extend/majiang/fuzhou/sound/" + local centerBox = self._view:GetChild("Comp_ConterBox") + self._ctr_cardbox = centerBox:GetController("seat") + self._tex_leftTime = centerBox:GetChild("Text_Time") + self._tex_round = self._view:GetChild("tex_round") + self._tex_LeftCard = self._view:GetChild("remaining_card") + self._anchor = self._view:GetChild("mask_tips") + + ------------------渲染桌面信息-------------------------- + + self._view:GetChild('text_time').text = os.date("%H:%M", os.time()) + self._view:GetChild('text_roomId').text = room.room_id + self._state = self._view:GetController("state") + + self._text_remined = self._view:GetChild('remaining_card') + self._text_round = self._view:GetChild('text_round') + self._cursor = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Ani_play_bj") + -- self._state.onChanged:Add(function() + -- self:UpdatePlayerInfoView() + -- end) + + self:UpdateRound() + self:InitPlayerInfoView() + self._player_card_info = {} + local _player_card_info = self._player_card_info + if room.curren_round > 0 then + for i = 1, #room.player_list do + local p = room.player_list[i] + local index = self:GetPos(p.seat) + print("lingmeng index", index) + local info = self._player_info[i] + local tem = self._view:GetChild("player_card_info" .. i) + _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i) + local cardInfo = _player_card_info[i] + cardInfo:SetPlayer(p) + cardInfo:UpdateHandCardWitness(false) + cardInfo:UpdateOutCardList(nil, nil, self._cursor) + for i = 1, #p.fz_list do + cardInfo:UpdateFzList(p.fz_list[i], -1) + end + info:FillData(p) + info._view.visible = true + end + else + for i = 1, room.room_config.people_num do + local tem = self._view:GetChild("player_card_info" .. i) + _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i) + end + for i = 1, #room.player_list do + local p = room.player_list[i] + local index = self:GetPos(p.seat) + local info = self._player_info[i] + local cardInfo = _player_card_info[index] + cardInfo:SetPlayer(p) + cardInfo:UpdateHandCardWitness(false) + cardInfo:UpdateOutCardList(nil, nil, self._cursor) + for i = 1, #p.fz_list do + cardInfo:UpdateFzList(p.fz_list[i], -1) + end + info:FillData(p) + info._view.visible = true + end + end + + + local btn_rule = self._view:GetChild('btn_rule') + if btn_rule ~= nil then + btn_rule.onClick:Set(function() + if self.RuleView == nil or self.RuleView._is_destroy then + self.RuleView = RoomInfoView.new(self._room) + end + self.RuleView:Show() + end) + end + + local btn_exit = self._view:GetChild('btn_exitWitness') + if btn_exit ~= nil then + btn_exit.onClick:Set(function() + self._gamectr:ExitWitnessGame() + ViewManager.ChangeView(ViewManager.View_Family) + end) + end + + local viewList_witness = self._view:GetChild('comp_witness'):GetChild('list_players') + viewList_witness:SetVirtual() + viewList_witness.itemRenderer = function(index, obj) + obj:GetChild('title').text = room.witness_player_list[index + 1].nick + ImageLoad.Load(room.witness_player_list[index + 1].portrait, obj:GetChild('btn_head')._iconObject) + end + + local btn_witness = self._view:GetChild('btn_pangGuang') + if btn_witness then + btn_witness.onClick:Set(function() + self._view:GetController('witness').selectedIndex = 1 + end) + end + + --直接渲染观战人员 + if viewList_witness.numItems == #room.witness_player_list then + viewList_witness:RefreshVirtualList() + else + viewList_witness.numItems = #room.witness_player_list + end + + --展示精牌 + self.jing = self._view:GetChild('jing') + self:ShowJing() + ------------------------------------------------------- + + self._state.selectedIndex = 4 + self.com_logocType.selectedIndex = 0 +end + +function M:EventInit() + -- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong") + getmetatable(M).__index.EventInit(self) + local _room = self._room + local _view = self._view + local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard") + local _player_info = self._player_info + local _gamectr = self._gamectr + + _gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...) + local arg = { ... } + print("lingmeng witness SendLaiZi") + end) + + _gamectr:AddEventListener(TX_GameEvent.SendGangZi, function(...) + local arg = { ... } + print("lingmeng witness SendGangZi") + end) + + _gamectr:AddEventListener(TX_GameEvent.EventBuGang, function(...) + local arg = { ... } + print("lingmeng witness EventBuGang") + end) + + _gamectr:AddEventListener(TX_GameEvent.OutHint, function(...) + print("lingmeng witness OutHint") + end) + + _gamectr:AddEventListener(TX_GameEvent.GetCard, function(...) + print("lingmeng witness GetCard") + end) + + _gamectr:AddEventListener(TX_GameEvent.FZTips, function(...) + print("lingmeng witness FZTips") + end) + + _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) + self._popEvent = false + self._left_time = 0 + self:UpdateCardBox(0) + local arg = { ... } + local win_seat = arg[1] + local lose_seat = arg[2] + local win_card = arg[3] + local cards = arg[4] + local win_list = arg[5] + local scoreData = arg[6] + local index = self:GetPos(win_seat) + local info = self._player_card_info[index] + local player = self._room:GetPlayerBySeat(win_seat) + MJMainView.ShowHand(self, scoreData) + info:ShowHuCard(win_card, index == 1) + + -- self.cHuCardEffect.selectedIndex = 1 + + local loader_HuEffect = info._viewLoader_selfHuCardEffect + local list_HuCardEffect = info._viewList_HuEffect + + --- + local isZiMo = win_seat == lose_seat + DataManager.CurrenRoom.isZiMoHu = isZiMo + local hu_sound = isZiMo and ("zimo") or ("hu") + printlog("声音====>>>", hu_sound) + self:PlaySound(self.asset_group, player.self_user.sex, hu_sound) + + local effects = isZiMo and ("tile_zimo") or ("tile_hu") + loader_HuEffect.visible = true + loader_HuEffect.url = "ui://Main_Majiang/" .. effects + loader_HuEffect:SetScale(2, 2) + loader_HuEffect:TweenScale(Vector2(1, 1), 0.3):SetEase(EaseType.QuartOut) + + --观战暂时把这个特效去了,现在这个特效位置也不对 + -- self.effect_ZiMo.xy = loader_HuEffect.xy + -- self.effect_ZiMo:SetPlaySettings(0, -1, 1, -1); + -- self.effect_ZiMo.visible = true + -- self.effect_ZiMo.playing = true + -- self.effect_ZiMo.onPlayEnd:Set(function() + -- self.effect_ZiMo.visible = false + -- end) + + coroutine.start(function() + coroutine.wait(0.5) + + loader_HuEffect.visible = false + local Effects = {} + for i = 1, #win_list do + local HuMsg = win_list[i] + + -- ↓↓↓先排列好特效图片 + if HuMsg.type > 2 and HuMsg.type < 32 then + local sound_name = string.format(self.Sound_path .. "%s/%s.mp3", + ViewUtil.Sex_Chat[player.self_user.sex], + "he" .. HuMsg.type) + ViewUtil.PlaySound(self.asset_group, sound_name) + -- self:PlaySound(self.asset_group, player.self_user.sex, "he" .. HuMsg.type) + local imgList = self.HuCardImg[HuMsg.type] + for _, img in pairs(imgList) do + local imgPath = "ui://Main_Majiang/" .. img + local imgObj = list_HuCardEffect:AddItemFromPool() + local imgLoader = imgObj:GetChild("loader_img") + imgLoader.url = imgPath + imgObj.visible = false + Effects[#Effects + 1] = imgObj + end + end + end + + -- ↓↓↓播放动画 + for _, imgObj in pairs(Effects) do + imgObj.visible = true + + local effect_xingxing = imgObj:GetChild("effect_xingxing") + effect_xingxing:SetPlaySettings(0, -1, 1, -1); + effect_xingxing.visible = true + effect_xingxing.playing = true + effect_xingxing.onPlayEnd:Set(function() + effect_xingxing.visible = false + end) + + local imgLoader = imgObj:GetChild("loader_img") + imgLoader:SetScale(2, 2) + imgLoader:Center() + imgLoader:TweenScale(Vector2(1, 1), 0.3) + coroutine.wait(0.5) + end + + -- 扣分动画 + for _, pScore in pairs(scoreData) do + local infoView = self._player_info[self:GetPos(pScore.seat)] + infoView:UpdateScore(pScore.total_score, true) + end + + coroutine.wait(0.5) + self._popEvent = true + list_HuCardEffect:RemoveChildrenToPool() + + -- self.cHuCardEffect.selectedIndex = 0 + end) + end) + + _gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...) + print("lingmeng witness EventNiao") + end) + + _gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...) + self:PlayMJSound("end_music.mp3") + local _room = self._room + self._left_time = 0 + self:UpdateCardBox(0) + self._ctr_cardbox.selectedIndex = 0 + local arg = { ... } + MJMainView.ShowHand(self, arg) + local result = arg[1] + local liuju = result.liuju + local data = result.info_list + local niao = result.niao + -- if liuju then + -- local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu") + -- self._view:AddChild(le) + -- le:Center() + -- le:GetTransition("t0"):Play() + -- coroutine.start(function() + -- coroutine.wait(1) + -- le:Dispose() + -- end) + -- end + -- self:RemoveCursor() + if self._clearingView == nil then + self._clearingView = EXClearingView.new(self) + coroutine.start(function() + coroutine.wait(0.5) + self._clearingView:Show() + self._popEvent = true + end) + end + + if _room.curren_round ~= _room.room_config.round then + -- if #niao == 0 then self._view:GetChild("n13").visible = false end + self._clearingView:InitData(0, _room, result, nil, function(...) + for i = 1, #data do + local p = _room:GetPlayerBySeat(data[i].seat) + p.total_score = data[i].total_score + local card_info = self._player_card_info[self:GetPos(p.seat)] + local info = self._player_info[self:GetPos(p.seat)] + --card_info:Clear() + card_info:ResetCardType() + if _room:checkHpNonnegative() then + p.cur_hp = data[i].total_score + end + info:UpdateScore() + info._view:GetChild("zhanji").visible = true + local num = data[i].total_score + if num >= 0 then + info._view:GetController("text_color").selectedIndex = 0 + info._view:GetChild("text_jifen").text = "+" .. num + else + info._view:GetController("text_color").selectedIndex = 1 + info._view:GetChild("text_jifen").text = num + end + + info._view:GetChild("mask_piao").title = "" + info._view:GetController("piao_niao").selectedIndex = 0 + p.fz_list = {} + end + DataManager.CurrenRoom.self_player.card_list = {} + self._clearingView = nil + end) + end + end) + + _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) + print("lingmeng witness ZPResult2") + self:UnmarkSelfTuoguan() + self._left_time = 0 + self:UpdateCardBox(0) + self._ctr_cardbox.selectedIndex = 0 + local arg = { ... } + local total_result = arg[2] + local result = arg[1] + local over = arg[3] + self._clearingView = EXClearingView.new() + if over ~= 2 or _room.curren_round > 0 then + coroutine.start(function() + coroutine.wait(0.5) + self._clearingView:Show() + end) + end + self._clearingView:InitData(over, _room, result, total_result) + ControllerManager.ChangeController(LoddyController) + end) + + _gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function() + print("lingmeng witness EvnetPiaoTip") + end) + + _gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...) + print("lingmeng witness EvnetPiao") + end) + + _gamectr:AddEventListener(TX_GameEvent.EventResidueCard, function(...) + print("lingmeng witness EventResidueCard") + end) + + --替换mianview的事件 + _gamectr:AddEventListener( + GameEvent.PlayerState, + function(...) + printlog("lingmeng OnEventOnlineState") + local arg = { ... } + local p = arg[1] + local info = self._player_info[self:GetPos(p.seat)] + info._ctr_offline.selectedIndex = p.line_state == 0 and 1 or 0 + end + ) +end + +function M:InitPlayerInfoView() + self._player_info = {} + local _player_info = self._player_info + for i = 1, self._room.room_config.people_num do + local tem = self._view:GetChild(string.format("player_info%d_2", i)) + _player_info[i] = PlayerInfoView.new(tem, self, true) + tem.visible = false + end +end + +function M:NewMJPlayerCardInfoView(view, index) + return MJMainView.NewMJPlayerCardInfoView(self, view, index) + --[[ + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self) + end + return MJPlayerCardInfoView.new(view, self) + ]] +end + +function M:RemoveCursor() + self._cursor:RemoveFromParent() +end + +function M:UpdateCardBox(seat) + local index = seat - 1 + local people_num = self._room.room_config.people_num + if people_num == 2 and seat == 2 then + index = 2 + end + self._ctr_cardbox.selectedIndex = index +end + +local majiang_asset_path = "base/main_majiang/sound/" +function M:PlayMJSound(path) + ViewUtil.PlaySound(self.asset_group, majiang_asset_path .. path) +end + +function M:PlaySound(group, sex, path) + local sex_path = ViewUtil.Sex_Chat[sex] + local path1 = majiang_asset_path .. string.format("%s/%s.mp3", sex_path, path) + ViewUtil.PlaySound(group, path1) +end + +function M:UpdateRound() + self._view:GetChild("text_round").text = string.format("局数:%d /%d", self._room.curren_round, + self._room.room_config.round) +end + +function M:ShowJing() + if self._room.jing then + self.jing.visible = true + MJPlayerCardInfoView.fillCard2(self, self.jing, "b202_", self._room.jing) + else + self.jing.visible = false + end +end + +-- function M:UpdatePlayerInfoView() +-- self._player_info = {} +-- local _player_info = self._player_info +-- local list = self._room.player_list + +-- for i = 1, self._room.room_config.people_num do +-- local seat = self:GetPos(list[i].seat) +-- local tem = self._view:GetChild(string.format("player_info%d_%d", seat, +-- (self._state.selectedIndex == 4 and 1 or 0) + 1)) +-- _player_info[seat] = PlayerInfoView.new(tem, self) +-- _player_info[seat]:FillData(list[i]) +-- printlog("lingmeng _player_info", tem, seat, list[i].self_user.nick_name) +-- end +-- end + +function M:ResetConnect() + +end + +function M:GetPos(seat) + return ViewUtil.GetPos(self._room.self_player.seat, seat, self._room.room_config.people_num) +end + +function M.HandCardSortAndJing(a, b) + local jing = DataManager.CurrenRoom.jing + if a == jing or b == jing then + if a == b then + return a < b + end + return a == jing + else + if a < 200 then + a = a + 1000 + elseif a < 300 then + a = a + 3000 + elseif a < 400 then + a = a + 2000 + else + a = a + 4000 + end + if b < 200 then + b = b + 1000 + elseif b < 300 then + b = b + 3000 + elseif b < 400 then + b = b + 2000 + else + b = b + 4000 + end + return a < b + end +end + +return M diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/hongzhong/ExtendConfig.lua index cda3fd88..aa9ae100 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/ExtendConfig.lua @@ -5,6 +5,7 @@ local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") local EXPlayBackView = import(".EXPlayBackView") +local EXWitnessView = import(".EXWitnessView") local MJRoom = require("main.majiang.MJRoom") local ExtendConfig = {} @@ -20,6 +21,7 @@ function ExtendConfig.new() self._viewMap = {} self._viewMap[ViewManager.View_Main] = EXMainView self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + self._viewMap[ViewManager.View_Witness] = EXWitnessView return self end diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/GameEvent.lua b/lua_probject/extend_project/extend/majiang/hongzhong/GameEvent.lua index 0550da46..396113cc 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/GameEvent.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/GameEvent.lua @@ -26,7 +26,14 @@ local TX_GameEvent = { EvnetPiaoTip = "EvnetPiaoTip", EvnetPiao = "EvnetPiao", - - EventXiPai="EventXiPai", + + + --- + SendLaiZi = "SendLaiZi", + SendGangZi = "SendGangZi", + EventBuGang = "EventBuGang", + + --- + EventResidueCard = "EventResidueCard" } return TX_GameEvent \ No newline at end of file diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/HuCardImg.lua b/lua_probject/extend_project/extend/majiang/hongzhong/HuCardImg.lua new file mode 100644 index 00000000..3a614c86 --- /dev/null +++ b/lua_probject/extend_project/extend/majiang/hongzhong/HuCardImg.lua @@ -0,0 +1,50 @@ +local HuCardImg = { +} + +HuCardImg[1] = { "tile_hu" } +HuCardImg[2] = { "tile_zimo" } +HuCardImg[3] = { "tile_cs_shisanlan" } +HuCardImg[4] = { "tile_cs_qxshisanlan" } +HuCardImg[5] = { "tile_cs_pengpenghu" } +HuCardImg[6] = { "tile_cs_pengpenghu", "tile_cs_qingyise" } +HuCardImg[7] = { "tile_cs_pengpenghu", "tile_cs_ziyise" } +HuCardImg[8] = { "tile_cs_qidui" } +HuCardImg[9] = { "tile_cs_qidui", "tile_cs_qingyise" } +HuCardImg[10] = { "tile_cs_qidui", "tile_cs_ziyise" } +HuCardImg[11] = { "tile_cs_qingyisezhenhu" } +HuCardImg[12] = { "tile_cs_qingyisejiahu" } +HuCardImg[13] = { "tile_cs_ziyisezhenhu" } +HuCardImg[14] = { "tile_cs_ziyisejiahu" } +HuCardImg[15] = { "tile_cs_tianhu" } +HuCardImg[16] = { "tile_cs_dihu" } +HuCardImg[17] = { "tile_cs_pinghu" } +HuCardImg[18] = { "tile_cs_qiangganghu" } +HuCardImg[19] = { "tile_cs_gangshanghua" } +HuCardImg[20] = { "缺失" } +HuCardImg[21] = { "tile_cs_siguiyi" } +HuCardImg[22] = { "tile_cs_baguiyi" } +HuCardImg[23] = { "tile_cs_seguiyi" } +HuCardImg[24] = { "tile_cs_qingyisejiahu","tile_cs_siguiyi" } +HuCardImg[25] = { "tile_cs_qingyisezhenhu","tile_cs_siguiyi" } +HuCardImg[26] = { "tile_cs_qingyisejiahu","tile_cs_baguiyi" } +HuCardImg[27] = { "tile_cs_qingyisezhenhu","tile_cs_baguiyi" } +HuCardImg[28] = { "tile_cs_qingyisejiahu","tile_cs_seguiyi" } +HuCardImg[29] = { "tile_cs_qingyisezhenhu","tile_cs_seguiyi" } +HuCardImg[30] = { "tile_cs_ziyisejiahu","tile_cs_siguiyi" } +HuCardImg[31] = { "tile_cs_ziyisezhenhu","tile_cs_siguiyi" } +HuCardImg[32] = { "tile_cs_ziyisejiahu","tile_cs_baguiyi" } +HuCardImg[33] = { "tile_cs_ziyisezhenhu","tile_cs_baguiyi" } +HuCardImg[34] = { "tile_cs_ziyisejiahu","tile_cs_seguiyi" } +HuCardImg[35] = { "tile_cs_ziyisezhenhu","tile_cs_seguiyi" } +HuCardImg[36] = { "tile_cs_qingyise","tile_cs_qidui","tile_cs_siguiyi" } +HuCardImg[37] = { "tile_cs_qingyise","tile_cs_qidui","tile_cs_baguiyi" } +HuCardImg[38] = { "tile_cs_qingyise","tile_cs_qidui","tile_cs_seguiyi" } +HuCardImg[39] = { "tile_cs_ziyise","tile_cs_qidui","tile_cs_siguiyi" } +HuCardImg[40] = { "tile_cs_ziyise","tile_cs_qidui","tile_cs_baguiyi" } +HuCardImg[41] = { "tile_cs_ziyise","tile_cs_qidui","tile_cs_seguiyi" } +HuCardImg[42] = { "tile_cs_qidui","tile_cs_siguiyi" } +HuCardImg[43] = { "tile_cs_qidui","tile_cs_baguiyi" } +HuCardImg[44] = { "tile_cs_qidui","tile_cs_seguiyi" } + + +return HuCardImg diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/hongzhong/MJPlayerSelfCardInfoView.lua index 37f180cb..134c3f64 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/MJPlayerSelfCardInfoView.lua @@ -4,177 +4,209 @@ local CardCheck = import(".CardCheck") local M = {} -- -function M.new(view, mainView) +function M.new(view, mainView, record, direction) setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) setmetatable(M, { __index = MJPlayerSelfCardInfoView }) local self = setmetatable({}, { __index = M }) self.class = "PlayerSelfCardInfoView" self._view = view self._mainView = mainView + self.direction = direction + self._flag_canTing = true self:init() return self end -function M:ShowHuTip(card_list) - local tingList = CardCheck.tingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, - DataManager.CurrenRoom.room_config.Laizi) - if #tingList > 0 then - table.insert(tingList, 412) +function M:init() + getmetatable(M).__index.init(self) +end + +function M:ShowHuTip(card_list, have_bg) + self._mainView._hu_tip:FillData(self:GetTingList(card_list), have_bg) +end + +function M:GetTingList(card_list) + if not self._flag_canTing then + return {} end - self._mainView._hu_tip:FillData(tingList) + return CardCheck.MuiltiplteCaculateTingPai(card_list, { _hu_qidui = true, _hu_shisanlan = true }) end function M:UpdateHandCard(getcard, mp) MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) - local _carViewList = self._carViewList - local card_list = DataManager.CurrenRoom.self_player.card_list - self:ShowHuTip(card_list) - if getcard then - self._out_card = true - local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list) - -- 记录需要标记听牌提示的牌 - local lst_mark = {} - local total_num = 0 - for i = 1, #_carViewList do - local btn = _carViewList[i].card - local card = self:GetCard(btn) - list_remove(card_list, card) - local tingList = CardCheck.tingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, - DataManager.CurrenRoom.room_config.Laizi) - if #tingList > 0 then - local count = 0 - for j = 1, #tingList do - count = count + self._mainView:CountCardLeftNum(tingList[j]) - end - local tem = {} - tem.item = btn - tem.count = count - total_num = total_num + count - table.insert(lst_mark, tem) - end - table.insert(card_list, card) - end - table.sort(lst_mark, function(a, b) - return a.count > b.count - end) - -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' - local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false - for i = 1, #lst_mark do - local tem = lst_mark[i] - if all_same or tem.count < lst_mark[1].count then - tem.item:GetController("mark_ting").selectedIndex = 1 - else - tem.item:GetController("mark_ting").selectedIndex = 2 - end - end - else - for i = 1, #_carViewList do - local btn = _carViewList[i].card - if btn:GetController("mark_ting").selectedIndex ~= 0 then - btn:GetController("mark_ting").selectedIndex = 0 - end - end - self._out_card = false - end + -- local _carViewList = self._carViewList + + -- if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then + -- for i = 1, #self._carViewList do + -- local obj = self._carViewList[i] + -- if obj and obj.card then + -- if IsHasDictionary(obj.card_item, DataManager.CurrenRoom.laiziInfo) then + -- if obj.card.GetController then + -- if obj.card:GetController("laizi") then + -- obj.card:GetController("laizi").selectedIndex = 1 + -- end + -- end + -- else + -- if obj.card.GetController then + -- if obj.card:GetController("laizi") then + -- obj.card:GetController("laizi").selectedIndex = 0 + -- end + -- end + -- end + -- end + -- end + -- end + + + -- local card_list = DataManager.CurrenRoom.self_player.card_list + -- -- self:ShowHuTip(card_list) + -- if getcard then + -- self._out_card = true + -- local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list) + -- -- 记录需要标记听牌提示的牌 + -- local lst_mark = {} + -- local total_num = 0 + -- for i = 1, #_carViewList do + -- local btn = _carViewList[i].card + -- local card = self:GetCard(btn) + -- list_remove(card_list, card) + -- local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, + -- DataManager.CurrenRoom.room_config.Qidui, DataManager.CurrenRoom.room_config.Laizi) + -- if #tingList > 0 then + -- local count = 0 + -- for j = 1, #tingList do + -- count = count + self._mainView:CountCardLeftNum(tingList[j]) + -- end + -- local tem = {} + -- tem.item = btn + -- tem.count = count + -- total_num = total_num + count + -- table.insert(lst_mark, tem) + -- end + -- table.insert(card_list, card) + -- end + -- table.sort(lst_mark, function(a, b) + -- return a.count > b.count + -- end) + -- -- 如果几张牌的可胡牌数一致,也只显示'三角',可胡牌数不一致才显示'多' + -- local all_same = #lst_mark ~= 0 and lst_mark[1].count == total_num / #lst_mark or false + -- for i = 1, #lst_mark do + -- local tem = lst_mark[i] + -- if all_same or tem.count < lst_mark[1].count then + -- tem.item:GetController("mark_ting").selectedIndex = 1 + -- else + -- tem.item:GetController("mark_ting").selectedIndex = 2 + -- end + -- end + -- else + -- for i = 1, #_carViewList do + -- local btn = _carViewList[i].card + -- if btn:GetController("mark_ting").selectedIndex ~= 0 then + -- btn:GetController("mark_ting").selectedIndex = 0 + -- end + -- end + -- self._out_card = false + -- end end -function M:__OnClickHandCard(context) - local button = context.sender - local _carViewList = self._carViewList - local refresh = true - local card_list = {} - for i = 1, #_carViewList do - local btn = _carViewList[i].card - local card = self:GetCard(btn) - if btn ~= button and btn.selected == true then - if button.data.card_item == card then - refresh = false - else - self._mainView:markOutCards(false, card) - end - btn.selected = false - end - if not btn.selected then - table.insert(card_list, card) - end - end +-- function M:__OnClickHandCard(context) +-- local button = context.sender +-- local _carViewList = self._carViewList +-- local refresh = true +-- local card_list = {} +-- for i = 1, #_carViewList do +-- local btn = _carViewList[i].card +-- local card = self:GetCard(btn) +-- if btn ~= button and btn.selected == true then +-- if button.data.card_item == card then +-- refresh = false +-- else +-- self._mainView:markOutCards(false, card) +-- end +-- btn.selected = false +-- end +-- if not btn.selected then +-- table.insert(card_list, card) +-- end +-- end - if self._out_card then - self:ShowHuTip(card_list) - end +-- if self._out_card then +-- -- self:ShowHuTip(card_list) +-- end - -- 标记出牌 - if refresh then - if button.selected then - self._mainView:markOutCards(true, button.data.card_item) - else - self._mainView:markOutCards(false, button.data.card_item) - end - end +-- -- 标记出牌 +-- if refresh then +-- if button.selected then +-- self._mainView:markOutCards(true, button.data.card_item) +-- else +-- self._mainView:markOutCards(false, button.data.card_item) +-- end +-- end - local _room = DataManager.CurrenRoom - if not button.selected and _room.curren_outcard_seat == _room.self_player.seat then - local card = button.data - self._mainView:OutCard(card.card_item) - end -end +-- local _room = DataManager.CurrenRoom +-- if not button.selected and _room.curren_outcard_seat == _room.self_player.seat then +-- local card = button.data +-- self._mainView:OutCard(card.card_item) +-- end +-- end -function M:__OnDragStart(card) - local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list) - list_remove(card_list, card) - self:ShowHuTip(card_list) -end +-- function M:__OnDragStart(card) +-- local card_list = membe_clone(DataManager.CurrenRoom.self_player.card_list) +-- list_remove(card_list, card) +-- -- self:ShowHuTip(card_list) +-- end -function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end - local button = context.sender +-- function M:__OnDragEnd(context) +-- if self.outcard_button then +-- self.outcard_button:Dispose() +-- self.outcard_button = nil +-- end +-- local button = context.sender - --button:RemoveFromParent() - local card = button.data - local _room = DataManager.CurrenRoom +-- --button:RemoveFromParent() +-- local card = button.data +-- local _room = DataManager.CurrenRoom - -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) - if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 412) then - self._mainView:OutCard(card.card_item) - button.touchable = false - self.outcard_button = button - else - self._area_handcard_list:AddChildAt(button, card.index) - button:TweenMove(card.old_postion, 0.2) - end -end +-- -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) +-- if (button.y - card.old_postion.y < -50 and _room.curren_outcard_seat == _room.self_player.seat and card.card_item ~= 0) then +-- self._mainView:OutCard(card.card_item) +-- button.touchable = false +-- self.outcard_button = button +-- else +-- self._area_handcard_list:AddChildAt(button, card.index) +-- button:TweenMove(card.old_postion, 0.2) +-- end +-- end -function M:CheckPlayerOnlineState() - local room = DataManager.CurrenRoom - for i = 1, #room.player_list do - if room.player_list[i].line_state == 0 then - return false - end - end - return true -end +-- function M:CheckPlayerOnlineState() +-- local room = DataManager.CurrenRoom +-- for i = 1, #room.player_list do +-- if room.player_list[i].line_state == 0 then +-- return false +-- end +-- end +-- return true +-- end function M:Clear(bskip) + MJPlayerSelfCardInfoView.Clear(self) --self._ctr_state.selectedIndex = 0 - self._area_fz_list.x = self._src_fz_list.x - self._area_fz_list.y = self._src_fz_list.y - self._area_fz_list.width = self._src_fz_list.z - self._area_fz_list.height = self._src_fz_list.w + -- self._area_fz_list.x = self._src_fz_list.x + -- self._area_fz_list.y = self._src_fz_list.y + -- self._area_fz_list.width = self._src_fz_list.z + -- self._area_fz_list.height = self._src_fz_list.w - self._area_fz_list:RemoveChildren(0, -1, true) - self._area_handcard_list:RemoveChildren(0, -1, true) - self._area_outcard_list:RemoveChildren(0, -1, true) - if bskip == nil or bskip == false then - self._mask_liangpai:RemoveChildren(0, -1, true) - end + -- self._area_fz_list:RemoveChildren(0, -1, true) + -- self._area_handcard_list:RemoveChildren(0, -1, true) + -- self._area_outcard_list:RemoveChildren(0, -1, true) + -- if bskip == nil or bskip == false then + -- self._mask_liangpai:RemoveChildren(0, -1, true) + -- end - for i = 1, #self._carViewList do - self._carViewList[i].card:Dispose() - end - self._carViewList = {} + -- for i = 1, #self._carViewList do + -- self._carViewList[i].card:Dispose() + -- end + -- self._carViewList = {} end return M diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/Protocol.lua b/lua_probject/extend_project/extend/majiang/hongzhong/Protocol.lua index e0efab7e..b1125f26 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/Protocol.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/Protocol.lua @@ -43,7 +43,16 @@ local Protocol = { -- 飘鸟事件 GAME_EVT_PIAO = "834", - + + GAME_EVT_GANGZI = "837", + GAME_EVT_BUGANG = "838", + GAME_EVT_DOGANG = "839", + + --送牌 + GAME_NEXT_CARD = "888", + GAME_RESIDUE_CARD = "613", + GAME_EVT_RESIDUE_CARD = "889", + GAME_XIPAI = "20836", GAME_EVENT_XIPAI = "20837", GAME_EVENT_NOTIFY_XIPAI = "20838", diff --git a/lua_probject/extend_project/extend/majiang/hongzhong/RecordEvent.lua b/lua_probject/extend_project/extend/majiang/hongzhong/RecordEvent.lua index 09748550..d2900571 100644 --- a/lua_probject/extend_project/extend/majiang/hongzhong/RecordEvent.lua +++ b/lua_probject/extend_project/extend/majiang/hongzhong/RecordEvent.lua @@ -6,6 +6,8 @@ local Record_Event = { Evt_Niao = "Niao", Evt_Piao = "PiaoNiao", Evt_Result = "Result", + Evt_FZTip = "FizTip", + Evt_GangScore = "GangScore", } return Record_Event \ No newline at end of file diff --git a/lua_probject/extend_project/extend/poker/duoduo/EXGameController.lua b/lua_probject/extend_project/extend/poker/duoduo/EXGameController.lua index ae99d1dd..f4fbc201 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/EXGameController.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/EXGameController.lua @@ -54,6 +54,8 @@ function M:RegisterEvt() self._eventmap[EXProtocol.GAME_EVT_CARDINHAND] = self.OnPlaySuccCheckHandCard self._eventmap[EXProtocol.EXBomb_Score_New] = self.OnBompScoreNew self._eventmap[EXProtocol.EXCheckCard_Succ] = self.OnCheckCard + self._eventmap[EXProtocol.EXBaseScore] = self.OnGetBaseScore + self._eventmap[EXProtocol.EXShowRank] = self.OnShowRank end -- function M:Oener(evt_data) @@ -209,19 +211,17 @@ function M:OnInitCard(evt_data) end function M:OnBombScore(evt_data) - printlog("lingmeng OnBombScore") - -- local scoreList = evt_data["gold_list"] - -- self._cacheEvent:Enqueue( - -- function() - -- -- for i = 1, #scoreList do - -- -- local score = scoreList[i].bom_score - -- -- local player = self._room:GetPlayerById(scoreList[i].aid) - -- -- player.total_score = player.total_score + score - -- -- end - -- -- DispatchEvent(self._dispatcher, EXGameEvent.OnBombScore, scoreList) - -- end - -- ) - printlog("lingmeng OnBombScoreend") + local scoreList = evt_data["gold_list"] + self._cacheEvent:Enqueue( + function() + for i = 1, #scoreList do + local score = scoreList[i].bom_score + local player = self._room:GetPlayerById(scoreList[i].aid) + player.total_score = player.total_score + score + end + DispatchEvent(self._dispatcher, EXGameEvent.OnBombScore, scoreList) + end + ) end function M:OnPlaySucc(evt_data) @@ -239,12 +239,13 @@ function M:OnPlaySuccCheck(evt_data) local card_obj = evt_data["card_obj"] local cards = card_obj["card_list"] local remain = evt_data["remain"] -- 报单 + local baseScore = evt_data["score"] or 0 self._cacheEvent:Enqueue( function() local player = self._room:GetPlayerBySeat(seat) player.hand_count = remain player.out_card_list = cards - DispatchEvent(self._dispatcher, EXGameEvent.OnPlaySucc, player, remain) + DispatchEvent(self._dispatcher, EXGameEvent.OnPlaySucc, player, remain, baseScore) end ) end @@ -263,11 +264,11 @@ function M:OnPassSucc(evt_data) local seat = evt_data["seat"] self._cacheEvent:Enqueue( function() - print("lingmeng OnPassSucc",seat) + print("lingmeng OnPassSucc", seat) local p = self._room:GetPlayerBySeat(seat) p.out_card_list = { 0 } DispatchEvent(self._dispatcher, EXGameEvent.OnPassSucc, p) - print("lingmeng OnPassSuccend",seat) + print("lingmeng OnPassSuccend", seat) end ) end @@ -301,11 +302,9 @@ function M:OnIndexMove(evt_data) local seat = evt_data["index"] self._cacheEvent:Enqueue( function() - printlog("lingmeng OnIndexMove", seat) self._room.curren_turn_seat = seat self._room.is_new_bout = self:GetIsNewBout(seat) DispatchEvent(self._dispatcher, EXGameEvent.OnIndexMove, seat) - printlog("lingmeng OnIndexMoveend", seat) end ) end @@ -358,6 +357,7 @@ function M:OnResult(evt_data) local info = evt_data["info"] local winseat = evt_data["winseat"] local remaincards = evt_data["remaincards"] + local dipais = evt_data["dipais"] DataManager.CurrenRoom.xipaiScore = evt_data["xipai_score"] --printlog("wwwwwwwwwwwwwwwwwwwww1111111 ",result_type) --pt(evt_data) @@ -368,13 +368,12 @@ function M:OnResult(evt_data) function() for i = 1, #info do local p = self._room:GetPlayerBySeat(info[i]["seat"]) - print("lingmeng log200", info[i]["score"], p.total_score) info[i].card_score = info[i]["score"] - p.total_score p.total_score = info[i]["score"] info[i]["self_user"] = p.self_user end - DispatchEvent(self._dispatcher, EXGameEvent.OnResult, over, info, winseat, remaincards) + DispatchEvent(self._dispatcher, EXGameEvent.OnResult, over, info, winseat, remaincards, dipais) end ) elseif result_type == 0 then @@ -383,12 +382,11 @@ function M:OnResult(evt_data) function() for i = 1, #info do local p = self._room:GetPlayerBySeat(info[i]["seat"]) - print("lingmeng log200", info[i]["score"], p.total_score) info[i].card_score = info[i]["score"] - p.total_score p.total_score = info[i]["score"] info[i]["self_user"] = p.self_user end - DispatchEvent(self._dispatcher, EXGameEvent.OnResult, over, info, winseat, remaincards) + DispatchEvent(self._dispatcher, EXGameEvent.OnResult, over, info, winseat, remaincards, dipais) end ) else @@ -748,4 +746,20 @@ function M:OnCheckCard(evt_data) ) end +function M:OnGetBaseScore(evt_data) + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnGetBaseScore, evt_data) + end + ) +end + +function M:OnShowRank(evt_data) + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnShowRank, evt_data) + end + ) +end + return M diff --git a/lua_probject/extend_project/extend/poker/duoduo/EXGameEvent.lua b/lua_probject/extend_project/extend/poker/duoduo/EXGameEvent.lua index bded1230..570bd518 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/EXGameEvent.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/EXGameEvent.lua @@ -20,6 +20,8 @@ local EXGameEvent = { EventXiPai = "EventXiPai", OnPassSuccCheckCard = "OnPassSuccCheckCard", OnBompScoreNew = "OnBompScoreNew", - OnCheckCard = "OnCheckCard" + OnCheckCard = "OnCheckCard", + OnGetBaseScore = "OnGetBaseScore", + OnShowRank = "OnShowRank" } return EXGameEvent diff --git a/lua_probject/extend_project/extend/poker/duoduo/EXMainView.lua b/lua_probject/extend_project/extend/poker/duoduo/EXMainView.lua index 19c130f2..30596eae 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/EXMainView.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/EXMainView.lua @@ -493,6 +493,7 @@ function M:EventInit() self.rank_view = nil end self._ctr_inClear.selectedIndex = 0 + self._view:GetChild('list_dipais'):RemoveChildrenToPool() self:UpdateRound(round) -- ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/fapai.mp3") local list = _room.player_list @@ -518,7 +519,7 @@ function M:EventInit() local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:Clear() head_info:Ready(false) - + head_info._ctr_rank.selectedIndex = 0 if p.seat == self._room.self_player.seat then if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then @@ -611,20 +612,18 @@ function M:EventInit() --出牌权和前端出牌提示挪到转向协议 local lastCardList = self._gamectr:GetLastCardList(self._room.self_player.seat) if index == 1 then - card_info:ShowOutCardOption2(lastCardList, 1) + card_info:ShowOutCardOption2(lastCardList, self._room.is_new_bout and 2 or 1) end end) _gamectr:AddEventListener(EXGameEvent.OnBombScore, function(...) local arg = { ... } local scoreList = arg[1] - -- for i = 1, #scoreList do - -- local player = self._room:GetPlayerBySeat(i) - -- local card_info = self._player_card_info[self:GetPos(i)] - -- local head_info = self._player_info[self:GetPos(i)] - -- card_info:PlayScore(scoreList[i], true) - -- head_info:UpdateScore(player.total_score) - -- end + for i = 1, #scoreList do + local player = self._room:GetPlayerBySeat(i) + local head_info = self._player_info[self:GetPos(i)] + head_info:UpdateScore(player.total_score) + end end) _gamectr:AddEventListener(EXGameEvent.OnPlaySucc, function(...) @@ -633,6 +632,7 @@ function M:EventInit() local arg = { ... } local p = arg[1] local card_number = arg[2] + local baseScore = arg[3] self.ctr_time.selectedIndex = 0 local index = self:GetPos(p.seat) if index == 1 then @@ -656,6 +656,8 @@ function M:EventInit() if index == 1 then card_info:DeleteHandCards(p.out_card_list) end + + self._view:GetChild('text_baseScore').text = baseScore end) _gamectr:AddEventListener(EXGameEvent.OnCheckCard, function(...) local arg = { ... } @@ -877,6 +879,8 @@ function M:EventInit() local info = arg[2] local win_seat = arg[3] local remaincards = arg[4] + local dipais = arg[5] + -- local energyTab = arg[5] local otherpoker_list = self._view:GetChild("otherpoker_list") local card_info = self._player_card_info[self:GetPos(self._room.self_player.seat)] @@ -959,33 +963,45 @@ function M:EventInit() head_info._view:GetChild('text_jifen').text = player.score -- head_info:PlayScore(player.winscore, win_seat == player.seat) head_info:PlayScore(player.card_score, win_seat == player.seat) + head_info:SetBaseScore() end - for i = 1, #info do - local player = info[i] - local p = self._room:GetPlayerBySeat(player.seat) - local head_info = self._player_info[self:GetPos(player.seat)] - local card_info = self._player_card_info[self:GetPos(player.seat)] - - if player.seat ~= win_seat then - card_info.ctr_outpoker.selectedIndex = 0 - end - if player.seat ~= self._room.self_player.seat then - local oneTime = 7 / 60 - - -- card_info:UpdateHandPoker(player.cards, false, true) - - card_info._view_resultOut:RemoveChildrenToPool() - card_info._ctr_resultOut.selectedIndex = 1 - for i = 1, #player.handCards do - local child_card = card_info._view_resultOut:AddItemFromPool() - card_info:FillPoker(child_card, "", nil, player.handCards[i]) - ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/fanCard.mp3") - printlog("lingmeng oneTime", oneTime) - coroutine.wait(oneTime) - end + --展示底牌 + if #dipais > 0 then + for i, v in ipairs(dipais) do + local card = self._view:GetChild('list_dipais'):AddItemFromPool() + card:GetChild("icon").url = string.format("ui://Main_Poker/%s", v) + coroutine.wait(0.1) end + coroutine.wait(1) end + + + -- for i = 1, #info do + -- local player = info[i] + -- local p = self._room:GetPlayerBySeat(player.seat) + -- local head_info = self._player_info[self:GetPos(player.seat)] + -- local card_info = self._player_card_info[self:GetPos(player.seat)] + + -- if player.seat ~= win_seat then + -- card_info.ctr_outpoker.selectedIndex = 0 + -- end + -- if player.seat ~= self._room.self_player.seat then + -- local oneTime = 7 / 60 + + -- -- card_info:UpdateHandPoker(player.cards, false, true) + + -- card_info._view_resultOut:RemoveChildrenToPool() + -- card_info._ctr_resultOut.selectedIndex = 1 + -- for i = 1, #player.handCards do + -- local child_card = card_info._view_resultOut:AddItemFromPool() + -- card_info:FillPoker(child_card, "", nil, player.handCards[i]) + -- ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/fanCard.mp3") + -- printlog("lingmeng oneTime", oneTime) + -- coroutine.wait(oneTime) + -- end + -- end + -- end self:ChangeBgmMusic(1) -- if over == 0 then -- if #self:GetSpringSeats(info) > 0 then @@ -1111,6 +1127,29 @@ function M:EventInit() info._ctr_offline.selectedIndex = p.line_state == 0 and 1 or 0 end ) + + _gamectr:AddEventListener( + EXGameEvent.OnGetBaseScore, + function(...) + local arg = { ... } + local data = arg[1] + self._view:GetChild('text_baseScore').text = 0 + local index = self:GetPos(data.seat) + local head_info = self._player_info[index] + head_info:SetBaseScore(data.score) + end + ) + + _gamectr:AddEventListener( + EXGameEvent.OnShowRank, + function(...) + local arg = { ... } + local data = arg[1] + local index = self:GetPos(data.player) + local head_info = self._player_info[index] + head_info._ctr_rank.selectedIndex = data.ranking + end + ) end function M:ReConnectForStart() @@ -1118,6 +1157,7 @@ function M:ReConnectForStart() self._room.is_new_bout = _gamectr:GetIsNewBout(self._room.curren_turn_seat) self._state.selectedIndex = 1 self._view:GetController("time").selectedIndex = self:GetPos(self._room.curren_turn_seat) + self._view:GetChild('text_baseScore').text = self._room.poolScore for _, player in ipairs(self._room.player_list) do local player_card_info = self._player_card_info[self:GetPos(player.seat)] @@ -1125,10 +1165,12 @@ function M:ReConnectForStart() head_info:Ready(false) head_info:UpdateScore(player.total_score) + head_info:SetBaseScore(player.roundCardScore) head_info:UpdateLineState(player.line_state) head_info:UpdatePiao(player.piao) head_info:SetBaoDan(player.hand_count == 1) head_info:MarkBank(player.seat == self._room.banker_seat) + head_info._ctr_rank.selectedIndex = player.ranking if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then -- body @@ -1173,7 +1215,7 @@ function M:ReConnectForStart() player_card_info:SetOutCardInfo(nil, false) if player.seat == self._room.self_player.seat then local lastCardList = self._gamectr:GetLastCardList(self._room.self_player.seat) - player_card_info:ShowOutCardOption2(lastCardList, 1) + player_card_info:ShowOutCardOption2(lastCardList, self._room.is_new_bout and 2 or 1) end else -- head_info:MarkBank(true) @@ -1192,7 +1234,7 @@ function M:ReconnectForClearing() --如果是体力值不可负分模式 则显示当前的hp值 if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then head_info:UpdateScore(d2ad(player.hp_info.cur_hp)) - head_info._view:GetChild('zhanji').visible = true + -- head_info._view:GetChild('zhanji').visible = true local num = player.hp_info.total_hp if num > 0 then head_info._view:GetController('text_color').selectedIndex = 0 @@ -1231,7 +1273,7 @@ function M:ReconnectForClearing() if player.seat == self._room.self_player.seat then - player_card_info:InitPoker(player.hand_list, false) + -- player_card_info:InitPoker(player.hand_list, false) else -- player_card_info:UpdateHandPoker(player.hand_list, false, true) end @@ -1250,7 +1292,7 @@ function M:ReconnectForClearing() coroutine.start(function() coroutine.wait(0.3) - self.result_view = EXResultView.new(self, self._room.player_list, 0, win_seat) + self.result_view = EXResultView.new(self, self._room.player_list, 0, win_seat) self.result_view:SetDestroryCallback(function() for i = 1, #self._player_card_info do local card_info = self._player_card_info[i] @@ -1416,15 +1458,15 @@ function M:UpdateRound(round) self._text_maxRound.text = string.format("/%s局", total_round) end --- function M:InitPlayerInfoView() --- self._player_info = {} --- local _player_info = self._player_info --- for i = 1, self._room.room_config.people_num do --- local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1)) --- _player_info[i] = PlayerInfoView.new(tem, self) --- tem.visible = false --- end --- end +function M:InitPlayerInfoView() + self._player_info = {} + local _player_info = self._player_info + for i = 1, self._room.room_config.people_num do + local tem = self._view:GetChild('player_info' .. i) + _player_info[i] = PlayerInfoView.new(tem, self) + tem.visible = false + end +end -- function M:GetSoundFileName(type, num, isNewBout) -- local fileName diff --git a/lua_probject/extend_project/extend/poker/duoduo/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/poker/duoduo/EXPlayerInfoView.lua index a186cc02..8ef4d7f4 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/EXPlayerInfoView.lua @@ -17,6 +17,8 @@ function M:init(flag_witness) --互动表情的父类 self._hudon = self._view:GetChild('comp_hudon') PlayerInfoView.init(self, flag_witness) + + self._ctr_rank = self._view:GetController('rank') end function M:FillData(player) @@ -67,4 +69,9 @@ function M:UpdatePiao(piao) end end +function M:SetBaseScore(score) + local score = score or 0 + self._view:GetChild('text_paijufen').text = score +end + return M diff --git a/lua_probject/extend_project/extend/poker/duoduo/EXPlayerPokerInfoView.lua b/lua_probject/extend_project/extend/poker/duoduo/EXPlayerPokerInfoView.lua index 27f00d64..63f25e4d 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/EXPlayerPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/EXPlayerPokerInfoView.lua @@ -175,23 +175,28 @@ function M:SetOutCardInfo(cardlist, isPass, isAnim) -- ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/chupai.mp3") -- end) -- else - local showOneCard + local zhaNum = 0 + local zhaMapFlower = { 0, 0, 0, 0 } + local zhaMapCode = { 0, 0 } for i = 1, #cardlist do - if cardlist[i] % 100 < 3 then - local poker_item = self._view_Out:AddItemFromPool() - self:FillPoker2(poker_item, cardlist[i]) + local poker_item = self._view_Out:AddItemFromPool() + self:FillPokerOut(poker_item, cardlist[i]) + local flower = math.floor(cardlist[i] / 100) + local code = cardlist[i] % 100 + if code >= 3 then + if zhaMapFlower[flower] == 3 then + zhaNum = zhaNum + 1 + end + zhaMapFlower[flower] = zhaMapFlower[flower] + 1 else - showOneCard = cardlist[i] + if zhaMapCode[code] == 3 then + zhaNum = zhaNum + 1 + end + zhaMapCode[code] = zhaMapCode[code] + 1 end end - if showOneCard then - local poker_item = self._view_Out:AddItemFromPool() + self._view:GetChild('text_paiNum').text = string.format("X%s", #cardlist + zhaNum * 3) - self:FillPoker2(poker_item, showOneCard) - -- self._view:GetChild('text_paiNum').text = string.format("X%s", #cardlist) - else - printlog("error 190", "除了鬼牌没有其他牌") - end self._view_Out:ResizeToFit(self._view_Out.numItems) -- end end @@ -470,6 +475,16 @@ function M:FillPoker(poker, prefix, num, code) end function M:FillPoker2(poker, code, suffix) + suffix = suffix or "" + code = code == 1 and "00" or code + if not poker.icon then + poker:GetChild('icon').url = string.format("ui://Extend_Poker_DuoDuo/%s%s", code, suffix) + else + poker.icon = string.format("ui://Extend_Poker_DuoDuo/%s%s", code, suffix) + end +end + +function M:FillPokerOut(poker, code, suffix) suffix = suffix or "" code = code == 1 and "00" or code if not poker.icon then @@ -480,21 +495,21 @@ function M:FillPoker2(poker, code, suffix) end function M:CreatPoker1(poker, scale, bank) - local poker_item = UIPackage.CreateObject("Main_Poker", "poker" .. scale * 10) + local poker_item = UIPackage.CreateObject("Extend_Poker_DuoDuo", "poker" .. scale * 10) local code = self:ChangeCodeByTo(poker) local card_code_obj if DataManager.CurrenRoom.pai == 0 then if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code .. "_1") else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code) end else if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code .. "_2") else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") end @@ -510,20 +525,20 @@ function M:CreatPoker1(poker, scale, bank) end function M:CreatPoker(poker, scale, bank) - local poker_item = UIPackage.CreateObject("Main_Poker", "poker" .. 12.5) + local poker_item = UIPackage.CreateObject("Extend_Poker_DuoDuo", "poker" .. 12.5) local code = self:ChangeCodeByTo(poker) local card_code_obj if DataManager.CurrenRoom.pai == 0 then if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code .. "_1") else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code) end else if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code .. "_2") else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") end diff --git a/lua_probject/extend_project/extend/poker/duoduo/EXPlayerPokerInfoView_tuo.lua b/lua_probject/extend_project/extend/poker/duoduo/EXPlayerPokerInfoView_qi.lua similarity index 94% rename from lua_probject/extend_project/extend/poker/duoduo/EXPlayerPokerInfoView_tuo.lua rename to lua_probject/extend_project/extend/poker/duoduo/EXPlayerPokerInfoView_qi.lua index c288d906..c4401146 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/EXPlayerPokerInfoView_tuo.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/EXPlayerPokerInfoView_qi.lua @@ -175,25 +175,16 @@ function M:SetOutCardInfo(cardlist, isPass, isAnim) -- ViewUtil.PlaySound("DuoDuo_PK", "extend/poker/duoduo/sound/chupai.mp3") -- end) -- else - local showOneCard for i = 1, #cardlist do - if cardlist[i] % 100 < 3 then - local poker_item = self._view_Out:AddItemFromPool() - self:FillPoker2(poker_item, cardlist[i]) - else - showOneCard = cardlist[i] - end - end - if showOneCard then local poker_item = self._view_Out:AddItemFromPool() - - self:FillPoker2(poker_item, showOneCard) - self._view:GetChild('text_paiNum').text = string.format("X%s", #cardlist) - else - printlog("error 190", "除了鬼牌没有其他牌") + self:FillPoker2(poker_item, cardlist[i]) end - self._view_Out:ResizeToFit(self._view_Out.numItems) - -- end + if #cardlist >= 8 then + self._view_Out.width = 432 + else + self._view_Out.width = 136 + 42*(#cardlist-1) + end + self._view:GetChild('text_paiNum').text = string.format("X%s", #cardlist) end end @@ -473,28 +464,28 @@ function M:FillPoker2(poker, code, suffix) suffix = suffix or "" code = code == 1 and "00" or code if not poker.icon then - poker:GetChild('icon').url = string.format("ui://Extend_Poker_DuoDuo/%s%s", code, suffix) + poker:GetChild('icon').url = string.format("ui://Main_Poker/%s%s", code, suffix) else - poker.icon = string.format("ui://Extend_Poker_DuoDuo/%s%s", code, suffix) + poker.icon = string.format("ui://Main_Poker/%s%s", code, suffix) end end function M:CreatPoker1(poker, scale, bank) - local poker_item = UIPackage.CreateObject("Extend_Poker_DuoDuo", "poker" .. scale * 10) + local poker_item = UIPackage.CreateObject("Main_Poker", "poker" .. scale * 10) local code = self:ChangeCodeByTo(poker) local card_code_obj if DataManager.CurrenRoom.pai == 0 then if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code .. "_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_1") else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code) end else if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") end @@ -510,20 +501,20 @@ function M:CreatPoker1(poker, scale, bank) end function M:CreatPoker(poker, scale, bank) - local poker_item = UIPackage.CreateObject("Extend_Poker_DuoDuo", "poker" .. 12.5) + local poker_item = UIPackage.CreateObject("Main_Poker", "poker" .. 12.5) local code = self:ChangeCodeByTo(poker) local card_code_obj if DataManager.CurrenRoom.pai == 0 then if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code .. "_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_1") else - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code) end else if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_DuoDuo/" .. code .. "_2") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") end diff --git a/lua_probject/extend_project/extend/poker/duoduo/EXPlayerSelfPokerInfoView.lua b/lua_probject/extend_project/extend/poker/duoduo/EXPlayerSelfPokerInfoView.lua index 3f75e32a..c1fb4906 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/EXPlayerSelfPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/EXPlayerSelfPokerInfoView.lua @@ -74,6 +74,7 @@ function M:init() self.text_bomb_score = self._view:GetChild('Score') self.ani_bomb_score = self._view:GetTransition('score') self.ani_result_score = self._view:GetTransition('score_1') + -- self._viewList_move = self._view:GetChild('list_moveCards') self.send_card = {} self.tips_click_count = 0 @@ -97,12 +98,15 @@ function M:InitPoker(pokerList, isPlayAni, open) end -- -- print(vardump(self.card_list)) self.cor_init_poker = nil - self.card_list = {} - self._ctr_canSendCard.selectedIndex = 0 + self.card_list = {} + self.newCard_list = {} + self._SendCards = {} + -- self._ctr_canSendCard.selectedIndex = 0 self._flag_ruleCard = false self._view_handCard:RemoveChildren(0, -1, true) - self.scaleW = (GRoot.inst.width * 0.86 - self._view_handCard.columnGap * 26) / 27 - self.scaleH = self.scaleW * 1.4 + self.scaleW = (GRoot.inst.width * 0.85 - self._view_handCard.columnGap * 14) / 15 + -- self._viewList_move.width = self.scaleW + self.scaleH = self.scaleW * 1.3 if isPlayAni == true then self.cor_init_poker = coroutine.start( @@ -172,25 +176,13 @@ function M:InitPoker(pokerList, isPlayAni, open) ) else for i = #pokerList, 1, -1 do - local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) - local card_flower_code = pokerList[i] - local btn_card = self._view_handCard:AddItemFromPool() - self:FillPoker(btn_card, "", card_number_code) - local card_view = NewCardView(btn_card, card_number_code, card_flower_code) - self.card_list[#self.card_list + 1] = card_view - btn_card.data = card_view - btn_card.width = self.scaleW - btn_card.height = self.scaleH - end - table.sort(self.card_list, tableSortNumber) - self:AddTouchMoveEvent(self._view_handCard) - for i = 1, #self.card_list do - local card = self.card_list[i] - if open ~= 1 then - -- body - self:AddCardTouchEvent(card) + if not self.newCard_list[pokerList[i] % 100] then + self.newCard_list[pokerList[i] % 100] = {} end + self.newCard_list[pokerList[i] % 100][math.floor(pokerList[i] / 100)] = (self.newCard_list[pokerList[i] % 100][math.floor(pokerList[i] / 100)] or 0) + + 1 end + self:UpdateHandCardsPos() end end @@ -205,23 +197,18 @@ end function M:AddTouchMoveEvent(list) local send_card = {} - list.onTouchBegin:Set( - function(context) - self.send_card = {} - if list.touchable == false then - return - end - local fristCard = self._view_handCard:GetChildAt(0) - local CardWidth = fristCard.width - local columnGap = self._view_handCard.columnGap - local oneCardWidth = CardWidth - columnGap - local xy = fristCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - -- if xy.y > -21 and xy.y < 316 then - self.touchBegin = xy - Stage.inst.onTouchMove:Add(self.touchMoveFun) - Stage.inst.onTouchEnd:Add(self.touchMoveEndFun) - end - ) + -- list.onTouchBegin:Set( + -- function(context) + -- self.send_card = {} + -- if list.touchable == false then + -- return + -- end + -- local xy = self._view_handCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + -- self.touchBegin = xy + -- Stage.inst.onTouchMove:Add(self.touchMoveFun) + -- Stage.inst.onTouchEnd:Add(self.touchMoveEndFun) + -- end + -- ) end function M:AddCardTouchEvent(card) @@ -230,7 +217,45 @@ function M:AddCardTouchEvent(card) if card.btn_card.touchable == false then return end - self:SetBtnCardColor(card, 1) + if card.card_code_flower % 100 < 3 then + local cindex = card.btn_card:GetController('choose').selectedIndex + if cindex == 1 then + self:SetBtnCardColor(card, 0) + if self._SendCards and #self._SendCards > 0 then + for k, v in pairs(self._SendCards) do + if card.card_code_flower % 100 == v.card_code_flower%100 then + table.remove(self._SendCards, k) + return + end + end + end + else + self:SetBtnCardColor(card, 1) + table.insert(self._SendCards, card) + end + else + if self._SendCards and #self._SendCards > 0 then + local tmp = {} + for k, v in pairs(self._SendCards) do + if v.card_code_flower % 100 ~= card.card_code_flower % 100 and (card.card_code_flower % 100 < 3 or v.card_code_flower % 100 < 3) then + table.insert(tmp, v) + else + self:SetBtnCardColor(v, 0) + end + end + self._SendCards = tmp + end + local cardList = card.fatherList + local touchIndex = cardList:GetChildIndex(card.btn_card) + self.touchCard = card + self.touchIndex = touchIndex + for i = 0, touchIndex do + local oncard = cardList:GetChildAt(i) + self:SetBtnCardColor(oncard.data, 1) + end + Stage.inst.onTouchMove:Add(self.touchMoveFun) + Stage.inst.onTouchEnd:Add(self.touchMoveEndFun) + end end ) end @@ -270,120 +295,37 @@ function M:TouchMoving(context) if self._view_handCard == nil then return end - local send_card1 = {} - local fristCard = self._view_handCard:GetChildAt(0) - local CardWidth = fristCard.width - local columnGap = self._view_handCard.columnGap - local oneCardWidth = CardWidth + columnGap - local xy = fristCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - self.isTouching = true - local max_x - local min_x - if xy.x - self.touchBegin.x > 0 then -- 往右边滑 - max_x = xy.x - min_x = self.touchBegin.x - -- elseif xy.x - self.touchBegin.x < 0 then -- 左边滑 - else - max_x = self.touchBegin.x - min_x = xy.x - end + local fatherList = self.touchCard.fatherList + local xy = fatherList:GetChildAt(0):GlobalToLocal(Vector2.New(context.inputEvent.x, + context.inputEvent.y)) - for i = 1, self._view_handCard.numItems do - local card = self._view_handCard:GetChildAt(i - 1).data - if card.btn_card.touchable == false or card.card_isTouchable == 1 then - else - if - (card.btn_card.x + oneCardWidth > min_x or (i == #self.card_list and card.btn_card.x + CardWidth > min_x)) - and card.btn_card.x < max_x - then - self:SetBtnCardColor(card, 1) - if #send_card1 == 0 then - send_card1[1] = card - end - if send_card1[#send_card1] ~= card then - send_card1[#send_card1 + 1] = card - end - else - self:SetBtnCardColor(card, 0) - end - end + for i = 0, fatherList.numItems - 1 do + local cardOne = fatherList:GetChildAt(i) + self:SetBtnCardColor(cardOne.data, xy.y > cardOne.y and 1 or 0) end - self.send_card = send_card1 end function M:TouchMoveEnd(context) - local send_card = {} - local currentCard = {} - local xuan_card = {} + local linexy = self._view_handCard:GlobalToLocal(Vector2.New(context.inputEvent.x, + context.inputEvent.y)) - local fristCard = self._view_handCard:GetChildAt(0) - local CardWidth = fristCard.width - local columnGap = self._view_handCard.columnGap - local oneCardWidth = CardWidth + columnGap - local xy = fristCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - local downCards = #self.card_list + local fatherList = self.touchCard.fatherList + local xy = fatherList:GetChildAt(0):GlobalToLocal(Vector2.New(context.inputEvent.x, + context.inputEvent.y)) + + for i = 0, fatherList.numItems - 1 do + local cardOne = fatherList:GetChildAt(i) + if xy.y > cardOne.y then + table.insert(self._SendCards, cardOne.data) + end + end + -- for i = 0, self.touchIndex do + -- local oncard = self.touchCard.fatherList:GetChildAt(i) + -- self:SetBtnCardColor(oncard.data, 0) + -- oncard.xy = Vector2.New(0, (self.scaleH + self.linegap) * i) + -- end Stage.inst.onTouchMove:Remove(self.touchMoveFun) Stage.inst.onTouchEnd:Remove(self.touchMoveEndFun) - - local max_x - local min_x - if xy.x - self.touchBegin.x > 0 then - max_x = xy.x - min_x = self.touchBegin.x - else - max_x = self.touchBegin.x - min_x = xy.x - end - - for k = 1, self._view_handCard.numItems do - local card = self._view_handCard:GetChildAt(k - 1).data - table.insert(currentCard, card.card_code_flower) - if not card.btn_card.selected then - downCards = downCards - 1 - end - if card.btn_card.touchable == false or card.card_isTouchable == 1 then - else - self:SetBtnCardColor(card, 0) - if - (card.btn_card.x + oneCardWidth > min_x or (k == #self.card_list and card.btn_card.x + CardWidth > min_x)) - and card.btn_card.x < max_x - then - self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - if card.btn_card.selected then - send_card[#send_card + 1] = card - end - --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") - else - if card.btn_card.selected then - send_card[#send_card + 1] = card - end - end - end - end - - -- ViewUtil.PlaySound('RunFastNew_PK', 'extend/poker/runfast/sound/click.mp3') - - Stage.inst:ResetInputState() - - if downCards == 0 then - xuan_card = self:zhizhanxuanpai() - end - - if #send_card > 0 then - table.sort(send_card, tableSortNumber) - send_card = #xuan_card > 0 and xuan_card or send_card - self._cardCheck:initCards(send_card, - { - flag = #xuan_card > 0, - flag_allCards = #send_card == self._view_handCard.numItems, - flag_ruleCard = self - ._flag_ruleCard - }) - - self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 - else - self._ctr_canSendCard.selectedIndex = 0 - end end -- function M:SetBtnCardColor(card, num) @@ -450,7 +392,7 @@ function M:ShowOutCardOption(ctr_select, type, number, length, mustPutMaxCard, p self.tips_click_count = 0 self.send_card = {} self.tips_card_list = self:GetCardTips(type, number, length, mustPutMaxCard) - self._ctr_canSendCard.selectedIndex = 0 + -- self._ctr_canSendCard.selectedIndex = 0 if #self.tips_card_list >= 1 then -- body --在这个方法里添加判断抬起牌是否符合出牌类型(少跑一次手牌循环) @@ -511,7 +453,7 @@ function M:SetOutCardInfo(cardlist, isPass, isAnim) for i = 1, #cardlist do local poker_item = self._view_Out:AddItemFromPool() - self:FillPoker2(poker_item, cardlist[i]) + self:FillPokerOut(poker_item, cardlist[i]) end -- end end @@ -651,27 +593,73 @@ end function M:DeleteHandCards(cardlist) self.ctr_put_card_option.selectedIndex = 0 for i = 1, #cardlist do - local card_code_number = cardlist[i] - for j = 1, #self.card_list do - local card = self.card_list[j] - if card_code_number == card.card_code_number then - list_remove(self.card_list, card) - self._view_handCard:RemoveChild(card.btn_card, true) - break + local tmpNum = nil + if self.newCard_list[cardlist[i] % 100] then + tmpNum = self.newCard_list[cardlist[i] % 100][math.floor(cardlist[i] / 100)] + end + if tmpNum then + if tmpNum == 1 then + self.newCard_list[cardlist[i] % 100][math.floor(cardlist[i] / 100)] = nil + else + self.newCard_list[cardlist[i] % 100][math.floor(cardlist[i] / 100)] = tmpNum - 1 + end + else + ViewUtil:ErrorTip("牌型出错,重新加载页面") + ViewManager.refreshGameView() + end + if i == #cardlist then + if #self.newCard_list[cardlist[i] % 100] == 0 then + self.newCard_list[cardlist[i] % 100] = nil end end end - self._view_handCard:ResizeToFit(self._view_handCard.numItems) self:UpdateHandCardsPos() end function M:UpdateHandCardsPos() - for i = 1, #self.card_list do - local card_view = self.card_list[i] - card_view.index = i - card_view.btn_card.touchable = true - self:UpdateCardMove(card_view.btn_card, false, false) - self:SetBtnCardColor(card_view, 0) + local maxHeight = 0 + self._view_handCard:RemoveChildrenToPool() + local sortTable = {} + for k, v in pairs(self.newCard_list) do + local btn_cardListFather = self._view_handCard:GetFromPool('') + btn_cardListFather.width = self.scaleW + local btn_cardList = btn_cardListFather:GetChild('list') + btn_cardList:RemoveChildrenToPool() + self.linegap = btn_cardList.lineGap + local tmpHeight = 0 + local noZhaIndex = 0 + local allCardNum = 0 + for k1, v1 in pairs(v) do + local card_number_code = k * 10 + k1 + local card_flower_code = k1 * 100 + k + for i = 1, v1 do + local btn_card = btn_cardList:GetFromPool('') + btn_cardList:AddChildAt(btn_card, noZhaIndex) + noZhaIndex = noZhaIndex + 1 + allCardNum = allCardNum + 1 + btn_card.height = self.scaleH + self:FillPoker2(btn_card, card_flower_code) + local card_view = NewCardView(btn_card, card_number_code, card_flower_code) + card_view.fatherList = btn_cardList + self.card_list[#self.card_list + 1] = card_view + btn_card.data = card_view + tmpHeight = tmpHeight + 1 + self:AddCardTouchEvent(card_view) + end + end + local index = ViewUtil.BinarySearch(sortTable, allCardNum, 1) + self._view_handCard:AddChildAt(btn_cardListFather, index - 1) + table.insert(sortTable, index, allCardNum) + if tmpHeight > maxHeight then + maxHeight = tmpHeight + end + end + if #self.newCard_list > 0 then + self._view:GetChild('btn_back').y = math.min(self._view_handCard.height - + (self.scaleH + (self.scaleH + self.linegap) * (maxHeight - 1)) - 30, 100) + self._view_Out.y = math.min(self._view_handCard.height - + (self.scaleH + (self.scaleH + self.linegap) * (maxHeight - 1)) - self._view_Out.height + self.scaleH * 0.3, + 50) end end @@ -716,9 +704,9 @@ function M:UpdateHandCardsColor() if #send_card > 0 then table.sort(send_card, tableSortNumber) self._cardCheck:initCards(send_card, { flag = false, flag_allCards = #send_card == self._view_handCard.numItems }) - self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 + -- self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 else - self._ctr_canSendCard.selectedIndex = 0 + -- self._ctr_canSendCard.selectedIndex = 0 end end @@ -726,32 +714,37 @@ function M:BtnEvent() self.btn_not_put = self._view:GetChild('btn_not_put') self.btn_tips = self._view:GetChild('Btn_Tip') -- 覆盖 self.btn_sendCards = self._view:GetChild('Btn_SendCard') - self._ctr_canSendCard = self.btn_sendCards:GetController('can') + -- self._ctr_canSendCard = self.btn_sendCards:GetController('can') self.btn_sendCards.onClick:Set( function() if self.Reset then return end - if self._ctr_canSendCard.selectedIndex == 0 then - return - end - local send_card = {} - self.send_card = {} - local currentCard = {} - for i = 1, #self.card_list do - local card = self.card_list[i] - table.insert(currentCard, card.card_code_flower) - if card.btn_card.selected then - send_card[#send_card + 1] = card.card_code_flower - self.send_card[#self.send_card + 1] = card + -- if self._ctr_canSendCard.selectedIndex == 0 then + -- return + -- end + local allcards = {} + for k, v in pairs(self.newCard_list) do + for k1, v1 in pairs(v) do + if v1 > 0 then + for i = 1, v1 do + local card_flower_code = k1 * 100 + k + table.insert(allcards, card_flower_code) + end + end end end - - if #send_card == 0 then + local SendCard = {} + for i, v in ipairs(self._SendCards) do + table.insert(SendCard, v.card_code_flower) + self:SetBtnCardColor(v, 0) + end + self._SendCards = {} + if #SendCard == 0 then self:ErrorTip('请选择要出的牌') else - self.gameCtr:SendCard(send_card, currentCard) + self.gameCtr:SendCard(SendCard, allcards) end end ) @@ -816,7 +809,7 @@ function M:ShowTipsCard(index) end pt(item) self._cardCheck:initCards(item) - self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 + -- self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 end function M:GetHandCardOffset(count) diff --git a/lua_probject/extend_project/extend/poker/duoduo/EXPlayerSelfPokerInfoView_tuo.lua b/lua_probject/extend_project/extend/poker/duoduo/EXPlayerSelfPokerInfoView_qi.lua similarity index 83% rename from lua_probject/extend_project/extend/poker/duoduo/EXPlayerSelfPokerInfoView_tuo.lua rename to lua_probject/extend_project/extend/poker/duoduo/EXPlayerSelfPokerInfoView_qi.lua index b1d370e0..1327a9f9 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/EXPlayerSelfPokerInfoView_tuo.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/EXPlayerSelfPokerInfoView_qi.lua @@ -74,7 +74,6 @@ function M:init() self.text_bomb_score = self._view:GetChild('Score') self.ani_bomb_score = self._view:GetTransition('score') self.ani_result_score = self._view:GetTransition('score_1') - self._viewList_move = self._view:GetChild('list_moveCards') self.send_card = {} self.tips_click_count = 0 @@ -96,16 +95,31 @@ function M:InitPoker(pokerList, isPlayAni, open) if self.cor_init_poker ~= nil then coroutine.stop(self.cor_init_poker) end + table.sort(pokerList, function(a, b) + local num_a = a % 100 + local num_b = b % 100 + local code_a = math.floor(a / 100) + local code_b = math.floor(b / 100) + if num_a < 3 then + num_a = num_a + 100 + end + if num_b < 3 then + num_b = num_b + 100 + end + if num_a == num_b then + return code_a < code_b + else + return num_a= self._view_handCard.height - lastCard.height then + self.chooseY = lastCard.y + end + Stage.inst.onTouchMove:Add(self.touchMoveFun) + Stage.inst.onTouchEnd:Add(self.touchMoveEndFun) + end + ) end function M:AddCardTouchEvent(card) @@ -216,32 +253,7 @@ function M:AddCardTouchEvent(card) if card.btn_card.touchable == false then return end - local cardList = card.fatherList - local touchIndex = cardList:GetChildIndex(card.btn_card) - self._SendCards = {} - self.touchCard = card - self.touchIndex = touchIndex - local copy_list = self._viewList_move:GetChild('list') - for i = 0, touchIndex do - local oncard = cardList:GetChildAt(i) - self:SetBtnCardColor(oncard.data, 1) - --复制一份列表作为移动对象 - local copy_card = copy_list:AddItemFromPool() - self:FillPoker2(copy_card, oncard.data.card_code_flower) - copy_card.height = self.scaleH - if oncard.data.zha then - for j = 1, 4 do - table.insert(self._SendCards, oncard.data.card_code_flower) - end - else - table.insert(self._SendCards, oncard.data.card_code_flower) - end - end - local xy = self.touchCard.fatherList:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - self._viewList_move.xy = self._view:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - Vector2.New(self.scaleW/2,self.scaleH + (self.scaleH + self.linegap)*(copy_list.numItems-1) + self.linegap) - self.touchBegin = xy - self._viewList_move.xy - Stage.inst.onTouchMove:Add(self.touchMoveFun) - Stage.inst.onTouchEnd:Add(self.touchMoveEndFun) + self:SetBtnCardColor(card, 1) end ) end @@ -282,61 +294,121 @@ function M:TouchMoving(context) return end local send_card1 = {} - local xy = self.touchCard.fatherList:GlobalToLocal(Vector2.New(context.inputEvent.x, - context.inputEvent.y)) - self._viewList_move.xy = xy - self.touchBegin + local fristCard = self._view_handCard:GetChildAt(0) + local CardWidth = fristCard.width + local columnGap = self._view_handCard.columnGap + local oneCardWidth = CardWidth + columnGap + local xy = fristCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + self.isTouching = true + local max_x + local min_x + if xy.x - self.touchBegin.x > 0 then -- 往右边滑 + max_x = xy.x + min_x = self.touchBegin.x + -- elseif xy.x - self.touchBegin.x < 0 then -- 左边滑 + else + max_x = self.touchBegin.x + min_x = xy.x + end + + + + for i = 1, self._view_handCard.numItems do + local card = self._view_handCard:GetChildAt(i - 1).data + if card.btn_card.touchable == false or card.card_isTouchable == 1 then + else + if + (card.btn_card.x + oneCardWidth > min_x or (i == #self.card_list and card.btn_card.x + CardWidth > min_x)) + and card.btn_card.x < max_x and self.chooseY == card.btn_card.y + then + self:SetBtnCardColor(card, 1) + if #send_card1 == 0 then + send_card1[1] = card + end + if send_card1[#send_card1] ~= card then + send_card1[#send_card1 + 1] = card + end + else + self:SetBtnCardColor(card, 0) + end + end + end + self.send_card = send_card1 end function M:TouchMoveEnd(context) - local linexy = self._view_handCard:GlobalToLocal(Vector2.New(context.inputEvent.x, - context.inputEvent.y)) + local send_card = {} + local currentCard = {} + local xuan_card = {} - if self.ctr_put_card_option.selectedIndex > 0 then - local allcards = {} - for k, v in pairs(self.newCard_list) do - for k1, v1 in pairs(v) do - if v1 > 0 then - for i = 1, v1 do - local card_flower_code = k1 * 100 + k - table.insert(allcards, card_flower_code) - end - end - end - end - if linexy.y < self._view:GetChild('n82').y then - self.gameCtr:SendCard(self._SendCards, allcards) - else - if self.touchCard.card_code_flower % 100 < 3 then - for i = self._view_handCard.numItems - 1, 0, -1 do - local oneCardList = self._view_handCard:GetChildAt(i):GetChild('list') - local listxy = oneCardList:GlobalToLocal(Vector2.New(context.inputEvent.x, - context.inputEvent.y)) - if listxy.x > 0 and oneCardList:GetChildAt(0).data.card_code_flower % 100 > 2 then - for i = 0, oneCardList.numItems - 1 do - local oncard = oneCardList:GetChildAt(i) - if oncard.data.zha then - for j = 1, 4 do - table.insert(self._SendCards, oncard.data.card_code_flower) - end - else - table.insert(self._SendCards, oncard.data.card_code_flower) - end - end - self.gameCtr:SendCard(self._SendCards, allcards) - break - end - end - end - end - end - self._viewList_move:GetChild('list'):RemoveChildrenToPool() - for i = 0, self.touchIndex do - local oncard = self.touchCard.fatherList:GetChildAt(i) - self:SetBtnCardColor(oncard.data, 0) - oncard.xy = Vector2.New(0, (self.scaleH + self.linegap) * i) - end + local fristCard = self._view_handCard:GetChildAt(0) + local CardWidth = fristCard.width + local columnGap = self._view_handCard.columnGap + local oneCardWidth = CardWidth + columnGap + local xy = fristCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + local downCards = #self.card_list Stage.inst.onTouchMove:Remove(self.touchMoveFun) Stage.inst.onTouchEnd:Remove(self.touchMoveEndFun) + + local max_x + local min_x + if xy.x - self.touchBegin.x > 0 then + max_x = xy.x + min_x = self.touchBegin.x + else + max_x = self.touchBegin.x + min_x = xy.x + end + + for k = 1, self._view_handCard.numItems do + local card = self._view_handCard:GetChildAt(k - 1).data + table.insert(currentCard, card.card_code_flower) + if not card.btn_card.selected then + downCards = downCards - 1 + end + if card.btn_card.touchable == false or card.card_isTouchable == 1 then + else + self:SetBtnCardColor(card, 0) + if + (card.btn_card.x + oneCardWidth > min_x or (k == #self.card_list and card.btn_card.x + CardWidth > min_x)) + and card.btn_card.x < max_x and self.chooseY == card.btn_card.y + then + self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) + if card.btn_card.selected then + send_card[#send_card + 1] = card + end + --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") + else + if card.btn_card.selected then + send_card[#send_card + 1] = card + end + end + end + end + + -- ViewUtil.PlaySound('RunFastNew_PK', 'extend/poker/runfast/sound/click.mp3') + + Stage.inst:ResetInputState() + + -- if downCards == 0 then + -- xuan_card = self:zhizhanxuanpai() + -- end + + -- if #send_card > 0 then + -- table.sort(send_card, tableSortNumber) + -- send_card = #xuan_card > 0 and xuan_card or send_card + -- self._cardCheck:initCards(send_card, + -- { + -- flag = #xuan_card > 0, + -- flag_allCards = #send_card == self._view_handCard.numItems, + -- flag_ruleCard = self + -- ._flag_ruleCard + -- }) + + -- self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 + -- else + -- self._ctr_canSendCard.selectedIndex = 0 + -- end end -- function M:SetBtnCardColor(card, num) @@ -403,7 +475,7 @@ function M:ShowOutCardOption(ctr_select, type, number, length, mustPutMaxCard, p self.tips_click_count = 0 self.send_card = {} self.tips_card_list = self:GetCardTips(type, number, length, mustPutMaxCard) - self._ctr_canSendCard.selectedIndex = 0 + -- self._ctr_canSendCard.selectedIndex = 0 if #self.tips_card_list >= 1 then -- body --在这个方法里添加判断抬起牌是否符合出牌类型(少跑一次手牌循环) @@ -604,83 +676,28 @@ end function M:DeleteHandCards(cardlist) self.ctr_put_card_option.selectedIndex = 0 for i = 1, #cardlist do - local tmpNum = nil - if self.newCard_list[cardlist[i] % 100] then - tmpNum = self.newCard_list[cardlist[i] % 100][math.floor(cardlist[i] / 100)] - end - if tmpNum then - if tmpNum == 1 then - self.newCard_list[cardlist[i] % 100][math.floor(cardlist[i] / 100)] = nil - else - self.newCard_list[cardlist[i] % 100][math.floor(cardlist[i] / 100)] = tmpNum - 1 - end - else - ViewUtil:ErrorTip("牌型出错,重新加载页面") - ViewManager.refreshGameView() - end - if i == #cardlist then - if #self.newCard_list[cardlist[i] % 100] == 0 then - self.newCard_list[cardlist[i] % 100] = nil + local card_code_number = cardlist[i] + for j = 1, #self.card_list do + local card = self.card_list[j] + if card_code_number == card.card_code_number then + list_remove(self.card_list, card) + self._view_handCard:RemoveChild(card.btn_card, true) + break end end end + self._view_handCard:ResizeToFit(self._view_handCard.numItems) self:UpdateHandCardsPos() end function M:UpdateHandCardsPos() - local maxHeight = 0 - self._view_handCard:RemoveChildrenToPool() - self._newCardSize = {} - self._viewList_move:GetChild('list'):RemoveChildrenToPool() - for k, v in pairs(self.newCard_list) do - local btn_cardListFather = self._view_handCard:AddItemFromPool() - btn_cardListFather.width = self.scaleW - -- btn_cardListFather.height = scaleH*12 - local btn_cardList = btn_cardListFather:GetChild('list') - btn_cardList:RemoveChildrenToPool() - self.linegap = btn_cardList.lineGap - local tmpHeight = 0 - local noZhaIndex = 0 - for k1, v1 in pairs(v) do - local card_number_code = k * 10 + k1 - local card_flower_code = k1 * 100 + k - if v1 ~= 4 then - for i = 1, v1 do - local btn_card = btn_cardList:GetFromPool('') - btn_cardList:AddChildAt(btn_card, noZhaIndex) - noZhaIndex = noZhaIndex + 1 - btn_card.height = self.scaleH - self:FillPoker2(btn_card, card_flower_code) - -- self.cards_view:AddChild(btn_card) - local card_view = NewCardView(btn_card, card_number_code, card_flower_code) - card_view.fatherList = btn_cardList - self.card_list[#self.card_list + 1] = card_view - btn_card.data = card_view - tmpHeight = tmpHeight + 1 - self:AddCardTouchEvent(card_view) - end - else - local btn_card = btn_cardList:AddItemFromPool() - btn_card.height = self.scaleH - self:FillPoker2(btn_card, card_flower_code, "_z") - -- self.cards_view:AddChild(btn_card) - local card_view = NewCardView(btn_card, card_number_code, card_flower_code) - card_view.fatherList = btn_cardList - card_view.zha = true - self.card_list[#self.card_list + 1] = card_view - btn_card.data = card_view - tmpHeight = tmpHeight + 1 - self:AddCardTouchEvent(card_view) - end - self._newCardSize[k1] = tmpHeight - end - - if tmpHeight > maxHeight then - maxHeight = tmpHeight - end + for i = 1, #self.card_list do + local card_view = self.card_list[i] + card_view.index = i + card_view.btn_card.touchable = true + self:UpdateCardMove(card_view.btn_card, false, false) + self:SetBtnCardColor(card_view, 0) end - self._view:GetChild('n82').y = self._view_handCard.height - - (self.scaleH + (self.scaleH + self.linegap) * (maxHeight - 1) + 50) end function M:ResetPoker() @@ -724,9 +741,9 @@ function M:UpdateHandCardsColor() if #send_card > 0 then table.sort(send_card, tableSortNumber) self._cardCheck:initCards(send_card, { flag = false, flag_allCards = #send_card == self._view_handCard.numItems }) - self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 + -- self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 else - self._ctr_canSendCard.selectedIndex = 0 + -- self._ctr_canSendCard.selectedIndex = 0 end end @@ -734,16 +751,16 @@ function M:BtnEvent() self.btn_not_put = self._view:GetChild('btn_not_put') self.btn_tips = self._view:GetChild('Btn_Tip') -- 覆盖 self.btn_sendCards = self._view:GetChild('Btn_SendCard') - self._ctr_canSendCard = self.btn_sendCards:GetController('can') + -- self._ctr_canSendCard = self.btn_sendCards:GetController('can') self.btn_sendCards.onClick:Set( function() if self.Reset then return end - if self._ctr_canSendCard.selectedIndex == 0 then - return - end + -- if self._ctr_canSendCard.selectedIndex == 0 then + -- return + -- end local send_card = {} self.send_card = {} local currentCard = {} @@ -824,7 +841,7 @@ function M:ShowTipsCard(index) end pt(item) self._cardCheck:initCards(item) - self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 + -- self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 end function M:GetHandCardOffset(count) diff --git a/lua_probject/extend_project/extend/poker/duoduo/EXProtocol.lua b/lua_probject/extend_project/extend/poker/duoduo/EXProtocol.lua index 0f37d05d..259160db 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/EXProtocol.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/EXProtocol.lua @@ -33,16 +33,19 @@ local EXProtocol = { EXPiao_Action = "2032", EXConfirmToNextGameSucc = "2010", - PT_GAMETUOGUAN = "2029", --托管 - SEND_TUOGUAN = "1018", --托管 - GAME_XIPAI = "20836", - GAME_EVENT_XIPAI = "20837", - GAME_EVENT_NOTIFY_XIPAI = "20838", - GAME_EVT_CARDINHAND = "202022", + PT_GAMETUOGUAN = "2029", --托管 + SEND_TUOGUAN = "1018", --托管 + GAME_XIPAI = "20836", + GAME_EVENT_XIPAI = "20837", + GAME_EVENT_NOTIFY_XIPAI = "20838", + GAME_EVT_CARDINHAND = "202022", EXCheckCard = "8881", EXCheckCard_Succ = "8882", - EXCheckCard_Send = "888" + EXCheckCard_Send = "888", + + EXBaseScore = "2034", + EXShowRank = "2035" } return EXProtocol diff --git a/lua_probject/extend_project/extend/poker/duoduo/EXResultView.lua b/lua_probject/extend_project/extend/poker/duoduo/EXResultView.lua index 506e5c5b..ee331543 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/EXResultView.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/EXResultView.lua @@ -74,7 +74,13 @@ function M:init(url, data, over, win_seat) local over0List = self._view:GetChild('list_over0') table.sort(data, function(a, b) - return a.ranking < b.ranking + if not a.ranking or a.ranking == 0 then + a.ranking = 4 + end + if not b.ranking or b.ranking == 0 then + b.ranking = 4 + end + return (a.ranking or 4) > (b.ranking or 4) end) over0List.itemRenderer = function(index, obj) local info = data[index + 1] diff --git a/lua_probject/extend_project/extend/poker/duoduo/ExtendConfig.lua b/lua_probject/extend_project/extend/poker/duoduo/ExtendConfig.lua index 39df2321..f00fa640 100644 --- a/lua_probject/extend_project/extend/poker/duoduo/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/poker/duoduo/ExtendConfig.lua @@ -138,6 +138,8 @@ function M:FillRoomData(s2croom) local reloadInfo = s2croom["reloadInfo"] local bank_seat = reloadInfo["banker_seat"] room.banker_seat = bank_seat + room.poolScore = reloadInfo["poolScore"] + local playing = reloadInfo["playing"] room.curren_turn_seat = reloadInfo["active_seat"] @@ -159,6 +161,9 @@ function M:FillRoomData(s2croom) p.piao = info_list[i]["piao"] p.handCards = info_list[i]["handCards"] p.outCards = info_list[i]["outCards"] + p.roundCardScore = info_list[i]["roundCardScore"] + p.ranking = info_list[i]["ranking"] + local last_outcard = info_list[i]["last_outcard"] if last_outcard ~= nil and last_outcard[1] ~= 0 then local out_card_list = last_outcard.card_list diff --git a/lua_probject/extend_project/extend/poker/sanqianfen/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/poker/sanqianfen/EXPlayerInfoView.lua index a4e5b1fd..748d3d85 100644 --- a/lua_probject/extend_project/extend/poker/sanqianfen/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/sanqianfen/EXPlayerInfoView.lua @@ -20,10 +20,6 @@ function M.new(view, mainView) self._tex_n4.visible=false end - if self._tex_player_name then - self._tex_player_name.visible=false - end - if self._tex_n5 then self._tex_n5.visible=false end diff --git a/wb_new_ui/assets/Common/buttons/Btn_Bg1WithText.xml b/wb_new_ui/assets/Common/buttons/Btn_Bg1WithText.xml index 718dac5d..33806ea5 100644 --- a/wb_new_ui/assets/Common/buttons/Btn_Bg1WithText.xml +++ b/wb_new_ui/assets/Common/buttons/Btn_Bg1WithText.xml @@ -5,15 +5,15 @@ - - - + + +