diff --git a/lua_probject/base_project/Game/View/Family/FamilyNumberRecord.lua b/lua_probject/base_project/Game/View/Family/FamilyNumberRecord.lua index 9ca3928f..3cd9b273 100644 --- a/lua_probject/base_project/Game/View/Family/FamilyNumberRecord.lua +++ b/lua_probject/base_project/Game/View/Family/FamilyNumberRecord.lua @@ -17,21 +17,86 @@ function FamilyNumberRecord.New(root) -- end self.familyType.selectedIndex = 5 - self._view:GetChild('text_titleRecord').text = string.format("%s(%s) 成员记录", self._group.name, self._group.id) - self._view:GetChild('text_residueDiamond').text = self._group.diamo - self._view:GetChild('text_timeRecord').visible = false - - local games = DataManager.SelfUser.games local comp_gameTypeList = self._view:GetChild('comp_gameTypeList'):GetChild('n0') local ctr_numberRecordRank = self._view:GetController('numberRecordRank') self._input_IDSerach = self._view:GetChild('input_numberID') + self._viewList_numberRank = self._view:GetChild('comp_numberRecordByGameType'):GetChild('n3') self._viewList_numverRecord = self._view:GetChild('list_numverRecord') + self._viewlist_numberRecordDetail = self._view:GetChild('list_numberRecordDetail') + self._viewText_titleRecord = self._view:GetChild('text_titleRecord') + + self.ctr_numberRecord = self._view:GetController('numberRecord') + self._text_groupTitle = string.format("%s(%s)", self._group.name, self._group.id) + + self._viewText_titleRecord.text = string.format("%s 成员记录", self._text_groupTitle) + self._view:GetChild('text_residueDiamond').text = self._group.diamo + self._view:GetChild('text_timeRecord').text = os.date('%Y-%m-%d %H:%M', os.time()) + + self:NumverRecordRenderer(self._group.id) + self:NumverRankRenderer(self._group.id) + self:GameTypeListRenderer(comp_gameTypeList) + self:NumberRecordDetailRender() + comp_gameTypeList.onClickItem:Set(function(context) + self:OnClickSortType(self._group.id, context.data.data.id) + ctr_numberRecordRank.selectedIndex = 0 + end) + self.btn_close.onClick:Set(function() + if self.ctr_numberRecord.selectedIndex > 0 then + self.ctr_numberRecord.selectedIndex = self.ctr_numberRecord.selectedIndex - 1 + else + self:InitCloseClick() + self.familyType.selectedIndex = 1 + end + end) + self.ctr_numberRecord.onChanged:Set(function() + if self.ctr_numberRecord.selectedIndex == 0 then + self._viewText_titleRecord.text = string.format("%s 成员记录", self._text_groupTitle) + self._view:GetChild('text_timeRecord').text = os.date('%Y-%m-%d %H:%M', os.time()) + elseif self.ctr_numberRecord.selectedIndex == 1 then + self._viewText_titleRecord.text = string.format("%s 个人记录", self._text_groupTitle) + self._view:GetChild('text_numberRecordTime').text = os.date('%Y-%m-%d %H:%M', os.time()) + elseif self.ctr_numberRecord.selectedIndex == 2 then + self._viewText_titleRecord.text = string.format("%s %s", self._text_groupTitle, + self._flag_unReadDetail and "未读详情" or "已读详情") + end + end) + self._view:GetChild('btn_clearInput').onClick:Set(function() + self._input_IDSerach.text = "" + end) + self._view:GetChild('btn_searchRecord').onClick:Set(function() + ViewUtil.ShowOneChooose("该功能还未开放") + end) + self._view:GetChild('btn_changeMJScore').onClick:Set(function() + ViewUtil.ShowOneChooose("该功能还未开放") + end) + + self._view:GetChild('btn_changePKScore').onClick:Set(function() + ViewUtil.ShowOneChooose("该功能还未开放") + end) + self._view:GetChild('btn_allChoose').onClick:Set(function() + ViewUtil.ShowOneChooose("该功能还未开放") + end) + self._view:GetChild('btn_allChooseRead').onClick:Set(function() + ViewUtil.ShowOneChooose("该功能还未开放") + end) + self._view:GetChild('btn_allChooseReverse').onClick:Set(function() + ViewUtil.ShowOneChooose("该功能还未开放") + end) + self._view:GetChild('comp_sortTypeList'):GetChild('n0').onClickItem:Set(function(context) + self:OnClickSortType(context) + ctr_numberRecordRank.selectedIndex = 0 + end) + + + return self +end + +function M:GameTypeListRenderer(comp_gameTypeList) + local games = DataManager.SelfUser.games - print("lingmengplayList", #games) - pt(games) comp_gameTypeList:SetVirtual() comp_gameTypeList.itemRenderer = function(index, obj) if index == 0 then @@ -52,46 +117,58 @@ function FamilyNumberRecord.New(root) end end comp_gameTypeList.numItems = #games + 2 - - self.btn_close.onClick:Set(function() - if self.ctr_numberRecord.selectedIndex > 0 then - self.ctr_numberRecord.selectedIndex = self.ctr_numberRecord.selectedIndex - 1 - else - self:InitCloseClick() - self.familyType.selectedIndex = 1 - end - end) - self:NumverRecordRenderer() - self._view:GetChild('btn_clearInput').onClick:Set(function() - self._input_IDSerach.text = "" - end) - self._view:GetChild('btn_searchRecord').onClick:Set(function() - ViewUtil.ShowOneChooose("该功能还未开放") - end) - self._view:GetChild('btn_changeMJScore').onClick:Set(function() - ViewUtil.ShowOneChooose("该功能还未开放") - end) - - self._view:GetChild('btn_changePKScore').onClick:Set(function() - ViewUtil.ShowOneChooose("该功能还未开放") - end) - self._view:GetChild('comp_sortTypeList'):GetChild('n0').onClickItem:Set(function(context) - self:OnClickSortType(context) - ctr_numberRecordRank.selectedIndex = 0 - end) - comp_gameTypeList.onClickItem:Set(function(context) - self:OnClickSortType(self._group.id, context.data.data.id) - ctr_numberRecordRank.selectedIndex = 0 - end) - - return self end function M:NumverRecordRenderer() + self:ResetRecords() + local numberRankList = self._viewList_numberRank + numberRankList:SetVirtual() + numberRankList.itemRenderer = function(index, obj) + local info = self.records[index + 1] + obj:GetChild('text_gameType').text = index == 0 and "麻将" or "扑克" + obj:GetChild('text_round').text = info.childNum + obj:GetChild('text_score').text = info.totalScore + obj:GetChild('text_winNum').text = info.winNum + obj:GetChild('btn_lookRecord').onClick:Set(function() + self._flag_unReadDetail = true + self.ctr_numberRecord.selectedIndex = 2 + self.gameTypeNum = index + 1 + self._viewlist_numberRecordDetail.numItems = info.childNum + end) + end + numberRankList.numItems = 2 +end + +function M:NumberRecordDetailRender() + local list_numberRecordDetail = self._viewlist_numberRecordDetail + list_numberRecordDetail:SetVirtual() + list_numberRecordDetail.itemRenderer = function(index, obj) + local info = self.records[self.gameTypeNum][index + 1] + obj:GetChild('text_gameName').text = info.game_info.name + obj:GetChild('text_time').text = os.date('%Y-%m-%d\n%H:%M', info.create_time) + obj:GetChild('text_roomID').text = info.room_id + obj:GetChild('text_userDiamond').text = 0 + obj:GetChild('btn_lookRecord').onClick:Set(function() + print("lingmeng查看") + end) + local resultDetailList = obj:GetChild('list') + resultDetailList:SetVirtual() + resultDetailList.itemRenderer = function(index, obj) + local resultInfo = info.totalScore[index + 1] + ImageLoad.Load(resultInfo.portrait, obj:GetChild('btn_head')._iconObject) + obj:GetChild('text_name').text = resultInfo.nick + obj:GetChild('text_score').text = resultInfo.score + obj:GetController('colour').selectedIndex = resultInfo.score >= 0 and 1 or 0 + end + resultDetailList.numItems = #info.totalScore + end +end + +function M:NumverRankRenderer(groupId) local numberRecordList = self._viewList_numverRecord numberRecordList:SetVirtual() numberRecordList.itemRenderer = function(index, obj) - local info = rank[index + 1] + local info = self.rank[index + 1] ImageLoad.Load(info.portrait, obj:GetChild('btn_head')._iconObject) obj:GetChild('text_ID').text = info.uid obj:GetChild('text_nick').text = info.nick @@ -99,6 +176,9 @@ function M:NumverRecordRenderer() obj:GetChild('btn_lookRecord').onClick:Set(function() self.ctr_numberRecord.selectedIndex = 1 self:OnClickNumberRank(groupId, info.uid, info.round) + self._view:GetChild('text_numberRecordName').text = info.nick + self._view:GetChild('text_numberRecordID').text = info.uid + ImageLoad.Load(info.portrait, self._view:GetChild('btn_numberRecordHead')._iconObject) end) end end @@ -112,9 +192,8 @@ function M:OnClickSortType(groupId, pid) if res.ReturnCode ~= 0 then ViewUtil.ShowOneChooose("获取排行榜失败" .. res.ReturnCode) else - local data = res.Data - local rank = data.ranks - numberRecordList.numItems = #rank + self.rank = res.Data.ranks + numberRecordList.numItems = #self.rank end end) end @@ -122,12 +201,46 @@ end function M:OnClickNumberRank(groupId, uid, round) print("lingmengOnClickNumberRank") local fgCtr = ControllerManager.GetController(NewGroupController) - local numberRecordList = self._viewList_numverRecord + local numberRankList = self._viewList_numberRank fgCtr:FG_GetGroupRecordSpe(groupId, GetPlatform(), uid, 0, 0, round, os.time() - 3600 * 120, os.time(), 3, function(res) pt(res) - pt("resdata", res.Data.records[1].totalScore) + if res.ReturnCode ~= 0 then + ViewUtil.ShowOneChooose("获取查看个人战绩失败" .. res.ReturnCode) + self.ctr_numberRecord.selectedIndex = 0 + else + local records = res.Data.records + self:ResetRecords() + for i = 1, #records do + local info = records[i] + local tempTableChild = self.records[info.game_info.gameType] + info.totalScore = json.decode(info.totalScore) + if info.round ~= 1 or info.totalScore.score ~= 0 then + table.insert(tempTableChild, info) + local totalScore + for i = 1, 2 do + if info.totalScore[i].accId == uid then + totalScore = info.totalScore[i].score + end + end + tempTableChild.totalScore = tempTableChild.totalScore + totalScore + tempTableChild.childNum = tempTableChild.childNum + 1 + tempTableChild.winNum = tempTableChild.winNum + (totalScore > 0 and 1 or 0) + end + end + numberRankList:RefreshVirtualList() + end end) end +function M:ResetRecords() + self.records = {} + for i = 1, 2 do + self.records[i] = {} + self.records[i].totalScore = 0 + self.records[i].childNum = 0 + self.records[i].winNum = 0 + end +end + return M diff --git a/lua_probject/base_project/Game/View/LobbyView.lua b/lua_probject/base_project/Game/View/LobbyView.lua index ce425037..51682b99 100644 --- a/lua_probject/base_project/Game/View/LobbyView.lua +++ b/lua_probject/base_project/Game/View/LobbyView.lua @@ -185,7 +185,7 @@ function M:InitView(url) view:GetChild("tex_name").text = DataManager.SelfUser.nick_name view:GetChild("tex_id").text = tostring(DataManager.SelfUser.account_id) - view:GetChild("btn_diamo"):GetChild("num").text = tostring(DataManager.SelfUser.diamo) + view:GetChild("btn_diamo").text = tostring(DataManager.SelfUser.diamo) --btn_joinroom.displayObject.gameObject:SetActive(false) @@ -487,7 +487,7 @@ function M:GetPlayerInfoData() end function M:ShowPlayerInfo(raffle, diamo, newMail) - self._view:GetChild("btn_diamo"):GetChild("num").text = diamo or 0 + self._view:GetChild("btn_diamo").text = diamo or 0 end function M:OnApplicationPause() diff --git a/lua_probject/base_project/Game/View/PlayerInfoView_copy.lua b/lua_probject/base_project/Game/View/PlayerInfoView2.lua similarity index 100% rename from lua_probject/base_project/Game/View/PlayerInfoView_copy.lua rename to lua_probject/base_project/Game/View/PlayerInfoView2.lua diff --git a/lua_probject/extend_project/extend/majiang/fuzhou/EXMainView.lua b/lua_probject/extend_project/extend/majiang/fuzhou/EXMainView.lua index c6eb1067..c2411f80 100644 --- a/lua_probject/extend_project/extend/majiang/fuzhou/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/fuzhou/EXMainView.lua @@ -1,5 +1,5 @@ local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi") +local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local MJMainView = require("main.majiang.MJMainView") local TableBG = require("Game.Data.TableBG") local EXClearingView = import(".EXClearingView") diff --git a/lua_probject/extend_project/extend/majiang/fuzhou/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/majiang/fuzhou/EXPlayerInfoView.lua index 19b5f58d..4cd18ffb 100644 --- a/lua_probject/extend_project/extend/majiang/fuzhou/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/fuzhou/EXPlayerInfoView.lua @@ -1,11 +1,11 @@ local PlayerInfoView = require("Game.View.PlayerInfoView") -local PlayerInfoView_copy = require("Game.View.PlayerInfoView_copy") +local PlayerInfoView2 = require("Game.View.PlayerInfoView2") local M = {} function M.new(view, mainView) if mainView._room.room_config.people_num == 2 then - setmetatable(M, { __index = PlayerInfoView_copy }) + setmetatable(M, { __index = PlayerInfoView2 }) else setmetatable(M, { __index = PlayerInfoView }) end @@ -17,13 +17,13 @@ function M.new(view, mainView) end function M:init() - PlayerInfoView_copy.init(self) + PlayerInfoView2.init(self) 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 @@ -32,25 +32,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_copy.FillData(self, player) + PlayerInfoView2.FillData(self, player) end function M:UpdateScore() diff --git a/lua_probject/extend_project/extend/majiang/fuzhou/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/fuzhou/MJPlayerSelfCardInfoView.lua index 0b215082..4fa39205 100644 --- a/lua_probject/extend_project/extend/majiang/fuzhou/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/fuzhou/MJPlayerSelfCardInfoView.lua @@ -1,5 +1,5 @@ -local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView_jiangxi") -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi") +local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView") +local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} diff --git a/lua_probject/extend_project/extend/majiang/jinxi/EXMainView.lua b/lua_probject/extend_project/extend/majiang/jinxi/EXMainView.lua index 9c6a553e..4d1037a7 100644 --- a/lua_probject/extend_project/extend/majiang/jinxi/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/jinxi/EXMainView.lua @@ -1,5 +1,5 @@ local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi") +local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local MJMainView = require("main.majiang.MJMainView") local TableBG = require("Game.Data.TableBG") local EXClearingView = import(".EXClearingView") diff --git a/lua_probject/extend_project/extend/majiang/jinxi/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/majiang/jinxi/EXPlayerInfoView.lua index 85850ecf..4cd18ffb 100644 --- a/lua_probject/extend_project/extend/majiang/jinxi/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/jinxi/EXPlayerInfoView.lua @@ -1,11 +1,11 @@ local PlayerInfoView = require("Game.View.PlayerInfoView") -local PlayerInfoView_copy = require("Game.View.PlayerInfoView_copy") +local PlayerInfoView2 = require("Game.View.PlayerInfoView2") local M = {} function M.new(view, mainView) if mainView._room.room_config.people_num == 2 then - setmetatable(M, { __index = PlayerInfoView_copy }) + setmetatable(M, { __index = PlayerInfoView2 }) else setmetatable(M, { __index = PlayerInfoView }) end @@ -17,7 +17,7 @@ function M.new(view, mainView) end function M:init() - PlayerInfoView_copy.init(self) + PlayerInfoView2.init(self) end function M:ShowInteraction(type, str) @@ -50,7 +50,7 @@ function M:UpdateRemainCard(card_num, hide) end function M:FillData(player) - PlayerInfoView_copy.FillData(self, player) + PlayerInfoView2.FillData(self, player) end function M:UpdateScore() diff --git a/lua_probject/extend_project/extend/majiang/jinxi/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/jinxi/MJPlayerSelfCardInfoView.lua index 0b215082..4fa39205 100644 --- a/lua_probject/extend_project/extend/majiang/jinxi/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/jinxi/MJPlayerSelfCardInfoView.lua @@ -1,5 +1,5 @@ -local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView_jiangxi") -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi") +local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView") +local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} diff --git a/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua b/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua index 0361cf13..926cc53e 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua @@ -1,5 +1,5 @@ local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi") +local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local MJMainView = require("main.majiang.MJMainView") local TableBG = require("Game.Data.TableBG") local EXClearingView = import(".EXClearingView") diff --git a/lua_probject/extend_project/extend/majiang/lichuan/EXMainView_jaingxi.lua b/lua_probject/extend_project/extend/majiang/lichuan/EXMainView_jaingxi.lua deleted file mode 100644 index c224997b..00000000 --- a/lua_probject/extend_project/extend/majiang/lichuan/EXMainView_jaingxi.lua +++ /dev/null @@ -1,962 +0,0 @@ -local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView_jiangxi") -local MJPlayerCardInfoView = import(".MJPlayerCardInfoView_jiangxi") --- local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") --- local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") -local MJMainView = require("main.majiang.MJMainView") -local EXClearingView = import(".EXClearingView") -local TX_GameEvent = import(".GameEvent") -local HuTipView = import("main.majiang.HuTipView") -local SettingView = import(".EXSettingView") -local PlayerInfoView = import(".EXPlayerInfoView_jiangxi") --- local PlayerInfoView = import(".EXPlayerInfoView") -local M = {} - ---- Create a new ZZ_MainView -function M.new() - setmetatable(M, { __index = MJMainView }) - local self = setmetatable({}, { __index = M }) - self.class = "MainView" - self.asset_group = "LiChuan_MJ" - self:init() - ViewUtil.PlayMuisc(self.asset_group, "extend/majiang/lichuan/sound/bg.mp3") - return self -end - -function M:InitView(url) - local room = self._room - self._style = 1 - self._gps_style = 1 - self._full = true - UIPackage.AddPackage("extend/majiang/lichuan/ui/Extend_MJ_LiChuan") - -- MJMainView.InitView(self, string.format("ui://Main_Majiang/Main_new_%d", room.room_config.people_num)) - MJMainView.InitView(self, string.format("ui://Main_Majiang/Main_new_%d_jiangxi", room.room_config.people_num)) - - self._hu_tip = HuTipView.new(self) - - self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人黎川麻将 ' .. room.score_times .. '倍' - - 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") - - --lingmeng - ---[[ - - --]] - self.jing = self._view:GetChild('jing') - - self._state.onChanged:Add(function() - print("==============================UpdatePlayerInfoView1") - self:UpdatePlayerInfoView() - end) - - local showNextCtr = self._view:GetController('showNext') - local ShowNextConfrimCtr = self._view:GetController('showNextConfrim') - local showNextList = self._view:GetChild('list_showNext') - local pop_showNextConfrim = self._view:GetChild('pop_showNextConfrim') - local btn_closeRoom = self._view:GetChild("btn_setting") - local conterBoxComp = self._view:GetChild("Comp_ConterBox") - - self._ctr_cardbox = conterBoxComp:GetController("seat") - self._tex_leftTime = conterBoxComp:GetChild("Text_Time") - - self._view:GetChild('btn_closeRoom').onClick:Set(function() - ---[[ - --旧 - local tip_owner = '您是否退出房间?\n(退出房间后房间将解散)' - local tip = '您是否退出房间?' -- \n (请注意,申请洗牌后退出,不会返还洗牌分) - local tipStr = '' - if self._room.agent then - tipStr = '您是否退出房间?' - else - tipStr = self._room.owner_id == self._room.self_player.self_user.account_id and tip_owner or tip - end - local _curren_msg = MsgWindow.new(self._root_view, tipStr, MsgWindow.MsgMode.OkAndCancel) - _curren_msg.onOk:Add( - function() - if self._state.selectedIndex > 0 and self._state.selectedIndex < 3 then - ViewUtil.ErrorTip(nil, '房间已开始,无法退出游戏。') - else - ViewUtil.ShowModalWait(self._root_view) - self._gamectr:LevelRoom( - function(res) - ViewUtil.CloseModalWait() - if res.ReturnCode == 0 then - ViewManager.ChangeView(ViewManager.View_Lobby) - else - ViewUtil.ErrorTip(res.ReturnCode) - end - end - ) - end - end - ) - _curren_msg:Show() - --]] - end) - - self._view:GetChild('btn_showNext').onClick:Set(function() - showNextCtr.selectedIndex = 1 - end) - - self._view:GetChild('btn_sendShow').onClick:Set(function() - self:SendShowNext(ShowNextConfrimCtr) - end) - self._view:GetChild('btn_closeShow').onClick:Set(function() - ShowNextConfrimCtr.selectedIndex = 0 - showNextCtr.selectedIndex = 0 - showNextList.selectedIndex = -1 - self._showNextName = nil - end) - showNextList.onClickItem:Set(function(context) - self:ClickShowNext(context, ShowNextConfrimCtr) - end) - ShowNextConfrimCtr.onChanged:Set(function() - pop_showNextConfrim:GetChild("btn_ShowCard").icon = self._showNextName - end) - pop_showNextConfrim:GetChild("btn_center").onClick:Set(function() - local _gamectr = ControllerManager.GetController(GameController) - _gamectr:SendNextCard(string.sub(self._showNextName, -3)) - ShowNextConfrimCtr.selectedIndex = 0 - showNextCtr.selectedIndex = 0 - showNextList.selectedIndex = -1 - self._showNextName = nil - end) - btn_closeRoom.onClick:Add(handler(self, function() - local settingView = SettingView.new(self) - settingView:Show() - 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_LiChuan", "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() - 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.icon = 'ui://Main_Majiang/' .. - get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. self._room.jing - self.jing.visible = true - if self.jing:GetController('jing') then - self.jing:GetController('jing').selectedIndex = 1 - end - else - self.jing.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(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1)) - -- local tem = self._view:GetChild(string.format("player_info%d", i)) - - _player_info[i] = PlayerInfoView.new(tem, self) - tem.visible = false - end -end - -function M:NewMJPlayerCardInfoView(view, index) - print("===============================NewMJPlayerCardInfoView") - if index == 1 then - return MJPlayerSelfCardInfoView.new(view, self) - end - return MJPlayerCardInfoView.new(view, self) -end - -function M:EventInit() - -- 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.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:UpdateRound() - self._state.selectedIndex = 1 - self:ShowJing() - local list = _room.player_list - 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() - end - end) - _gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...) - local arg = { ... } - self._left_time = 15 - local seat = arg[1] - self:UpdateCardBox(self:GetPos(seat)) - -- if seat == self._room.self_player.seat then - -- self:ShowHuTip() - -- end - end) - - _gamectr:AddEventListener(TX_GameEvent.OutHint, function(...) - local info = self._player_card_info[self:GetPos(_room.self_player.seat)] - info:UpdateHandCard(true) - end) - - local _gcm_outcard_url = "ui://Main_Majiang/Gcm_OutCard" - _gamectr:AddEventListener(TX_GameEvent.OutCard, function(...) - self:__CloseTip() - self._left_time = 0 - local arg = { ... } - local p = arg[1] - local card = arg[2] - local seat = p.seat - local info = self._player_card_info[self:GetPos(seat)] - self:RemoveCursor() - info:UpdateHandCard() - local outcard = UIPackage.CreateObjectFromURL(_gcm_outcard_url) - info:UpdateOutCardList(outcard, card, self._cursor) - self:PlaySound("LiChuan_MJ", p.self_user.sex, tostring(card)) - self:PlayMJSound("chupai.mp3") - if seat == _room.self_player.seat then - _room.curren_outcard_seat = -1 - end - end) - _gamectr:AddEventListener(TX_GameEvent.GetCard, function(...) - self:__CloseTip() - local arg = { ... } - local seat = arg[1] - local card = arg[2] - -- self._tex_leftTime.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) - end) - - _gamectr:AddEventListener(TX_GameEvent.FZTips, function(...) - print("========================OnEventFzTips1") - 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.ZPHuCard, function(...) - self._left_time = 0 - self:UpdateCardBox(0) - self:__CloseTip() - self._popEvent = false - 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 index = self:GetPos(win_seat) - local info = self._player_card_info[index] - self:RemoveCursor() - info:UpdateHandCard(true, true) - - local obj_win_card = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Btn_Card_jiangxi") - obj_win_card.icon = "ui://Main_Majiang/202_" .. win_card - obj_win_card:GetController("bg").selectedIndex = 1 - info._view:AddChild(obj_win_card) - obj_win_card:Center() - - local url, pNode - local player = _room:GetPlayerBySeat(win_seat) - if win_seat ~= _room.self_player.seat then - url = "ui://Main_Majiang/别人胡" - pNode = info._mask_liangpai - elseif win_seat == _room.self_player.seat then - url = "ui://Main_Majiang/自己胡牌" - pNode = self._view - end - if win_seat == lose_seat then - url = "ui://Main_Majiang/eff_zimo" - end - - local he = UIPackage.CreateObjectFromURL(url) - pNode:AddChild(he) - he:GetTransition("t2"):Play() - 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" .. math.random(1, 3)) or ("hu" .. math.random(1, 2)) - 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 - -- print("===================================com_name", 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) - - _gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...) - local arg = { ... } - self._popEvent = false - local list = arg[1] - local start_seat = arg[2] - -- ViewUtil.PlaySound("LiChuan_MJ", "extend/majiang/chaozhou/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao, self, list, start_seat) - end) - - _gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...) - self._popEvent = false - self:__CloseTip() - self._left_time = 0 - self:UpdateCardBox(0) - self._ctr_cardbox.selectedIndex = 0 - local 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._root_view) - 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(...) - print("===============================lingthis") - 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_hp - if num >= 0 then - info._view:GetController("text_color").selectedIndex = 0 - info._view:GetChild("text_jifen").text = "+" .. d2ad(num) - else - info._view:GetController("text_color").selectedIndex = 1 - info._view:GetChild("text_jifen").text = d2ad(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._state.selectedIndex = 2 - self._clearingView = nil - print("===============================lingend") - end) - end - self._player_card_info[1]:ShowHuTip() - end) - - _gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...) - 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() - coroutine.start(function() - coroutine.wait(0.5) - self._clearingView:Show() - 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() - end) - - _gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...) - 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 - if seat == _room.self_player.seat 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) -end - -function M:OutCard(card) - 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("LiChuan_MJ", self._room.self_player.self_user.sex, tostring(card)) - self:PlayMJSound("chupai.mp3") - -- self:ShowHuTip() - end) - else - printlog("鬼牌不能出===>>>" .. card) - end -end - -function M:__FangziTip(tip, weight) - print("========================OnEventFzTips2", tip, weight) - 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:__TipAction(context) - local data = context.sender.data - local _gamectr = self._gamectr - 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) - self:__CloseTip() - end) - self._chipeng_tip.visible = false - return - end - - _gamectr:SendAction(td.id) - if (self._chipeng_tip == nil) then return end - self._chipeng_tip:Dispose() - self._chipeng_tip = nil -end - -function M:_ChiView(tiplist, callback) - self._chipeng_tip.visible = false - printlog("_ChiView") - pt(tiplist) - local _pop_tip_choice = UIPackage.CreateObject("Extend_MJ_LiChuan", "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 - (#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_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 = (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) - self._view:AddChild(_pop_tip_choice) - self._pop_tip_choice = _pop_tip_choice -end - -function M:OnFangziAction(...) - self:__CloseTip() - local arg = { ... } - local _player_card_info = self._player_card_info - local fz = arg[1] - local player = arg[2] - local index = arg[3] - printlog("OnFangziAction") - local info = _player_card_info[self:GetPos(player.seat)] - local pNode = info._mask_liangpai - local effect = UIPackage.CreateObject("Extend_MJ_LiChuan", "FzEffect") - if fz.type == FZType.Peng then - self:PlaySound("LiChuan_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", "碰框") - elseif fz.type == FZType.Chi then - self:PlaySound("LiChuan_MJ", player.self_user.sex, "chi" .. math.random(1, 3)) - effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "吃") - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "吃") - else - self:PlaySound("LiChuan_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.3) - self._popEvent = true - end) - coroutine.start(function() - coroutine.wait(2) - 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 - printlog(getcard) - 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_LiChuan", "Panel_Birds") - self._view: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:GetChildAt(i - 1) - 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 - end - coroutine.start(function() - coroutine.wait(1) - _niao_View:Dispose() - self._popEvent = true - end) -end - --- function M:markOutCards(showTip, data) --- for i = 1, #self._room.player_list do --- local p = self._room.player_list[i] --- local info = self._player_card_info[self:GetPos(p.seat)] --- for j = 1, #p.outcard_list do --- local card = p.outcard_list[j] --- if card == data then --- local obj = info:GetOutCardByIndex(j) --- obj:GetController("gray").selectedIndex = showTip and 1 or 0 --- end --- 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 - 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) - print("lingmengReloadRoom") - local room = self._room - -- if not room.playing then - -- self._state.selectedIndex = 2 - -- else - -- self._state.selectedIndex = 1 - -- self._room._reload_flag = true - -- 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 - end - - - 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() - local head_info = self._player_info[self:GetPos(p.seat)] - -- head_info:UpdateScore() - head_info._view:GetChild('zhanji').visible = true - local num = p.total_hp or 0 - if num > 0 then - head_info._view:GetController('text_color').selectedIndex = 0 - head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num) - else - head_info._view:GetController('text_color').selectedIndex = 1 - head_info._view:GetChild('text_jifen').text = 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) - elseif p.seat == room.curren_outcard_seat then - info:UpdateHandCard(true) - info:UpdateOutCardList() - else - info:UpdateOutCardList() - end - if p.seat == room.banker_seat then - head_info:MarkBank(true) - end - -- if p.ready then - -- 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 - 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 = string.format("剩余%d张牌", room.left_count) - self:UpdateRound() - 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 -end - ------------------------lingmeng---------------------------- -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: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 tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1)) - _player_info[i] = PlayerInfoView.new(tem, self) - _player_info[i]:FillData(list[i]) - end -end - -function M:UpdateCardBox(seat) - local index = seat - if self._room.room_config.people_num == 2 then - self._ctr_cardbox.selectedIndex = index - else - self._ctr_cardbox.selectedIndex = index - 1 - end -end - ------------------------------------------------------------ - - -function M:__CloseTip() - if self._chipeng_tip then - self._chipeng_tip:Dispose() - self._chipeng_tip = nil - end - if self._pop_tip_choice then - self._pop_tip_choice:Dispose() - self._pop_tip_choice = nil - 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/lichuan/ui/Extend_MJ_LiChuan") -end - -return M diff --git a/lua_probject/extend_project/extend/majiang/lichuan/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/majiang/lichuan/EXPlayerInfoView.lua index 85850ecf..4cd18ffb 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/EXPlayerInfoView.lua @@ -1,11 +1,11 @@ local PlayerInfoView = require("Game.View.PlayerInfoView") -local PlayerInfoView_copy = require("Game.View.PlayerInfoView_copy") +local PlayerInfoView2 = require("Game.View.PlayerInfoView2") local M = {} function M.new(view, mainView) if mainView._room.room_config.people_num == 2 then - setmetatable(M, { __index = PlayerInfoView_copy }) + setmetatable(M, { __index = PlayerInfoView2 }) else setmetatable(M, { __index = PlayerInfoView }) end @@ -17,7 +17,7 @@ function M.new(view, mainView) end function M:init() - PlayerInfoView_copy.init(self) + PlayerInfoView2.init(self) end function M:ShowInteraction(type, str) @@ -50,7 +50,7 @@ function M:UpdateRemainCard(card_num, hide) end function M:FillData(player) - PlayerInfoView_copy.FillData(self, player) + PlayerInfoView2.FillData(self, player) end function M:UpdateScore() diff --git a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerCardInfoView.lua b/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerCardInfoView.lua deleted file mode 100644 index f855e2f3..00000000 --- a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerCardInfoView.lua +++ /dev/null @@ -1,213 +0,0 @@ -local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView") -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") -local CardCheck = import(".CardCheck") - -local M = {} --- -function M.new(view, mainView) - setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) - setmetatable(M, { __index = MJPlayerSelfCardInfoView }) - local self = setmetatable({}, { __index = M }) - self.class = "PlayerSelfCardInfoView" - self._view = view - self._mainView = mainView - self:init() - return self -end - -function M:ShowHuTip(card_list) - printlog("ShowHuTip") - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, - DataManager.CurrenRoom.room_config.Laizi) - pt(tingList) - if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then - for i = 1, #DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then - table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) - end - end - end - end - self._mainView._hu_tip:FillData(tingList) -end - -function M:UpdateHandCard(getcard, mp) - print("====================================UpdateHandCard1", mp) - MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) - 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 - - print("====================================UpdateHandCard3") - 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) - -- print("==========================__OnClickHandCard") - 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 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 - -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 - - --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 ~= 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:Clear(bskip) - --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: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 = {} -end - -return M diff --git a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerCardInfoView_jiangxi.lua b/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerCardInfoView_jiangxi.lua deleted file mode 100644 index 025b12c6..00000000 --- a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerCardInfoView_jiangxi.lua +++ /dev/null @@ -1,379 +0,0 @@ -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") - - -local M = {} - ---- Create a new PlayerCardInfoView -function M.new(view, mainView) - local self = {} - setmetatable(M, { __index = MJPlayerCardInfoView }) - setmetatable(self, { __index = M }) - self._view = view - self._mainView = mainView - self:init() - return self -end - -function M:init() - MJPlayerCardInfoView.init(self) - - local CardInfo = self._view:GetChild('Text_CardInfo') - self._viewText_cardInfo = json.decode(CardInfo.text) - - local CardInfo = self._view:GetChild('Text_CardInfo') - self._viewText_cardInfo = json.decode(CardInfo.text) - - self._view_handCardList = self._view:GetChild('List_HandCard') - self._view_FZList = self._view:GetChild('List_FZ') - self._view_outCardList = self._view:GetChild('List_OutCard') - self._viewBtn_getCard = self._view:GetChild('Btn_HandCard') - - self._ctr_getCard = self._view:GetController('getCard') - self._ctr_seletedGet = self._view:GetController('seletedGetCard') -end - -function M:SetMJSize(zS) - local tempSzieConfig = {} - tempSzieConfig.size = zS - local filename = 'mjsize' .. DataManager.SelfUser.account_id - Utils.SaveLocalFile(filename, json.encode(tempSzieConfig)) - - --ControllerManager.OnConnect(SocketCode.TimeoutDisconnect) - ViewManager.refreshGameView() -end - -function M:SetPlayer(p) - self._player = p -end - -function M:FillData(begin) - if (begin) then - for i = 1, #self._player.fz_list do - self:UpdateFzList(self._player.fz_list[i], -1) - end - self:UpdateOutCardList() - else - self._current_card_type = DataManager.CurrenRoom.card_type - - if self._current_card_type == 2 then - local c3d = self._view:GetController('3d') - if c3d ~= nil then - c3d.selectedIndex = 1 - end - else - local c3d = self._view:GetController('3d') - if c3d ~= nil then - c3d.selectedIndex = 0 - end - end - end -end - -function M:Clear() - --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:RemoveChildren(0, -1, true) - self._area_handcard_list:RemoveChildren(0, -1, true) - self._area_outcard_list:RemoveChildren(0, -1, true) - self._mask_liangpai:RemoveChildren(0, -1, true) - self._view_handCardList:RemoveChildren(0, -1, true) - self._view_outCardList:RemoveChildren(0, -1, true) - self._view_FZList:RemoveChildren(0, -1, true) -end - --- 获取麻将资源前缀 -function M:GetPrefix() - -- local card_type = DataManager.CurrenRoom.card_type - -- local prefix = card_type == 1 and "a" or "" - -- return prefix - return get_majiang_prefix(DataManager.CurrenRoom.game_id) -end - -function M:fillCard(obj, pos_str, card, use3d) - if DataManager.CurrenRoom.jing and card == DataManager.CurrenRoom.jing and obj:GetController('jing') then - obj:GetController('jing').selectedIndex = 1 - end - if self._current_card_type == 2 and (use3d == nil or use3d == true) then - obj.icon = 'ui://MajiangCard3d/' .. 'b' .. pos_str .. card - else - obj.icon = 'ui://Main_Majiang/' .. self:GetPrefix() .. pos_str .. card - end -end - -function M:fillCard2(obj, pos_str, card) - if DataManager.CurrenRoom.jing and card == DataManager.CurrenRoom.jing and obj:GetController('jing') then - obj:GetController('jing').selectedIndex = 1 - end - print("=========================lingmengfz", obj, obj:GetChild("icon")) - obj:GetChild("icon").url = 'ui://Main_Majiang/' .. pos_str .. card -end - -function M:getBackCard(card) - return 'ui://Main_Majiang/' .. card -end - -function M:GetCard(btn) - local pic_name = split(btn.icon, '/')[4] - local lst = string.split(pic_name, '_') - return tonumber(lst[2] or 0) -end - -function M:UpdateHandCard(getcard, mp) - print("==============================UpdateHandCardlingmeng", self._player.hand_left_count) - -- MJPlayerCardInfoView.UpdateHandCard(self, getcard, mp) - - getcard = getcard or false - mp = mp or false - - self._view_handCardList:RemoveChildren() - for i = 0, self._player.hand_left_count - 1 do - -- if i >= self._view_handCardList.numItems then - self._view_handCardList:AddItemFromPool() - -- end - end - self._ctr_getCard.selectedIndex = getcard and 1 or 0 -end - --- 获取麻将图片资源位置,可以在扩展中复写 -function M:GetCardPicPack() - -- if DataManager.CurrenRoom.card_type == 2 then - -- return "MajiangCard3d" - -- else - return 'Main_Majiang' - -- end -end - -function M:adjust3dOutPut(obj, area, oder, num, index) - if index >= num then - local row = 1 + math.floor(((index - num) / (num + 2))) - local col = ((index - num) % (num + 2)) - - if oder == AreaOderType.left_right then - obj.x = obj.x + math.floor((area.width - obj.width * (num + 2)) / 2) - elseif oder == AreaOderType.right_left then - obj.x = obj.x - math.floor((area.width - obj.width * (num + 2)) / 2) - elseif oder == AreaOderType.up_down then - obj.y = obj.y + math.floor((area.height - obj.height * (num + 2)) / 2) - obj.x = obj.x - col * 7 + 7 * (row + 1) - elseif oder == AreaOderType.down_up then - obj.y = obj.y - math.floor((area.height - obj.height * (num + 2)) / 2) - obj.x = obj.x - col * 7 - 7 * (row - 1) - end - else - if oder == AreaOderType.left_right then - obj.x = obj.x + math.floor((area.width - obj.width * num) / 2) - elseif oder == AreaOderType.right_left then - obj.x = obj.x - math.floor((area.width - obj.width * num) / 2) - elseif oder == AreaOderType.up_down then - obj.y = obj.y + math.floor((area.height - obj.height * num) / 2) - obj.x = obj.x - index * 7 - elseif oder == AreaOderType.down_up then - obj.y = obj.y - math.floor((area.height - obj.height * num) / 2) - obj.x = obj.x - index * 7 - end - end -end - -function M:UpdateOutCardList(outcard, card_item, cursor) - print("lingmengoutpu", outcard, card_item, cursor) - outcard = outcard or nil - card_item = card_item or 0 - cursor = cursor or nil - - local outCardName = self._viewText_cardInfo['Out_Card'] - - local outlist = self._player.outcard_list - -- if self._view_outCardList.numItems < #outlist - 1 then - -- for i = 1, #outlist - 1 do - -- outcard = self._view_outCardList:AddItemFromPool() - -- -- end - -- self:fillCard2(outcard, outCardName, outlist[i]) - -- end - -- end - -- -- if self._viewText_cardInfo['Order'] == "desc" then - -- -- outcard = self._view_handCardList:GetFromPool("ui://Main_Majiang/Comp_4_OutCard") - -- -- self._view_outCardList:AddChildAt(outcard, 0) - -- -- else - -- outcard = self._view_outCardList:AddItemFromPool() - -- -- end - -- self:fillCard2(outcard, outCardName, card_item) - for i = 0, #outlist - 1 do - outcard = self._view_outCardList:AddItemFromPool() - self:fillCard2(outcard, outCardName, outlist[i + 1]) - end -end - --- 设置添加角标的方法 -function M:SetAddFlag(cb) - self.__addFlag = cb -end - --- 给麻将牌添加flag -function M:AddFlag(index, card, btn) - if not self.__addFlag then - return - end - local str_flag = self.__addFlag(index, card, btn) - btn:GetController('hun').selectedIndex = str_flag == '' and 0 or 1 - btn:GetChild('flag').icon = str_flag -end - -local function getPos(my_seat, other_seat, total) - local pos = 0 - pos = other_seat - my_seat + 1 - if pos <= 0 then - pos = pos + total - end - if total ~= 4 and pos == total then - pos = total + 1 - end - return pos -end - -function M:UpdateFzList(fz, index, show_card) - local isFour = false - if fz.type == FZType.Gang or fz.type == FZType.Gang_An or fz.type == FZType.Gang_Peng then - isFour = true - end - - local FZame = self._viewText_cardInfo['FZ_Card'] - index = index or 0 - show_card = show_card or nil - - local outCard = self._view_FZList:AddItemFromPool() - - if fz.type == FZType.Chi then - for i = 1, 3 do - local FZCard = outCard:GetChild(string.format("Comp_Card%d", i)) - self:fillCard2(FZCard, FZame, fz.opcard[i]) - end - else - local ctr_Four = outCard:GetController("isFour") - for i = 1, 3 do - local FZCard = outCard:GetChild(string.format("Comp_Card%d", i)) - print("lingmengfz", string.format("Comp_Card%d", i), FZCard) - self:fillCard2(FZCard, FZame, fz.card) - end - if fz.type == FZType.Peng then - ctr_Four.selectedIndex = 0 - else - ctr_Four.selectedIndex = 1 - local FZCard = outCard:GetChild(string.format("Comp_Card%d", 4)) - self:fillCard2(FZCard, FZame, fz.card) - if fz.type == FZType.Gang_An then - self:fillCard2(FZCard, FZame, '00') - end - end - end - -end - -function M:GetOutCardByIndex(index) - local outcard_list = self._mask_data['outcard_list'] - local oder = outcard_list['oder'] - local multi_draw_oder = 0 - if (outcard_list['multi_draw_oder']) then - multi_draw_oder = outcard_list['multi_draw_oder'] - end - - if (oder == AreaOderType.down_up or (multi_draw_oder == 1)) then - return self._area_outcard_list:GetChildAt(self._area_outcard_list.numChildren - index) - else - return self._area_outcard_list:GetChildAt(index - 1) - end -end - -function M:ResetFzList() - for i = 1, #self._player.fz_list do - local fz = self._player.fz_list[i] - -- if fz.type ~= FZType.Gang_Peng then - self:UpdateFzList(fz, -1) - -- else - -- self:UpdateFzList(fz, i) - -- end - end -end - -local function replace_card(obj, prefix) - local url = obj.icon - if url then - local len = string.len(url) - local pos = string.len('ui://Main_Majiang/') + 1 - local head_char = string.sub(url, pos, pos) - local card = string.sub(url, pos, len) - if head_char >= 'a' then - card = string.sub(card, 2, len) - end - obj.icon = 'ui://Main_Majiang/' .. prefix .. card - end -end - -function M:ResetCardType() - local old_card_type = self._current_card_type - self._current_card_type = DataManager.CurrenRoom.card_type - - --设置3d标志 - if self._current_card_type == 2 then - local c3d = self._view:GetController('3d') - if c3d ~= nil then - c3d.selectedIndex = 1 - - self._area_fz_list.x = self._src_fz_list_3d.x - self._area_fz_list.y = self._src_fz_list_3d.y - self._area_fz_list.width = self._src_fz_list_3d.z - self._area_fz_list.height = self._src_fz_list_3d.w - end - else - local c3d = self._view:GetController('3d') - if c3d ~= nil then - c3d.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 - end - end - - local change2d = false - if old_card_type == 2 and self._current_card_type ~= 2 then - change2d = true - end - - local change3d = false - if old_card_type ~= 2 and self._current_card_type == 2 then - change3d = true - end - - if change2d == false and change3d == false and self._current_card_type ~= 2 then - local prefix = self:GetPrefix() - - --更新已出牌 - for i = 1, self._area_outcard_list.numChildren do - local obj = self._area_outcard_list:GetChildAt(i - 1) - replace_card(obj, prefix) - end - - --更新手牌 - for i = 1, self._area_handcard_list.numChildren do - local obj = self._area_handcard_list:GetChildAt(i - 1) - replace_card(obj, prefix) - end - - --更新放子牌 - for i = 1, self._area_fz_list.numChildren do - local com = self._area_fz_list:GetChildAt(i - 1) - for j = 1, 4 do - local obj = com:GetChild('card_' .. j) - if obj then - replace_card(obj, prefix) - end - end - end - end -end - -return M diff --git a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua index 0b215082..4fa39205 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView.lua @@ -1,5 +1,5 @@ -local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView_jiangxi") -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi") +local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView") +local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} diff --git a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView_jiangxi.lua b/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView_jiangxi.lua deleted file mode 100644 index af6da3b9..00000000 --- a/lua_probject/extend_project/extend/majiang/lichuan/MJPlayerSelfCardInfoView_jiangxi.lua +++ /dev/null @@ -1,371 +0,0 @@ -local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView") -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") -local CardCheck = import(".CardCheck") - -local M = {} - ------------------------lingmeng--------------------------- ---原有mianmajiang -local CardView = { - card = nil, - -- 牌序号 - card_item = 0, - -- 索引 - index = 0, - -- 原始位置 - old_postion = Vector2.zero -} -local function NewCardView(card, cardItem) - local self = {} - setmetatable(self, { __index = CardView }) - self.card = card - self.card_item = cardItem - return self -end ----------------------------------------------------------- --- -function M.new(view, mainView) - setmetatable(MJPlayerSelfCardInfoView, { __index = MJPlayerCardInfoView }) - setmetatable(M, { __index = MJPlayerSelfCardInfoView }) - local self = setmetatable({}, { __index = M }) - self.class = "PlayerSelfCardInfoView" - self._view = view - self._mainView = mainView - self:init() - return self -end - -function M:init() - -- print("lingmenginithand") - -- MJPlayerSelfCardInfoView.init(self) - - -- local CardInfo = self._view:GetChild('Text_CardInfo') - --手机蓝屏点 - -- local CardInfoText = CardInfo.text - -- self._viewText_cardInfo = json.decode(CardInfoText) - - self._view_handCardList = self._view:GetChild('List_HandCard') - self._view_FZList = self._view:GetChild('List_FZ') - self._view_outCardList = self._view:GetChild('List_OutCard') - self._view_getCard = self._view:GetChild('Btn_HandCard') - - self._ctr_getCard = self._view:GetController('getCard') - self._ctr_seletedGet = self._view:GetController('seletedGetCard') - self._ctr_tip = self._view:GetController('tip') -end - -function M:ShowHuTip(card_list) - printlog("ShowHuTip") - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, - DataManager.CurrenRoom.room_config.Laizi) - pt(tingList) - if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then - for i = 1, #DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then - table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) - end - end - end - end - self._mainView._hu_tip:FillData(tingList) -end - -function M:UpdateHandCard(getcard, mp) - -- -- MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp) - local _carViewList = self._carViewList - local card_list = DataManager.CurrenRoom.self_player.card_list - --[[ - 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 - - - -- 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 - --]] - - - - -- -----------------------lingmeng--------------------------- - getcard = getcard or false - mp = mp or false - - -- -- local handCardName = self._viewText_cardInfo['Hand_Card'] - local handCardName = "202_" - if self._view_handCardList.numItems > 0 then - self._view_handCardList:RemoveChildren() - end - if self._view_getCard.numItems > 0 then - self._view_getCard:RemoveChildren() - end - - for i = 0, (#card_list) - 1 do - local tem_card = card_list[i + 1] - local btn_card - if getcard and i == (#card_list) - 1 then - btn_card = self._view_getCard:AddItemFromPool() - btn_card.onClick:Add(function(context) - self:__OnClickGetCard(context) - end) - else - btn_card = self._view_handCardList:AddItemFromPool() - end - self:fillCard2(btn_card, handCardName, tem_card) - local c_v = NewCardView(btn_card, tem_card) - c_v.index = i - c_v.old_postion = btn_card.xy - btn_card.data = c_v - btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin)) - btn_card.onTouchMove:Set(handler(self, self.onTouchMove)) - btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd)) - -- btn_card.onClick:Set(handler(self, self.__OnClickHandCard)) - end - - if getcard then - self._ctr_getCard.selectedIndex = 1 - else - self._ctr_getCard.selectedIndex = 0 - end - self._view_handCardList.onClickItem:Set(function(context) - self:__OnClickHandCard(context) - end) - ---------------------------------------------------------- -end - ----[[ ---新 -function M:UpdateOutCardList(outcard, card_item) - outcard = outcard or nil - card_item = card_item or 0 - - -- local outCardName = self._viewText_cardInfo['Out_Card'] - local outCardName = "202_" - local outcard - - local outlist = self._player.outcard_list - self._view_outCardList:RemoveChildren() - - for i = 0, #outlist - 1 do - outcard = self._view_outCardList:AddItemFromPool() - self:fillCard2(outcard, outCardName, outlist[i + 1]) - end -end - -function M:onTouchBegin(context) - local button = context.sender - self._touchPos = button.xy - local card = button.data - self._touchIndex = card.index - local xy = self._view_handCardList:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - card.touch_pos = xy - button.xy -end - -function M:onTouchMove(context) - local button = context.sender - - local card = button.data - local xy = self._view_handCardList:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - button.xy = xy - card.touch_pos -end - -function M:__OnDragEnd(context) - -- if self.outcard_button then - -- self.outcard_button:Dispose() - -- self.outcard_button = nil - -- end - local button = context.sender - -- -- button.onDragEnd:Set(nil) - -- --button:RemoveFromParent() - local card = button.data - local _room = DataManager.CurrenRoom - if not _room or _room:GetReloadStatus() then return end - - if (button.y < -150 and _room.curren_outcard_seat == _room.self_player.seat) then - self._mainView:OutCard(card.card_item) - button.touchable = false - self.outcard_button = button - button.xy = self._touchPos - else - if self._touchIndex ~= card.index then - -- local tempPos = self._touchPos - -- self._touchPos = button.xy - -- button:TweenMove(tempPos, 0.2) - else - button:TweenMove(self._touchPos, 0.2) - self._touchPos = -1 - self._touchIndex = -1 - end - end -end - -function M:__OnClickHandCard(context) - print("=======================lingmengclickhand") - self._ctr_seletedGet.selectedIndex = 1 - local button = context.data - -- local _carViewList = self._carViewList - -- for i = 1, #_carViewList do - -- if (_carViewList[i].card ~= button) then - -- _carViewList[i].card.selected = false - -- end - -- end - local _room = DataManager.CurrenRoom - if ((Utils.IsDoubleClick(context) or self._click_index == self._view_handCardList.selectedIndex) and _room.curren_outcard_seat == _room.self_player.seat) then - local card = button.data - self._mainView:OutCard(card.card_item) - self._view_handCardList.selectedIndex = -1 - self._click_index = self._view_handCardList.selectedIndex - self._ctr_seletedGet.selectedIndex = 0 - end - self._click_index = self._view_handCardList.selectedIndex -end - -function M:__OnClickGetCard(context) - self._view_handCardList.selectedIndex = -1 - local button = context.sender - local _room = DataManager.CurrenRoom - if (Utils.IsDoubleClick(context) and _room.curren_outcard_seat == _room.self_player.seat) then - local card = button.data - self._mainView:OutCard(card.card_item) - self._view_handCardList.selectedIndex = -1 - self._click_index = self._view_handCardList.selectedIndex - self._ctr_seletedGet.selectedIndex = 0 - end -end - -function M:UpdateFzList(fz, index, show_card) - local isFour = false - if fz.type == FZType.Gang or fz.type == FZType.Gang_An or fz.type == FZType.Gang_Peng then - isFour = true - end - - -- local FZame = self._viewText_cardInfo['FZ_Card'] - local FZame = "202_" - index = index or 0 - show_card = show_card or nil - - local outCard - - outCard = self._view_FZList:AddItemFromPool() - - if fz.type == FZType.Chi then - for i = 1, 3 do - local FZCard = outCard:GetChild(string.format("Comp_Card%d", i)) - self:fillCard2(FZCard, FZame, fz.opcard[i]) - end - else - local ctr_Four = outCard:GetController("isFour") - for i = 1, 3 do - local FZCard = outCard:GetChild(string.format("Comp_Card%d", i)) - self:fillCard2(FZCard, FZame, fz.card) - end - if fz.type == FZType.Peng then - ctr_Four.selectedIndex = 0 - else - ctr_Four.selectedIndex = 1 - local FZCard = outCard:GetChild(string.format("Comp_Card%d", 4)) - self:fillCard2(FZCard, FZame, fz.card) - if fz.type == FZType.Gang_An then - self:fillCard2(FZCard, FZame, '00') - elseif fz.type == FZType.Gang_Peng then - self._view_FZList:RemoveChildAt(self._view_FZList.numItems - 2) - end - end - end -end - ---]] - -function M:Clear(bskip) - --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:RemoveChildren(0, -1, true) - self._area_handcard_list:RemoveChildren(0, -1, true) - self._area_outcard_list:RemoveChildren(0, -1, true) - self._view_handCardList:RemoveChildren(0, -1, true) - self._view_outCardList:RemoveChildren(0, -1, true) - self._view_FZList:RemoveChildren(0, -1, true) - self._view_getCard:RemoveChildren(0, -1, true) - - self._view_handCardList.selectedIndex = -1 - self._click_index = self._view_handCardList.selectedIndex - self._ctr_seletedGet.selectedIndex = 0 - - 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 = {} -end - -return M diff --git a/lua_probject/extend_project/extend/majiang/nancheng/EXMainView.lua b/lua_probject/extend_project/extend/majiang/nancheng/EXMainView.lua index 585df5ce..87ff7045 100644 --- a/lua_probject/extend_project/extend/majiang/nancheng/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/nancheng/EXMainView.lua @@ -1,5 +1,5 @@ local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi") +local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local MJMainView = require("main.majiang.MJMainView") local TableBG = require("Game.Data.TableBG") local EXClearingView = import(".EXClearingView") diff --git a/lua_probject/extend_project/extend/majiang/nancheng/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/majiang/nancheng/EXPlayerInfoView.lua index 85850ecf..4cd18ffb 100644 --- a/lua_probject/extend_project/extend/majiang/nancheng/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/nancheng/EXPlayerInfoView.lua @@ -1,11 +1,11 @@ local PlayerInfoView = require("Game.View.PlayerInfoView") -local PlayerInfoView_copy = require("Game.View.PlayerInfoView_copy") +local PlayerInfoView2 = require("Game.View.PlayerInfoView2") local M = {} function M.new(view, mainView) if mainView._room.room_config.people_num == 2 then - setmetatable(M, { __index = PlayerInfoView_copy }) + setmetatable(M, { __index = PlayerInfoView2 }) else setmetatable(M, { __index = PlayerInfoView }) end @@ -17,7 +17,7 @@ function M.new(view, mainView) end function M:init() - PlayerInfoView_copy.init(self) + PlayerInfoView2.init(self) end function M:ShowInteraction(type, str) @@ -50,7 +50,7 @@ function M:UpdateRemainCard(card_num, hide) end function M:FillData(player) - PlayerInfoView_copy.FillData(self, player) + PlayerInfoView2.FillData(self, player) end function M:UpdateScore() diff --git a/lua_probject/extend_project/extend/majiang/nancheng/MJPlayerSelfCardInfoView.lua b/lua_probject/extend_project/extend/majiang/nancheng/MJPlayerSelfCardInfoView.lua index 0b215082..4fa39205 100644 --- a/lua_probject/extend_project/extend/majiang/nancheng/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/nancheng/MJPlayerSelfCardInfoView.lua @@ -1,5 +1,5 @@ -local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView_jiangxi") -local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView_jiangxi") +local MJPlayerSelfCardInfoView = require("main.majiang.MJPlayerSelfCardInfoView") +local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local CardCheck = import(".CardCheck") local M = {} diff --git a/lua_probject/extend_project/extend/poker/runfast/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/poker/runfast/EXPlayerInfoView.lua index 541ed751..4fccee69 100644 --- a/lua_probject/extend_project/extend/poker/runfast/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/poker/runfast/EXPlayerInfoView.lua @@ -1,4 +1,4 @@ -local PlayerInfoView = require("Game.View.PlayerInfoView_copy") +local PlayerInfoView = require("Game.View.PlayerInfoView2") local M = {} diff --git a/lua_probject/extend_project/extend/poker2/suoha/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/poker2/suoha/EXPlayerInfoView.lua index 541ed751..4fccee69 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/EXPlayerInfoView.lua @@ -1,4 +1,4 @@ -local PlayerInfoView = require("Game.View.PlayerInfoView_copy") +local PlayerInfoView = require("Game.View.PlayerInfoView2") local M = {} diff --git a/lua_probject/main_project/main/majiang/MJPlayerCardInfoView.lua b/lua_probject/main_project/main/majiang/MJPlayerCardInfoView.lua index 6d1c28e9..42041326 100644 --- a/lua_probject/main_project/main/majiang/MJPlayerCardInfoView.lua +++ b/lua_probject/main_project/main/majiang/MJPlayerCardInfoView.lua @@ -28,44 +28,15 @@ function M.new(view, mainView) end function M:init() - local view = self._view - local _area_mask = view:GetChild('area_mask') - local mask = _area_mask.text + local CardInfo = self._view:GetChild('Text_CardInfo') + self._viewText_cardInfo = json.decode(CardInfo.text) - self._mask_data = json.decode(mask) - self._area_handcard_list = view:GetChild('area_handcard_list') + self._view_handCardList = self._view:GetChild('List_HandCard') + self._view_FZList = self._view:GetChild('List_FZ') + self._view_outCardList = self._view:GetChild('List_OutCard') + self._view_getCard = self._view:GetChild('Comp_HandCard') - self._area_fz_list = view:GetChild('area_fz_list') - self._area_outcard_list = view:GetChild('area_outcard_list') - self._src_fz_list = - Vector4(self._area_fz_list.x, self._area_fz_list.y, self._area_fz_list.width, self._area_fz_list.height) - local c3d = self._view:GetController('3d') - if c3d ~= nil then - c3d.selectedIndex = 1 - end - self._src_fz_list_3d = - Vector4(self._area_fz_list.x, self._area_fz_list.y, self._area_fz_list.width, self._area_fz_list.height) - local c3d = self._view:GetController('3d') - if c3d ~= nil then - c3d.selectedIndex = 0 - end - - self._mask_liangpai = view:GetChild('mask_liangpai') - - local _gamectr = ControllerManager.GetController(GameController) - if _gamectr then - _gamectr:AddEventListener(GameEvent.MJModifySzie, handler(self, self.SetMJSize)) - end -end - -function M:SetMJSize(zS) - local tempSzieConfig = {} - tempSzieConfig.size = zS - local filename = 'mjsize' .. DataManager.SelfUser.account_id - Utils.SaveLocalFile(filename, json.encode(tempSzieConfig)) - - --ControllerManager.OnConnect(SocketCode.TimeoutDisconnect) - ViewManager.refreshGameView() + self._ctr_getCard = self._view:GetController('getCard') end function M:SetPlayer(p) @@ -74,6 +45,8 @@ end function M:FillData(begin) if (begin) then + print("lingmengResetFzList2") + pt(self._player) for i = 1, #self._player.fz_list do self:UpdateFzList(self._player.fz_list[i], -1) end @@ -97,15 +70,14 @@ end function M:Clear() --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:RemoveChildren(0, -1, true) - self._area_handcard_list:RemoveChildren(0, -1, true) - self._area_outcard_list:RemoveChildren(0, -1, true) - self._mask_liangpai:RemoveChildren(0, -1, true) + self._view_handCardList:RemoveChildren(0, -1, true) + self._view_outCardList:RemoveChildren(0, -1, true) + self._view_FZList:RemoveChildren(0, -1, true) + self._view_getCard:RemoveChildren(0, -1, true) + + self._view_handCardList.selectedIndex = -1 + self._click_index = self._view_handCardList.selectedIndex end -- 获取麻将资源前缀 @@ -131,6 +103,8 @@ function M:fillCard2(obj, pos_str, card) if DataManager.CurrenRoom.jing and card == DataManager.CurrenRoom.jing and obj:GetController('jing') then obj:GetController('jing').selectedIndex = 1 end + + obj:GetChild("icon").url = 'ui://Main_Majiang/' .. pos_str .. card end @@ -147,73 +121,18 @@ end function M:UpdateHandCard(getcard, mp) getcard = getcard or false mp = mp or false - local handcard_list = self._mask_data['handcard_list'] - local oder = handcard_list['oder'] - local _player = self._player - -- -- print(vardump(self._player)) - self._area_handcard_list:RemoveChildren(0, -1, true) - -- -- print(vardump(_player.card_list)) - if (not mp) then - local comp_back = handcard_list['comp_back'] - if self._current_card_type == 2 then - comp_back = comp_back .. '_3d' - end - - for i = 0, _player.hand_left_count - 1 do - local obj = UIPackage.CreateObjectFromURL(self:getBackCard(comp_back)) - local _room = DataManager.CurrenRoom - local people_num = _room.room_config.people_num - local pos = ViewUtil.GetPos(_room.self_player.seat, _player.seat, people_num) - local gap = (pos == 3 and people_num == 4 or pos == 2 and people_num == 2) and 15 or 45 - local offset = getcard and (i == _player.hand_left_count - 1 and gap or 0) - -- local offset = getcard and (i == _player.hand_left_count - 1 and 15 or 0) - ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset) - - --改变左右两边的手牌的x值 - if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then - obj.x = i * -7.0 - end - - if (oder == AreaOderType.down_up) then - self._area_handcard_list:AddChildAt(obj, 0) - else - self._area_handcard_list:AddChild(obj) - end - end - else - local outcard_list = self._mask_data['outcard_list'] - local comp = handcard_list['comp'] - local card = outcard_list['card'] - ---- print("comp"..comp) - -- -- print(vardump(_player.card_list)) - - if self._current_card_type == 2 then - comp = comp .. '_3d' - end - - for i = 0, #_player.card_list - 1 do - local obj = UIPackage.CreateObject('Main_Majiang', comp) - - self:fillCard(obj, card, _player.card_list[i + 1]) - -- obj.icon = UIPackage.GetItemURL("Main_Majiang", card .. _player.card_list[i+1]) - - local offset = getcard and (i == _player.hand_left_count - 1 and 0 or 0) - - ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset) - - --改变左右两边的手牌的x值 - if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then - obj.x = i * -7 - end - - if (oder == AreaOderType.down_up) then - self._area_handcard_list:AddChildAt(obj, 0) - else - self._area_handcard_list:AddChild(obj) - end + self._view_handCardList:RemoveChildren() + self._view_getCard:RemoveChildren() + for i = 0, self._player.hand_left_count - 1 do + if getcard and i == self._player.hand_left_count - 1 then + self._view_getCard:AddItemFromPool() + else + self._view_handCardList:AddItemFromPool() end end + self._ctr_getCard.selectedIndex = getcard and 1 or 0 + print("lingmenghand", self._ctr_getCard.selectedIndex, self._view_getCard.numItems, self._view_getCard.visible) end -- 获取麻将图片资源位置,可以在扩展中复写 @@ -261,91 +180,15 @@ function M:UpdateOutCardList(outcard, card_item, cursor) card_item = card_item or 0 cursor = cursor or nil + local outCardName = self._viewText_cardInfo['Out_Card'] + local outlist = self._player.outcard_list - if (outcard) then - outcard:SetPivot(0.5, 0.5, true) - outcard.touchable = false - -- outcard.icon = "ui://Main_Majiang/" .. self:GetPrefix() .. "202_" .. card_item - outcard.icon = string.format('ui://%s/%s202_%s', self:GetCardPicPack(), self:GetPrefix(), card_item) - self._mask_liangpai:AddChild(outcard) - end - local outcard_list = self._mask_data['outcard_list'] - local oder = outcard_list['oder'] - local comp = outcard_list['comp'] - local card = outcard_list['card'] - local multi_oder = outcard_list['multi_oder'] - local num = outcard_list['num'] - local multi_draw_oder = 0 - local sortStart = 0 - local sortType = 0 - local sortStep = 0 - if (outcard_list['multi_draw_oder']) then - multi_draw_oder = outcard_list['multi_draw_oder'] - end + self._view_outCardList:RemoveChildrenToPool() - if self._current_card_type == 2 then - comp = comp .. '_3d' - num = outcard_list['num3d'] - multi_oder = outcard_list['multi_oder3d'] - sortType = outcard_list['sorting_order3d'] - card = outcard_list['card3d'] - if sortType == 1 then - sortStart = 1 - sortStep = 1 - elseif sortType == -1 then - sortStart = #outlist - sortStep = -1 - end - end - - local obj = nil - self._area_outcard_list:RemoveChildren(0, -1, true) for i = 0, #outlist - 1 do - obj = UIPackage.CreateObjectFromURL('ui://Main_Majiang/' .. comp) - local row = math.floor(i / num) - local col = math.floor(i % num) - - if self._current_card_type == 2 then - if i >= num then - row = 1 + math.floor(((i - num) / (num + 2))) - col = ((i - num) % (num + 2)) - end - end - if DataManager.CurrenRoom.room_config.people_num == 2 then - ViewUtil.CardPos(obj, self._area_outcard_list, oder, col, nil, nil, -6) - ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row, nil, nil, -12) - elseif DataManager.CurrenRoom.room_config.people_num == 4 then - ViewUtil.CardPos(obj, self._area_outcard_list, oder, col, nil, nil, -6) - ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row, nil, nil, -12) - else - ViewUtil.CardPos(obj, self._area_outcard_list, oder, col) - ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row) - end - - - if self._current_card_type == 2 then - self:adjust3dOutPut(obj, self._area_outcard_list, oder, num, i) - end - - self:fillCard(obj, card, outlist[i + 1]) - -- 添加角标 - self:AddFlag(i + 1, outlist[i], obj) - -- obj.icon = "ui://Main_Majiang/"..card .. outlist[i+1] - sortStart = sortStart + sortStep - obj.sortingOrder = sortStart - obj.data = outlist[i + 1] - - if (oder == AreaOderType.down_up or (multi_draw_oder == 1)) then - self._area_outcard_list:AddChildAt(obj, 0) - else - self._area_outcard_list:AddChild(obj) - end - end - if (obj and cursor) then - cursor.xy = Vector2(obj.width / 2, obj.height / 2) - obj:AddChild(cursor) - obj:GetController('color').selectedIndex = 1 + local outcard = self._view_outCardList:AddItemFromPool() + self:fillCard2(outcard, outCardName, outlist[i + 1]) end end @@ -377,155 +220,54 @@ local function getPos(my_seat, other_seat, total) end function M:UpdateFzList(fz, index, show_card) - local gn = 3 - if fz.type == FZType.Gang or fz.type == FZType.Gang_An or fz.type == FZType.Gang_Peng then - gn = 4 - end + local room = DataManager.CurrenRoom + -- local seat = (room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1 + local seat = ViewUtil.GetPos(room.self_player.seat, fz.from_seat, room.room_config.people_num) + seat = (room.room_config.people_num == 2 and seat == 2) and 2 or seat - 1 + print("lingmengUpdateFzList", fz, index, show_card, seat) + local FZame = self._viewText_cardInfo['FZ_Card'] + index = index or 0 + show_card = show_card or nil - local fz_list = self._mask_data['fz_list'] - local oder = fz_list['oder'] - local comp = fz_list['comp'] .. gn - local card = fz_list['card'] - local card3d = '' - local adjust3d = 0 - if self._current_card_type == 2 then - comp = comp .. '_3d' - oder = fz_list['oder3d'] - adjust3d = fz_list['adjust3d'] - card = fz_list['card3d'] - card3d = 'b' - end - - local obj = UIPackage.CreateObjectFromURL('ui://Main_Majiang/' .. comp) - -- print("============================================pengpengpeng", comp) - - local _area_fz_list = self._area_fz_list - local _area_outcard_list = self._area_outcard_list - - if (index == -1) then - local num = _area_fz_list.numChildren - - if (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then - _area_fz_list.height = _area_fz_list.height + obj.height - if (oder == AreaOderType.down_up) then - local tem1 = obj.height - for i = 1, num do - local tem = _area_fz_list:GetChildAt(num - i) - tem.y = tem.y + tem1 - end - _area_fz_list.y = _area_fz_list.y - obj.height - else - ViewUtil.CardPos(obj, _area_outcard_list, oder, num) - end - elseif (oder == AreaOderType.left_right or oder == AreaOderType.right_left) then - _area_fz_list.width = _area_fz_list.width + obj.width - if (oder == AreaOderType.right_left) then - local tem1 = obj.width - for i = 1, num do - local tem = _area_fz_list:GetChildAt(num - i) - tem.x = tem.x + tem1 - end - _area_fz_list.x = _area_fz_list.x - obj.width - else - ViewUtil.CardPos(obj, _area_outcard_list, oder, num) - end - end - _area_fz_list:AddChild(obj) - - if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then - num = _area_fz_list.numChildren - for i = 1, num do - local tem = _area_fz_list:GetChildAt(i - 1) - tem.x = adjust3d * (i - 1) - end + local outCard = self._view_FZList:AddItemFromPool() + outCard:GetController("seat").selectedIndex = seat or 0 + if fz.type == FZType.Chi then + for i = 1, 3 do + local FZCard = outCard:GetChild(string.format("Comp_Card%d", i)) + self:fillCard2(FZCard, FZame, fz.opcard[i]) end else - local obj1 = _area_fz_list:RemoveChildAt(index) - obj1:Dispose() - obj.xy = obj1.xy - _area_fz_list:AddChildAt(obj, index) - end + local ctr_Four = outCard:GetController("isFour") + outCard.data = fz.card - -- 显示fz的牌 - local obj_show - if show_card then - obj_show = UIPackage.CreateObjectFromURL('ui://Main_Majiang/Fz_0_' .. gn) - end - - for i = 1, gn do - local _oc = obj:GetChild('card_' .. i) - local _oc2 = nil - - if show_card then - _oc2 = obj_show:GetChild('card_' .. i) + for i = 1, 3 do + local FZCard = outCard:GetChild(string.format("Comp_Card%d", i)) + self:fillCard2(FZCard, FZame, fz.card) end - - if (fz.type == FZType.Gang_An and i == gn) then - if self._current_card_type == 2 then - _oc.icon = UIPackage.GetItemURL('MajiangCard3d', card3d .. card .. '00') - else - _oc.icon = UIPackage.GetItemURL(self:GetCardPicPack(), card3d .. card .. '00') - end - - if show_card then - _oc2.icon = UIPackage.GetItemURL('Main_Majiang', '202_00') - end + if fz.type == FZType.Peng then + ctr_Four.selectedIndex = 0 else - if (fz.type == FZType.Chi) then - local index = i - if oder == AreaOderType.right_left or oder == AreaOderType.down_up then - index = gn - i + 1 + ctr_Four.selectedIndex = 1 + local FZCard = outCard:GetChild(string.format("Comp_Card%d", 4)) + self:fillCard2(FZCard, FZame, fz.card) + if fz.type == FZType.Gang_An then + self:fillCard2(FZCard, FZame, '00') + if FZCard:GetController('jing') then + FZCard:GetController('jing').selectedIndex = 0 end - - self:fillCard(_oc, card, fz.opcard[index]) - - if show_card then - self:fillCard(_oc2, '202_', fz.opcard[index], false) - end - else - self:fillCard(_oc, card, fz.card) - - if show_card then - self:fillCard(_oc2, '202_', fz.card, false) + elseif fz.type == FZType.Gang_Peng then + for i = 1, self._view_FZList.numItems do + if self._view_FZList:GetChildAt(i - 1).data and self._view_FZList:GetChildAt(i - 1).data == fz.card then + outCard:GetController("seat").selectedIndex = self._view_FZList:GetChildAt(i - 1):GetController( + "seat").selectedIndex + self._view_FZList:RemoveChildrenToPool(i - 1, i - 1) + return + end end end end end - - obj.touchable = false - - if show_card then - obj_show.touchable = false - obj_show:SetPivot(0.5, 0.5, true) - obj_show:SetScale(0.8, 0.8) - self._mask_liangpai:AddChildAt(obj_show, 0) - coroutine.start( - function() - coroutine.wait(2) - obj_show:Dispose() - end - ) - end - - -- -- 标记碰牌对象 - -- local num = self._area_fz_list.numChildren - -- if num == 0 then return end - -- if index == -1 then - -- -- local obj = self._area_fz_list:GetChildAt(num - 1) - -- local pic_arrow = UIPackage.CreateObjectFromURL("ui://Main_Majiang/com_arrow") - -- obj:AddChild(pic_arrow) - -- pic_arrow:Center() - -- local my_seat = self._player.seat - -- if fz.from_seat ~= my_seat then - -- pic_arrow:GetController("show").selectedIndex = 1 - -- pic_arrow:GetController("pos").selectedIndex = getPos(DataManager.CurrenRoom.self_player.seat, fz.from_seat, #DataManager.CurrenRoom.player_list) - -- pic_arrow:SetPivot(0.5, 0.5) - -- if DataManager.CurrenRoom.self_player.seat ~= self._player.seat then - -- pic_arrow.scaleX = 0.5 - -- pic_arrow.scaleY = 0.5 - -- end - -- end - -- end + -- self:fillCard2(outcard, outCardName, card_item) end function M:GetOutCardByIndex(index) @@ -545,6 +287,8 @@ end function M:ResetFzList() for i = 1, #self._player.fz_list do + print("lingmengResetFzList") + pt(self._player) local fz = self._player.fz_list[i] -- if fz.type ~= FZType.Gang_Peng then self:UpdateFzList(fz, -1) @@ -569,67 +313,67 @@ local function replace_card(obj, prefix) end function M:ResetCardType() - local old_card_type = self._current_card_type - self._current_card_type = DataManager.CurrenRoom.card_type + -- local old_card_type = self._current_card_type + -- self._current_card_type = DataManager.CurrenRoom.card_type - --设置3d标志 - if self._current_card_type == 2 then - local c3d = self._view:GetController('3d') - if c3d ~= nil then - c3d.selectedIndex = 1 + -- --设置3d标志 + -- if self._current_card_type == 2 then + -- local c3d = self._view:GetController('3d') + -- if c3d ~= nil then + -- c3d.selectedIndex = 1 - self._area_fz_list.x = self._src_fz_list_3d.x - self._area_fz_list.y = self._src_fz_list_3d.y - self._area_fz_list.width = self._src_fz_list_3d.z - self._area_fz_list.height = self._src_fz_list_3d.w - end - else - local c3d = self._view:GetController('3d') - if c3d ~= nil then - c3d.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 - end - end + -- self._area_fz_list.x = self._src_fz_list_3d.x + -- self._area_fz_list.y = self._src_fz_list_3d.y + -- self._area_fz_list.width = self._src_fz_list_3d.z + -- self._area_fz_list.height = self._src_fz_list_3d.w + -- end + -- else + -- local c3d = self._view:GetController('3d') + -- if c3d ~= nil then + -- c3d.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 + -- end + -- end - local change2d = false - if old_card_type == 2 and self._current_card_type ~= 2 then - change2d = true - end + -- local change2d = false + -- if old_card_type == 2 and self._current_card_type ~= 2 then + -- change2d = true + -- end - local change3d = false - if old_card_type ~= 2 and self._current_card_type == 2 then - change3d = true - end + -- local change3d = false + -- if old_card_type ~= 2 and self._current_card_type == 2 then + -- change3d = true + -- end - if change2d == false and change3d == false and self._current_card_type ~= 2 then - local prefix = self:GetPrefix() + -- if change2d == false and change3d == false and self._current_card_type ~= 2 then + -- local prefix = self:GetPrefix() - --更新已出牌 - for i = 1, self._area_outcard_list.numChildren do - local obj = self._area_outcard_list:GetChildAt(i - 1) - replace_card(obj, prefix) - end + -- --更新已出牌 + -- for i = 1, self._area_outcard_list.numChildren do + -- local obj = self._area_outcard_list:GetChildAt(i - 1) + -- replace_card(obj, prefix) + -- end - --更新手牌 - for i = 1, self._area_handcard_list.numChildren do - local obj = self._area_handcard_list:GetChildAt(i - 1) - replace_card(obj, prefix) - end + -- --更新手牌 + -- for i = 1, self._area_handcard_list.numChildren do + -- local obj = self._area_handcard_list:GetChildAt(i - 1) + -- replace_card(obj, prefix) + -- end - --更新放子牌 - for i = 1, self._area_fz_list.numChildren do - local com = self._area_fz_list:GetChildAt(i - 1) - for j = 1, 4 do - local obj = com:GetChild('card_' .. j) - if obj then - replace_card(obj, prefix) - end - end - end - end + -- --更新放子牌 + -- for i = 1, self._area_fz_list.numChildren do + -- local com = self._area_fz_list:GetChildAt(i - 1) + -- for j = 1, 4 do + -- local obj = com:GetChild('card_' .. j) + -- if obj then + -- replace_card(obj, prefix) + -- end + -- end + -- end + -- end end return M diff --git a/lua_probject/main_project/main/majiang/MJPlayerCardInfoView_jiangxi.lua b/lua_probject/main_project/main/majiang/MJPlayerCardInfoView_jiangxi.lua deleted file mode 100644 index 42041326..00000000 --- a/lua_probject/main_project/main/majiang/MJPlayerCardInfoView_jiangxi.lua +++ /dev/null @@ -1,379 +0,0 @@ -AreaOderType = { - left_right = 'left_right', - right_left = 'right_left', - up_down = 'up_down', - down_up = 'down_up' -} - -local PlayerCardInfoView = { - _view = nil, - _mainView = nil, - _mask_liangpai = nil, - _mask_data = nil, - _area_handcard_list = nil, - _src_fz_list = nil, - _current_card_type = -1 -} - -local M = PlayerCardInfoView - ---- Create a new PlayerCardInfoView -function M.new(view, mainView) - local self = {} - setmetatable(self, { __index = M }) - self._view = view - self._mainView = mainView - self:init() - return self -end - -function M:init() - local CardInfo = self._view:GetChild('Text_CardInfo') - self._viewText_cardInfo = json.decode(CardInfo.text) - - self._view_handCardList = self._view:GetChild('List_HandCard') - self._view_FZList = self._view:GetChild('List_FZ') - self._view_outCardList = self._view:GetChild('List_OutCard') - self._view_getCard = self._view:GetChild('Comp_HandCard') - - self._ctr_getCard = self._view:GetController('getCard') -end - -function M:SetPlayer(p) - self._player = p -end - -function M:FillData(begin) - if (begin) then - print("lingmengResetFzList2") - pt(self._player) - for i = 1, #self._player.fz_list do - self:UpdateFzList(self._player.fz_list[i], -1) - end - self:UpdateOutCardList() - else - self._current_card_type = DataManager.CurrenRoom.card_type - - if self._current_card_type == 2 then - local c3d = self._view:GetController('3d') - if c3d ~= nil then - c3d.selectedIndex = 1 - end - else - local c3d = self._view:GetController('3d') - if c3d ~= nil then - c3d.selectedIndex = 0 - end - end - end -end - -function M:Clear() - --self._ctr_state.selectedIndex = 0 - - self._view_handCardList:RemoveChildren(0, -1, true) - self._view_outCardList:RemoveChildren(0, -1, true) - self._view_FZList:RemoveChildren(0, -1, true) - self._view_getCard:RemoveChildren(0, -1, true) - - self._view_handCardList.selectedIndex = -1 - self._click_index = self._view_handCardList.selectedIndex -end - --- 获取麻将资源前缀 -function M:GetPrefix() - -- local card_type = DataManager.CurrenRoom.card_type - -- local prefix = card_type == 1 and "a" or "" - -- return prefix - return get_majiang_prefix(DataManager.CurrenRoom.game_id) -end - -function M:fillCard(obj, pos_str, card, use3d) - if DataManager.CurrenRoom.jing and card == DataManager.CurrenRoom.jing and obj:GetController('jing') then - obj:GetController('jing').selectedIndex = 1 - end - if self._current_card_type == 2 and (use3d == nil or use3d == true) then - obj.icon = 'ui://MajiangCard3d/' .. 'b' .. pos_str .. card - else - obj.icon = 'ui://Main_Majiang/' .. self:GetPrefix() .. pos_str .. card - end -end - -function M:fillCard2(obj, pos_str, card) - if DataManager.CurrenRoom.jing and card == DataManager.CurrenRoom.jing and obj:GetController('jing') then - obj:GetController('jing').selectedIndex = 1 - end - - - obj:GetChild("icon").url = 'ui://Main_Majiang/' .. pos_str .. card -end - -function M:getBackCard(card) - return 'ui://Main_Majiang/' .. card -end - -function M:GetCard(btn) - local pic_name = split(btn.icon, '/')[4] - local lst = string.split(pic_name, '_') - return tonumber(lst[2] or 0) -end - -function M:UpdateHandCard(getcard, mp) - getcard = getcard or false - mp = mp or false - - self._view_handCardList:RemoveChildren() - self._view_getCard:RemoveChildren() - for i = 0, self._player.hand_left_count - 1 do - if getcard and i == self._player.hand_left_count - 1 then - self._view_getCard:AddItemFromPool() - else - self._view_handCardList:AddItemFromPool() - end - end - self._ctr_getCard.selectedIndex = getcard and 1 or 0 - print("lingmenghand", self._ctr_getCard.selectedIndex, self._view_getCard.numItems, self._view_getCard.visible) -end - --- 获取麻将图片资源位置,可以在扩展中复写 -function M:GetCardPicPack() - -- if DataManager.CurrenRoom.card_type == 2 then - -- return "MajiangCard3d" - -- else - return 'Main_Majiang' - -- end -end - -function M:adjust3dOutPut(obj, area, oder, num, index) - if index >= num then - local row = 1 + math.floor(((index - num) / (num + 2))) - local col = ((index - num) % (num + 2)) - - if oder == AreaOderType.left_right then - obj.x = obj.x + math.floor((area.width - obj.width * (num + 2)) / 2) - elseif oder == AreaOderType.right_left then - obj.x = obj.x - math.floor((area.width - obj.width * (num + 2)) / 2) - elseif oder == AreaOderType.up_down then - obj.y = obj.y + math.floor((area.height - obj.height * (num + 2)) / 2) - obj.x = obj.x - col * 7 + 7 * (row + 1) - elseif oder == AreaOderType.down_up then - obj.y = obj.y - math.floor((area.height - obj.height * (num + 2)) / 2) - obj.x = obj.x - col * 7 - 7 * (row - 1) - end - else - if oder == AreaOderType.left_right then - obj.x = obj.x + math.floor((area.width - obj.width * num) / 2) - elseif oder == AreaOderType.right_left then - obj.x = obj.x - math.floor((area.width - obj.width * num) / 2) - elseif oder == AreaOderType.up_down then - obj.y = obj.y + math.floor((area.height - obj.height * num) / 2) - obj.x = obj.x - index * 7 - elseif oder == AreaOderType.down_up then - obj.y = obj.y - math.floor((area.height - obj.height * num) / 2) - obj.x = obj.x - index * 7 - end - end -end - -function M:UpdateOutCardList(outcard, card_item, cursor) - outcard = outcard or nil - card_item = card_item or 0 - cursor = cursor or nil - - local outCardName = self._viewText_cardInfo['Out_Card'] - - local outlist = self._player.outcard_list - - self._view_outCardList:RemoveChildrenToPool() - - for i = 0, #outlist - 1 do - local outcard = self._view_outCardList:AddItemFromPool() - self:fillCard2(outcard, outCardName, outlist[i + 1]) - end -end - --- 设置添加角标的方法 -function M:SetAddFlag(cb) - self.__addFlag = cb -end - --- 给麻将牌添加flag -function M:AddFlag(index, card, btn) - if not self.__addFlag then - return - end - local str_flag = self.__addFlag(index, card, btn) - btn:GetController('hun').selectedIndex = str_flag == '' and 0 or 1 - btn:GetChild('flag').icon = str_flag -end - -local function getPos(my_seat, other_seat, total) - local pos = 0 - pos = other_seat - my_seat + 1 - if pos <= 0 then - pos = pos + total - end - if total ~= 4 and pos == total then - pos = total + 1 - end - return pos -end - -function M:UpdateFzList(fz, index, show_card) - local room = DataManager.CurrenRoom - -- local seat = (room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1 - local seat = ViewUtil.GetPos(room.self_player.seat, fz.from_seat, room.room_config.people_num) - seat = (room.room_config.people_num == 2 and seat == 2) and 2 or seat - 1 - print("lingmengUpdateFzList", fz, index, show_card, seat) - local FZame = self._viewText_cardInfo['FZ_Card'] - index = index or 0 - show_card = show_card or nil - - local outCard = self._view_FZList:AddItemFromPool() - outCard:GetController("seat").selectedIndex = seat or 0 - if fz.type == FZType.Chi then - for i = 1, 3 do - local FZCard = outCard:GetChild(string.format("Comp_Card%d", i)) - self:fillCard2(FZCard, FZame, fz.opcard[i]) - end - else - local ctr_Four = outCard:GetController("isFour") - outCard.data = fz.card - - for i = 1, 3 do - local FZCard = outCard:GetChild(string.format("Comp_Card%d", i)) - self:fillCard2(FZCard, FZame, fz.card) - end - if fz.type == FZType.Peng then - ctr_Four.selectedIndex = 0 - else - ctr_Four.selectedIndex = 1 - local FZCard = outCard:GetChild(string.format("Comp_Card%d", 4)) - self:fillCard2(FZCard, FZame, fz.card) - if fz.type == FZType.Gang_An then - self:fillCard2(FZCard, FZame, '00') - if FZCard:GetController('jing') then - FZCard:GetController('jing').selectedIndex = 0 - end - elseif fz.type == FZType.Gang_Peng then - for i = 1, self._view_FZList.numItems do - if self._view_FZList:GetChildAt(i - 1).data and self._view_FZList:GetChildAt(i - 1).data == fz.card then - outCard:GetController("seat").selectedIndex = self._view_FZList:GetChildAt(i - 1):GetController( - "seat").selectedIndex - self._view_FZList:RemoveChildrenToPool(i - 1, i - 1) - return - end - end - end - end - end - -- self:fillCard2(outcard, outCardName, card_item) -end - -function M:GetOutCardByIndex(index) - local outcard_list = self._mask_data['outcard_list'] - local oder = outcard_list['oder'] - local multi_draw_oder = 0 - if (outcard_list['multi_draw_oder']) then - multi_draw_oder = outcard_list['multi_draw_oder'] - end - - if (oder == AreaOderType.down_up or (multi_draw_oder == 1)) then - return self._area_outcard_list:GetChildAt(self._area_outcard_list.numChildren - index) - else - return self._area_outcard_list:GetChildAt(index - 1) - end -end - -function M:ResetFzList() - for i = 1, #self._player.fz_list do - print("lingmengResetFzList") - pt(self._player) - local fz = self._player.fz_list[i] - -- if fz.type ~= FZType.Gang_Peng then - self:UpdateFzList(fz, -1) - -- else - -- self:UpdateFzList(fz, i) - -- end - end -end - -local function replace_card(obj, prefix) - local url = obj.icon - if url then - local len = string.len(url) - local pos = string.len('ui://Main_Majiang/') + 1 - local head_char = string.sub(url, pos, pos) - local card = string.sub(url, pos, len) - if head_char >= 'a' then - card = string.sub(card, 2, len) - end - obj.icon = 'ui://Main_Majiang/' .. prefix .. card - end -end - -function M:ResetCardType() - -- local old_card_type = self._current_card_type - -- self._current_card_type = DataManager.CurrenRoom.card_type - - -- --设置3d标志 - -- if self._current_card_type == 2 then - -- local c3d = self._view:GetController('3d') - -- if c3d ~= nil then - -- c3d.selectedIndex = 1 - - -- self._area_fz_list.x = self._src_fz_list_3d.x - -- self._area_fz_list.y = self._src_fz_list_3d.y - -- self._area_fz_list.width = self._src_fz_list_3d.z - -- self._area_fz_list.height = self._src_fz_list_3d.w - -- end - -- else - -- local c3d = self._view:GetController('3d') - -- if c3d ~= nil then - -- c3d.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 - -- end - -- end - - -- local change2d = false - -- if old_card_type == 2 and self._current_card_type ~= 2 then - -- change2d = true - -- end - - -- local change3d = false - -- if old_card_type ~= 2 and self._current_card_type == 2 then - -- change3d = true - -- end - - -- if change2d == false and change3d == false and self._current_card_type ~= 2 then - -- local prefix = self:GetPrefix() - - -- --更新已出牌 - -- for i = 1, self._area_outcard_list.numChildren do - -- local obj = self._area_outcard_list:GetChildAt(i - 1) - -- replace_card(obj, prefix) - -- end - - -- --更新手牌 - -- for i = 1, self._area_handcard_list.numChildren do - -- local obj = self._area_handcard_list:GetChildAt(i - 1) - -- replace_card(obj, prefix) - -- end - - -- --更新放子牌 - -- for i = 1, self._area_fz_list.numChildren do - -- local com = self._area_fz_list:GetChildAt(i - 1) - -- for j = 1, 4 do - -- local obj = com:GetChild('card_' .. j) - -- if obj then - -- replace_card(obj, prefix) - -- end - -- end - -- end - -- end -end - -return M diff --git a/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView.lua b/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView.lua index bbfc7933..f428544a 100644 --- a/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView.lua +++ b/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView.lua @@ -37,177 +37,286 @@ end function M:init() MJPlayerCardInfoView.init(self) - local filename = 'mjsize' .. DataManager.SelfUser.account_id - local json_data = Utils.LoadLocalFile(filename) - if json_data then - local _data = json.decode(json_data) - if _data.size == 0 then - self._area_handcard_list:SetScale(1, 1.1) - self._area_fz_list:SetScale(0.6, 0.6) - elseif _data.size == 1 then - self._area_handcard_list:SetScale(1, 1) - self._area_fz_list:SetScale(1, 1) - elseif _data.size == 2 then - self._area_handcard_list:SetScale(0.8, 0.8) - self._area_fz_list:SetScale(0.8, 0.8) - end - end + self._view_getCard = self._view:GetChild('Btn_HandCard') + self._view_FZTips = self._view:GetChild('Comp_FZTips') + self._area_allDown = self._view:GetChild('area_allDown') + + self._ctr_seletedGet = self._view:GetController('seletedGetCard') + self._ctr_tip = self._view:GetController('tip') + + self._area_allDown.onClick:Set(function() + self._view_handCardList.selectedIndex = -1 + self._click_index = self._view_handCardList.selectedIndex + self._ctr_seletedGet.selectedIndex = 1 + end) end -function M:setHandCardPos(btn_card, i, getcard) - if DataManager.CurrenRoom.room_config.people_num == 2 then - btn_card.x = i * (btn_card.width - 12) + (getcard and 20 or 0) - elseif DataManager.CurrenRoom.room_config.people_num == 4 then - btn_card.x = i * (btn_card.width - 12) + (getcard and 20 or 0) - else - btn_card.x = i * btn_card.width * 1.05 + (getcard and 20 or 0) +function M:ShowHuTip(card_list) + printlog("ShowHuTip") + local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, + DataManager.CurrenRoom.room_config.Laizi) + pt(tingList) + if #tingList > 0 then + if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then + for i = 1, #DataManager.CurrenRoom.laiziInfo do + if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then + table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) + end + end + end end + self._mainView._hu_tip:FillData(tingList) end function M:UpdateHandCard(getcard, mp) - print("==========================UpdateHandCardold", getcard, mp) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil - end + local _carViewList = self._carViewList + local card_list = DataManager.CurrenRoom.self_player.card_list + getcard = getcard or false mp = mp or false - local pv = self - local _carViewList = self._carViewList + self.getcard = getcard - local _lit = pv._area_handcard_list - for i = 1, #_carViewList do - _carViewList[i].card:Dispose() + if self._view_handCardList.numItems > 0 then + self._view_handCardList:RemoveChildren() end - _carViewList = {} - local _dragCom = self._dragCom - if (_dragCom == nil) then - _dragCom = UIPackage.CreateObject("Common", "UIPanel") - _dragCom.size = Vector2(1, 1) - pv._view:AddChild(_dragCom) - end - _dragCom.xy = pv._area_handcard_list.xy - self._dragCom = _dragCom - self._carViewList = _carViewList - - local b3d = "" - if self._current_card_type == 2 then - b3d = "_3d" + if self._view_getCard.numItems > 0 then + self._view_getCard:RemoveChildren() end - local _room = DataManager.CurrenRoom - local cards = _room.self_player.card_list - - if (not mp) then - for i = 0, (#cards) - 1 do - local tem_card = cards[i + 1] - local btn_card = nil - if _room.room_config.people_num == 2 then - btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card_jiangxi" .. b3d) - elseif _room.room_config.people_num == 4 then - btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card_new_4" .. b3d) - else - btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d) - btn_card:SetScale(1.05, 1.05) - end - - -- btn_card.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. tem_card) - self:fillCard(btn_card, "201_", tem_card) - self:setHandCardPos(btn_card, i, i == #cards - 1 and getcard) - local c_v = NewCardView(btn_card, tem_card) - c_v.index = i - c_v.old_postion = btn_card.xy - _carViewList[#_carViewList + 1] = c_v - - _lit:AddChild(btn_card) - - if (not self._player.auto_out_card) then - btn_card.data = c_v - -- btn_card.draggable = true; - -- btn_card.onDragStart:Set(function(evt) - -- local _agent = evt.sender - -- _agent:RemoveFromParent() - -- _dragCom:AddChild(_agent) - -- if self.__OnDragStart then - -- self:__OnDragStart(evt) - -- end - -- _agent.onDragEnd:Set(self.__OnDragEnd,self) - -- end) - btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin)) - btn_card.onTouchMove:Set(handler(self, self.onTouchMove)) - btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd)) - btn_card.onClick:Set(self.__OnClickHandCard, self) - else - btn_card:GetChild("icon").color = Color(0.5, 0.5, 0.5) - btn_card.touchable = false - end + for i = 0, (#card_list) - 1 do + local tem_card = card_list[i + 1] + local btn_card + if getcard and i == (#card_list) - 1 then + btn_card = self._view_getCard:AddItemFromPool() + btn_card.onClick:Add(function(context) + self:__OnClickGetCard(context) + end) + else + btn_card = self._view_handCardList:AddItemFromPool() end + self:FillHandCard(i, btn_card, tem_card, true) + -- btn_card.onClick:Set(handler(self, self.__OnClickHandCard)) + end + + if getcard then + self._ctr_getCard.selectedIndex = 1 else - for i = 0, (#cards) - 1 do - local mp_card = UIPackage.CreateObject("Main_Majiang", "Mp_self_card" .. b3d) - -- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1]) - self:fillCard(mp_card, "202_", cards[i + 1]) - mp_card:SetScale(1.05, 1.05) - -- mp_card.x = i * mp_card.width + (i == #cards - 1 and getcard and 20 or 0) - self:setHandCardPos(mp_card, i, i == #cards - 1 and getcard) - _lit:AddChild(mp_card) - end + self._ctr_getCard.selectedIndex = 0 + end + self._view_handCardList.onClickItem:Set(function(context) + self:__OnClickHandCard(context) + end) + + self:ClearMove() +end + +function M:FillHandCard(i, btn_card, tem_card, event) + local handCardName = self._viewText_cardInfo['Hand_Card'] + + self:fillCard2(btn_card, handCardName, tem_card) + local c_v = NewCardView(btn_card, tem_card) + c_v.index = i + c_v.old_postion = btn_card.xy + c_v.touch_pos = Vector2.New(btn_card.width / 2, btn_card.height / 2) + btn_card.data = c_v + if event then + btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin)) + btn_card.onTouchMove:Set(handler(self, self.onTouchMove)) + btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd)) end end function M:onTouchBegin(context) + self.touch = true local button = context.sender - local card = button.data - local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - card.touch_pos = xy - button.xy - if self.__OnDragStart then - self:__OnDragStart(card.card_item) - end + self.touchPos = Vector2.New(context.inputEvent.x, context.inputEvent.y) end function M:onTouchMove(context) local button = context.sender + local xy = self._view_handCardList:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + self.touchStart = true + if xy.y <= -35 or self.isMoive then + self.isMoive = true + if self.touch then + if self.ischoose then + if self._ctr_seletedGet.selectedIndex == 0 then + button = self._view_getCard:GetChildAt(0) + else + button = self._view_handCardList:GetChildAt(self._view_handCardList.selectedIndex) + end + end + local xy_event = Vector2.New(context.inputEvent.x, context.inputEvent.y) + local xy_btnCard = self._view_getCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + if self.__OnDragStart then + self:__OnDragStart(button, xy_event) + end + self.touch = false + end + self:outCardMove(context) + else + local touchPos = self._view_handCardList:GetChildAt(0):GlobalToLocal(Vector2.New(context.inputEvent.x, + context.inputEvent.y)) + if touchPos.x < 0 then + return + end + local cardWidth = button.width; + local grap = self._view_handCardList.columnGap + local chooseIndex = math.floor(touchPos.x / (cardWidth + grap)) + + if chooseIndex >= self._view_handCardList.numItems then + self.ischoose = true + if touchPos.x > cardWidth + (cardWidth + grap) * (self._view_handCardList.numItems - 1) and self.getcard then + self:ChooseOut() + else + if self._view_handCardList.selectedIndex ~= self._view_handCardList.numItems - 1 then + self:ChooseHand(self._view_handCardList.numItems - 1) + end + end + else + print("lingmengonTouchMove", chooseIndex, self._view_handCardList.numItems) + + self.ischoose = true + if self._view_handCardList.selectedIndex ~= chooseIndex then + self:ChooseHand(chooseIndex) + else + + end + end + end + + -- local card = button.data + -- local xy = GRoot.inst:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + -- button.xy = xy - card.touch_pos +end + +function M:__OnDragStart(button, xy_event, isGet) + button:GetController('move').selectedIndex = 1 + local card = button.data - local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - button.xy = xy - card.touch_pos + --复制一个按钮 + + local btn_card = self._view_getCard:GetFromPool(nil) + self._outCardMove = btn_card + + self:FillHandCard(card.index, btn_card, card.card_item, false) + + local xy = GRoot.inst:GlobalToLocal(xy_event) + + --将虚影按钮替换移动的按钮 + -- GRoot.inst:BringToFront(button) + GRoot.inst:AddChild(btn_card) + self._outCardMove.data = card + self._outCardMove.xy = xy - card.touch_pos + --设置弹起 + -- if isGet then + -- self._view_handCardList.selectedIndex = -1 + -- self._ctr_seletedGet.selectedIndex = 0 + -- else + -- self._view_handCardList.selectedIndex = card.index + -- self._ctr_seletedGet.selectedIndex = 1 + -- end end function M:__OnDragEnd(context) - if self.outcard_button then - self.outcard_button:Dispose() - self.outcard_button = nil + if not self.touchStart then + return end local button = context.sender - -- button.onDragEnd:Set(nil) - --button:RemoveFromParent() + if self.ischoose then + if self._ctr_seletedGet.selectedIndex == 0 then + button = self._view_getCard:GetChildAt(0) + else + button = self._view_handCardList:GetChildAt(self._view_handCardList.selectedIndex) + end + end local card = button.data local _room = DataManager.CurrenRoom if not _room or _room:GetReloadStatus() then return end - -- -- print("button.y"..button.y .. "_room.curren_outcard_seat".._room.curren_outcard_seat) - if (button.y < -150 and _room.curren_outcard_seat == _room.self_player.seat) then + local xy = self._view_handCardList:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + local cardHeight = button.height + if ((xy.y < -35 or (self.ischoose and self._ctr_seletedGet.selectedIndex == 0) or (context.inputEvent.y - self.touchPos.y < -cardHeight * 0.2)) and _room.curren_outcard_seat == _room.self_player.seat) then self._mainView:OutCard(card.card_item) - button.touchable = false - self.outcard_button = buttond + self.outcard_button = button + self:ClearChoose() else - self._area_handcard_list:AddChildAt(button, card.index) - button:TweenMove(card.old_postion, 0.2) + button:GetController('move').selectedIndex = 0 end + + if self._outCardMove then + self._outCardMove:Dispose() + end + self.isMoive = false + self.touch = false + self.ischoose = false + self.touchStart = false +end + +function M:outCardMove(context) + local card = self._outCardMove.data + local xy = GRoot.inst:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) + self._outCardMove.xy = xy - card.touch_pos end function M:__OnClickHandCard(context) - local button = context.sender - local _carViewList = self._carViewList - for i = 1, #_carViewList do - if (_carViewList[i].card ~= button) then - _carViewList[i].card.selected = false - end - end + self._ctr_seletedGet.selectedIndex = 1 + self._flag_seletedGet = 0 + local button = context.data + local _room = DataManager.CurrenRoom - if (Utils.IsDoubleClick(context) and _room.curren_outcard_seat == _room.self_player.seat) then + if ((Utils.IsDoubleClick(context) or self._click_index == self._view_handCardList.selectedIndex) and _room.curren_outcard_seat == _room.self_player.seat) then local card = button.data self._mainView:OutCard(card.card_item) + self:ClearChoose() end + self._click_index = self._view_handCardList.selectedIndex +end + +function M:__OnClickGetCard(context, flag) + self._view_handCardList.selectedIndex = -1 + self._click_index = self._view_handCardList.selectedIndex + local button = context.sender + local _room = DataManager.CurrenRoom + if ((Utils.IsDoubleClick(context) or self._flag_seletedGet == 1) and _room.curren_outcard_seat == _room.self_player.seat) then + local card = button.data + self._mainView:OutCard(card.card_item) + self:ClearChoose() + return + end + self._flag_seletedGet = 1 +end + +function M:ChooseHand(index) + self._click_index = index + self._view_handCardList.selectedIndex = index + self._ctr_seletedGet.selectedIndex = 1 + self._flag_seletedGet = 0 +end + +function M:ChooseOut() + self._click_index = -1 + self._view_handCardList.selectedIndex = -1 + self._ctr_seletedGet.selectedIndex = 0 + self._flag_seletedGet = 1 +end + +function M:ClearChoose() + self._click_index = -1 + self._view_handCardList.selectedIndex = -1 + self._ctr_seletedGet.selectedIndex = 1 + self._flag_seletedGet = 0 +end + +function M:ClearMove() + self:ClearChoose() + if self._outCardMove then + self._outCardMove:Dispose() + end + self.isMoive = false + self.touch = false + self.ischoose = false + self.touchStart = false end -- 获取手牌资源位置,可以在扩展中复写 @@ -217,10 +326,11 @@ end function M:Clear() MJPlayerCardInfoView.Clear(self) - for i = 1, #self._carViewList do - self._carViewList[i].card:Dispose() - end - self._carViewList = {} + + -- self._view_FZTips:RemoveChildren(0, -1, true) + + self._ctr_seletedGet.selectedIndex = 1 + self._ctr_tip.selectedIndex = 0 end return M diff --git a/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView_jiangxi.lua b/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView_jiangxi.lua deleted file mode 100644 index 841cb405..00000000 --- a/lua_probject/main_project/main/majiang/MJPlayerSelfCardInfoView_jiangxi.lua +++ /dev/null @@ -1,336 +0,0 @@ -local MJPlayerCardInfoView = import(".MJPlayerCardInfoView_jiangxi") - -local CardView = { - card = nil, - -- 牌序号 - card_item = 0, - -- 索引 - index = 0, - -- 原始位置 - old_postion = Vector2.zero -} - -local function NewCardView(card, cardItem) - local self = {} - setmetatable(self, { __index = CardView }) - self.card = card - self.card_item = cardItem - return self -end - -local PlayerSelfView = { - _dragCom = nil, - _carViewList = {} -} - -local M = PlayerSelfView - -function PlayerSelfView.new(view, mainView) - setmetatable(M, { __index = MJPlayerCardInfoView }) - local self = setmetatable({}, { __index = M }) - self._view = view - self._mainView = mainView - self:init() - return self -end - -function M:init() - MJPlayerCardInfoView.init(self) - - self._view_getCard = self._view:GetChild('Btn_HandCard') - self._view_FZTips = self._view:GetChild('Comp_FZTips') - self._area_allDown = self._view:GetChild('area_allDown') - - self._ctr_seletedGet = self._view:GetController('seletedGetCard') - self._ctr_tip = self._view:GetController('tip') - - self._area_allDown.onClick:Set(function() - self._view_handCardList.selectedIndex = -1 - self._click_index = self._view_handCardList.selectedIndex - self._ctr_seletedGet.selectedIndex = 1 - end) -end - -function M:ShowHuTip(card_list) - printlog("ShowHuTip") - local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui, - DataManager.CurrenRoom.room_config.Laizi) - pt(tingList) - if #tingList > 0 then - if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then - for i = 1, #DataManager.CurrenRoom.laiziInfo do - if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then - table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i]) - end - end - end - end - self._mainView._hu_tip:FillData(tingList) -end - -function M:UpdateHandCard(getcard, mp) - local _carViewList = self._carViewList - local card_list = DataManager.CurrenRoom.self_player.card_list - - getcard = getcard or false - mp = mp or false - self.getcard = getcard - - if self._view_handCardList.numItems > 0 then - self._view_handCardList:RemoveChildren() - end - if self._view_getCard.numItems > 0 then - self._view_getCard:RemoveChildren() - end - - for i = 0, (#card_list) - 1 do - local tem_card = card_list[i + 1] - local btn_card - if getcard and i == (#card_list) - 1 then - btn_card = self._view_getCard:AddItemFromPool() - btn_card.onClick:Add(function(context) - self:__OnClickGetCard(context) - end) - else - btn_card = self._view_handCardList:AddItemFromPool() - end - self:FillHandCard(i, btn_card, tem_card, true) - -- btn_card.onClick:Set(handler(self, self.__OnClickHandCard)) - end - - if getcard then - self._ctr_getCard.selectedIndex = 1 - else - self._ctr_getCard.selectedIndex = 0 - end - self._view_handCardList.onClickItem:Set(function(context) - self:__OnClickHandCard(context) - end) - - self:ClearMove() -end - -function M:FillHandCard(i, btn_card, tem_card, event) - local handCardName = self._viewText_cardInfo['Hand_Card'] - - self:fillCard2(btn_card, handCardName, tem_card) - local c_v = NewCardView(btn_card, tem_card) - c_v.index = i - c_v.old_postion = btn_card.xy - c_v.touch_pos = Vector2.New(btn_card.width / 2, btn_card.height / 2) - btn_card.data = c_v - if event then - btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin)) - btn_card.onTouchMove:Set(handler(self, self.onTouchMove)) - btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd)) - end -end - -function M:onTouchBegin(context) - self.touch = true - local button = context.sender - self.touchPos = Vector2.New(context.inputEvent.x, context.inputEvent.y) -end - -function M:onTouchMove(context) - local button = context.sender - local xy = self._view_handCardList:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - self.touchStart = true - if xy.y <= -35 or self.isMoive then - self.isMoive = true - if self.touch then - if self.ischoose then - if self._ctr_seletedGet.selectedIndex == 0 then - button = self._view_getCard:GetChildAt(0) - else - button = self._view_handCardList:GetChildAt(self._view_handCardList.selectedIndex) - end - end - local xy_event = Vector2.New(context.inputEvent.x, context.inputEvent.y) - local xy_btnCard = self._view_getCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - if self.__OnDragStart then - self:__OnDragStart(button, xy_event) - end - self.touch = false - end - self:outCardMove(context) - else - local touchPos = self._view_handCardList:GetChildAt(0):GlobalToLocal(Vector2.New(context.inputEvent.x, - context.inputEvent.y)) - if touchPos.x < 0 then - return - end - local cardWidth = button.width; - local grap = self._view_handCardList.columnGap - local chooseIndex = math.floor(touchPos.x / (cardWidth + grap)) - - if chooseIndex >= self._view_handCardList.numItems then - self.ischoose = true - if touchPos.x > cardWidth + (cardWidth + grap) * (self._view_handCardList.numItems - 1) and self.getcard then - self:ChooseOut() - else - if self._view_handCardList.selectedIndex ~= self._view_handCardList.numItems - 1 then - self:ChooseHand(self._view_handCardList.numItems - 1) - end - end - else - print("lingmengonTouchMove", chooseIndex, self._view_handCardList.numItems) - - self.ischoose = true - if self._view_handCardList.selectedIndex ~= chooseIndex then - self:ChooseHand(chooseIndex) - else - - end - end - end - - -- local card = button.data - -- local xy = GRoot.inst:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - -- button.xy = xy - card.touch_pos -end - -function M:__OnDragStart(button, xy_event, isGet) - button:GetController('move').selectedIndex = 1 - - local card = button.data - --复制一个按钮 - - local btn_card = self._view_getCard:GetFromPool(nil) - self._outCardMove = btn_card - - self:FillHandCard(card.index, btn_card, card.card_item, false) - - local xy = GRoot.inst:GlobalToLocal(xy_event) - - --将虚影按钮替换移动的按钮 - -- GRoot.inst:BringToFront(button) - GRoot.inst:AddChild(btn_card) - self._outCardMove.data = card - self._outCardMove.xy = xy - card.touch_pos - --设置弹起 - -- if isGet then - -- self._view_handCardList.selectedIndex = -1 - -- self._ctr_seletedGet.selectedIndex = 0 - -- else - -- self._view_handCardList.selectedIndex = card.index - -- self._ctr_seletedGet.selectedIndex = 1 - -- end -end - -function M:__OnDragEnd(context) - if not self.touchStart then - return - end - local button = context.sender - if self.ischoose then - if self._ctr_seletedGet.selectedIndex == 0 then - button = self._view_getCard:GetChildAt(0) - else - button = self._view_handCardList:GetChildAt(self._view_handCardList.selectedIndex) - end - end - local card = button.data - local _room = DataManager.CurrenRoom - if not _room or _room:GetReloadStatus() then return end - - local xy = self._view_handCardList:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - local cardHeight = button.height - if ((xy.y < -35 or (self.ischoose and self._ctr_seletedGet.selectedIndex == 0) or (context.inputEvent.y - self.touchPos.y < -cardHeight * 0.2)) and _room.curren_outcard_seat == _room.self_player.seat) then - self._mainView:OutCard(card.card_item) - self.outcard_button = button - self:ClearChoose() - else - button:GetController('move').selectedIndex = 0 - end - - if self._outCardMove then - self._outCardMove:Dispose() - end - self.isMoive = false - self.touch = false - self.ischoose = false - self.touchStart = false -end - -function M:outCardMove(context) - local card = self._outCardMove.data - local xy = GRoot.inst:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - self._outCardMove.xy = xy - card.touch_pos -end - -function M:__OnClickHandCard(context) - self._ctr_seletedGet.selectedIndex = 1 - self._flag_seletedGet = 0 - local button = context.data - - local _room = DataManager.CurrenRoom - if ((Utils.IsDoubleClick(context) or self._click_index == self._view_handCardList.selectedIndex) and _room.curren_outcard_seat == _room.self_player.seat) then - local card = button.data - self._mainView:OutCard(card.card_item) - self:ClearChoose() - end - self._click_index = self._view_handCardList.selectedIndex -end - -function M:__OnClickGetCard(context, flag) - self._view_handCardList.selectedIndex = -1 - self._click_index = self._view_handCardList.selectedIndex - local button = context.sender - local _room = DataManager.CurrenRoom - if ((Utils.IsDoubleClick(context) or self._flag_seletedGet == 1) and _room.curren_outcard_seat == _room.self_player.seat) then - local card = button.data - self._mainView:OutCard(card.card_item) - self:ClearChoose() - return - end - self._flag_seletedGet = 1 -end - -function M:ChooseHand(index) - self._click_index = index - self._view_handCardList.selectedIndex = index - self._ctr_seletedGet.selectedIndex = 1 - self._flag_seletedGet = 0 -end - -function M:ChooseOut() - self._click_index = -1 - self._view_handCardList.selectedIndex = -1 - self._ctr_seletedGet.selectedIndex = 0 - self._flag_seletedGet = 1 -end - -function M:ClearChoose() - self._click_index = -1 - self._view_handCardList.selectedIndex = -1 - self._ctr_seletedGet.selectedIndex = 1 - self._flag_seletedGet = 0 -end - -function M:ClearMove() - self:ClearChoose() - if self._outCardMove then - self._outCardMove:Dispose() - end - self.isMoive = false - self.touch = false - self.ischoose = false - self.touchStart = false -end - --- 获取手牌资源位置,可以在扩展中复写 -function M:GetCardObjPack() - return "Main_Majiang" -end - -function M:Clear() - MJPlayerCardInfoView.Clear(self) - - -- self._view_FZTips:RemoveChildren(0, -1, true) - - self._ctr_seletedGet.selectedIndex = 1 - self._ctr_tip.selectedIndex = 0 -end - -return M diff --git a/wb_unity_pro/Assets/ART/base/Family/ui/Family_atlas0.png b/wb_unity_pro/Assets/ART/base/Family/ui/Family_atlas0.png index 6db991b4..eb880766 100644 Binary files a/wb_unity_pro/Assets/ART/base/Family/ui/Family_atlas0.png and b/wb_unity_pro/Assets/ART/base/Family/ui/Family_atlas0.png differ diff --git a/wb_unity_pro/Assets/ART/base/Family/ui/Family_fui.bytes b/wb_unity_pro/Assets/ART/base/Family/ui/Family_fui.bytes index 985c38d6..0ac15288 100644 Binary files a/wb_unity_pro/Assets/ART/base/Family/ui/Family_fui.bytes and b/wb_unity_pro/Assets/ART/base/Family/ui/Family_fui.bytes differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0.png index 2132ebb9..766ea5ac 100644 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0.png and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0.png differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_1.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_1.png index b7b4a386..b1ec3248 100644 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_1.png and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_1.png differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_2.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_2.png index 23f74b61..5f9eaff8 100644 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_2.png and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_2.png differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_3.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_3.png index bf230663..e89f3471 100644 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_3.png and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_3.png differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_4.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_4.png index bd582d2f..e99dd34a 100644 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_4.png and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_4.png differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_5.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_5.png index 782d0ff5..06b07b9c 100644 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_5.png and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_5.png differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_6.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_6.png index 06b07b9c..4e420dca 100644 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_6.png and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_6.png differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_7.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_7.png index 1d8b9bc2..2cff82ba 100644 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_7.png and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_7.png differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_8.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_8.png index 1c26cf9c..11183d91 100644 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_8.png and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_8.png differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_9.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_9.png deleted file mode 100644 index d2e20717..00000000 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_9.png and /dev/null differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas_jrro7cxo.png b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas_jrro7cxo.png new file mode 100644 index 00000000..e6f6372a Binary files /dev/null and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas_jrro7cxo.png differ diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_9.png.meta b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas_jrro7cxo.png.meta similarity index 95% rename from wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_9.png.meta rename to wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas_jrro7cxo.png.meta index 44901a09..c997ecad 100644 --- a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas0_9.png.meta +++ b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_atlas_jrro7cxo.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 33e431d5d531bfa4ca088c16e422ed58 +guid: e6f99dd407f53f544acf8dba5e1ff3c1 TextureImporter: internalIDToNameTable: [] externalObjects: {} @@ -88,5 +88,5 @@ TextureImporter: pSDRemoveMatte: 0 pSDShowRemoveMatteOption: 0 userData: - assetBundleName: base/lobby/4a425335ab0e1c246f741e6da62b244f + assetBundleName: assetBundleVariant: diff --git a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_fui.bytes b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_fui.bytes index 53dfcb52..cadc3649 100644 Binary files a/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_fui.bytes and b/wb_unity_pro/Assets/ART/base/lobby/ui/Lobby_fui.bytes differ diff --git a/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_fui.bytes b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_fui.bytes index d9dd8fd4..d1253e28 100644 Binary files a/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_fui.bytes and b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_fui.bytes differ