------------------------------------------------ -- 作者:xihan -- 日期:2019-04-03 -- 文件:KeyCodeSystem.lua -- 模块:KeyCodeSystem -- 描述:键盘快捷键监听系统 ------------------------------------------------ local M = {} local CSInput = CS.UnityEngine.Input local GetKeyDown = CS.UnityEngine.Input.GetKeyDown local GetTouch = CS.UnityEngine.Input.GetTouch local GetMouseButtonDown = CS.UnityEngine.Input.GetMouseButtonDown local KeyCode = CS.UnityEngine.KeyCode M.IsDown = false M.IsOpenEnter = true M.CfgPassword = {5, 2, 1} M.CurPassword = {} M.CfgTotalTime = 10 M.CurTotalTime = 0 M.CfgSingleTime = 0.33 M.CurSingleTime = 0 M.CurNumber = 0 function M.Update(deltaTime) if GetKeyDown(KeyCode.Y) then M.KeyCodeY() elseif GetKeyDown(KeyCode.F) then M.KeyCodeF(); elseif GetKeyDown(KeyCode.G) then M.KeyCodeG(); elseif GetKeyDown(KeyCode.H) then M.KeyCodeH(); end if M.IsOpenEnter then M.InputPassword(deltaTime) end end function M.InputPassword(deltaTime) if M.IsDown then if CSInput.touchCount == 0 then M.IsDown = false; end else if CSInput.touchCount > 0 then M.IsDown = true; M.CurSingleTime = 0 M.CurNumber = M.CurNumber + 1 end end if M.CurNumber > 0 then M.CurTotalTime = M.CurTotalTime + deltaTime if M.CurTotalTime > M.CfgTotalTime then M.ClearPassword() else M.CurSingleTime = M.CurSingleTime + deltaTime if M.CurSingleTime > M.CfgSingleTime then table.insert(M.CurPassword, M.CurNumber) M.CurNumber = 0 end end end if #M.CurPassword > 0 then local _isInputRight = true local _isDone = true for i = 1, #M.CfgPassword do if M.CurPassword[i] then if M.CurPassword[i] ~= M.CfgPassword[i] then _isInputRight = false end else _isDone = false end end if _isInputRight and _isDone then M.ClearPassword() -- CS.Thousandto.Code.Logic.RunTimeProfiler2.instance.isRunProfiler = true; CS.Thousandto.Code.Center.GameUICenter.UIFormManager.UIRoot.gameObject:SetActive(true); elseif not _isInputRight then M.ClearPassword() end end end function M.ClearPassword() M.CurNumber = 0 M.CurTotalTime = 0 M.CurSingleTime = 0 for j = #M.CurPassword, 1, -1 do M.CurPassword[j] = nil end end function M.KeyCodeY() Debug.Log("=============[KeyCode.Y]=================") -- GameCenter.TimelineSystem:CreatGameobject(1, function(info) -- info:SetPlayCallBack(function(info) -- Debug.Log("=============[Play]=================") -- end); -- info:SetPauseCallBack(function(info) -- Debug.Log("=============[Pause]=================") -- end); -- info:SetEndCallBack(function(info) -- Debug.Log("=============[End]=================") -- end); -- info:Play() -- end) -- local _go = GameObject("hehe1"); -- UnityUtils.RequireComponent(_go.transform, "UnityEngine.Animator") local _castList = CS.Thousandto.Core.Asset.CastList() local _go = GameObject.Instantiate(GameCenter.GameSceneSystem:GetLocalPlayer().ModelTransform:GetChild(0):GetChild(0):GetChild(1).gameObject) _castList:Add("actor_02", _go) CS.Thousandto.Core.Asset.TimelinePlayer.Play(1, function(info) Debug.Log(info.TimelinePlayState) info.IsDestroyAtEnd = true end, _castList, true) end function M.KeyCodeF() -- Debug.Log("=============[KeyCode.F]=================") -- GameCenter.TimelineSystem:Pause() CS.Thousandto.Core.Asset.TimelinePlayer.Stop() -- Debug.Log(math.ceil(-1.9)) end function M.KeyCodeG() -- Debug.Log("=============[KeyCode.G]=================") -- GameCenter.TimelineSystem:Stop() -- CS.Thousandto.Core.Asset.TimelinePlayer.Destroy(1) -- GameCenter.PushFixEvent(UIEventDefine.UIDailyRechargeForm_OPEN); -- GameCenter.PushFixEvent(UIEventDefine.UIWelfareForm_OPEN,WelfareType.LevelGift) GameCenter.PushFixEvent(UILuaEventDefine.UIYYHDChild3000Form_CLOSE) end function M.KeyCodeH1() -- Debug.Log("=============[KeyCode.H]=================") -- GameCenter.TimelineSystem:Play() -- GameCenter.TimelineSystem:DestroyTimeline(1) -- GameCenter.TimelineSystem:PreLoad(1) -- GameCenter.TimelineSystem:PreLoad(1, function(x) -- Debug.Log("================ 1 ", x) -- end) -- GameCenter.TimelineSystem:PreLoad(1, function(x) -- Debug.Log("================ 2 ", x) -- end) -- GameCenter.TimelineSystem:CreatGameobject(1, function(info) -- Debug.Log("================ 3 ", info.Id) -- end) -- GameCenter.TimelineSystem:DestroyTimeline(1) -- GameCenter.PushFixEvent(UIEventDefine.UIFristChargeForm_Open, 2) -- local _t = { -- [1001] = { -- ["Id"] = 1001, -- ["name"] = "AAA" -- }, -- [1002] = { -- ["Id"] = 1002, -- ["name"] = "BBB" -- } -- } -- local _data = {1001, 1, 1002, 2} -- local _key = {[1001]=1,[1002]=2} -- local _dataReal = {[1001]={},[1002]={}} end function M.KeyCodeH() -- local function testFunc(num) -- Debug.Log("===============", num) -- local x = nil; -- if x > 0 then -- end -- end -- GameCenter.Network.DoResTest("MSG_Commercialize.ResDailyRechargeInfo", { -- rechargeTotal = 100 -- }) -- Debug.LogTable(Json.decode("{12:13}")) -- GameCenter.PushFixEvent(UIEventDefine.UIShopMallForm_OPEN, ShopPanelEnum.LimitShop) -- GameCenter.PushFixEvent(UIEventDefine.UIWelfareForm_OPEN,WelfareType.LevelGift) -- GameCenter.PushFixEvent(UIEventDefine.UIDailyActivityForm_OPEN, 9) -- GameCenter.PushFixEvent(UILuaEventDefine.UIYYHDChild3000Form_OPEN) -- GameObject.Instantiate(GameCenter.GameSceneSystem:GetLocalPlayer().RootGameObject) -- CS.Thousandto.Core.Asset.TimelinePlayer.Play() -- GameCenter.PushFixEvent((UILuaEventDefine.UIUpdateNoticeRewardForm_OPEN)) -- if pcall(testFunc,2) then -- Debug.Log("true") -- else -- Debug.Log("false") -- end -- testFunc(2) -- GameCenter.ItemQuickGetSystem:OpenItemQuickGetForm(12) --GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_BONFIRE_REFRESH_PANEL) -- GameCenter.PushFixEvent(UILuaEventDefine.UIFreeGiftForm_OPEN) -- GameCenter.Network.DoResTest("MSG_WorldBonfire.ResWorldBonfirePanel", -- { -- ['param1'] = 1, -- ['param2'] = 0, -- ['remainTime'] = 881263,}) -- GameCenter.PushFixEvent(UILuaEventDefine.UIShareAndLikeForm_OPEN, 1) -- GameCenter.PushFixEvent(UIEventDefine.UIWelfareGetItemForm_OPEN) -- GameCenter.PushFixEvent(UIEventDefine.UILimitShopTipsForm_OPEN) -- GameCenter.LimitShopSystem.NewShopId = 1 -- GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_NEWLIMITSHOP_REFRESH); -- GameCenter.DailyActivitySystem:JoinActivity(3) -- GameCenter.PushFixEvent(UILuaEventDefine.UIFreeGiftForm_OPEN) GameCenter.MainFunctionSystem:DoFunctionCallBack(FunctionStartIdCode.Calendar) end return M