yunque9/lua_probject/extend_project/extend/poker/runfast/RunFast_PlayerPokerInfoView...

371 lines
14 KiB
Lua
Raw Normal View History

2025-05-24 14:29:14 +08:00
---
--- Created by 谌建军.
--- DateTime: 2017/12/13 16:35
---
local RunFast_PlayerPokerInfoView = {
_view = nil,
_mainView = nil,
_mask_liangpai = nil,
}
local M = RunFast_PlayerPokerInfoView
2025-05-26 01:39:48 +08:00
function M.new(view, mainView)
2025-05-24 14:29:14 +08:00
local self = {}
2025-05-26 01:39:48 +08:00
setmetatable(self, { __index = M })
2025-05-24 14:29:14 +08:00
self._view = view
self._mainView = mainView
self:init()
return self
end
function M:init()
local view = self._view
self._gameCtr = ControllerManager.GetController(GameController)
self.item_data = json.decode(self._view:GetChild("area_mask").text)
self.out_card_data = self.item_data["outcard_list"]
self._mask_liangpai = view:GetChild("mask_liangpai")
self.ctr_outpoker = view:GetController("output")
self.outpoker_list = view:GetChild(self.out_card_data["parent"])
self.hand_card_list = view:GetChild("hand_card_list")
self.ctr_one_card = view:GetController("one_card")
self.eff_one_card = view:GetChild("one_card_eff"):GetTransition("t0")
self.text_bomb_score = view:GetChild("Score")
self.ani_bomb_score = view:GetTransition("score")
self.ani_result_score = view:GetTransition("score_1")
end
2025-05-26 01:39:48 +08:00
function M:SetOutCardInfo(cardlist, isPass, isAnim)
self.outpoker_list:RemoveChildren(0, -1, true)
2025-05-24 14:29:14 +08:00
if cardlist == nil then
if isPass == true then
self.ctr_outpoker.selectedIndex = 2
else
self.ctr_outpoker.selectedIndex = 0
end
else
if isAnim then
if self.move_cor then
coroutine.stop(self.move_cor)
self.move_cor = nil
end
local time = 0.1
for i = 1, #cardlist do
local poker_item = UIPackage.CreateObject("Extend_Poker_RunFastNew", "poker7")
local code = self:ChangeCodeByTo(cardlist[i])
-- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/"..code)
-- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2")
local card_code_obj
-- if DataManager.CurrenRoom.pai==0 then
-- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/"..code)
-- else
-- card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2")
-- end
-- if code==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
-- -- body
-- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/"..code.."_1")
-- end
2025-05-26 01:39:48 +08:00
if DataManager.CurrenRoom.pai == 0 then
if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
2025-05-24 14:29:14 +08:00
-- body
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code .. "_1")
2025-05-24 14:29:14 +08:00
else
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code)
2025-05-24 14:29:14 +08:00
end
else
2025-05-26 01:39:48 +08:00
if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
2025-05-24 14:29:14 +08:00
-- body
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code .. "_2")
2025-05-24 14:29:14 +08:00
else
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2")
end
end
if card_code_obj == nil then
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/00")
end
--card_code_obj:SetScale(1,1)
poker_item:AddChild(card_code_obj)
--local poker = self:CreatPoker(cardlist[i],0.7)
self.outpoker_list:AddChild(poker_item)
2025-05-26 01:39:48 +08:00
poker_item.xy = Vector2.New(self.out_card_data["start_x"], self.out_card_data["start_y"])
poker_item:TweenMove(
self:GetOutCardEndPokerPos(i, #cardlist, self.outpoker_list, poker_item, self.out_card_data
["maxcount_x"], 1), time)
2025-05-24 14:29:14 +08:00
--card_code_obj
-- self.tween = TweenUtils.TweenFloat(1,0.7,time,function(x)
-- card_code_obj:SetScale(x,x)
-- end)
2025-05-26 01:39:48 +08:00
card_code_obj:SetScale(0.7, 0.7)
2025-05-24 14:29:14 +08:00
end
self.move_cor = coroutine.start(function()
coroutine.wait(0.1)
ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/runfast/sound/chupai.mp3")
end)
else
for i = 1, #cardlist do
local poker_item = UIPackage.CreateObject("Extend_Poker_RunFastNew", "poker7")
local code = self:ChangeCodeByTo(cardlist[i])
local card_code_obj
2025-05-26 01:39:48 +08:00
if DataManager.CurrenRoom.pai == 0 then
if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
2025-05-24 14:29:14 +08:00
-- body
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code .. "_1")
2025-05-24 14:29:14 +08:00
else
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code)
2025-05-24 14:29:14 +08:00
end
else
2025-05-26 01:39:48 +08:00
if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
2025-05-24 14:29:14 +08:00
-- body
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code .. "_2")
2025-05-24 14:29:14 +08:00
else
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2")
end
end
if card_code_obj == nil then
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/00")
end
2025-05-26 01:39:48 +08:00
card_code_obj:SetScale(0.7, 0.7)
2025-05-24 14:29:14 +08:00
poker_item:AddChild(card_code_obj)
--local poker = self:CreatPoker(cardlist[i],0.7)
self.outpoker_list:AddChild(poker_item)
2025-05-26 01:39:48 +08:00
poker_item.xy = self:GetOutCardEndPokerPos(i, #cardlist, self.outpoker_list, poker_item,
self.out_card_data["maxcount_x"], 1)
2025-05-24 14:29:14 +08:00
end
end
--self.ctr_outpoker.selectedIndex = 1
end
end
function M:SetOutCardBlack()
for i = 0, self.outpoker_list.numChildren - 1 do
2025-05-26 01:39:48 +08:00
self.outpoker_list:GetChildAt(i):GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(0.7, 0.7, 0.7)
2025-05-24 14:29:14 +08:00
end
end
-- 12 -61 --11 58 --10 55 --46
2025-05-26 01:39:48 +08:00
function M:GetOffSet(cardLength) -- 15 -70
2025-05-24 14:29:14 +08:00
if cardLength > 8 then
2025-05-26 01:39:48 +08:00
return 52 --40
2025-05-24 14:29:14 +08:00
else
2025-05-26 01:39:48 +08:00
return -cardLength * 5 + 80
2025-05-24 14:29:14 +08:00
end
end
2025-05-26 01:39:48 +08:00
function M:GetOutCardEndFirstPokerPos(count, parent_com, poker_obj, max_count, scale)
local parent_width, parent_height = parent_com.width, parent_com.height
local poker_width, poker_height = poker_obj.width * scale, poker_obj.height * scale
2025-05-24 14:29:14 +08:00
local offset = self:GetOffSet(count)
2025-05-26 01:39:48 +08:00
local x, y = 0, 0
2025-05-24 14:29:14 +08:00
--local length = (count - 1) * (poker_width + offset) + poker_width
--if length <= parent_width then
-- x = (parent_width - length) / 2
-- y = (parent_height - poker_height) / 2
--end
if count <= max_count then
local length = (count - 1) * offset + poker_width
x = (parent_width - length) / 2
y = ((parent_height - poker_height) / 2)
end
2025-05-26 01:39:48 +08:00
return Vector2.New(x, y)
2025-05-24 14:29:14 +08:00
end
2025-05-26 01:39:48 +08:00
function M:GetOutCardEndPokerPos(index, count, parent_com, poker_obj, max_count, scale)
local offset_x, offset_y = self:GetOffSet(count), -50
local start_pos = self:GetOutCardEndFirstPokerPos(count, parent_com, poker_obj, max_count, scale)
local poker_width, poker_height = poker_obj.width * scale, poker_obj.height * scale
local parent_width, parent_height = parent_com.width, parent_com.height
local pos_x, pos_y = start_pos.x + (index - 1) * offset_x, start_pos.y
2025-05-24 14:29:14 +08:00
if index > max_count then
pos_x = (index - max_count - 1) * offset_x
pos_y = pos_y + poker_height + offset_y
end
2025-05-26 01:39:48 +08:00
return Vector2.New(pos_x, pos_y)
2025-05-24 14:29:14 +08:00
end
-- function M:PlayCardTypeEff(type1)
-- if type1 < 7 and type1 ~= 4 then return end
-- local eff_code = 0
-- if type1 == 10 then
-- eff_code = 2
-- elseif type1 == 11 then
-- eff_code = 3
-- elseif type1 == 4 then
-- eff_code = 4
-- else
-- eff_code = 1
-- end
-- if self.cro_type_eff ~= nil then
-- coroutine.stop(self.cro_type_eff)
-- end
-- self.cro_type_eff = nil
-- self.cro_type_eff = coroutine.start(function()
-- self.type_eff_view = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/eff_"..eff_code)
-- if self.type_eff_view == nil then return end
-- self._view:AddChild(self.type_eff_view)
-- self.type_eff_view:SetXY((self._view.width - self.type_eff_view.width) / 2,self.outpoker_list.y)
-- self.type_eff_view:GetTransition("t0"):Play()
-- coroutine.wait(1.5)
-- if self.type_eff_view ~= nil then
-- self.type_eff_view:Dispose()
-- self.type_eff_view = nil
-- end
-- end)
-- end
2025-05-26 01:39:48 +08:00
function M:PlayScore(score, isBomb, isWin)
2025-05-24 14:29:14 +08:00
if score == nil then
self.text_bomb_score.alpha = 0
return
end
if isBomb then
2025-05-26 01:39:48 +08:00
self.text_bomb_score.text = score >= 0 and "+" .. score or tostring(score)
2025-05-24 14:29:14 +08:00
self.text_bomb_score.grayed = score < 0
self.ani_bomb_score:Play()
else
if score < 0 then
self.text_bomb_score.text = tostring(score)
self.text_bomb_score.grayed = true
elseif score > 0 then
2025-05-26 01:39:48 +08:00
self.text_bomb_score.text = "+" .. score
2025-05-24 14:29:14 +08:00
self.text_bomb_score.grayed = false
else
local str = isWin and "+" or "-"
2025-05-26 01:39:48 +08:00
self.text_bomb_score.text = str .. score
2025-05-24 14:29:14 +08:00
self.text_bomb_score.grayed = not isWin
end
self.ani_result_score:Play()
end
end
2025-05-26 01:39:48 +08:00
function M:UpdateHandPoker(cardList, isPlayAni, isMing)
2025-05-24 14:29:14 +08:00
if self.cor_init_poker ~= nil then
coroutine.stop(self.cor_init_poker)
end
self.cor_init_poker = nil
self.card_list = {}
2025-05-26 01:39:48 +08:00
self.hand_card_list:RemoveChildren(0, -1, true)
2025-05-24 14:29:14 +08:00
local card_length
local new_card_list
if isMing == true then
2025-05-26 01:39:48 +08:00
new_card_list = self._gameCtr:ChangeCodeByFrom(cardList, true)
2025-05-24 14:29:14 +08:00
card_length = #cardList
else
card_length = cardList
end
if isPlayAni == true then
self.cor_init_poker = coroutine.start(function()
2025-05-26 01:39:48 +08:00
for i = card_length, 1, -1 do
2025-05-24 14:29:14 +08:00
local code = isMing == true and new_card_list[i] or 0
coroutine.wait(0.01)
2025-05-26 01:39:48 +08:00
local poker = self:CreatPoker1(code, 0.4)
2025-05-24 14:29:14 +08:00
self.hand_card_list:AddChild(poker)
end
end)
else
2025-05-26 01:39:48 +08:00
for i = card_length, 1, -1 do
2025-05-24 14:29:14 +08:00
local code = isMing == true and new_card_list[i] or 0
2025-05-26 01:39:48 +08:00
local poker = self:CreatPoker1(code, 0.4)
2025-05-24 14:29:14 +08:00
self.hand_card_list:AddChild(poker)
end
end
end
function M:SetRemainCardNumber(isPlay)
if isPlay then
self.ctr_one_card.selectedIndex = 1
2025-05-26 01:39:48 +08:00
self.eff_one_card:Play(-1, 0, nil)
2025-05-24 14:29:14 +08:00
else
self.ctr_one_card.selectedIndex = 0
end
--if self.card_number then
-- self.card_number.visible = show
-- self.card_number.text = string.format("剩余:%d",number)
--end
end
2025-05-26 01:39:48 +08:00
function M:CreatPoker1(poker, scale, bank)
local poker_item = UIPackage.CreateObject("Extend_Poker_RunFastNew", "poker" .. scale * 10)
2025-05-24 14:29:14 +08:00
local code = self:ChangeCodeByTo(poker)
local card_code_obj
2025-05-26 01:39:48 +08:00
if DataManager.CurrenRoom.pai == 0 then
if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
2025-05-24 14:29:14 +08:00
-- body
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code .. "_1")
2025-05-24 14:29:14 +08:00
else
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code)
2025-05-24 14:29:14 +08:00
end
else
2025-05-26 01:39:48 +08:00
if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
2025-05-24 14:29:14 +08:00
-- body
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code .. "_2")
2025-05-24 14:29:14 +08:00
else
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2")
end
end
2025-05-26 01:39:48 +08:00
if card_code_obj == nil or bank == 1 then
2025-05-24 14:29:14 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/00")
end
2025-05-26 01:39:48 +08:00
card_code_obj:SetScale(scale, scale)
2025-05-24 14:29:14 +08:00
poker_item:AddChild(card_code_obj)
2025-05-26 01:39:48 +08:00
2025-05-24 14:29:14 +08:00
return poker_item
end
2025-05-26 01:39:48 +08:00
function M:CreatPoker(poker, scale, bank)
local poker_item = UIPackage.CreateObject("Extend_Poker_RunFastNew", "poker" .. 12.5)
2025-05-24 14:29:14 +08:00
local code = self:ChangeCodeByTo(poker)
local card_code_obj
2025-05-26 01:39:48 +08:00
if DataManager.CurrenRoom.pai == 0 then
if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
2025-05-24 14:29:14 +08:00
-- body
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code .. "_1")
2025-05-24 14:29:14 +08:00
else
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code)
2025-05-24 14:29:14 +08:00
end
else
2025-05-26 01:39:48 +08:00
if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then
2025-05-24 14:29:14 +08:00
-- body
2025-05-26 01:39:48 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. code .. "_2")
2025-05-24 14:29:14 +08:00
else
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2")
end
end
2025-05-26 01:39:48 +08:00
if card_code_obj == nil or bank == 1 then
2025-05-24 14:29:14 +08:00
card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/00")
end
2025-05-26 01:39:48 +08:00
card_code_obj:SetScale(scale, scale)
2025-05-24 14:29:14 +08:00
poker_item:AddChild(card_code_obj)
2025-05-26 01:39:48 +08:00
2025-05-24 14:29:14 +08:00
return poker_item
end
2025-05-26 01:39:48 +08:00
function M:ChangeCodeByTo(card)
2025-05-24 14:29:14 +08:00
local flower = card % 10
local number = math.floor(card / 10)
if number == 15 then
number = 2
end
return flower * 100 + number
end
function M:Clear()
self:PlayScore(nil)
self:SetRemainCardNumber(false)
2025-05-26 01:39:48 +08:00
self:SetOutCardInfo(nil, false)
self.hand_card_list:RemoveChildren(0, -1, true)
self._mask_liangpai:RemoveChildren(0, -1, true)
2025-05-24 14:29:14 +08:00
end
function M:Destroy()
end
2025-05-26 01:39:48 +08:00
return M