双人对局新界面
parent
8515e03703
commit
6c104ef0fd
|
|
@ -120,7 +120,7 @@ function M:InitView(url, isHideIpAdds)
|
|||
self:continue_game(v)
|
||||
end)
|
||||
self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and
|
||||
self._state.selectedIndex < 3 and 1 or 0
|
||||
self._state.selectedIndex < 3 and 1 or 0
|
||||
self.distance_view:Show()
|
||||
end)
|
||||
end
|
||||
|
|
@ -232,18 +232,21 @@ function M:InitView(url, isHideIpAdds)
|
|||
self._gamectr:PlayerReady()
|
||||
end)
|
||||
|
||||
-- local btn_xipai = _view:GetChild('btn_xipai')
|
||||
-- if btn_xipai then
|
||||
-- btn_xipai.onClick:Set(function()
|
||||
-- self._gamectr:PlayerXiPai()
|
||||
-- end)
|
||||
-- end
|
||||
if self._room.room_config.people_num ~= 2 then
|
||||
local btn_xipai = _view:GetChild('btn_xipai')
|
||||
if btn_xipai then
|
||||
btn_xipai.onClick:Set(function()
|
||||
self._gamectr:PlayerXiPai()
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
-- local btn_start = _view:GetChild('btn_start')
|
||||
-- btn_start.onClick:Set(function()
|
||||
-- self._gamectr:StartGame()
|
||||
-- end)
|
||||
local btn_start = _view:GetChild('btn_start')
|
||||
btn_start.onClick:Set(function()
|
||||
self._gamectr:StartGame()
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local _btn_wxyqhy = _view:GetChild('btn_wxyqhy')
|
||||
if _btn_wxyqhy then
|
||||
|
|
@ -781,7 +784,7 @@ function M:OnPlayerEnter(...)
|
|||
self:continue_game(v)
|
||||
end)
|
||||
self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and
|
||||
self._state.selectedIndex < 3 and 1 or 0
|
||||
self._state.selectedIndex < 3 and 1 or 0
|
||||
self.distance_view:Show()
|
||||
if self.btn_distance then
|
||||
self.btn_distance:GetController("state").selectedIndex = 1
|
||||
|
|
@ -1115,7 +1118,7 @@ function M:Show()
|
|||
self:continue_game(v)
|
||||
end)
|
||||
self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and
|
||||
self._state.selectedIndex < 3 and 1 or 0
|
||||
self._state.selectedIndex < 3 and 1 or 0
|
||||
self.distance_view:Show()
|
||||
self.btn_distance:GetController("state").selectedIndex = 1
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
---
|
||||
|
||||
local PlayerInfoView = {
|
||||
_view = nil,
|
||||
_main_view = nil,
|
||||
|
|
@ -51,6 +49,7 @@ function M:init()
|
|||
self._ctr_room_owner = view:GetController('room_owner')
|
||||
self._ctr_mask_voice = view:GetController('mask_voice')
|
||||
self._ctr_dismiss_room = view:GetController('dismiss_room')
|
||||
self._ctr_site = view:GetController('site')
|
||||
|
||||
self.PlayerTGTips = view:GetChild('tuoguanTips')
|
||||
if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then
|
||||
|
|
@ -162,6 +161,23 @@ function M:FillData(player)
|
|||
end
|
||||
end
|
||||
|
||||
function M:SetStartType(peopleNum, seat)
|
||||
if peopleNum == 2 then
|
||||
if seat == 1 then
|
||||
self._ctr_site.selectedIndex = 1
|
||||
else
|
||||
self._ctr_site.selectedIndex = 2
|
||||
self._tex_player_name = 154
|
||||
end
|
||||
elseif peopleNum == 3 then
|
||||
self._ctr_site.selectedIndex = 2 + seat
|
||||
elseif peopleNum == 4 then
|
||||
self._ctr_site.selectedIndex = 5 + seat
|
||||
else
|
||||
self._ctr_site.selectedIndex = 0
|
||||
end
|
||||
end
|
||||
|
||||
function M:DismissRoom(state)
|
||||
state = state or false
|
||||
self._ctr_dismiss_room.selectedIndex = state == true and 1 or 0
|
||||
|
|
|
|||
|
|
@ -2,45 +2,45 @@ ViewUtil = {
|
|||
Num_Converted = { "一", "二", "三", "四" },
|
||||
|
||||
Sex_Chat = {
|
||||
"man",
|
||||
"woman"
|
||||
"man",
|
||||
"woman"
|
||||
},
|
||||
|
||||
Fix_Msg_Chat = {
|
||||
"大家好,很高兴见到各位!",
|
||||
"和你合作太愉快了!",
|
||||
"快点啊,我等的花儿都谢了!",
|
||||
"你丫的牌打得也忒好了",
|
||||
"不要吵了不要吵了,吵什么吵啊,专心打牌",
|
||||
"怎么又断线了,网络这么差!",
|
||||
"各位,真不好意思啊,我得离开一会",
|
||||
"不要走,决战到天亮!",
|
||||
"你是妹妹,还是哥哥啊?",
|
||||
"我们交个朋友吧,能不能告诉我你的联系方法",
|
||||
"再见了,我会想念大家的",
|
||||
"不好意思临时有事,申请解散!"
|
||||
}
|
||||
"大家好,很高兴见到各位!",
|
||||
"和你合作太愉快了!",
|
||||
"快点啊,我等的花儿都谢了!",
|
||||
"你丫的牌打得也忒好了",
|
||||
"不要吵了不要吵了,吵什么吵啊,专心打牌",
|
||||
"怎么又断线了,网络这么差!",
|
||||
"各位,真不好意思啊,我得离开一会",
|
||||
"不要走,决战到天亮!",
|
||||
"你是妹妹,还是哥哥啊?",
|
||||
"我们交个朋友吧,能不能告诉我你的联系方法",
|
||||
"再见了,我会想念大家的",
|
||||
"不好意思临时有事,申请解散!"
|
||||
}
|
||||
}
|
||||
|
||||
function ViewUtil.GetPos(self_seat,seat,people_num)
|
||||
function ViewUtil.GetPos(self_seat, seat, people_num)
|
||||
if self_seat == 0 then return seat end
|
||||
local cur_seat = self_seat
|
||||
local tem = seat - (cur_seat - 1)
|
||||
if (tem <= 0) then tem = tem +people_num end
|
||||
if (tem <= 0) then tem = tem + people_num end
|
||||
return tem
|
||||
end
|
||||
|
||||
-- 隐藏手机号
|
||||
function ViewUtil.phone_hide(phone)
|
||||
return string.sub(phone,1,3).."****"..string.sub(phone,8)
|
||||
return string.sub(phone, 1, 3) .. "****" .. string.sub(phone, 8)
|
||||
end
|
||||
|
||||
-- 隐藏身份证
|
||||
function ViewUtil.identity_hide(identity)
|
||||
return string.sub(identity,1,8).."****"..string.sub(identity,13)
|
||||
return string.sub(identity, 1, 8) .. "****" .. string.sub(identity, 13)
|
||||
end
|
||||
|
||||
local modal_wait_win =nil
|
||||
local modal_wait_win = nil
|
||||
-- local modal_wait_win_url = "ui://Common/GlobalModalWaiting"
|
||||
function ViewUtil.ShowModalWait(blur_view, title)
|
||||
ViewUtil.CloseModalWait()
|
||||
|
|
@ -51,14 +51,14 @@ function ViewUtil.CloseModalWait()
|
|||
ModalWaitingWindow.CloseModal()
|
||||
end
|
||||
|
||||
local _defaultTooltipWin =nil
|
||||
local _defaultTooltipWin = nil
|
||||
local function __waittips(obj)
|
||||
_defaultTooltipWin:Dispose()
|
||||
_defaultTooltipWin = nil
|
||||
end
|
||||
|
||||
local _tip_timer
|
||||
local function __ShowTips(msg,time)
|
||||
local function __ShowTips(msg, time)
|
||||
time = time or 2
|
||||
if _defaultTooltipWin then
|
||||
_tip_timer:Stop()
|
||||
|
|
@ -72,24 +72,24 @@ local function __ShowTips(msg,time)
|
|||
_defaultTooltipWin:MakeFullScreen()
|
||||
_tip_timer = Timer.New(function()
|
||||
__waittips()
|
||||
end,time,1,true)
|
||||
end, time, 1, true)
|
||||
_tip_timer:Start()
|
||||
end
|
||||
|
||||
function ViewUtil.ErrorTip(code,tip,time)
|
||||
if(Table_Error_code_Map[code]~=nil) then
|
||||
__ShowTips(string.format("%s",Table_Error_code_Map[code].note), time)
|
||||
function ViewUtil.ErrorTip(code, tip, time)
|
||||
if (Table_Error_code_Map[code] ~= nil) then
|
||||
__ShowTips(string.format("%s", Table_Error_code_Map[code].note), time)
|
||||
else
|
||||
__ShowTips(tip,time)
|
||||
__ShowTips(tip, time)
|
||||
end
|
||||
end
|
||||
|
||||
function ViewUtil.ErrorMsg(_root_view,code,tip,url)
|
||||
function ViewUtil.ErrorMsg(_root_view, code, tip, url)
|
||||
local msg = tip
|
||||
if(Table_Error_code_Map[code]~=nil) then
|
||||
msg = string.format("%s",Table_Error_code_Map[code].note)
|
||||
if (Table_Error_code_Map[code] ~= nil) then
|
||||
msg = string.format("%s", Table_Error_code_Map[code].note)
|
||||
end
|
||||
local _curren_msg = MsgWindow.new(_root_view, msg, MsgWindow.MsgMode.OnlyOk,url)
|
||||
local _curren_msg = MsgWindow.new(_root_view, msg, MsgWindow.MsgMode.OnlyOk, url)
|
||||
_curren_msg:Show()
|
||||
end
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ function ViewUtil.ShowBannerOnScreenCenter(msg, s)
|
|||
ViewUtil._banner = banner
|
||||
local timer = Timer.New(function()
|
||||
banner:Dispose()
|
||||
end,time,1,true)
|
||||
end, time, 1, true)
|
||||
timer:Start()
|
||||
end
|
||||
|
||||
|
|
@ -117,51 +117,47 @@ function ViewUtil.PlaySoundBg()
|
|||
GameApplication.Instance:PlayMuisc("base/common/sound/bgmusic1.mp3")
|
||||
end
|
||||
|
||||
function ViewUtil.HandCardSort(a,b)
|
||||
function ViewUtil.HandCardSort(a, b)
|
||||
local sort_a = a
|
||||
local sort_b = b
|
||||
if a >= 400 then sort_a = sort_a -1000 end
|
||||
if a >= 400 then sort_a = sort_a - 1000 end
|
||||
if b >= 400 then sort_b = sort_b - 1000 end
|
||||
|
||||
return sort_a<sort_b
|
||||
return sort_a < sort_b
|
||||
end
|
||||
|
||||
function ViewUtil.HandCardSort2(a,b)
|
||||
a=tonumber(string.sub(a,2))
|
||||
b=tonumber(string.sub(b,2))
|
||||
--print(a)
|
||||
--print(b)
|
||||
return a < b
|
||||
function ViewUtil.HandCardSort2(a, b)
|
||||
a = tonumber(string.sub(a, 2))
|
||||
b = tonumber(string.sub(b, 2))
|
||||
--print(a)
|
||||
--print(b)
|
||||
return a < b
|
||||
end
|
||||
|
||||
|
||||
function ViewUtil.HandCardSort3(a,b)
|
||||
function ViewUtil.HandCardSort3(a, b)
|
||||
local sort_a = a[1] or 101
|
||||
local sort_b = b[1] or 101
|
||||
|
||||
return sort_a<sort_b
|
||||
return sort_a < sort_b
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function ViewUtil.CardPos(obj, area, oder, index, offset,isAdd)
|
||||
offset = offset or 0
|
||||
if oder == AreaOderType.left_right then
|
||||
obj.x = index * obj.width + offset
|
||||
elseif oder == AreaOderType.up_down then
|
||||
obj.y = index * obj.height + offset
|
||||
elseif oder == AreaOderType.right_left then
|
||||
obj.x = (area.width - obj.width) - index * obj.width - offset
|
||||
elseif oder == AreaOderType.down_up then
|
||||
if isAdd then
|
||||
obj.y = area.height - obj.height - index * obj.height*1.5 - offset
|
||||
else
|
||||
obj.y = area.height - obj.height - index * obj.height - offset
|
||||
end
|
||||
--obj.y = area.height - obj.height - index * obj.height - offset
|
||||
end
|
||||
function ViewUtil.CardPos(obj, area, oder, index, offset, isAdd, padding)
|
||||
offset = offset or 0
|
||||
padding = padding or 0
|
||||
if oder == AreaOderType.left_right then
|
||||
obj.x = index * (obj.width + padding) + offset
|
||||
elseif oder == AreaOderType.up_down then
|
||||
obj.y = index * (obj.height + padding) + offset
|
||||
elseif oder == AreaOderType.right_left then
|
||||
obj.x = (area.width - obj.width) - index * (obj.width + padding) - offset
|
||||
elseif oder == AreaOderType.down_up then
|
||||
if isAdd then
|
||||
obj.y = area.height - obj.height - index * obj.height * 1.5 - offset
|
||||
else
|
||||
obj.y = area.height - obj.height - index * obj.height - offset
|
||||
end
|
||||
--obj.y = area.height - obj.height - index * obj.height - offset
|
||||
end
|
||||
end
|
||||
|
||||
local _current_group = nil
|
||||
|
|
@ -174,6 +170,7 @@ function ViewUtil.PlayMuisc(group, path)
|
|||
end
|
||||
GameApplication.Instance:PlayMuisc(group, path)
|
||||
end
|
||||
|
||||
function ViewUtil.PlaySound(group, path)
|
||||
if group ~= _current_group then
|
||||
if _current_group then
|
||||
|
|
@ -195,9 +192,9 @@ function get_majiang_prefix(game_id)
|
|||
local ct = 1
|
||||
if DataManager.CurrenRoom and DataManager.CurrenRoom.card_type then
|
||||
ct = DataManager.CurrenRoom.card_type
|
||||
--printlog("get_majiang_prefix=============1111")
|
||||
--printlog("get_majiang_prefix=============1111")
|
||||
elseif game_id then
|
||||
--printlog("get_majiang_prefix=============1111222222222222")
|
||||
--printlog("get_majiang_prefix=============1111222222222222")
|
||||
local ct_data = nil
|
||||
local json_data = Utils.LoadLocalFile("CardTypeData")
|
||||
if json_data then
|
||||
|
|
@ -208,7 +205,7 @@ function get_majiang_prefix(game_id)
|
|||
ct = ct_data[tostring(game_id)] or 0
|
||||
end
|
||||
local prefix = ct == 0 and "" or "a"
|
||||
--printlog("get_majiang_prefix===>>>",prefix,ct)
|
||||
--printlog("get_majiang_prefix===>>>",prefix,ct)
|
||||
return prefix
|
||||
end
|
||||
|
||||
|
|
@ -237,7 +234,7 @@ end
|
|||
-- 获取gps
|
||||
function get_gps(callback)
|
||||
if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then
|
||||
local s,e = pcall(function()
|
||||
local s, e = pcall(function()
|
||||
Utils.LocalAddress(function(result, latitude, longitude)
|
||||
if not result or (latitude == 0 and longitude == 0) then return end
|
||||
DataManager.SelfUser.location = Location.new(tostring(longitude) .. "," .. tostring(latitude))
|
||||
|
|
@ -255,8 +252,7 @@ function get_gps(callback)
|
|||
end
|
||||
|
||||
--依据宽度截断字符
|
||||
function ViewUtil.stringEllipsis(szText,size,full)
|
||||
|
||||
function ViewUtil.stringEllipsis(szText, size, full)
|
||||
full = full or false
|
||||
size = size or 4
|
||||
--截断结果
|
||||
|
|
@ -267,7 +263,7 @@ function ViewUtil.stringEllipsis(szText,size,full)
|
|||
local i = 1
|
||||
local char_count = 0
|
||||
while true do
|
||||
local cur = string.sub(szText,i,i)
|
||||
local cur = string.sub(szText, i, i)
|
||||
local byte = string.byte(cur)
|
||||
if byte == nil then
|
||||
break
|
||||
|
|
@ -281,10 +277,8 @@ function ViewUtil.stringEllipsis(szText,size,full)
|
|||
if byte > 128 then
|
||||
i = i + 3
|
||||
char_count = char_count + 1
|
||||
elseif byte ~= 32 then
|
||||
|
||||
elseif byte ~= 32 then
|
||||
if string.byte('A') <= byte and byte <= string.byte('Z') then
|
||||
|
||||
char_count = char_count + 1
|
||||
else
|
||||
char_count = char_count + 0.5
|
||||
|
|
@ -297,23 +291,23 @@ function ViewUtil.stringEllipsis(szText,size,full)
|
|||
end
|
||||
|
||||
if i ~= 1 then
|
||||
szResult = string.sub(szText, 1, i-1)
|
||||
if(bOK) then
|
||||
szResult = szResult.."..."
|
||||
szResult = string.sub(szText, 1, i - 1)
|
||||
if (bOK) then
|
||||
szResult = szResult .. "..."
|
||||
end
|
||||
end
|
||||
return szResult
|
||||
end
|
||||
|
||||
-------------------------lingmeng---------------------------
|
||||
function ViewUtil.ShowOneChooose(showText,btnType,callback)
|
||||
function ViewUtil.ShowOneChooose(showText, btnType, callback)
|
||||
local pop_oneChoose = UIPackage.CreateObjectFromURL("ui://Common/pop_oneChoose")
|
||||
pop_oneChoose:GetChild('text_show').text = showText
|
||||
GRoot.inst:AddChild(pop_oneChoose)
|
||||
pop_oneChoose:Center()
|
||||
local btn_center = pop_oneChoose:GetChild('btn_center')
|
||||
if type(btnType) == "number" then
|
||||
btn_center.icon = string.format("ui://Common/btn_%d",btnType)
|
||||
btn_center.icon = string.format("ui://Common/btn_%d", btnType)
|
||||
else
|
||||
btn_center.icon = btnType
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@ local M = {}
|
|||
|
||||
--- Create a new CS_GameController
|
||||
function M.new()
|
||||
setmetatable(M,{__index = GameController})
|
||||
local self = setmetatable({}, {__index = M})
|
||||
self:init("测试麻将")
|
||||
self.class = "CS_GameController"
|
||||
return self
|
||||
setmetatable(M, { __index = GameController })
|
||||
local self = setmetatable({}, { __index = M })
|
||||
self:init("测试麻将")
|
||||
self.class = "CS_GameController"
|
||||
return self
|
||||
end
|
||||
|
||||
function M:init(name)
|
||||
GameController.init(self,name)
|
||||
GameController.init(self, name)
|
||||
|
||||
self._eventmap[CS_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards
|
||||
self._eventmap[CS_Protocol.GAME_EVT_PLAYER_DEAL] = self.OnEventSendCards
|
||||
self._eventmap[CS_Protocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnEventTurn
|
||||
|
||||
self._eventmap[CS_Protocol.GAME_EVT_DRAW] = self.OnEventTakeCard
|
||||
|
|
@ -40,22 +40,22 @@ function M:init(name)
|
|||
self._eventmap[CS_Protocol.GAME_EVT_PIAO] = self.OnEventPiao
|
||||
self._eventmap[CS_Protocol.GAME_EVT_TING_TIP] = self.OnEventTingTip
|
||||
self._eventmap[CS_Protocol.GAME_EVT_TING] = self.OnEventTing
|
||||
self._eventmap[CS_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai
|
||||
self._eventmap[CS_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim
|
||||
self._eventmap[CS_Protocol.GAME_EVENT_XIPAI] = self.OnEventXiPai
|
||||
self._eventmap[CS_Protocol.GAME_EVENT_NOTIFY_XIPAI] = self.OnEventXiPaiAnim
|
||||
end
|
||||
|
||||
local __pre_delete_card = false
|
||||
-- 发送出牌指令到服务器
|
||||
function M:SendOutCard(card, callback)
|
||||
local _room = self._room
|
||||
local p = _room.self_player
|
||||
local _room = self._room
|
||||
local p = _room.self_player
|
||||
|
||||
local _data = {}
|
||||
_data["card"] = card
|
||||
_data["card_list"] = p.card_list
|
||||
if p.outcard_list and #p.outcard_list>0 then
|
||||
_data["outcard_list"] = p.outcard_list
|
||||
end
|
||||
_data["card_list"] = p.card_list
|
||||
if p.outcard_list and #p.outcard_list > 0 then
|
||||
_data["outcard_list"] = p.outcard_list
|
||||
end
|
||||
|
||||
|
||||
local _client = ControllerManager.GameNetClinet
|
||||
|
|
@ -64,11 +64,11 @@ function M:SendOutCard(card, callback)
|
|||
-- 进行预删牌处理
|
||||
|
||||
_room.curren_outcard_seat = -1
|
||||
list_remove(p.card_list,card)
|
||||
list_remove(p.card_list, card)
|
||||
table.sort(p.card_list, ViewUtil.HandCardSort)
|
||||
p.hand_left_count = p.hand_left_count - 1
|
||||
if not p.outcard_list then p.outcard_list = {} end
|
||||
p.outcard_list[#p.outcard_list+1] = card
|
||||
p.outcard_list[#p.outcard_list + 1] = card
|
||||
__pre_delete_card = true
|
||||
callback()
|
||||
end
|
||||
|
|
@ -81,56 +81,51 @@ function M:SendAction(id)
|
|||
_client:send(CS_Protocol.GAME_ACTION, _data)
|
||||
end
|
||||
|
||||
|
||||
function M:SendXiPaiAction(callBack)
|
||||
local _data = {}
|
||||
local _client = ControllerManager.GameNetClinet
|
||||
_client:send(CS_Protocol.GAME_XIPAI, _data)
|
||||
self.XiPaiCallBack=callBack
|
||||
self.XiPaiCallBack = callBack
|
||||
end
|
||||
|
||||
function M:OnEventXiPai(evt_data)
|
||||
if evt_data["result"]==0 then
|
||||
if self.XiPaiCallBack then
|
||||
self.XiPaiCallBack()
|
||||
end
|
||||
else
|
||||
ViewUtil.ErrorTip(1000000,"申请洗牌失败")
|
||||
end
|
||||
|
||||
if evt_data["result"] == 0 then
|
||||
if self.XiPaiCallBack then
|
||||
self.XiPaiCallBack()
|
||||
end
|
||||
else
|
||||
ViewUtil.ErrorTip(1000000, "申请洗牌失败")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function M:OnEventXiPaiAnim(evt_data)
|
||||
printlog("洗牌动画===》》》》")
|
||||
pt(evt_data)
|
||||
local playeridList = evt_data["list"]
|
||||
local my_isXiPai=false
|
||||
local other_isXiPai=false
|
||||
if playeridList and #playeridList>0 then
|
||||
for i=1,#playeridList do
|
||||
local p = self._room:GetPlayerById(playeridList[i])
|
||||
if p== self._room.self_player then
|
||||
my_isXiPai=true
|
||||
else
|
||||
other_isXiPai=true
|
||||
end
|
||||
end
|
||||
end
|
||||
printlog("洗牌动画===》》》》")
|
||||
pt(evt_data)
|
||||
local playeridList = evt_data["list"]
|
||||
local my_isXiPai = false
|
||||
local other_isXiPai = false
|
||||
if playeridList and #playeridList > 0 then
|
||||
for i = 1, #playeridList do
|
||||
local p = self._room:GetPlayerById(playeridList[i])
|
||||
if p == self._room.self_player then
|
||||
my_isXiPai = true
|
||||
else
|
||||
other_isXiPai = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EventXiPai,my_isXiPai,other_isXiPai)
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EventXiPai, my_isXiPai, other_isXiPai)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
function M:OnEventSendCards(evt_data)
|
||||
if ViewManager.GetCurrenView().dview_class == LobbyView then
|
||||
self:ReturnToRoom()
|
||||
return
|
||||
end
|
||||
local _room = self._room
|
||||
local _room = self._room
|
||||
-- if(_room.CurnrenState == StateType.Ready) then
|
||||
-- _room.CurnrenState = StateType.Palying
|
||||
-- end
|
||||
|
|
@ -145,15 +140,15 @@ function M:OnEventSendCards(evt_data)
|
|||
local left_count = evt_data["left_count"]
|
||||
self._cacheEvent:Enqueue(function()
|
||||
_room.banker_seat = seat
|
||||
for i=1,#_room.player_list do
|
||||
for i = 1, #_room.player_list do
|
||||
_room.player_list[i].hand_left_count = _room.player_list[i].seat == _room.banker_seat and 14 or 13
|
||||
_room.player_list[i].fz_list = {}
|
||||
_room.player_list[i].card_list = {}
|
||||
end
|
||||
p.card_list = handcards
|
||||
self._room.self_player.hand_left_count = #handcards
|
||||
table.sort( handcards, ViewUtil.HandCardSort )
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.SendCards, left_count)
|
||||
self._room.self_player.hand_left_count = #handcards
|
||||
table.sort(handcards, ViewUtil.HandCardSort)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.SendCards, left_count)
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
@ -162,7 +157,7 @@ function M:OnEventOutCard(evt_data)
|
|||
local card = evt_data["card"]
|
||||
local p = self._room:GetPlayerBySeat(seat)
|
||||
self._cacheEvent:Enqueue(function()
|
||||
local _room = self._room
|
||||
local _room = self._room
|
||||
if seat == _room.self_player.seat and __pre_delete_card then
|
||||
__pre_delete_card = false
|
||||
else
|
||||
|
|
@ -172,13 +167,12 @@ function M:OnEventOutCard(evt_data)
|
|||
end
|
||||
p.hand_left_count = p.hand_left_count - 1
|
||||
if not p.outcard_list then p.outcard_list = {} end
|
||||
p.outcard_list[#p.outcard_list+1] = card
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.OutCard, p, card)
|
||||
p.outcard_list[#p.outcard_list + 1] = card
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.OutCard, p, card)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
function M:OnEventTakeCard(evt_data)
|
||||
local _room = self._room
|
||||
local seat = evt_data["seat"]
|
||||
|
|
@ -186,34 +180,34 @@ function M:OnEventTakeCard(evt_data)
|
|||
local left_count = evt_data["left_count"]
|
||||
local p = _room:GetPlayerBySeat(seat)
|
||||
self._cacheEvent:Enqueue(function()
|
||||
p.hand_left_count = p.hand_left_count +1
|
||||
p.hand_left_count = p.hand_left_count + 1
|
||||
if (seat == _room.self_player.seat) then
|
||||
_room.self_player.card_list[#_room.self_player.card_list+1] = card
|
||||
_room.self_player.card_list[#_room.self_player.card_list + 1] = card
|
||||
-- table.sort( _room.self_player.card_list, ViewUtil.HandCardSort )
|
||||
end
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.GetCard, seat, card, left_count)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.GetCard, seat, card, left_count)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:OnEventOutHint(evt_data)
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.OutHint, evt_data)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.OutHint, evt_data)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:OnEventTurn(evt_data)
|
||||
local seat = evt_data["seat"]
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EventTurn, seat)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EventTurn, seat)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:OnEventFzTips(evt_data)
|
||||
self._cacheEvent:Enqueue(function()
|
||||
local tiplist = FZTipList.new()
|
||||
local list = evt_data["tip_list"]
|
||||
for i=1,#list do
|
||||
local dtip = list[i]
|
||||
local list = evt_data["tip_list"]
|
||||
for i = 1, #list do
|
||||
local dtip = list[i]
|
||||
local tip = {}
|
||||
tip.id = dtip["id"]
|
||||
tip.weight = dtip["weight"]
|
||||
|
|
@ -222,12 +216,12 @@ function M:OnEventFzTips(evt_data)
|
|||
tip.opcard = dtip["opcard"]
|
||||
tiplist:AddTip(tip)
|
||||
end
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.FZTips, tiplist)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.FZTips, tiplist)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:OnEventFzAction(evt_data)
|
||||
local _room = self._room
|
||||
local _room = self._room
|
||||
local playerid = evt_data["playerid"]
|
||||
local card = evt_data["card"]
|
||||
local actice_card = evt_data["active_card"]
|
||||
|
|
@ -243,12 +237,12 @@ function M:OnEventFzAction(evt_data)
|
|||
local index = -1
|
||||
local ftype = type
|
||||
if (ftype == FZType.Gang_Peng) then
|
||||
for i=1,#p.fz_list do
|
||||
for i = 1, #p.fz_list do
|
||||
if (p.fz_list[i].card == card) then
|
||||
p.fz_list[i].card = card
|
||||
fz = p.fz_list[i]
|
||||
fz.type = type
|
||||
index = i -1
|
||||
index = i - 1
|
||||
break
|
||||
end
|
||||
end
|
||||
|
|
@ -259,21 +253,21 @@ function M:OnEventFzAction(evt_data)
|
|||
fz.opengang = opengang
|
||||
if (index == -1) then
|
||||
if (ftype == FZType.Chi) then
|
||||
local data ={}
|
||||
data[1] = opcard[1]
|
||||
data[2] = card
|
||||
data[3] = opcard[2]
|
||||
fz.opcard =data
|
||||
local data = {}
|
||||
data[1] = opcard[1]
|
||||
data[2] = card
|
||||
data[3] = opcard[2]
|
||||
fz.opcard = data
|
||||
end
|
||||
p.fz_list[#p.fz_list+1] = fz
|
||||
p.fz_list[#p.fz_list + 1] = fz
|
||||
end
|
||||
fz.from_seat = from_seat
|
||||
local remove_num = #opcard
|
||||
|
||||
if (p == _room.self_player) then
|
||||
for i=1,remove_num do
|
||||
list_remove(p.card_list,opcard[i])
|
||||
end
|
||||
for i = 1, remove_num do
|
||||
list_remove(p.card_list, opcard[i])
|
||||
end
|
||||
end
|
||||
|
||||
p.hand_left_count = p.hand_left_count - remove_num
|
||||
|
|
@ -281,13 +275,13 @@ function M:OnEventFzAction(evt_data)
|
|||
-- if (fz.Type == FZType.Chi) then card = actice_card end
|
||||
local fp = _room:GetPlayerBySeat(from_seat)
|
||||
if card == fp.outcard_list[#fp.outcard_list] then
|
||||
table.remove(fp.outcard_list,#fp.outcard_list)
|
||||
table.remove(fp.outcard_list, #fp.outcard_list)
|
||||
else
|
||||
table.remove(fp.outcard_list,#fp.outcard_list - 1)
|
||||
table.remove(fp.outcard_list, #fp.outcard_list - 1)
|
||||
end
|
||||
end
|
||||
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.FangziAction, fz, p, index)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.FangziAction, fz, p, index)
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
@ -300,8 +294,9 @@ function M:OnEventHu(evt_data)
|
|||
|
||||
self._cacheEvent:Enqueue(function()
|
||||
win_p.card_list = cards
|
||||
table.sort( win_p.card_list, ViewUtil.HandCardSort)
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], win_card, cards, win_list)
|
||||
table.sort(win_p.card_list, ViewUtil.HandCardSort)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.ZPHuCard, evt_data["seat"], evt_data["from_seat"], win_card, cards,
|
||||
win_list)
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
@ -317,15 +312,15 @@ function M:OneventResult1(evt_data)
|
|||
p.hand_left_count = 0
|
||||
p.outcard_list = {}
|
||||
end
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.ZPResult1, result);
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.ZPResult1, result);
|
||||
end)
|
||||
elseif 1 == over or 2 == over then
|
||||
DataManager.CurrenRoom.Over = true
|
||||
ControllerManager.SetGameNetClient(nil,true)
|
||||
ControllerManager.SetGameNetClient(nil, true)
|
||||
local total_result = evt_data.total_result
|
||||
local result = evt_data.result
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.ZPResult2, result, total_result, over);
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.ZPResult2, result, total_result, over);
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
@ -334,19 +329,19 @@ function M:OnEventNiao(evt_data)
|
|||
local list = evt_data["niao"]
|
||||
local start_seat = evt_data["start_seat"]
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EventNiao, list, start_seat)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EventNiao, list, start_seat)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:OnEventQSTip(evt_data)
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EventQSTip, evt_data)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EventQSTip, evt_data)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:OnEventQSAction(evt_data)
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EvnetQSAction, evt_data)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EvnetQSAction, evt_data)
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
@ -360,13 +355,13 @@ function M:OnEventKaiGang(evt_data)
|
|||
for i = 1, #cardList do
|
||||
p.outcard_list[#p.outcard_list + 1] = cardList[i]
|
||||
end
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EventKaiGang, evt_data, self._room.self_player.outcard_list)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EventKaiGang, evt_data, self._room.self_player.outcard_list)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:OnEventHaidi()
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EvnetHaiDi, evt_data)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EvnetHaiDi, evt_data)
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
@ -378,44 +373,44 @@ function M:OnEventPiaoTip(evt_data)
|
|||
|
||||
self._cacheEvent:Enqueue(function()
|
||||
self._room.playing = true
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EvnetPiaoTip, evt_data)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EvnetPiaoTip, evt_data)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:OnEventTingTip()
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EventTingTip)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EventTingTip)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:OnEventTing(evt_data)
|
||||
self._cacheEvent:Enqueue(function()
|
||||
local seat = evt_data.seat
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EventTing, seat)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EventTing, seat)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:OnEventPiao(evt_data)
|
||||
self._cacheEvent:Enqueue(function()
|
||||
DispatchEvent(self._dispatcher,CS_GameEvent.EvnetPiao, evt_data.seat, evt_data.num)
|
||||
DispatchEvent(self._dispatcher, CS_GameEvent.EvnetPiao, evt_data.seat, evt_data.num)
|
||||
end)
|
||||
end
|
||||
|
||||
function M:GetPosString( seat )
|
||||
if DataManager.CurrenRoom.room_config.people_num ~= 4 then return"" end
|
||||
if seat == 1 then
|
||||
return "北"
|
||||
elseif seat == 2 then
|
||||
return "西"
|
||||
elseif seat == 3 then
|
||||
return "南"
|
||||
elseif seat == 4 then
|
||||
return "东"
|
||||
end
|
||||
function M:GetPosString(seat)
|
||||
if DataManager.CurrenRoom.room_config.people_num ~= 4 then return "" end
|
||||
if seat == 1 then
|
||||
return "北"
|
||||
elseif seat == 2 then
|
||||
return "西"
|
||||
elseif seat == 3 then
|
||||
return "南"
|
||||
elseif seat == 4 then
|
||||
return "东"
|
||||
end
|
||||
end
|
||||
|
||||
function M:Discard(card)
|
||||
local _data = {}
|
||||
local _data = {}
|
||||
_data["card"] = card
|
||||
local _room = self._room
|
||||
local _client = ControllerManager.GameNetClinet
|
||||
|
|
|
|||
|
|
@ -46,8 +46,13 @@ function M:InitView(url)
|
|||
self._full = true
|
||||
-- self.Fix_Msg_Chat = Fix_Msg_Chat
|
||||
UIPackage.AddPackage("extend/majiang/changsha/ui/Extend_MJ_ChangSha")
|
||||
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
|
||||
-- MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2")
|
||||
if self._room.room_config.people_num == 2 then
|
||||
MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num)
|
||||
else
|
||||
MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -57,10 +62,10 @@ function M:InitView(url)
|
|||
self.LaiziBG.text = "鬼牌"
|
||||
self.LaiziBG.visible = false
|
||||
self.selectLaiziBtn = self._view:GetChild('selectlaizi')
|
||||
self.Laizi1Btn = self._view:GetChild('selectlaizi1')
|
||||
self.Laizi2Btn = self._view:GetChild('selectlaizi2')
|
||||
self.Laizi1Btn.visible = false
|
||||
self.Laizi2Btn.visible = false
|
||||
-- self.Laizi1Btn = self._view:GetChild('selectlaizi1')
|
||||
-- self.Laizi2Btn = self._view:GetChild('selectlaizi2')
|
||||
-- self.Laizi1Btn.visible = false
|
||||
-- self.Laizi2Btn.visible = false
|
||||
self.selectLaiziBtn.visible = false
|
||||
|
||||
self._hu_tip = HuTipView.new(self)
|
||||
|
|
@ -111,7 +116,7 @@ function M:EventInit()
|
|||
|
||||
_gamectr:AddEventListener(CS_GameEvent.SendCards, function(...)
|
||||
local arg = { ... }
|
||||
self._tex_LeftCard.text = arg[1]
|
||||
self._tex_LeftCard.text = string.format("剩余%d张牌", arg[1])
|
||||
local info = self._player_card_info[1]
|
||||
info._player.auto_out_card = false
|
||||
self:UpdateRound()
|
||||
|
|
@ -121,6 +126,7 @@ function M:EventInit()
|
|||
local p = list[i]
|
||||
local info = self._player_info[self:GetPos(p.seat)]
|
||||
info:FillData(p)
|
||||
info:SetStartType(_room.room_config.people_num, p.seat)
|
||||
info:MarkBank(p.seat == _room.banker_seat)
|
||||
info:Ready(false)
|
||||
local card_info = self._player_card_info[self:GetPos(p.seat)]
|
||||
|
|
@ -182,7 +188,7 @@ function M:EventInit()
|
|||
local arg = { ... }
|
||||
local seat = arg[1]
|
||||
local card = arg[2]
|
||||
self._tex_LeftCard.text = arg[3]
|
||||
self._tex_LeftCard.text = string.format("剩余%d张牌", arg[3])
|
||||
-- self:UpdateRoomInfo()
|
||||
local info = self._player_card_info[self:GetPos(seat)]
|
||||
info:UpdateHandCard(true)
|
||||
|
|
@ -450,7 +456,7 @@ function M:EventInit()
|
|||
|
||||
_gamectr:AddEventListener(CS_GameEvent.EvnetPiaoTip, function()
|
||||
self:UpdateRound()
|
||||
self._tex_LeftCard.text = "0"
|
||||
self._tex_LeftCard.text = "剩余0张牌"
|
||||
self._state.selectedIndex = 1
|
||||
if oldGameVersion == 1 then
|
||||
self:__PiaoNiaoTip()
|
||||
|
|
@ -514,8 +520,13 @@ function M:EventInit()
|
|||
end
|
||||
|
||||
function M:UpdateRound()
|
||||
self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round,
|
||||
self._room.room_config.round)
|
||||
if self._room.room_config.people_num == 2 then
|
||||
self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round,
|
||||
self._room.room_config.round)
|
||||
else
|
||||
self._view:GetChild("tex_round1").text = self._room.curren_round
|
||||
self._view:GetChild("tex_round2").text = self._room.room_config.round
|
||||
end
|
||||
end
|
||||
|
||||
function M:InitPlayerInfoView()
|
||||
|
|
@ -851,7 +862,6 @@ function M:__KaiGang(data)
|
|||
self._view:AddChild(self.kg_card)
|
||||
self.kg_card:Center()
|
||||
info:UpdateOutCardList(nil, card, self._cursor)
|
||||
self._view:GetChild("remaining_card").text = string.format("剩余%d张牌", self._room.remain_cards)
|
||||
|
||||
coroutine.wait(1)
|
||||
self._popEvent = true
|
||||
|
|
@ -1105,7 +1115,7 @@ function M:ReloadRoom(bskip)
|
|||
|
||||
if bskip == nil or bskip == false then
|
||||
self:UpdateCardBox(self:GetPos(room.curren_outcard_seat))
|
||||
self._tex_LeftCard.text = room.left_count
|
||||
self._tex_LeftCard.text = string.format("剩余%d张牌", room.left_count)
|
||||
self:UpdateRound()
|
||||
end
|
||||
local me = room.self_player
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
local PlayerInfoView = require("Game.View.PlayerInfoView copy")
|
||||
local PlayerInfoView_copy = require("Game.View.PlayerInfoView copy")
|
||||
local PlayerInfoView = require("Game.View.PlayerInfoView")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.new(view, mainView)
|
||||
setmetatable(M, { __index = PlayerInfoView })
|
||||
if mainView._room.room_config.people_num == 2 then
|
||||
setmetatable(M, { __index = PlayerInfoView_copy })
|
||||
else
|
||||
setmetatable(M, { __index = PlayerInfoView })
|
||||
end
|
||||
local self = setmetatable({}, { __index = M })
|
||||
self._view = view
|
||||
self._main_view = mainView
|
||||
|
|
@ -12,7 +17,14 @@ function M.new(view, mainView)
|
|||
end
|
||||
|
||||
function M:init()
|
||||
PlayerInfoView.init(self)
|
||||
if self._main_view._room.room_config.people_num ~= 2 then
|
||||
PlayerInfoView.init(self)
|
||||
self._tex_score = self._view:GetChild("info"):GetChild("tex_score1")
|
||||
self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2")
|
||||
self._ct_score = self._view:GetChild("info"):GetController("score")
|
||||
else
|
||||
PlayerInfoView_copy.init(self)
|
||||
end
|
||||
end
|
||||
|
||||
function M:ShowInteraction(type, str)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ local function CardPos(obj, area, oder, loc, offset)
|
|||
end
|
||||
|
||||
function M:UpdateHandCard(getcard, mp, opcard)
|
||||
print("nandaodaozhelil", getcard, mp, opcard)
|
||||
-- mp 是否明牌
|
||||
-- 如果不明牌,但是有 opcard 表示是起手胡
|
||||
getcard = getcard or false
|
||||
|
|
@ -56,7 +57,6 @@ function M:UpdateHandCard(getcard, mp, opcard)
|
|||
opnum = #opcard
|
||||
end
|
||||
local loc = 0
|
||||
print("===============================UpdateHandCard", getcard, mp, opcard, comp)
|
||||
if not mp then
|
||||
local comp_back = handcard_list["comp_back"]
|
||||
if self._current_card_type == 2 then
|
||||
|
|
@ -74,7 +74,8 @@ function M:UpdateHandCard(getcard, mp, opcard)
|
|||
if opnum ~= -1 then
|
||||
loc = CardPos(obj, self._area_handcard_list, oder, loc, offset)
|
||||
else
|
||||
ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset)
|
||||
print("=======zhihoudaizheli", oder)
|
||||
ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset, nil, -12)
|
||||
end
|
||||
--改变左右两边的手牌的x值
|
||||
if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
local MJPlayerCardInfoView = import(".MJPlayerCardInfoView")
|
||||
|
||||
local CardView = {
|
||||
card = nil,
|
||||
-- 牌序号
|
||||
card_item =0,
|
||||
-- 索引
|
||||
index = 0,
|
||||
-- 原始位置
|
||||
old_postion = Vector2.zero
|
||||
card = nil,
|
||||
-- 牌序号
|
||||
card_item = 0,
|
||||
-- 索引
|
||||
index = 0,
|
||||
-- 原始位置
|
||||
old_postion = Vector2.zero
|
||||
}
|
||||
|
||||
local function NewCardView(card,cardItem)
|
||||
local function NewCardView(card, cardItem)
|
||||
local self = {}
|
||||
setmetatable(self,{__index = CardView})
|
||||
setmetatable(self, { __index = CardView })
|
||||
self.card = card
|
||||
self.card_item = cardItem
|
||||
return self
|
||||
end
|
||||
|
||||
local PlayerSelfView = {
|
||||
_dragCom=nil,
|
||||
_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
|
||||
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()
|
||||
|
|
@ -42,26 +42,27 @@ function M:setHandCardPos(btn_card, i, getcard)
|
|||
btn_card.x = i * btn_card.width * 1.05 + (getcard and 80 or 0)
|
||||
end
|
||||
|
||||
function M:UpdateHandCard(getcard,mp)
|
||||
function M:UpdateHandCard(getcard, mp)
|
||||
print("======================onthisUpdateHandCard")
|
||||
if self.outcard_button then
|
||||
self.outcard_button:Dispose()
|
||||
self.outcard_button = nil
|
||||
end
|
||||
getcard = getcard or false
|
||||
mp = mp or false
|
||||
mp = mp or false
|
||||
local pv = self
|
||||
local _carViewList = self._carViewList
|
||||
|
||||
local _lit = pv._area_handcard_list
|
||||
for i=1,#_carViewList do
|
||||
for i = 1, #_carViewList do
|
||||
_carViewList[i].card:Dispose()
|
||||
end
|
||||
_carViewList = {}
|
||||
local _dragCom = self._dragCom
|
||||
if (_dragCom == nil) then
|
||||
_dragCom = UIPackage.CreateObject("Common","UIPanel")
|
||||
_dragCom.size = Vector2(1,1)
|
||||
pv._view:AddChild(_dragCom)
|
||||
_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
|
||||
|
|
@ -74,61 +75,60 @@ function M:UpdateHandCard(getcard,mp)
|
|||
|
||||
local cards = DataManager.CurrenRoom.self_player.card_list
|
||||
if (not mp) then
|
||||
for i=0,(#cards)-1 do
|
||||
local tem_card = cards[i+1]
|
||||
for i = 0, (#cards) - 1 do
|
||||
local tem_card = cards[i + 1]
|
||||
|
||||
|
||||
local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card"..b3d)
|
||||
btn_card:SetScale(0.9,0.9)--(1.05,1.05)
|
||||
-- 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
|
||||
local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d)
|
||||
btn_card:SetScale(0.9, 0.9) --(1.05,1.05)
|
||||
-- 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)
|
||||
_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
|
||||
end
|
||||
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
|
||||
end
|
||||
else
|
||||
for i=0,(#cards)-1 do
|
||||
|
||||
local mp_card = UIPackage.CreateObject("Main_PokeMaJiang", "Mp_self_card"..b3d)
|
||||
-- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1])
|
||||
self:fillCard(mp_card,"201_",cards[i+1])
|
||||
mp_card:SetScale(0.9,0.9)--(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
|
||||
for i = 0, (#cards) - 1 do
|
||||
local mp_card = UIPackage.CreateObject("Main_PokeMaJiang", "Mp_self_card" .. b3d)
|
||||
-- mp_card.icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. cards[i+1])
|
||||
self:fillCard(mp_card, "201_", cards[i + 1])
|
||||
mp_card:SetScale(0.9, 0.9) --(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
|
||||
end
|
||||
end
|
||||
|
||||
function M:onTouchBegin(context)
|
||||
local button = context.sender
|
||||
local card = button.data
|
||||
local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y))
|
||||
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)
|
||||
|
|
@ -138,7 +138,7 @@ end
|
|||
function M:onTouchMove(context)
|
||||
local button = context.sender
|
||||
local card = button.data
|
||||
local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x,context.inputEvent.y))
|
||||
local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
|
||||
button.xy = xy - card.touch_pos
|
||||
end
|
||||
|
||||
|
|
@ -147,37 +147,37 @@ function M:__OnDragEnd(context)
|
|||
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
|
||||
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
|
||||
|
||||
-- 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
|
||||
self._mainView:OutCard(card.card_item)
|
||||
button.touchable = false
|
||||
self.outcard_button = buttond
|
||||
else
|
||||
self._area_handcard_list:AddChildAt(button, card.index)
|
||||
button:TweenMove(card.old_postion, 0.2)
|
||||
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
|
||||
self._mainView:OutCard(card.card_item)
|
||||
button.touchable = false
|
||||
self.outcard_button = buttond
|
||||
else
|
||||
self._area_handcard_list:AddChildAt(button, card.index)
|
||||
button:TweenMove(card.old_postion, 0.2)
|
||||
end
|
||||
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
|
||||
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)
|
||||
end
|
||||
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
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
-- 获取手牌资源位置,可以在扩展中复写
|
||||
|
|
@ -187,7 +187,7 @@ end
|
|||
|
||||
function M:Clear()
|
||||
MJPlayerCardInfoView.Clear(self)
|
||||
for i=1,#self._carViewList do
|
||||
for i = 1, #self._carViewList do
|
||||
self._carViewList[i].card:Dispose()
|
||||
end
|
||||
self._carViewList = {}
|
||||
|
|
|
|||
|
|
@ -303,16 +303,20 @@ function M:UpdateOutCardList(outcard, card_item, cursor)
|
|||
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)
|
||||
else
|
||||
ViewUtil.CardPos(obj, self._area_outcard_list, oder, col)
|
||||
ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row)
|
||||
end
|
||||
|
||||
ViewUtil.CardPos(obj, self._area_outcard_list, oder, col)
|
||||
ViewUtil.CardPos(obj, self._area_outcard_list, multi_oder, row)
|
||||
|
||||
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])
|
||||
print("==============================thisout", obj, card, outlist[i + 1])
|
||||
-- 添加角标
|
||||
self:AddFlag(i + 1, outlist[i], obj)
|
||||
-- obj.icon = "ui://Main_Majiang/"..card .. outlist[i+1]
|
||||
|
|
|
|||
|
|
@ -55,11 +55,14 @@ function M:init()
|
|||
end
|
||||
|
||||
function M:setHandCardPos(btn_card, i, getcard)
|
||||
btn_card.x = i * btn_card.width * 1.05 + (getcard and 20 or 0)
|
||||
if DataManager.CurrenRoom.room_config.people_num == 2 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)
|
||||
end
|
||||
end
|
||||
|
||||
function M:UpdateHandCard(getcard, mp)
|
||||
print("======================main", getcard, mp)
|
||||
if self.outcard_button then
|
||||
self.outcard_button:Dispose()
|
||||
self.outcard_button = nil
|
||||
|
|
@ -93,10 +96,15 @@ function M:UpdateHandCard(getcard, mp)
|
|||
if (not mp) then
|
||||
for i = 0, (#cards) - 1 do
|
||||
local tem_card = cards[i + 1]
|
||||
local btn_card = nil
|
||||
if DataManager.CurrenRoom.room_config.people_num == 2 then
|
||||
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card_jiangxi" .. b3d)
|
||||
else
|
||||
btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d)
|
||||
btn_card:SetScale(1.05, 1.05)
|
||||
end
|
||||
|
||||
|
||||
local btn_card = UIPackage.CreateObject(self:GetCardObjPack(), "Btn_Card" .. b3d)
|
||||
btn_card:SetScale(1.05, 1.05)
|
||||
-- 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)
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue