local LuaUtils = require("LuaUtil"); local Util = require("Util"); LuaMoneyTree ={}; local model;-- 模型 local _MoneyTreeDesc;-- 活动描述 local _vcoinBtn;-- 元宝按钮 local _vcoinEndBtn;-- 元宝按钮-结束 local _vcoinVipHintBtn; local _vcoinBtnDesc;-- 元宝按钮描述 local _vcoinBtnDescNum -- 元宝消耗数量 local _vcoinBtnRedDot;-- 元宝按钮红点 local _lingYuBtn;-- 灵玉按钮 local _lingYuEndBtn;-- 灵玉按钮-结束 local _lingYuVipHintBtn; local _lingYuBtnDesc;-- 灵玉按钮描述 local _lingYuBtnDescNum -- 灵玉消耗数量 local _lingYuBtnRedDot;-- 灵玉按钮红点 local _localData; -- 后端返回 local _lingYuStr; -- 灵玉 local _yuanBaoStr; --元宝 local _StrDictionary = CS.GCGame.Table.StrDictionary; function LuaMoneyTree.Awake() --获取组件 LuaMoneyTree.GetModule(); end function LuaMoneyTree.OnEnable() LuaMoneyTree.ReqData(); -- 加载模型 LuaMoneyTree.ShowModel(4115); end function LuaMoneyTree.GetModule() model = UICameraTexture:GetComponent("UICameraTexture"); -- 模型 _MoneyTreeDesc = MoneyTreeDesc :GetComponent("Text"); -- 活动描述 _vcoinBtn = vcoinBtn :GetComponent("Button"); -- 元宝按钮 _vcoinEndBtn = vcoinEndBtn :GetComponent("Button"); -- 元宝按钮-结束 _vcoinVipHintBtn = vcoinVipHintBtn :GetComponent("Button"); -- 元宝按钮-vip _vcoinBtnDesc = vcoinBtnDesc :GetComponent("Text"); -- 元宝按钮描述 _vcoinBtnDescNum= vcoinBtnDescNum :GetComponent("Text"); _vcoinBtnRedDot = vcoinBtnRedDot :GetComponent("Transform"); -- 元宝按钮红点 _lingYuBtn = lingYuBtn :GetComponent("Button"); -- 灵玉按钮 _lingYuEndBtn = lingYuEndBtn :GetComponent("Button"); -- 灵玉按钮-结束 _lingYuVipHintBtn = lingYuVipHintBtn :GetComponent("Button"); -- 灵玉按钮-vip _lingYuBtnDesc = lingYuBtnDesc :GetComponent("Text"); -- 灵玉按钮描述 _lingYuBtnDescNum=lingYuBtnDescNum:GetComponent("Text"); _lingYuBtnRedDot = lingYuBtnRedDot:GetComponent("Transform"); -- 领域按钮红点 -- 默认值 LuaMoneyTree.TheDefaultValue(); end function LuaMoneyTree.TheDefaultValue() _vcoinBtn.gameObject:SetActive(true); _vcoinEndBtn.gameObject:SetActive(false); _vcoinBtnRedDot.gameObject:SetActive(false); _vcoinVipHintBtn.gameObject:SetActive(false); _lingYuBtn.gameObject:SetActive(true); _lingYuEndBtn.gameObject:SetActive(false); _lingYuBtnRedDot.gameObject:SetActive(false); _lingYuVipHintBtn.gameObject:SetActive(false); _lingYuStr = _StrDictionary.GetClientDictionaryString("#{6001}"); _yuanBaoStr = _StrDictionary.GetClientDictionaryString("#{6002}"); --按钮事件绑定 LuaMoneyTree.TheBindingEvent(); end function LuaMoneyTree.TheBindingEvent() -- 元宝摇钱 _vcoinBtn.onClick:RemoveAllListeners(); _vcoinBtn.onClick:AddListener(LuaMoneyTree.OnYuanBaoBtnClick); -- 元宝摇钱次数不够 _vcoinEndBtn.onClick:RemoveAllListeners(); _vcoinEndBtn.onClick:AddListener(LuaMoneyTree.OngrayBtnClick); --元宝摇钱vip提示 _vcoinVipHintBtn.onClick:RemoveAllListeners(); _vcoinVipHintBtn.onClick:AddListener(LuaMoneyTree.OnYuVipHintBtnClick); ------------------------------------------------------------------------------ --灵玉摇钱 _lingYuBtn.onClick:RemoveAllListeners(); _lingYuBtn.onClick:AddListener(LuaMoneyTree.OnLingYuBtnClick); --灵玉摇钱次数不够 _lingYuEndBtn.onClick:RemoveAllListeners(); _lingYuEndBtn.onClick:AddListener(LuaMoneyTree.OngrayBtnClick); --灵玉摇钱VIP提示 _lingYuVipHintBtn.onClick:RemoveAllListeners(); _lingYuVipHintBtn.onClick:AddListener(LuaMoneyTree.OnYuVipHintBtnClick); end -- 请求协议 function LuaMoneyTree.ReqData() local _actId = self:GetComponent("WelfarePageBaseCS")._NodeId; Log("请求_actId==".._actId); require("LuaDistributesReqMoneyTree") local req = {actID = _actId} LuaDistributesReqMoneyTree.SendPacket(req) end --接收返回数据 function LuaMoneyTree.RetData(data) if data == nil then ELog("没有收到 RetMoneyTree 协议返回的数据"); return; end _localData = data; -- 模型ID=4115 --LuaMoneyTree.ShowModel(4115) -- 活动描述 _MoneyTreeDesc.text = _StrDictionary.GetClientDictionaryString("#{60048}",data.rewdBaseCoppers, data.multiplePower1 , data.multiplePower2); -- 按钮状态 按钮描述 红点状态 LuaMoneyTree.BtnDesc(data) end function LuaMoneyTree.BtnDesc(_RetData) --[=[ actID = 1; button1State = 2;//元宝按钮状态 0 免费 1 没有次数 2 可用 button1MonyeNum = 3;//元宝按钮上的元宝数 button2State = 4;//灵玉按钮状态 0 免费 1 没有次数 2 可用 button2MonyeNum = 5;//灵玉按钮上的灵玉数 rewdBaseCoppers = 6;//奖励的基础铜币数 multiplePower1 = 7;//倍率1 multiplePower2 = 8;//倍率2 isRedPoint = 9;//元宝红点,0没有 1有 viplimYuanBao = 10;//元宝VIP限制 viplimLinYu = 11;//灵玉VIP限制 ]=]-- Log("actId == ".._RetData.actID); Log("基础铜币数 rewdBaseCoppers == ".._RetData.rewdBaseCoppers); Log("元宝红点 isRedPoint == ".._RetData.isRedPoint); Log("元宝按钮状态 button1State == ".._RetData.button1State); Log("元宝按钮上的元宝数 button1MonyeNum == ".._RetData.button1MonyeNum); Log("灵玉按钮状态 button2State == ".._RetData.button2State); Log("灵玉按钮上的灵玉数 button2MonyeNum == ".._RetData.button2MonyeNum); Log("元宝VIP限制 viplimYuanBao == ".._RetData.viplimYuanBao); Log("灵玉VIP限制 viplimLinYu == ".._RetData.viplimLinYu); --元宝按钮 状态 _vcoinEndBtn.gameObject:SetActive(_RetData.button1State == 1); _vcoinBtnRedDot.gameObject:SetActive(_RetData.isRedPoint == 1); _vcoinVipHintBtn.gameObject:SetActive(_RetData.viplimYuanBao > 0); --元宝按钮 描述 if _RetData.button1State == 0 and _RetData.button1MonyeNum <= 0 then _vcoinBtnDesc.gameObject:SetActive(true); vcoinBtnDesc_Num.gameObject:SetActive(false); _vcoinBtnDesc.text = _StrDictionary.GetClientDictionaryString("#{60049}"); end if _RetData.button1State == 1 then _vcoinBtnDesc.gameObject:SetActive(true); vcoinBtnDesc_Num.gameObject:SetActive(false); _vcoinBtnDesc.text = _StrDictionary.GetClientDictionaryString("#{60051}"); end if _RetData.button1State == 2 then _vcoinBtnDesc.gameObject:SetActive(false); vcoinBtnDesc_Num.gameObject:SetActive(true); _vcoinBtnDescNum.text = _RetData.button1MonyeNum; end if _RetData.viplimYuanBao > 0 then _vcoinBtnDesc.gameObject:SetActive(true); vcoinBtnDesc_Num.gameObject:SetActive(false); _vcoinBtnDesc.text = _StrDictionary.GetClientDictionaryString("#{60054}",_RetData.viplimYuanBao); end --灵玉按钮 状态 _lingYuEndBtn.gameObject:SetActive(_RetData.button2State == 1); _lingYuVipHintBtn.gameObject:SetActive(_RetData.viplimLinYu > 0); --灵玉按钮 描述 if _RetData.button2State == 0 and _RetData.button2MonyeNum <= 0 then _lingYuBtnDesc.gameObject:SetActive(true); lingYuBtnDesc_Num.gameObject:SetActive(false); _lingYuBtnDesc.text = _StrDictionary.GetClientDictionaryString("#{60049}"); end if _RetData.button2State == 1 then _lingYuBtnDesc.gameObject:SetActive(true); lingYuBtnDesc_Num.gameObject:SetActive(false); _lingYuBtnDesc.text = _StrDictionary.GetClientDictionaryString("#{60051}"); end if _RetData.button2State == 2 then _lingYuBtnDesc.gameObject:SetActive(false); lingYuBtnDesc_Num.gameObject:SetActive(true); _lingYuBtnDescNum.text = _RetData.button2MonyeNum; end if _RetData.viplimLinYu > 0 then _lingYuBtnDesc.gameObject:SetActive(true); lingYuBtnDesc_Num.gameObject:SetActive(false); _lingYuBtnDesc.text = _StrDictionary.GetClientDictionaryString("#{60054}",_RetData.viplimLinYu); end end --模型 function LuaMoneyTree.ShowModel(modelID) if modelID ~= 0 then local tab = TabMan.GetCharModelByID(modelID, 0) if tab ~= nil then model:GetComponent("UICameraTexture"):InitModelPath(tab.ResPath, tab,CS.LoadAssetBundle.BUNDLE_PATH_MODEL,true,function() --model._CameraPrefab:GetComponent("Camera").orthographicSize = tab.Scale; model.gameObject:SetActive(true); end) else model.gameObject:SetActive(false) end end end -------------------------------------------------------------------------- function LuaMoneyTree.OngrayBtnClick() -- 点击灰色按钮 飄字提示 60052 CS.GUIData.AddNotifyData(_StrDictionary.GetClientDictionaryString("#{60052}")); end function LuaMoneyTree.OnYuVipHintBtnClick() -- 点击vip按钮 飄字提示 60053 提升VIP等级可继续摇奖! CS.GUIData.AddNotifyData(_StrDictionary.GetClientDictionaryString("#{60053}")); end function LuaMoneyTree.OnYuanBaoBtnClick() -- 申请元宝摇奖 local yuanBaoNum = CS.GameManager.gameManager.PlayerDataPool.Money:GetMoney_YuanBaoBind(); if yuanBaoNum < _localData.button1MonyeNum then --CS.GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{1406}")); CS.MessageBoxLogic.OpenOKCancelBox(_StrDictionary.GetClientDictionaryString("#{6101}"),nil,function() --跳转充值界面 CS.UIManager.ShowUI(CS.UIInfo.SwitchMoneyPanl, function() CS.SwitchMoneyPanlCtr.Instance:OnMenuItemClick(1); end); end,nil); return; end LuaMoneyTree.ReqShakeMoney(1); end function LuaMoneyTree.OnLingYuBtnClick() -- 申请灵玉摇奖 local lingYuNum = CS.GameManager.gameManager.PlayerDataPool.Money:GetMoney_YuanBao(); if lingYuNum < _localData.button2MonyeNum then --CS.GUIData.AddNotifyData(_StrDictionary.GetClientDictionaryString("#{6100}")); CS.MessageBoxLogic.OpenOKCancelBox(_StrDictionary.GetClientDictionaryString("#{6100}"),nil,function() --跳转充值界面 CS.YuanBaoShopLogic.OpenChargePage(); end,nil) return; end LuaMoneyTree.ReqShakeMoney(2); end --申请摇奖协议 function LuaMoneyTree.ReqShakeMoney(data) -- 申请摇奖 require("LuaDistributesReqMoneyAct") local reqInfo = {actID = _localData.actID,type = data} Log("摇钱树 actID == ".._localData.actID); LuaDistributesReqMoneyAct.SendPacket(reqInfo) end -- 返回摇钱结果 function LuaMoneyTree.RetMoneyAct(data) -- 动作ID = data.actIndex local animationTab = CS.GCGame.Table.TableManager.GetAnimationByID(data.actIndex, 0); if animationTab == nil then ELog("animationTab is null : " + data.actIndex); return; end if model._FakeObj ~= nil and model._FakeObj.FakeObj ~= nil and model._FakeObj.FakeObj.AnimLogic ~= nil then local animationLogic = model._FakeObj.FakeObj.AnimLogic; --animationLogic:Trigger(data.actIndex); animationLogic:Play(data.actIndex); end end ---------------------------------------------------------------------------