├── Docs ├── 战斗.JPG └── 编辑器.jpg ├── README.md └── LuaScript ├── framework ├── window │ ├── control │ │ ├── windowControl.lua │ │ └── windowPanel.lua │ ├── windowCamera.lua │ ├── effect │ │ ├── windowEffectManager.lua │ │ └── windowEffect.lua │ ├── windowClickEffect.lua │ ├── windowRapidBlurEffect.lua │ ├── windowUtility.lua │ ├── windowMask.lua │ └── windowQueueRegister.lua ├── layer │ ├── windowLayerBase.lua │ ├── windowLayerDefinition.lua │ └── windowLayerManager.lua ├── scene │ ├── sceneSwitchRes.lua │ ├── sceneSwitchUtility.lua │ └── sceneSwitchManager.lua ├── logger │ ├── loggerWriter.lua │ └── loggerManager.lua ├── loader │ ├── asyncObject.lua │ ├── asset.lua │ ├── assetUtil.lua │ ├── listLoader.lua │ └── assetLoadTask.lua ├── audio │ ├── audioItem.lua │ ├── audioConfig.lua │ └── audioPlay.lua └── library │ ├── LuaXml.lua │ └── eventLib.lua ├── utility ├── layerUtility.lua ├── fileUtility.lua ├── qualitySettingUtility.lua ├── collectionUtility.lua ├── mathUtility.lua ├── timeManagerUtility.lua ├── vipBuyTipsUtility.lua ├── errorInfo.lua ├── stoneMatrixPropsUtility.lua ├── languageUtility.lua ├── mathBit.lua ├── attributeUtility.lua ├── spriteProxy.lua ├── shaderUtility.lua ├── syntaxUtility.lua ├── debugUtility.lua ├── uiAssetCache.lua ├── gameUtils.lua ├── stringUtility.lua ├── gameObjectUtility.lua ├── colorUtility.lua └── timeUtility.lua ├── reader ├── data.lua └── dataReader.lua ├── application.lua ├── module ├── alert │ ├── alertPanel.lua │ └── alertMessagePanel.lua └── bag │ ├── bagItem.lua │ ├── bagAA.lua │ └── bagHandlerPanel.lua ├── applicationLoadStartup.lua ├── applicationConfig.lua ├── applicationGlobal.lua ├── platform └── platformResponse.lua ├── applicationLoadAfter.lua └── applicationLoad.lua /Docs/战斗.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengguo07q/UnityLuaFramework/HEAD/Docs/战斗.JPG -------------------------------------------------------------------------------- /Docs/编辑器.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengguo07q/UnityLuaFramework/HEAD/Docs/编辑器.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnityLuaFramework 2 | 一个用LUA写的框架游戏框架 3 | 4 | 我把基本上所有的业务多删除了。 就保留了一个最基本的背包业务,可以用来研究逻辑层的写法。 5 | 6 | 这套框架运行是非常良好的, 拥有多层级的PROXY, 开发效率,运行效率都比较的高。 7 | 8 | ![战斗](https://github.com/zhengguo07q/UnityLuaFramework/blob/master/Docs/%E6%88%98%E6%96%97.JPG) 9 | 10 | 11 | ![编辑器](https://github.com/zhengguo07q/UnityLuaFramework/blob/master/Docs/%E7%BC%96%E8%BE%91%E5%99%A8.jpg) -------------------------------------------------------------------------------- /LuaScript/framework/window/control/windowControl.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : WindowControl.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-4 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | WindowControl = BaseClass() 11 | 12 | 13 | function WindowControl:initialize( ... ) 14 | -- body 15 | end 16 | 17 | 18 | function WindowControl:dispose( ... ) 19 | -- body 20 | end -------------------------------------------------------------------------------- /LuaScript/framework/layer/windowLayerBase.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowLayerBase.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-12 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | WindowLayerBase = BaseClass() 11 | 12 | 13 | function WindowLayerBase:initialize() 14 | 15 | end 16 | 17 | 18 | function WindowLayerBase:onDestroy() 19 | self:dispose() 20 | end 21 | 22 | 23 | function WindowLayerBase:dispose() 24 | 25 | end -------------------------------------------------------------------------------- /LuaScript/utility/layerUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : layerUtility.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-7 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("layerUtility", package.seeall) 11 | 12 | 13 | function setLayer(gameobject, layer) 14 | gameobject.layer = layer 15 | local trans = gameobject.transform 16 | 17 | for i=1, trans.childCount do 18 | local child = trans:GetChild(i-1) 19 | setLayer(child.gameObject, layer) 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /LuaScript/utility/fileUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : fileUtility.lua 4 | -- Creator : zg 5 | -- Date : 2016-11-13 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("fileUtility", package.seeall) 11 | 12 | 13 | --如果是prefix + path组成的字符串, 则去掉prefix, 如果不是, 则返回path 14 | function getPathAndNotPrefix(path, prefix) 15 | path = string.gsub(path, '\\', '/') 16 | prefix = string.gsub(prefix, '\\', '/') 17 | local i, j = string.find(path, prefix) 18 | if j ~= nil then 19 | return string.sub(path, j + 1) 20 | else 21 | return path 22 | end 23 | end 24 | 25 | -------------------------------------------------------------------------------- /LuaScript/utility/qualitySettingUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : qualitySettingUtility.lua 4 | -- Creator : 5 | -- Date : 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("qualitySettingUtility", package.seeall) 11 | 12 | 13 | function setBaseQuality() 14 | QualitySettings.antiAliasing = 4 15 | QualitySettings.vSyncCount = 0 16 | QualitySettings.anisotropicFiltering = AnisotropicFiltering.Disable 17 | Application.targetFrameRate = 30 18 | end 19 | 20 | 21 | function setAntiAliasing(val) 22 | QualitySettings.antiAliasing = val 23 | end -------------------------------------------------------------------------------- /LuaScript/utility/collectionUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : collectionUtility.lua 4 | -- Creator : xiewenjian 5 | -- Date : 2017-4-11 6 | -- Comment : 表数据转移 7 | -- *************************************************************** 8 | 9 | 10 | module("collectionUtility", package.seeall) 11 | 12 | --转移字典 13 | function CloneDictionary(dictionary) 14 | local destDict = {} 15 | for k, v in pairs(dictionary) do 16 | destDict[k] = v 17 | end 18 | return destDict 19 | end 20 | 21 | 22 | --转移列表 23 | function CloneListNQueue(list) 24 | local destList = {} 25 | for i = 1, #list do 26 | table.insert(destList, list[i]) 27 | end 28 | return destList 29 | end 30 | 31 | 32 | -- function CloneQueue(queue) 33 | -- local destQueue = {} 34 | -- for 35 | -- end -------------------------------------------------------------------------------- /LuaScript/framework/window/control/windowPanel.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowPanel.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-10 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | WindowPanel = BaseClass() 11 | 12 | 13 | function WindowPanel:initialize( ... ) 14 | 15 | end 16 | 17 | 18 | function WindowPanel:afterInitialize( ... ) 19 | 20 | end 21 | 22 | 23 | --关闭再次打开时需要重置UI 24 | function WindowPanel:resetUI() 25 | 26 | end 27 | 28 | 29 | function WindowPanel:close() 30 | self.window:close() 31 | end 32 | 33 | 34 | --打开窗口之后 35 | function WindowPanel:afterOpen() 36 | end 37 | 38 | 39 | --关闭窗口之后 40 | function WindowPanel:afterClose() 41 | 42 | end 43 | 44 | 45 | function WindowPanel:onDestroy() 46 | self:dispose() 47 | end 48 | 49 | 50 | function WindowPanel:dispose( ... ) 51 | 52 | end 53 | 54 | 55 | function WindowPanel:refresh() 56 | self:resetUI() 57 | end -------------------------------------------------------------------------------- /LuaScript/utility/mathUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : mathUtility.lua 4 | -- Creator : panyuhuan 5 | -- Date : 2017-1-9 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("mathUtility", package.seeall) 11 | 12 | 13 | -- 取整数部分 14 | function getIntNum(x) 15 | if x == 0 then 16 | return 0 17 | end 18 | 19 | if math.ceil(x) == x then 20 | x = math.ceil(x) 21 | else 22 | x = math.ceil(x) - 1 23 | end 24 | return x 25 | end 26 | 27 | 28 | -- 四舍五入 29 | function round(x) 30 | if x - math.floor(x) > 0.4 then 31 | return math.ceil(x) 32 | else 33 | return math.floor(x) 34 | end 35 | end 36 | 37 | 38 | -- 限制大小 39 | function clamp(value, min, max) 40 | if value <= min then 41 | value = min 42 | elseif value >= max then 43 | value = max 44 | end 45 | 46 | return value 47 | end 48 | 49 | 50 | --取小数部分 51 | function getDecimalNum(x) 52 | if x == 0 then 53 | return 0 54 | end 55 | 56 | if math.floor(x) == x then 57 | return 0 58 | else 59 | return x - math.floor(x) 60 | end 61 | end -------------------------------------------------------------------------------- /LuaScript/reader/data.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : data.lua 4 | -- Creator : zg 5 | -- Date : 2016-11-10 6 | -- Comment : 配置读取, 这个data里面持有所有的配置, 可以直接通过data.xxx来获取整个配置table 7 | -- *************************************************************** 8 | 9 | module("data", package.seeall) 10 | 11 | 12 | --返回多列, 包含特定key的值为value的项 13 | function foreach(data, key, value) 14 | if type(data) ~= 'table' then 15 | error('data conf type is not table :' .. type(data)) 16 | end 17 | tb = {} 18 | table.foreach(data, function(k, v) 19 | if v[key] == nil then 20 | error('data column not exist key : ' .. key) 21 | end 22 | if v[key] == value then 23 | tb[k] = v 24 | end 25 | end) 26 | return tb 27 | end 28 | 29 | 30 | --返回一列, 查找到第一个匹配此key, v的项,例子:conf.foreachOne(conf.farmSeed, "seedId", 400001) 31 | function foreachOne(data, key, value) 32 | if type(data) ~= 'table' then 33 | error('data conf type is not table :' .. type(data)) 34 | end 35 | local ret = nil 36 | table.foreach(data, function(k, v) 37 | if v[key] == nil then 38 | error('data column not exist key : ' .. key) 39 | end 40 | if v[key] == value then 41 | ret = v 42 | end 43 | end) 44 | return ret 45 | end 46 | 47 | _G['conf'] = data -------------------------------------------------------------------------------- /LuaScript/framework/window/windowCamera.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowCamera.lua 4 | -- Creator : xujianlong 5 | -- Date : 2018/1/15 6 | -- Comment : 管理UI摄像机 7 | -- *************************************************************** 8 | 9 | 10 | WindowCamera = BaseClass() 11 | 12 | 13 | function WindowCamera:initialize() 14 | local uiRoot = GameObject.Find("UI Root") 15 | self.uiCamera = GameObjectUtility.FindAndGet("Camera", uiRoot, "UnityEngine.Camera,UnityEngine") 16 | self.cameraShock = CameraShock.new() 17 | self.cameraShock:initialize() 18 | self.cameraShock:initCamera(self.uiCamera.transform) 19 | end 20 | 21 | 22 | function WindowCamera:getUICamera() 23 | return self.uiCamera 24 | end 25 | 26 | 27 | function WindowCamera:update() 28 | if self.cameraShock ~= nil then 29 | self.cameraShock:shockUpdate() 30 | end 31 | end 32 | 33 | 34 | --震屏 35 | function WindowCamera:onShockScreen(mode, time, x, y, z) 36 | if self.cameraShock ~= nil then 37 | self.cameraShock:onShock(mode, time, x, y, z) 38 | end 39 | end 40 | 41 | 42 | function WindowCamera:dispose() 43 | self.cameraShock:dispose() 44 | self.cameraShock = nil 45 | 46 | self.delete(self) 47 | end 48 | 49 | 50 | WindowCamera.instance = WindowCamera.new() -------------------------------------------------------------------------------- /LuaScript/framework/scene/sceneSwitchRes.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : sceneSwitchRes.lua 4 | -- Creator : zg 5 | -- Date : 2016-12-16 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("sceneSwitchRes", package.seeall) 11 | 12 | loginSwitchScene = SceneSwitchUtility.instance:sceneRes(SceneSwitchType.sstLoginSwitch, "module/login/loginInstance") 13 | loginScene = SceneSwitchUtility.instance:sceneRes(SceneSwitchType.sstLogin, "module/login/loginInstance") 14 | battleScene = SceneSwitchUtility.instance:sceneRes(SceneSwitchType.sstBattle, "battle/battleInstance", SceneLoaderRes.commonLoader) 15 | battlePvpScene = SceneSwitchUtility.instance:sceneRes(SceneSwitchType.sstBattle, "battle/battleInstance", SceneLoaderRes.pvpLoader) 16 | mainUiScene = SceneSwitchUtility.instance:sceneRes(SceneSwitchType.sstMainUI, "module/mainUi/mainUiInstance", SceneLoaderRes.commonLoader) 17 | universeScene = SceneSwitchUtility.instance:sceneRes(SceneSwitchType.sstUniverse, "module/universe/universeInstance", SceneLoaderRes.commonLoader) 18 | ownPlanetScene = SceneSwitchUtility.instance:sceneRes(SceneSwitchType.sstOwnPlanet, "module/ownPlanet/ownPlanetInstance", SceneLoaderRes.commonLoader) 19 | towerScene = SceneSwitchUtility.instance:sceneRes(SceneSwitchType.sstTower, "module/tower/towerInstance", SceneLoaderRes.commonLoader) 20 | 21 | -------------------------------------------------------------------------------- /LuaScript/utility/timeManagerUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : timeManagerUtility.lua 4 | -- Creator : linyongqing 5 | -- Date : 2017-4-18 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("timeManagerUtility", package.seeall) 11 | 12 | 13 | serverTimeNow = 0 14 | centenTime = 0 15 | heartCount = 0 16 | 17 | 18 | -- 获取服务器时间(毫秒) 19 | function getServerTimeNow() 20 | local time = serverTimeNow + (Time.time - centenTime) * 1000 21 | return time 22 | end 23 | 24 | 25 | -- 获取服务器时间(毫秒) 26 | function getServerTimeBySes() 27 | return getServerTimeNow() 28 | end 29 | 30 | 31 | -- 获取服务器时间(秒) 32 | function getServerTimeMs() 33 | return getServerTimeNow() * 0.001 34 | end 35 | 36 | 37 | function enterGameSuccUpdateTime(data) 38 | serverTimeNow = data.currTime 39 | centenTime = Time.time 40 | end 41 | 42 | 43 | function updateServerTime(data) 44 | heartCount = heartCount + 1 45 | local clientTime = Time.time * 1000 46 | if heartCount <= 1 or clientTime - data.clientTime < 200 then 47 | serverTimeNow = data.serverTime + (clientTime - data.clientTime) / 2 48 | centenTime = Time.time 49 | end 50 | end 51 | 52 | 53 | function sendHeart() 54 | NetClient.Send(20010131, { delayTime = Time.time * 1000 }) 55 | LuaTimer.Add(0, 3000, function () 56 | NetClient.Send(20010131, { delayTime = Time.time * 1000 }) 57 | return true 58 | end) 59 | end -------------------------------------------------------------------------------- /LuaScript/framework/scene/sceneSwitchUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : sceneSwitchUtility.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-12 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | SceneSwitchUtility = BaseClass() 11 | 12 | function SceneSwitchUtility:sceneRes(sceneType, sceneScript, sceneLoadResouece) 13 | local sceneResId = {} 14 | sceneResId.sceneType = sceneType 15 | sceneResId.sceneScript = sceneScript --场景脚本 16 | sceneResId.sceneLoadResouece = sceneLoadResouece --场景装载的资源 17 | return sceneResId 18 | end 19 | 20 | 21 | --获取场景loader需要先加载的资源 22 | function SceneSwitchUtility:getLoaderRes(sceneName) 23 | local tab = {} 24 | if sceneName == SceneLoaderRes.pvpLoader then 25 | tab = {"UI/Loader/PvpLoadingPanel"} 26 | elseif sceneName == SceneLoaderRes.commonLoader then 27 | loadConf = conf.loading["2"] 28 | 29 | --登录界面用图片1 30 | if applicationGlobal.sceneSwitchManager.lastSceneInstance ~= nil then -- 登录成功loaing主界面 31 | local sceneType = applicationGlobal.sceneSwitchManager.lastSceneInstance.currentSceneDefine.sceneType 32 | if sceneType == SceneSwitchType.sstLogin or sceneType == SceneSwitchType.sstLoginSwitch then 33 | loadConf = conf.loading["1"] 34 | end 35 | end 36 | 37 | commonLoaderBB.bg = loadConf.bg 38 | tab = {"UI/Loader/CommonLoader", "Texture/BigTexV1/" .. commonLoaderBB.bg} 39 | end 40 | return tab 41 | end 42 | 43 | SceneSwitchUtility.instance = SceneSwitchUtility.new() 44 | 45 | -------------------------------------------------------------------------------- /LuaScript/framework/window/effect/windowEffectManager.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowEffectManager.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-6 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | WindowEffectManager = BaseClass() 11 | 12 | 13 | UIEffectType = 14 | { 15 | uetCloseNull = 1, 16 | uetOpen = 2, 17 | uetOpenNull = 3, 18 | uetOpenSecond = 4, 19 | uetGuassianBlur = 5, -- 启动高斯模糊 20 | uetOpenEffectScale = 6, -- 打开特效缩放效果 21 | } 22 | 23 | 24 | function WindowEffectManager:getWindowEffect(windowBase, effectType) 25 | local effect = nil 26 | 27 | if effectType == UIEffectType.uetOpen then 28 | effect = WindowOpenAlphaEffect.new() 29 | elseif effectType == UIEffectType.uetOpenNull then 30 | effect = WindowOpenNullEffect.new() 31 | elseif effectType == UIEffectType.uetOpenSecond then 32 | effect = WindowOpenSecondScaleEffect.new() 33 | elseif effectType == UIEffectType.uetCloseNull then 34 | effect = WindowCloseNullEffect.new() 35 | elseif effectType == UIEffectType.uetGuassianBlur then 36 | effect = WindowBgGuassianBlurEffect.new() 37 | elseif effectType == UIEffectType.uetOpenEffectScale then 38 | effect = WindowOpenEffectScaleEffect.new() 39 | else 40 | effect = WindowEffect.new() 41 | end 42 | 43 | effect.window = windowBase 44 | effect:initialize() 45 | return effect 46 | end 47 | 48 | 49 | WindowEffectManager.Instance = WindowEffectManager.new() -------------------------------------------------------------------------------- /LuaScript/application.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : application.lua 4 | -- Creator : zg 5 | -- Date : 2016-11-10 6 | -- Comment : 启动类 7 | -- *************************************************************** 8 | 9 | 10 | import "UnityEngine" 11 | 12 | 13 | function printInfo() 14 | --print("lua engine version : " .. _VERSION) 15 | end 16 | 17 | 18 | function initVsObject() 19 | local uiRoot = GameObject.Find("UI Root") 20 | -- GameObject.DontDestroyOnLoad(uiRoot) 21 | 22 | WindowLayerManager.instance:buildHolder(uiRoot) 23 | end 24 | 25 | 26 | function reload(moduleName) 27 | package.loaded[moduleName] = nil 28 | require(moduleName) 29 | end 30 | 31 | 32 | -- 使用协程,加载全局lua文件 33 | function delayLoadGlobalLua(moduleName) 34 | table.insert(dataReader.globalLuaScripts, moduleName) 35 | end 36 | 37 | 38 | function loadScript() 39 | reload("applicationLoadStartup") 40 | languageUtility.setLanguage() 41 | GameProgress.Instance:SetWarningLbl(startupLocalization.getLocal("jiankangzhonggao")) 42 | MacroUtility.SetLuaMacro() 43 | end 44 | 45 | 46 | --初始化网络 47 | function initNetwrok() 48 | NetClient.GetInstance():BindScript("module/network/network") 49 | _G["protoData"] = {} 50 | end 51 | 52 | 53 | function startGame() 54 | qualitySettingUtility.setBaseQuality() 55 | UnityEngine.Screen.sleepTimeout = -1 --设置不休眠 56 | ScreenDebugUtility.GetInstance() 57 | startupStatusManager.initialize() 58 | end 59 | 60 | 61 | function main() 62 | printInfo() 63 | loadScript() 64 | initVsObject() 65 | initNetwrok() 66 | startGame() 67 | end 68 | -------------------------------------------------------------------------------- /LuaScript/module/alert/alertPanel.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : alertPanel.lua 4 | -- Creator : zg 5 | -- Date : 2016-12-22 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | AlertPanel = BaseClass(WindowLayerBase) 11 | 12 | 13 | function AlertPanel:initialize() 14 | self.varCache.go_messageAlert:SetActive(false) 15 | end 16 | 17 | 18 | function AlertPanel:getMessageAlert() 19 | self.varCache.go_messageAlert:SetActive(true) 20 | if self.messageAlert == nil then 21 | self.messageAlert = ScriptManager.GetInstance():WrapperWindowControl(self.varCache.go_messageAlert, nil) 22 | end 23 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_PopUp_Tips) 24 | end 25 | 26 | 27 | --一个按钮的弹出框 28 | function AlertPanel:alertSingle(title, message, callback, btnName, playAudio) 29 | self:getMessageAlert() 30 | self.messageAlert:alertSingle(title, message, callback, btnName) 31 | 32 | end 33 | 34 | 35 | --两个按钮的弹出框 36 | function AlertPanel:alertTwo(title, message, callback1, callback2, btnNam1, btnName2) 37 | self:getMessageAlert() 38 | self.messageAlert:alertTwo(title, message, callback1, callback2, btnNam1, btnName2) 39 | end 40 | 41 | 42 | -- 弹出图文的二次确认框 43 | function AlertPanel:alertTwoTeletext(title, message, callback1, callback2, btnNam1, btnName2) 44 | self:getMessageAlert() 45 | self.messageAlert:alertTwoTeletext(title, message, callback1, callback2, btnNam1, btnName2) 46 | end 47 | 48 | 49 | --关闭所有alert 50 | function AlertPanel:closeAllAlert() 51 | self.messageAlert.gameObject:SetActive(false) 52 | end 53 | -------------------------------------------------------------------------------- /LuaScript/framework/logger/loggerWriter.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : loggerWriter.lua 4 | -- Creator : zg 5 | -- Date : 2017-5-9 6 | -- Comment : 写入到日志文件 7 | -- 必须写的日志有: 8 | -- 1启动登录到进入游戏的所有流程性的日志 9 | -- 2所有关键点日志,比如说打开窗口日志, 切换场景日志 10 | -- 3重要节点日志,比如说切换出去 11 | -- *************************************************************** 12 | 13 | 14 | LoggerWriter = BaseClass() 15 | 16 | 17 | function LoggerWriter:initialize() 18 | 19 | end 20 | 21 | 22 | function LoggerWriter.info(str) 23 | LogUtility.Log(str) 24 | -- 编辑器模式下输出 25 | if applicationConfig.macro.UNITY_EDITOR then 26 | print("" .. str .. "") 27 | end 28 | end 29 | 30 | function LoggerWriter.error(str) 31 | applicationGlobal.logger:errorToServer("[Error:] " .. str) 32 | LogUtility.Log("[Error:] " .. str) 33 | -- 编辑器模式下输出 34 | if applicationConfig.macro.UNITY_EDITOR then 35 | print("" .. str .. "") 36 | end 37 | 38 | if videoBB ~= nil and videoBB.videoState == videoBB.enumVideoState.play then 39 | applicationGlobal.tooltip:errorMessage(str) 40 | videoBB.quitVideo() 41 | end 42 | 43 | if videoBB ~= nil and applicationGlobal.loading.isUploadVideo then 44 | applicationGlobal.loading:showUploadVideo(false) 45 | end 46 | 47 | if videoBB ~= nil and applicationGlobal.loading.isDownloadVideo then 48 | applicationGlobal.loading:showDownLoadVideo(false) 49 | end 50 | end 51 | 52 | 53 | LoggerWriter.instance = LoggerWriter.new() 54 | 55 | 56 | _G['logInfo'] = LoggerWriter.instance.info 57 | _G['logError'] = LoggerWriter.instance.error 58 | -- _G['error'] = LoggerWriter.instance.info() 59 | -------------------------------------------------------------------------------- /LuaScript/framework/loader/asyncObject.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : AsyncObject.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-13 6 | -- Comment : 异步的载入的一个组件 7 | -- *************************************************************** 8 | 9 | 10 | AsyncObject = BaseClass() 11 | 12 | 13 | function AsyncObject:load(resourcePath) 14 | self.resourcePath = resourcePath 15 | AssetLoader.instance:asyncLoad(self.resourcePath, function (asset) 16 | self:loadCompleteCallback(asset) 17 | end) 18 | end 19 | 20 | 21 | function AsyncObject:loadCompleteCallback(asset) 22 | if Slua.IsNull(self.gameObject) or self.gameObject == nil then 23 | return 24 | end 25 | 26 | self.asset = asset 27 | self.asset:AddRef() 28 | 29 | GameObjectUtility.AddGameObjectPrefab(self.gameObject, self.asset.mainObject) 30 | if self.layer ~= nil then 31 | layerUtility.setLayer(self.gameObject, self.layer) 32 | end 33 | if self.delayTime ~= nil then 34 | local coroFunc = coroutine.create(function () 35 | Yield(WaitForSeconds(self.delayTime)) 36 | GameObjectUtility.DestroyGameObject(self.gameObject, false) 37 | end) 38 | coroutine.resume(coroFunc) 39 | end 40 | end 41 | 42 | 43 | function AsyncObject.makePrefab(resourcePath, delayTime, layer) 44 | local asyncObject = GameObject(resourcePath) 45 | local asyncObjectScript = ScriptManager.GetInstance():WrapperWindowControl(asyncObject, 'framework/loader/asyncObject') 46 | asyncObjectScript.delayTime = delayTime 47 | asyncObjectScript.layer = layer 48 | asyncObjectScript:load(resourcePath) 49 | return asyncObjectScript 50 | end 51 | 52 | 53 | function AsyncObject:destory() 54 | if self.asset == nil then 55 | return 56 | end 57 | self.asset:ReleaseRef() 58 | self.asset = nil 59 | end 60 | 61 | 62 | function AsyncObject:dispose() 63 | self:destory() 64 | end 65 | -------------------------------------------------------------------------------- /LuaScript/utility/vipBuyTipsUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : vipBuyTipsUtility.lua 4 | -- Creator : lxy 5 | -- Date : 2017-2-11 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("vipBuyTipsUtility", package.seeall) 11 | 12 | function showVipBuyTips(type) 13 | local nowVipLv = playerInfoBB.playerInfo.vipLevel 14 | local buyTimesTbl = getBuyModuleType(type) 15 | local vip = buyTimesTbl[vipBB.vipData.vipName] 16 | local times = buyTimesTbl[vipBB.vipData.timesName] 17 | 18 | -- 最高级 19 | if nowVipLv == vipBB.vipData.VipLevelMax then 20 | local tip = string.format(stringUtility.rejuctSymbol(L("vip_buy_02")), vip, times) 21 | applicationGlobal.tooltip:errorMessage(tip) 22 | return 23 | end 24 | 25 | if vip == nowVipLv then 26 | local tip = string.format(stringUtility.rejuctSymbol(L("bigsail_cishubugou")), vip, times) 27 | applicationGlobal.tooltip:errorMessage(tip) 28 | end 29 | 30 | applicationGlobal.alert:alertTwo( 31 | string.format(stringUtility.rejuctSymbol(L("vip_buy_01")), vip, times), 32 | function() 33 | if not mainUIBB.mainUIData.openRecharge then 34 | applicationGlobal.tooltip:errorMessage(L("vip_recharge_function_not_open")) 35 | else 36 | mallBB.currSelectPanel = mallBB.uiMallType.ustRecharge 37 | WindowStack.instance:openWindow(windowResId.mallPanel, nil, false) 38 | end 39 | end 40 | ) 41 | end 42 | 43 | 44 | function getBuyModuleType(type) 45 | if type == vipBB.buyModuleType.gold then 46 | return vipBB.upperVipLimitGoldInfo 47 | elseif type == vipBB.buyModuleType.ration then 48 | return vipBB.upperVipLimitRationInfo 49 | elseif type == vipBB.buyModuleType.bigSail then 50 | return vipBB.upperVipLimitBigSailInfo 51 | elseif type == vipBB.buyModuleType.warGodDungeon then 52 | return vipBB.upperVipLimitWarGodDungeonInfo 53 | end 54 | end -------------------------------------------------------------------------------- /LuaScript/framework/layer/windowLayerDefinition.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowLayerDefinition.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-11 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | WindowLayerDefinition = 11 | { 12 | wldBackgroundLayer = {layerIndex = 10000, renderLayerIndex = 5}, 13 | wldSceneTreasure = {layerIndex = 11000, renderLayerIndex = 5}, 14 | wldSceneBigSail = {layerIndex = 12000, renderLayerIndex = 5}, 15 | wldSceneRelic = {layerIndex = 13000, renderLayerIndex = 5}, 16 | wldSceneCityLayer = {layerIndex = 14000, renderLayerIndex = 5}, 17 | wldSceneRole = {layerIndex = 14099, renderLayerIndex = 5}, 18 | wldFogOfWarLayer = {layerIndex = 15000, renderLayerIndex = 5}, 19 | wldSceneCityGroupLayer = {layerIndex = 16000, renderLayerIndex = 5}, 20 | wldMainUILayer = {layerIndex = 17000, renderLayerIndex = 5}, 21 | wldSceneWindowLayer = {layerIndex = 20000, renderLayerIndex = 5}, 22 | wldSceneEffectLayer = {layerIndex = 21000, renderLayerIndex = 5}, 23 | wldExploitLayer = {layerIndex = 22000, renderLayerIndex = 5}, 24 | wldBattleUILayer = {layerIndex = 22500, renderLayerIndex = 5}, 25 | wldUILayer = {layerIndex = 23000, renderLayerIndex = 5}, 26 | wldChatSwapLayer = {layerIndex = 24000, renderLayerIndex = 5}, 27 | wldGuideLayer = {layerIndex = 30000, renderLayerIndex = 5}, 28 | wldEffectLayer = {layerIndex = 35000, renderLayerIndex = 5}, 29 | wldDiglogLayer = {layerIndex = 100000, renderLayerIndex = 16}, 30 | wldTooltipLayer = {layerIndex = 110000, renderLayerIndex = 16}, 31 | wldCloudSplashLayer = {layerIndex = 120000, renderLayerIndex = 5}, 32 | wldLoadingLayer = {layerIndex = 130000, renderLayerIndex = 5}, 33 | wldAlertLayer = {layerIndex = 140000, renderLayerIndex = 16}, 34 | wldReconnectLayer = {layerIndex = 150000, renderLayerIndex = 16}, 35 | } 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /LuaScript/utility/errorInfo.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : errorInfo.lua 4 | -- Creator : panyuhuan 5 | -- Date : 2017-4-1 6 | -- Comment : 后端协议回调,错误码提示 7 | -- *************************************************************** 8 | 9 | 10 | module("errorInfo", package.seeall) 11 | 12 | 13 | function getInfo(errorCoderId) 14 | print("errorID", errorCoderId) 15 | for k,v in pairs(conf.errorCode) do 16 | if v.code == errorCoderId then 17 | if errorCoderId == 7 then -- 体力不足 18 | local currScene = applicationGlobal.sceneSwitchManager.currentSceneInstance 19 | if currScene ~= nil and (isSuper(currScene, MainUiInstance) or isSuper(currScene, UniverseInstance)) then 20 | CommonUITop.instance.prefabInstance:noPowerToBuy() 21 | end 22 | return '' 23 | elseif errorCoderId == 11 then 24 | applicationGlobal.alert:alertTwo(L("common_titel_2"), L("common_tishi_2"), 25 | function () 26 | if not mainUIBB.mainUIData.openRecharge then --充值是否开放的判断 默认开放 27 | applicationGlobal.tooltip:errorMessage(L("vip_recharge_function_not_open")) 28 | else 29 | mallBB.currSelectPanel = mallBB.uiMallType.ustRecharge 30 | WindowStack.instance:openWindow(windowResId.mallPanel, nil, false) 31 | local mallPanel = WindowStack.instance:getWindow(windowResId.mallPanel) 32 | if mallPanel ~= nil and mallPanel.window.isShow then 33 | mallPanel:openCurrClickPanel(true) 34 | end 35 | end 36 | end, 37 | nil, 38 | L("common_button_1"), L("common_button_2") 39 | ) 40 | 41 | return '' 42 | elseif errorCoderId == 12 then 43 | print("============= errorCoderId == 12 ================== ") --金币不足 44 | applicationGlobal.alert:alertTwo(L("common_titel_3"), L("common_tishi_3"), 45 | function () 46 | -- shopBB.openShopUI(shopBB.uiShopType.ustGold) 47 | mallBB.currSelectPanel = mallBB.uiMallType.ustGold 48 | WindowStack.instance:openWindow(windowResId.mallPanel, nil, false) 49 | end 50 | ) 51 | 52 | return '' 53 | end 54 | 55 | return L(v.tip) 56 | end 57 | end 58 | 59 | return "unknown status " 60 | end -------------------------------------------------------------------------------- /LuaScript/framework/loader/asset.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : Asset.lua 4 | -- Creator : sf 5 | -- Date : 2017-5-8 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | AssetList = BaseClass() 10 | 11 | function AssetList:ctor() 12 | self.assetList = {} 13 | end 14 | 15 | 16 | function AssetList:get(name) 17 | if name == nil or name == "" then 18 | return nil 19 | end 20 | for i, v in pairs(self.assetList) do 21 | if v.name == name then 22 | return v 23 | end 24 | end 25 | return nil 26 | end 27 | 28 | 29 | function AssetList:exsits(name) 30 | local asset = self:get(name) 31 | if asset == nil then 32 | return false 33 | else 34 | return true 35 | end 36 | end 37 | 38 | 39 | function AssetList:put(asset) 40 | local asset2 = self:get(asset.name) 41 | if asset2 == nil then 42 | table.insert(self.assetList, asset) 43 | return asset 44 | else 45 | Debug.LogError("asset already exists, name:" .. asset.name) 46 | return asset2 47 | end 48 | end 49 | 50 | 51 | function AssetList:putWithoutCheck(asset) 52 | table.insert(self.assetList, asset) 53 | end 54 | 55 | 56 | -- function AssetList:printDebug() 57 | -- local desc = "" 58 | -- for i, v in pairs(self.assetList) do 59 | -- desc = desc .. v:toString() 60 | -- end 61 | -- Debug.LogError("AssetList Count : " .. #self.assetList .. " List : " .. desc) 62 | -- end 63 | 64 | 65 | function AssetList:printNeverUseRef() 66 | local desc = "" 67 | local count = 0 68 | for i, v in pairs(self.assetList) do 69 | if v.gcType == AssetGCType.actRefCounted then 70 | if not v:IsRefUsed() then 71 | count = count + 1 72 | desc = desc .. v:toString() 73 | end 74 | end 75 | end 76 | Debug.LogError("never user refcount : " .. count .. " List : " .. desc) 77 | end 78 | 79 | 80 | function AssetList:printRefNotZero() 81 | local desc = "" 82 | local count = 0 83 | for i, v in pairs(self.assetList) do 84 | if v.gcType == AssetGCType.actRefCounted then 85 | if not v:IsUnused() then 86 | count = count + 1 87 | desc = desc .. v:toString() 88 | end 89 | end 90 | end 91 | Debug.LogError("used assets count : " .. count .. " List : " .. desc) 92 | end 93 | -------------------------------------------------------------------------------- /LuaScript/module/bag/bagItem.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : bagItem.lua 4 | -- Creator : panyuhuan 5 | -- Date : 2017-1-14 6 | -- Comment : 背包item 7 | -- *************************************************************** 8 | 9 | 10 | BagItem = BaseClass(UIScriptBehaviour) 11 | 12 | 13 | function BagItem:initialize() 14 | self.varCache.lbl_level.text = "" 15 | self.itemPrefab = civilCommonItem.addCommonItem(self.gameObject, Vector3(0, 0, 0)) 16 | GameObjectUtility.LocalScale(self.itemPrefab, 1.3, 1.3, 1) 17 | self.itemScript = ScriptManager.GetInstance():WrapperWindowControl(self.itemPrefab, nil) 18 | end 19 | 20 | 21 | function BagItem:clickButton(go, btnName) 22 | if btnName == "btn_this" then 23 | -- 点击播放动画 24 | self.varCache.tweenScale.gameObject:SetActive(true) 25 | self.varCache.tweenScale.from = Vector3(1.2, 1.2, 1.2) 26 | self.varCache.tweenScale.to = Vector3(1, 1, 1) 27 | self.varCache.tweenScale.duration = 0.4 28 | self.varCache.tweenScale:ResetToBeginning() 29 | self.varCache.tweenScale:PlayForward() 30 | self:brocast("SelectBagItem", {self.bagData, self}) 31 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Click_Tips) 32 | end 33 | end 34 | 35 | 36 | function BagItem:setSelected(selected) 37 | self.varCache.go_SelectedBg:SetActive(selected) 38 | end 39 | 40 | 41 | --更新格子数据 42 | function BagItem:commitData() 43 | self.bagData = self.data 44 | 45 | if self.bagData.customDataIndex == bagBB.curSelectItemData.customDataIndex then 46 | self.varCache.go_SelectedBg:SetActive(true) 47 | else 48 | self.varCache.go_SelectedBg:SetActive(false) 49 | end 50 | 51 | if self.bagData.itemModelId == 99999999 then 52 | self.itemPrefab:SetActive(false) 53 | self.varCache.sp_bg.gameObject:SetActive(true) 54 | self.varCache.lbl_level.text = "" 55 | return 56 | end 57 | 58 | self.itemPrefab:SetActive(true) 59 | self.varCache.sp_bg.gameObject:SetActive(false) 60 | self.itemScript:setItemData(self.bagData.itemModelId, self.bagData.numb, nil, nil, nil, nil, false) 61 | -- 是武将装备且装备等级大于0 62 | if self.bagData.type == 7 and self.bagData.equipLevel > 0 then 63 | self.varCache.lbl_level.text = "[f5f04a]+" .. self.bagData.equipLevel .. "[-]" 64 | else 65 | self.varCache.lbl_level.text = "" 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /LuaScript/applicationLoadStartup.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : applicationLoadStartup.lua 4 | -- Creator : xujianlong 5 | -- Date : 2017-8-17 6 | -- Comment : 这里只装载启动流程所需要的 7 | -- *************************************************************** 8 | 9 | 10 | module("applicationLoadStartup", package.seeall) 11 | 12 | 13 | reload("framework/profiler/profilerClass") 14 | reload("framework/baseClass") 15 | reload("framework/loader/assetUtil") 16 | reload("framework/loader/assetLoadTask") 17 | reload("framework/loader/asset") 18 | reload("framework/loader/assetLoader") 19 | 20 | reload("utility/syntaxUtility") 21 | reload("utility/fileUtility") 22 | reload("utility/screenDebugUtility") 23 | reload("utility/stringUtility") 24 | reload("utility/layerUtility") 25 | reload("utility/debugUtility") 26 | reload("utility/qualitySettingUtility") 27 | reload("utility/languageUtility") 28 | reload("utility/mathUtility") 29 | 30 | reload("framework/uiComponent/data/listCollection") 31 | 32 | -- 资源加载、解析 33 | reload("framework/library/json") 34 | reload("framework/assetsManager/assetBB") 35 | reload("framework/assetsManager/assetConfProject") 36 | reload("framework/assetsManager/assetDownloader") 37 | reload("framework/assetsManager/assetDelayDownloader") 38 | reload("framework/assetsManager/assetUtility") 39 | reload("framework/assetsManager/assetStatusManager") 40 | reload("framework/assetsManager/assetResultHandler") 41 | reload("framework/assetsManager/assetDelayDownloadManager") 42 | reload("reader/data") 43 | reload("reader/dataReader") 44 | 45 | reload("platform/platformBridge") 46 | reload("platform/platformRequest") 47 | reload("platform/platformResponse") 48 | 49 | reload("startup/startupStatusManager") 50 | reload("startup/startupLocalization") 51 | 52 | --载入器相关 53 | reload("framework/loader/listLoader") 54 | 55 | --图层相关 56 | reload("framework/layer/windowLayerBase") 57 | reload("framework/layer/windowLayerDefinition") 58 | reload("framework/layer/windowLayerManager") 59 | reload("framework/window/windowUtility") 60 | 61 | --场景相关 62 | reload("framework/scene/sceneInstanceBase") 63 | reload("framework/scene/sceneSwitchUtility") 64 | reload("framework/scene/sceneSwitchManager") 65 | reload("framework/scene/sceneSwitchRes") 66 | 67 | --application 68 | reload("applicationConfig") 69 | reload("applicationGlobal") 70 | -- 音频 71 | reload("framework/audio/audioConfig") 72 | --log 73 | reload("framework/logger/loggerWriter") 74 | --提示框 75 | reload("module/alert/alertPanel") 76 | reload("module/alert/alertMessagePanel") -------------------------------------------------------------------------------- /LuaScript/utility/stoneMatrixPropsUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : stoneMatrixPropsUtility.lua 4 | -- Creator : lxy 5 | -- Date : 2017-3-14 21:20 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | module("stoneMatrixPropsUtility", package.seeall) 10 | 11 | 12 | -- 获取符文道具形状 13 | function getRuneShapeByType(type) 14 | local ret = "" 15 | if type == 0 then 16 | ret = "sanjiaoxing" 17 | elseif type == 1 then 18 | ret = "lingxing" 19 | elseif type == 2 then 20 | ret = "xingxing" 21 | end 22 | return ret 23 | end 24 | 25 | 26 | --获取符文道具颜色 27 | function getRuneColorByLevel(level) 28 | local ret = "" 29 | if level == 1 then 30 | ret = "baise" 31 | elseif level == 2 then 32 | ret = "lvse" 33 | elseif level == 3 then 34 | ret = "lanse" 35 | elseif level == 4 then 36 | ret = "zise" 37 | elseif level == 5 then 38 | ret = "chengse" 39 | elseif level == 6 then 40 | ret = "hongse" 41 | elseif level == 7 then 42 | ret = "jinse" 43 | elseif level == 8 then 44 | ret = "heise" 45 | elseif level == 9 then 46 | ret = "fense" 47 | elseif level == 10 then 48 | ret = "shenghongse" 49 | end 50 | return ret 51 | end 52 | 53 | 54 | -- 根据类型等级得到符文的icon 55 | function getBgSpriteName(level, type) 56 | local color = getRuneColorByLevel(level) 57 | local shape = getRuneShapeByType(type) 58 | return "icon_" .. shape .. "-" ..color 59 | end 60 | 61 | 62 | -- 符文符号 63 | function remarkSprite(fuhaokaitou, attr) 64 | local ret = "" 65 | if attr == "hp" then 66 | ret = fuhaokaitou .. "shengming" 67 | elseif attr == "atk" then 68 | ret = fuhaokaitou .. "gongji" 69 | elseif attr == "as" then 70 | ret = fuhaokaitou .. "gongjisudu" 71 | elseif attr == "ms" then 72 | ret = fuhaokaitou .. "yidong" 73 | elseif attr == "crit" then 74 | ret = fuhaokaitou .. "baojilv" 75 | elseif attr == "cthm" then 76 | ret = fuhaokaitou .. "baoji" 77 | elseif attr == "drpt" then 78 | ret = fuhaokaitou .. "baoji" 79 | end 80 | return ret 81 | end 82 | 83 | 84 | function isPercent(percent, attribute) 85 | if attribute and attribute ~= "" then 86 | if (attribute == "crit" or attribute == "drpt") then -- 暴击率 ---免伤率 87 | return true 88 | end 89 | end 90 | 91 | local percentstr = string.lower(percent) 92 | if (percentstr == "base" or percentstr == "add") then return false end 93 | 94 | if percentstr == "addpt" or percentstr == "pt" or percentstr == "basept" then 95 | return true 96 | end 97 | return false 98 | end 99 | -------------------------------------------------------------------------------- /LuaScript/applicationConfig.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : applicationConfig.lua 4 | -- Creator : zg 5 | -- Date : 2016-11-10 6 | -- Comment : 配置信息 7 | -- *************************************************************** 8 | 9 | 10 | module("applicationConfig", package.seeall) 11 | 12 | 13 | -- 包体中包含了的语言-国家配置, 14 | languageContryConfig = 15 | { 16 | -- k是组合键:语言地区码 17 | -- v是程序定义的 18 | zh_CN = "CN", -- 中文简体 19 | zh_TW = "TW", -- 中文繁体(新马地区) 20 | --en = "en", -- 英语 21 | } 22 | 23 | 24 | macro = 25 | { 26 | UNITY_IOS = false, 27 | UNITY_ANDROID = false, 28 | UNITY_EDITOR = false, 29 | } 30 | 31 | 32 | gameConfig = 33 | { 34 | persistentDataPath = "", 35 | sdcardPath = "", 36 | packageName = "", 37 | gameId = 102, 38 | sdkid = 1000, 39 | channelId = 0, -- 0 内网渠道 1 外网渠道 40 | macAddress = "", 41 | serverCdnUrl = "http://api.sdk.yetogame.com/gamenew.php", --获取网络上配置的CDN地址 42 | -- serverCdnUrl = "http://api.yetogame.com:81/gamenew.php", --获取网络上配置的CDN地址 43 | cdnUrl = "http://172.16.4.17:8800/", 44 | -- cdnUrl = "http://cdn.yetogame.com/t2_dev_release/", 45 | -- serverListUrl = "http://api.sdk.yetogame.com/gamenew.php", --选服列表 46 | serverListUrl = "http://sdkt2.yetogame.com/gamenew.php", --选服列表 47 | serverErrorUrl = "http://monitor.yetogame.com/?action=api.Exceptlog!record", 48 | videoUploadUrl = "http://video.yetogame.com/?action=api.replay!uploadReplay", -- 录像上传url 49 | videoDownloadUrl = "http://video.yetogame.com/?action=api.replay!downloadReplay&id=", -- 录像下载url 50 | videoGetListUrl = "http://video.yetogame.com/?action=api.replay!replayList&playerId=", -- 录像列表url 51 | appVersion = "1.0", 52 | zoneTime = 8, -- 时区 53 | isDebug = true, 54 | language = "CN", 55 | country = "xm", 56 | languagePhone = "zh-CN", 57 | packageVersion = "1", 58 | voiceAppId = "1404126435", 59 | voiceAppKey = "5f9fcb57fc8f51e43a62b3bedeb7bfd8", 60 | voiceServerUrl = "udp://cn.voice.gcloudcs.com:10001", 61 | rechargePlatform = 0 62 | } 63 | 64 | 65 | loginConfig = 66 | { 67 | uid = "", 68 | access_token = "", 69 | zoneid = "" 70 | } 71 | 72 | -------------------------------------------------------------------------------- /LuaScript/framework/window/windowClickEffect.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowClickEffect.lua 4 | -- Creator : linyongqing 5 | -- Date : 2017-9-14 6 | -- Comment : 窗口点击特效 7 | -- *************************************************************** 8 | 9 | 10 | WindowClickEffect = BaseClass() 11 | 12 | 13 | function WindowClickEffect:initialize() 14 | local uiRoot = GameObject.Find("UI Root") 15 | self.uiCamera = uiRoot.transform:Find("CameraUITop"):GetComponent("Camera") 16 | self.effectRoot = GameObject("UIClickEffectRoot") 17 | GameObjectUtility.SetParent(self.effectRoot, uiRoot, true) 18 | GameObjectUtility.LocalPosition(self.effectRoot, 0, 0, 0) 19 | GameObjectUtility.LocalScale(self.effectRoot, 1, 1, 1) 20 | self.effectRoot.layer = 16 21 | 22 | AssetLoader.instance:asyncLoad("Effect/UI/ui_dianji_01", function(asset) 23 | self.clickEffectAsset = asset 24 | self.clickEffectAsset:AddRef() 25 | end) 26 | 27 | self.effectCache = {} 28 | WindowClickEffect.instance = self 29 | end 30 | 31 | 32 | function WindowClickEffect:update() 33 | -- 战斗中没有点击效果 34 | if BattleInstance == nil or BattleInstance.instance == nil then 35 | if Input.GetMouseButtonDown(0) then-- or (Input.touchCount == 1 and Input.GetTouch(0).phase == TouchPhase.Began) then 36 | self:showClickEffect() 37 | end 38 | end 39 | end 40 | 41 | 42 | function WindowClickEffect:showClickEffect() 43 | local effect = self:getEffect() 44 | local clickPosition = self.uiCamera:ScreenToWorldPoint(Input.mousePosition) 45 | GameObjectUtility.Position(effect, clickPosition.x, clickPosition.y, clickPosition.z) 46 | 47 | LuaTimer.Add(2000, 0, function () 48 | effect:SetActive(false) 49 | table.insert(self.effectCache, effect) 50 | return false 51 | end) 52 | end 53 | 54 | 55 | function WindowClickEffect:getEffect() 56 | local effect = nil 57 | if #self.effectCache > 0 then 58 | effect = self.effectCache[1] 59 | table.remove(self.effectCache, 1) 60 | effect:SetActive(true) 61 | return effect 62 | end 63 | 64 | effect = GameObject("ClickEffect") 65 | if self.clickEffectAsset == nil then 66 | AssetLoader.instance:asyncLoad("Effect/UI/ui_dianji_01", function(asset) 67 | local clickEffect = GameObject.Instantiate(asset.mainObject) 68 | GameObjectUtility.SetParent(clickEffect, effect, true) 69 | GameObjectUtility.LocalPosition(clickEffect, 0, 0, 0) 70 | GameObjectUtility.LocalScale(clickEffect, 1, 1, 1) 71 | end) 72 | else 73 | local clickEffect = GameObject.Instantiate(self.clickEffectAsset.mainObject) 74 | GameObjectUtility.SetParent(clickEffect, effect, true) 75 | GameObjectUtility.LocalPosition(clickEffect, 0, 0, 0) 76 | GameObjectUtility.LocalScale(clickEffect, 1, 1, 1) 77 | end 78 | GameObjectUtility.SetParent(effect, self.effectRoot, true) 79 | return effect 80 | end 81 | 82 | 83 | function WindowClickEffect:dispose() 84 | 85 | end -------------------------------------------------------------------------------- /LuaScript/utility/languageUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : languageUtility.lua 4 | -- Creator : 5 | -- Date : 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("languageUtility", package.seeall) 11 | 12 | 13 | function getLanguageLocalizationName() 14 | --临时处理,修复zh版本获取不到资源的临时解决方案 15 | -- if applicationConfig.gameConfig.country == "zh" then 16 | -- return "xm" .. applicationConfig.gameConfig.language 17 | -- end 18 | return applicationConfig.gameConfig.country .. applicationConfig.gameConfig.language --xmCN 19 | end 20 | 21 | 22 | 23 | function getResourceLocalizationName() 24 | return getLanguageLocalizationName() .. applicationConfig.gameConfig.packageVersion --xmCN1 , xmCN2 25 | end 26 | 27 | 28 | --设置语言 29 | function setLanguage() 30 | local currentCountry = nil 31 | if PlayerPrefs.HasKey("CurrentCountry") then 32 | currentCountry = PlayerPrefs.GetString("CurrentCountry") 33 | else 34 | currentCountry = StartupManager.GetInstance().country 35 | end 36 | 37 | local currentLanguage = nil 38 | if PlayerPrefs.HasKey("CurrentLanguage") then 39 | currentLanguage = PlayerPrefs.GetString("CurrentLanguage") 40 | else 41 | logInfo("----------- StartupManager.Instance.language :-------------"..StartupManager.GetInstance().language) 42 | logInfo("----------- StartupManager.Instance.languagePhone :-------------"..StartupManager.GetInstance().languagePhone) 43 | if checkLanguageIsContain(StartupManager.GetInstance().language) then 44 | currentLanguage = StartupManager.GetInstance().language 45 | else 46 | currentLanguage = getDefautLanguage(StartupManager.GetInstance().languagePhone) 47 | end 48 | end 49 | 50 | local currentPackageVersion = StartupManager.GetInstance().packageVersion 51 | logInfo("=============当前选择语言:============ "..currentCountry..currentLanguage) 52 | 53 | PlayerPrefs.SetString("CurrentCountry", currentCountry) 54 | PlayerPrefs.SetString("CurrentLanguage", currentLanguage) 55 | 56 | local options = {language = currentLanguage, country = currentCountry, packageVersion = currentPackageVersion} 57 | syntaxUtility.mergeTable(applicationConfig.gameConfig, options) 58 | end 59 | 60 | 61 | -- 检查sdk中设置的语言类型是否在包体中 62 | function checkLanguageIsContain(language) 63 | local result = false 64 | for k, v in pairs(applicationConfig.languageContryConfig) do 65 | if language == v then 66 | result = true 67 | break 68 | end 69 | end 70 | return result 71 | end 72 | 73 | 74 | -- 根据手机设置,返回语言类型 75 | function getDefautLanguage(languagePhone) 76 | local result = nil 77 | for k, v in pairs(applicationConfig.languageContryConfig) do 78 | if k == languagePhone then 79 | result = v 80 | break 81 | end 82 | end 83 | return result 84 | end -------------------------------------------------------------------------------- /LuaScript/utility/mathBit.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : mathBit.lua 4 | -- Creator : liyibao 5 | -- Date : 2017-8-3 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("mathBit", package.seeall) 11 | 12 | data32={} 13 | 14 | for i=1,32 do 15 | data32[i]=2^(32-i) 16 | end 17 | 18 | function d2b(arg) 19 | local tr={} 20 | for i=1,32 do 21 | if arg >= data32[i] then 22 | tr[i]=1 23 | arg=arg-data32[i] 24 | else 25 | tr[i]=0 26 | end 27 | end 28 | return tr 29 | end --d2b 30 | 31 | function b2d(arg) 32 | local nr=0 33 | for i=1,32 do 34 | if arg[i] ==1 then 35 | nr=nr+2^(32-i) 36 | end 37 | end 38 | return nr 39 | end --b2d 40 | 41 | function _xor(a,b) 42 | local op1=d2b(a) 43 | local op2=d2b(b) 44 | local r={} 45 | 46 | for i=1,32 do 47 | if op1[i]==op2[i] then 48 | r[i]=0 49 | else 50 | r[i]=1 51 | end 52 | end 53 | return b2d(r) 54 | end --xor 55 | 56 | function _and(a,b) 57 | local op1=d2b(a) 58 | local op2=d2b(b) 59 | local r={} 60 | 61 | for i=1,32 do 62 | if op1[i]==1 and op2[i]==1 then 63 | r[i]=1 64 | else 65 | r[i]=0 66 | end 67 | end 68 | return b2d(r) 69 | 70 | end --_and 71 | 72 | function _or(a,b) 73 | local op1=d2b(a) 74 | local op2=d2b(b) 75 | local r={} 76 | 77 | for i=1,32 do 78 | if op1[i]==1 or op2[i]==1 then 79 | r[i]=1 80 | else 81 | r[i]=0 82 | end 83 | end 84 | return b2d(r) 85 | end --_or 86 | 87 | function _not(a) 88 | local op1=d2b(a) 89 | local r={} 90 | 91 | for i=1,32 do 92 | if op1[i]==1 then 93 | r[i]=0 94 | else 95 | r[i]=1 96 | end 97 | end 98 | return b2d(r) 99 | end --_not 100 | 101 | function _rshift(a,n) 102 | local op1=d2b(a) 103 | local r=d2b(0) 104 | 105 | if n < 32 and n > 0 then 106 | for i=1,n do 107 | for i=31,1,-1 do 108 | op1[i+1]=op1[i] 109 | end 110 | op1[1]=0 111 | end 112 | r=op1 113 | end 114 | return b2d(r) 115 | end --_rshift 116 | 117 | function _lshift(a,n) 118 | local op1=d2b(a) 119 | local r=d2b(0) 120 | 121 | if n < 32 and n > 0 then 122 | for i=1,n do 123 | for i=1,31 do 124 | op1[i]=op1[i+1] 125 | end 126 | op1[32]=0 127 | end 128 | r=op1 129 | end 130 | return b2d(r) 131 | end --_lshift 132 | 133 | 134 | function _print(tab) 135 | local str="" 136 | for i=1,32 do 137 | str=str .. tab[i] 138 | end 139 | print(str) 140 | end -------------------------------------------------------------------------------- /LuaScript/framework/audio/audioItem.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : audioItem.lua 4 | -- Creator : zg 5 | -- Date : 2016-12-17 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | AudioItem = BaseClass() 11 | 12 | 13 | function AudioItem:initialize(audioData) 14 | self.audioData = audioData 15 | self:initAudio() 16 | end 17 | 18 | 19 | --播放 20 | function AudioItem:initAudio() 21 | local audioAsset = applicationGlobal.audioPlay:getAudioAsset(self.audioData.id .. '') 22 | if audioAsset == nil then 23 | AssetLoader.instance:asyncLoad("Audio/" .. self.audioData.id, function(asset) 24 | applicationGlobal.audioPlay:addAudioAsset(self.audioData.id .. '', asset) 25 | self:loadResoureFinish(asset) 26 | end) 27 | else 28 | self:loadResoureFinish(audioAsset) 29 | end 30 | end 31 | 32 | 33 | function AudioItem:loadResoureFinish(asset) 34 | if self.destroy == true then return end 35 | self.audioSource = self.gameObject:AddComponent(AudioSource) 36 | self.audioSource.clip = asset.mainObject 37 | 38 | if self.audioData.isBackground == 0 then 39 | self.audioSource.volume = applicationGlobal.audioPlay.otherVolume * self.audioData.volume 40 | else 41 | self.audioSource.volume = applicationGlobal.audioPlay.bgMusicVolume * self.audioData.volume 42 | end 43 | 44 | self.audioSource.loop = syntaxUtility.getTrueOrFalse(self.audioData.loop) 45 | self.audioSource:Play() 46 | if not syntaxUtility.getTrueOrFalse(self.audioData.isBackground) then 47 | self.releaseTime = LuaTimer.Add(self.audioSource.clip.length * 1000, 0, function() 48 | applicationGlobal.audioPlay:releaseAudioItem(self.audioData.id .. '', self) 49 | LuaTimer.Delete(self.releaseTime) 50 | self.releaseTime = nil 51 | return false 52 | end) 53 | end 54 | end 55 | 56 | 57 | function AudioItem:playAudio() 58 | if self.audioSource ~= nil then 59 | self.audioSource:Play() 60 | 61 | if not syntaxUtility.getTrueOrFalse(self.audioData.isBackground) then 62 | if self.releaseTime ~= nil then 63 | LuaTimer.Delete(self.releaseTime) 64 | self.releaseTime = nil 65 | end 66 | self.releaseTime = LuaTimer.Add(self.audioSource.clip.length * 1000, 0, function() 67 | applicationGlobal.audioPlay:releaseAudioItem(self.audioData.id .. '', self) 68 | LuaTimer.Delete(self.releaseTime) 69 | self.releaseTime = nil 70 | return false 71 | end) 72 | end 73 | end 74 | end 75 | 76 | 77 | function AudioItem:isBgMusic() 78 | if self.audioData.isBackground == 0 then 79 | return false 80 | else 81 | return true 82 | end 83 | end 84 | 85 | 86 | function AudioItem:setVolume(value) 87 | if self.audioSource ~= nil then 88 | self.audioSource.volume = value * self.audioData.volume 89 | end 90 | end 91 | 92 | 93 | function AudioItem:onDestroy() 94 | self.destroy = true 95 | if self.releaseTime ~= nil then 96 | LuaTimer.Delete(self.releaseTime) 97 | self.releaseTime = nil 98 | end 99 | end 100 | -------------------------------------------------------------------------------- /LuaScript/utility/attributeUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : attributeUtility.lua 4 | -- Creator : ly 5 | -- Date : 2017-3-3 6 | -- Comment : 属性计算工具 7 | -- *************************************************************** 8 | 9 | 10 | module("attributeUtility", package.seeall) 11 | 12 | eunmAttrKey = { 13 | HP = "hp", -- 生命值 14 | ATK = "at", -- 攻击力 15 | AS = "as", -- 攻击速度 16 | MS = "ms", -- 移动速度 17 | SD = "sd", -- 攻击距离 18 | CRIT = "cit", -- 暴击率 19 | DG = "dg", -- 闪避率 20 | BK = "bk", -- 格挡率 21 | CTHM = "cthm", -- 暴击伤害加成 22 | BKHM = "bkhm", -- 格挡伤害加成 23 | DRPT = "drpt", -- 免伤率 24 | LEGATK = "legAtk", -- 军团攻击 25 | LEGDEF = "legDef", -- 军团防御 26 | HOMEHP = "homeHp" 27 | } 28 | 29 | 30 | eunmAttrValueKey = { 31 | BASE = "base", -- 基础值 32 | BASEPT = "basePt", -- 基础百分比 33 | ADD = "add", -- 附加值 34 | ADDPT = "addPt", -- 附加百分比 35 | PT = "pt" -- 总百分比 36 | 37 | } 38 | 39 | -- 设置属性键值 40 | function setAttribute(attributeDic, attrStr) 41 | if attributeDic == nil then attributeDic = {} end 42 | 43 | -- local strArr = stringUtility.split(attrStr, ",") 44 | -- for i,v in ipairs(strArr) do 45 | local subArr = stringUtility.split(attrStr, "_") 46 | if #subArr > 2 then 47 | local attributeValueVO = attributeDic[subArr[1]] 48 | if attributeValueVO ~= nil then 49 | attributeValueVO[subArr[2]] = attributeValueVO[subArr[2]] + tonumber(subArr[3]) 50 | else 51 | attributeValueVO = {} 52 | attributeValueVO[subArr[2]] = tonumber(subArr[3]) 53 | end 54 | attributeDic[subArr[1]] = attributeValueVO 55 | end 56 | -- end 57 | return attributeDic 58 | end 59 | 60 | 61 | function addAttributeValue(oriAttrValueVO, attributeValueVO) 62 | if attributeValueVO == nil or oriAttrValueVO == nil then return end 63 | 64 | oriAttrValueVO.base = attributeValueVO.base or 0 65 | oriAttrValueVO.basePt = attributeValueVO.basePt or 0 66 | oriAttrValueVO.add = attributeValueVO.add or 0 67 | oriAttrValueVO.addPt = attributeValueVO.addPt or 0 68 | oriAttrValueVO.pt = attributeValueVO.pt or 0 69 | 70 | return oriAttrValueVO 71 | end 72 | 73 | 74 | function getTotalValue(oriAttrValueVO) 75 | if oriAttrValueVO == nil then 76 | return 0 77 | end 78 | 79 | local base = oriAttrValueVO.base or 0 80 | local basePt = oriAttrValueVO.basePt or 0 81 | local add = oriAttrValueVO.add or 0 82 | local addPt = oriAttrValueVO.addPt or 0 83 | local pt = oriAttrValueVO.pt or 0 84 | 85 | -- return (base * (1 + basePt) + add * (1 + addPt)) * (1 + pt) 86 | local value = 0 87 | if base ~= 0 or add ~= 0 then 88 | value = (base * (1 + basePt) + add * (1 + addPt)) * (1 + pt) 89 | else 90 | value = pt 91 | end 92 | return value 93 | end 94 | 95 | 96 | function setTotalValue(oriAttrValueVO, value) 97 | if oriAttrValueVO == nil then 98 | return 99 | end 100 | oriAttrValueVO.base = oriAttrValueVO.base or 0 101 | oriAttrValueVO.basePt = oriAttrValueVO.base or 0 102 | oriAttrValueVO.add = oriAttrValueVO.base or 0 103 | oriAttrValueVO.addPt = oriAttrValueVO.base or 0 104 | oriAttrValueVO.pt = oriAttrValueVO.base or 0 105 | 106 | oriAttrValueVO.serverAttrValue = value 107 | 108 | end -------------------------------------------------------------------------------- /LuaScript/framework/loader/assetUtil.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : assetUtil.lua 4 | -- Creator : sf 5 | -- Date : 2017-5-8 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | AssetUtil = BaseClass() 10 | 11 | 12 | function AssetUtil:getAssetWWWPath(path) 13 | local readPath = self:getAssetAbsolutePath(path) 14 | 15 | if string.find(readPath, "jar:file:///") ~= nil then --判断是否为android下的streamingAssets 16 | return readPath 17 | end 18 | 19 | if applicationConfig.macro.UNITY_EDITOR then 20 | readPath = "file:///" .. readPath 21 | else 22 | readPath = "file://" .. readPath 23 | end 24 | return readPath 25 | end 26 | 27 | 28 | --获取Asset完整路径 29 | function AssetUtil:getAssetAbsolutePath(path) 30 | local bundleName = self:addfirstChard(path) --实际用到的bundleName 31 | if bundleName == nil then 32 | return "" 33 | end 34 | -- if assetBB.localizationAssetList[bundleName] ~= nil then --如果是国际化资源需要重新按当前语言获取 35 | -- bundleName = bundleName .. "_" .. languageUtility.getResourceLocalizationName() .. "_" 36 | -- end 37 | bundleName = assetBB.getLocalizationAssetName(bundleName) 38 | 39 | local abpath = nil 40 | if applicationConfig.macro.UNITY_EDITOR and applicationConfig.macro.UNITY_IOS then 41 | abpath = "AssetBundle/IOS/" 42 | abpath = UnityEngine.Application.dataPath .. "/../" .. abpath .. bundleName .. ".ab" 43 | elseif applicationConfig.macro.UNITY_EDITOR and applicationConfig.macro.UNITY_ANDROID then 44 | 45 | abpath = "AssetBundle/Android/" 46 | abpath = UnityEngine.Application.dataPath .. "/../" .. abpath .. bundleName .. ".ab" 47 | 48 | 49 | --方便测试 50 | -- abpath = AssetUtility.instance:getResourcePath(bundleName)..".ab" 51 | else 52 | abpath = AssetUtility.instance:getResourcePath(bundleName)..".ab" --移动平台 53 | end 54 | 55 | LogUtility.ForLogAB(bundleName) 56 | -- print("加载ab=========== "..abpath) 57 | return abpath 58 | end 59 | 60 | 61 | function AssetUtil:addfirstChard(path) 62 | local dest_filename = "" 63 | if string.find(path, "/") == nil then 64 | logInfo("path中不存在'/' :"..path) 65 | end 66 | local fn_flag2 = string.find(path, "/") 67 | 68 | if fn_flag1 then 69 | local dir = string.match(path, "(.+)\\[^\\]*") 70 | if dir == nil or dir == "" then 71 | return path 72 | end 73 | dest_filename = string.match(path, ".+\\([^\\]*)$") 74 | return dir .. "/" ..string.sub(self:getFirstFilChar(dir),1,1) .. dest_filename 75 | end 76 | 77 | if fn_flag2 then 78 | local dir2 = string.match(path, "(.+)/[^/]*") 79 | if dir2 == nil or dir2 == "" then 80 | return path 81 | end 82 | dest_filename = string.match(path, ".+/([^/]*)") 83 | return dir2 .. "/" ..string.sub(self:getFirstFilChar(dir2),1,1) .. dest_filename 84 | end 85 | end 86 | 87 | 88 | --传路径 89 | function AssetUtil:getFirstFilChar(path) 90 | local index = string.find(path, "/") 91 | if index ~= nil then 92 | return self:getFirstFilChar(string.sub(path,index + 1)) 93 | end 94 | return path 95 | end 96 | 97 | 98 | -- function AssetUtil:encryptData(data) 99 | -- return 100 | -- end 101 | 102 | 103 | -- function AssetUtil:decryptData(data) 104 | -- return 105 | -- end 106 | 107 | AssetUtil.instance = AssetUtil.new() -------------------------------------------------------------------------------- /LuaScript/applicationGlobal.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : applicationGlobal.lua 4 | -- Creator : zg 5 | -- Date : 2016-11-10 6 | -- Comment : 全局信息 7 | -- *************************************************************** 8 | 9 | 10 | module("applicationGlobal", package.seeall) 11 | 12 | 13 | --服务器配置 14 | serverConfig = nil 15 | 16 | 17 | --可能未拷贝资源时就用到了AlertPanel,所以如需用到需要先调用这里初始化一下,预先从Resource下加载一个 18 | function prepareAlert() 19 | alert = ScriptManager.GetInstance():LoadScriptBehaviourFromStartup("UI/Alert/AlertPanel") 20 | WindowUtility.instance:adjustmentPanelDepth(alert.gameObject, WindowLayerDefinition.wldAlertLayer.layerIndex) 21 | layerUtility.setLayer(alert.gameObject, WindowLayerDefinition.wldAlertLayer.renderLayerIndex) 22 | GameObjectUtility.AddGameObject(WindowLayerManager.instance:getLayerRootObject(WindowLayerDefinition.wldAlertLayer), alert.gameObject) 23 | alert:initialize() 24 | end 25 | 26 | 27 | --进入登录场景之后 28 | function enterLoginBefore() 29 | tooltip = WindowLayerManager.instance:builder("UI/Tooltip/TooltipPanel", WindowLayerDefinition.wldTooltipLayer) 30 | 31 | if alert ~= nil then --销毁登陆之前预先创建的 32 | GameObject.Destroy(alert.gameObject) 33 | end 34 | alert = WindowLayerManager.instance:builder("UI/AlertTip/AlertPanel", WindowLayerDefinition.wldAlertLayer) 35 | 36 | reconnect = WindowLayerManager.instance:builder("UI/Reconnect/ReConnectPanel", WindowLayerDefinition.wldReconnectLayer) 37 | loading = WindowLayerManager.instance:builder("UI/Common/CommonLoadingPanel", WindowLayerDefinition.wldReconnectLayer) 38 | 39 | GameObjectUtility.AddGameObject(WindowLayerManager.instance:getLayerRootObject(WindowLayerDefinition.wldTooltipLayer), tooltip.gameObject) 40 | GameObjectUtility.AddGameObject(WindowLayerManager.instance:getLayerRootObject(WindowLayerDefinition.wldAlertLayer), alert.gameObject) 41 | GameObjectUtility.AddGameObject(WindowLayerManager.instance:getLayerRootObject(WindowLayerDefinition.wldReconnectLayer), reconnect.gameObject) 42 | GameObjectUtility.AddGameObject(WindowLayerManager.instance:getLayerRootObject(WindowLayerDefinition.wldReconnectLayer), loading.gameObject) 43 | 44 | tooltip:initialize() 45 | alert:initialize() 46 | reconnect:initialize() 47 | loading:initialize() 48 | 49 | WindowQueueManager.instance:initialize() 50 | WindowQueueRegister:initialize() 51 | 52 | -- 引导层 53 | guidePanel = WindowLayerManager.instance:builder("UI/Guide/GuidePanel", WindowLayerDefinition.wldGuideLayer) 54 | GameObjectUtility.AddGameObject(WindowLayerManager.instance:getLayerRootObject(WindowLayerDefinition.wldGuideLayer), guidePanel.gameObject) 55 | guidePanel:initialize() 56 | 57 | -- 升级界面 58 | playerUILevelUpPanel = WindowLayerManager.instance:builder("UI/MainPanel/MainUILevelUpPanel", WindowLayerDefinition.wldDiglogLayer) 59 | GameObjectUtility.AddGameObject(WindowLayerManager.instance:getLayerRootObject(WindowLayerDefinition.wldDiglogLayer), playerUILevelUpPanel.gameObject) 60 | playerUILevelUpPanel:initialize() 61 | 62 | WindowCamera.instance:initialize() 63 | end 64 | 65 | 66 | logger = syntaxUtility.getInstance("framework/logger/loggerManager") 67 | audioPlay = syntaxUtility.getInstance("framework/audio/audioPlay") 68 | sceneSwitchManager = syntaxUtility.getInstance("framework/scene/sceneSwitchManager") 69 | 70 | effectCache = syntaxUtility.getInstance("battle/effect/effectCache") 71 | sceneObjectEffect = syntaxUtility.getInstance("battle/sceneObject/sceneObjectEffect") 72 | assetLoader = syntaxUtility.getInstance("framework/loader/assetLoader") -------------------------------------------------------------------------------- /LuaScript/framework/window/windowRapidBlurEffect.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowRapidBlurEffect.lua 4 | -- Creator : sf 5 | -- Date : 2017-10-25 6 | -- Comment : 毛玻璃 7 | -- *************************************************************** 8 | 9 | 10 | WindowRapidBlurEffect = BaseClass() 11 | 12 | 13 | function WindowRapidBlurEffect:initData() 14 | self.init = false 15 | self.commandBuffer = nil 16 | self.material = nil 17 | self.copyTexId = nil 18 | self.tempTexID = nil 19 | self.shaderName = "Yeto/UI/Rapid Blur" 20 | self.downSampleNum = 2 21 | self.blurSpreadSize = 2 22 | self.blurIterations = 3 23 | self.show = false 24 | end 25 | 26 | 27 | function WindowRapidBlurEffect:enableRapidBlurEffect() 28 | if self.init == nil or not self.init then 29 | self:initData() 30 | self.init = true 31 | end 32 | if self.show then 33 | return 34 | end 35 | 36 | self.show = true 37 | self.material = nil 38 | self.material = Material(shaderUtility.getShader(self.shaderName)) 39 | self.material:SetFloat("_AntiAliasing", QualitySettings.antiAliasing) 40 | 41 | self.commandBuffer = Rendering.CommandBuffer() 42 | self.commandBuffer.name = "RapidBlurEffect" 43 | 44 | self.srcTex = Shader.PropertyToID("srcTex") 45 | self.commandBuffer:GetTemporaryRT(self.srcTex, -1, -1, 0, FilterMode.Bilinear) 46 | self.tempTexId1 = Shader.PropertyToID("tempTex1") 47 | self.commandBuffer:GetTemporaryRT(self.tempTexId1, -3, -3, 0, FilterMode.Bilinear) 48 | self.tempTexId2 = Shader.PropertyToID("tempTex2"); 49 | self.commandBuffer:GetTemporaryRT(self.tempTexId2, -3, -3, 0, FilterMode.Bilinear) 50 | 51 | self.commandBuffer:Blit(SLuaSupportUtility.RenderTargetIdentifier(1, Rendering.BuiltinRenderTextureType.CurrentActive), SLuaSupportUtility.RenderTargetIdentifier(2, self.srcTex)) 52 | self.commandBuffer:Blit(SLuaSupportUtility.RenderTargetIdentifier(2, self.srcTex), SLuaSupportUtility.RenderTargetIdentifier(2, self.tempTexId1), self.material, 0) 53 | 54 | for i = 0, self.blurIterations - 1 do 55 | local iterationOffs = i * 1.0 56 | self.material:SetFloat("_DownSampleValue", self.blurSpreadSize * (1.0 / (1.0 * 4)) + iterationOffs) 57 | 58 | self.commandBuffer:Blit(SLuaSupportUtility.RenderTargetIdentifier(2, self.tempTexId1), SLuaSupportUtility.RenderTargetIdentifier(2, self.tempTexId2), self.material, 1) 59 | self.commandBuffer:Blit(SLuaSupportUtility.RenderTargetIdentifier(2, self.tempTexId2), SLuaSupportUtility.RenderTargetIdentifier(2, self.tempTexId1), self.material, 2) 60 | end 61 | 62 | self.commandBuffer:Blit(SLuaSupportUtility.RenderTargetIdentifier(2, self.tempTexId1), SLuaSupportUtility.RenderTargetIdentifier(1, Rendering.BuiltinRenderTextureType.CameraTarget)) 63 | local camera = self.gameObject:GetComponent(Camera) 64 | camera:AddCommandBuffer(Rendering.CameraEvent.AfterForwardAlpha, self.commandBuffer) 65 | end 66 | 67 | 68 | function WindowRapidBlurEffect:disableRapidBlurEffect() 69 | if not self.show then 70 | return 71 | end 72 | 73 | self.show = false 74 | local camera2 = self.gameObject:GetComponent(Camera) 75 | if self.commandBuffer ~= nil then 76 | self.commandBuffer:ReleaseTemporaryRT(self.srcTex) 77 | self.commandBuffer:ReleaseTemporaryRT(self.tempTexId1) 78 | self.commandBuffer:ReleaseTemporaryRT(self.tempTexId2) 79 | camera2:RemoveCommandBuffer(Rendering.CameraEvent.AfterForwardAlpha, self.commandBuffer) 80 | --camera2:RemoveAllCommandBuffers() 81 | self.commandBuffer:Clear() 82 | end 83 | 84 | --self.material 85 | 86 | 87 | end -------------------------------------------------------------------------------- /LuaScript/framework/layer/windowLayerManager.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowLayerManager.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-11 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | WindowLayerManager = BaseClass() 11 | 12 | 13 | WindowLayerManager.layerDict = {} 14 | 15 | 16 | function WindowLayerManager:builder(scriptResourcePath, layerDefinition) 17 | local scriptBehaviour = ScriptManager.GetInstance():LoadScriptBehaviourFromResource(scriptResourcePath) 18 | if scriptBehaviour == nil then 19 | print("scriptBehaviour is nil") 20 | end 21 | self:apply(scriptBehaviour.gameObject, layerDefinition) 22 | return scriptBehaviour 23 | end 24 | 25 | 26 | function WindowLayerManager:apply(go, layerDefintion) 27 | WindowUtility.instance:adjustmentPanelDepth(go, layerDefintion.layerIndex) 28 | layerUtility.setLayer(go, layerDefintion.renderLayerIndex) 29 | end 30 | 31 | 32 | --得到层的根节点 33 | function WindowLayerManager:getLayerRootObject(layerDefinition) 34 | local holder = WindowLayerManager.layerDict[layerDefinition] 35 | if holder ~= nil then 36 | return holder.gameObject 37 | end 38 | end 39 | 40 | 41 | --清除层里面的所有子对象 42 | function WindowLayerManager:clearLayerObject(layerDefinition) 43 | local holder = WindowLayerManager.layerDict[layerDefinition] 44 | if holder ~= nil then 45 | local layerObject = holder.gameObject 46 | GameObjectUtility.ClearChildGameObject(layerObject, false) 47 | end 48 | end 49 | 50 | 51 | --构建所有的层, 特殊的loading图层已经开始的时候就加入进来了 52 | function WindowLayerManager:buildHolder(rootGo) 53 | local scene2d = GameObject.Find("UI Root/Scene2d") --检查scene2d是否有创建 54 | 55 | if scene2d == nil then 56 | local scene2d = GameObject("Scene2d") 57 | GameObjectUtility.AddGameObject(rootGo, scene2d) 58 | end 59 | 60 | for layerName, layerDefinition in pairs(WindowLayerDefinition) do 61 | local tr = scene2d.transform:Find(layerName) 62 | local layerGameObject = nil 63 | if tr == nil then 64 | layerGameObject = GameObject() 65 | layerGameObject.name = layerName 66 | GameObjectUtility.AddGameObject(scene2d, layerGameObject) 67 | else 68 | layerGameObject = tr.gameObject 69 | end 70 | 71 | layerHolder = {} 72 | layerHolder.gameObject = layerGameObject 73 | layerHolder.layerName = layerName 74 | layerHolder.layerDefinition = layerDefinition 75 | 76 | WindowLayerManager.layerDict[layerDefinition] = layerHolder 77 | end 78 | end 79 | 80 | 81 | --交换两个图层 82 | function WindowLayerManager:swapLayer(srcLayerDef, destLayerDef) 83 | local destGo = self:getLayerRootObject(destLayerDef) 84 | if GameObjectUtility.IsExistsChildGameObject(destGo) == true then 85 | for i = 0, destGo.transform.childCount - 1 do 86 | trans = destGo.transform:GetChild(i) 87 | error(trans.gameObject.name .. "MMP 占聊天的层了") 88 | end 89 | error("Layer definition child object is not nil : " ) 90 | print_t(destLayerDef) 91 | end 92 | 93 | local srcGo = self:getLayerRootObject(srcLayerDef) 94 | local srcChildList = GameObjectUtility.GetChildGameObject(srcGo) 95 | local srcChildGo 96 | for i = 1, #srcChildList do 97 | srcChildGo = srcChildList[i] 98 | if srcChildGo ~= nil then 99 | self:apply(srcChildGo, destLayerDef) 100 | GameObjectUtility.AddGameObject(self:getLayerRootObject(destLayerDef), srcChildGo) 101 | end 102 | end 103 | end 104 | 105 | 106 | WindowLayerManager.instance = WindowLayerManager.new() -------------------------------------------------------------------------------- /LuaScript/utility/spriteProxy.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : spriteProxy.lua 4 | -- Creator : pyh 5 | -- Date : 2016-12-29 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("spriteProxy", package.seeall) 11 | 12 | local consumeAtlasPath = "Atlas/ItemIcon/ConsumeAtlas" --消耗类0 13 | local materialAtlasPath = "Atlas/ItemIcon/MaterialAtlas" --材料类 14 | local captainEquipAtlasPath = "Atlas/ItemIcon/CaptainEquipAtlas" --舰长装备 15 | local cardSoulAtlasPath = "Atlas/ItemIcon/CardSoulAtlas" --卡魂 16 | local cardItemAtlasPath = "Atlas/ItemIcon/CardItemAtlas" --卡魂 17 | local consumeAtlas1Path = "Atlas/ItemIcon/ConsumeAtlas1" --消耗类1 18 | 19 | 20 | function getAtalsPath(altas) 21 | if altas == 0 then 22 | return consumeAtlasPath 23 | elseif altas == 1 then 24 | return materialAtlasPath 25 | elseif altas == 2 then 26 | return captainEquipAtlasPath 27 | elseif altas == 3 then 28 | return cardSoulAtlasPath 29 | elseif altas == 4 then 30 | return cardItemAtlasPath 31 | elseif altas == 5 then 32 | return consumeAtlas1Path 33 | else 34 | return "" 35 | end 36 | end 37 | 38 | 39 | function getTroopAtalsPath(isTroop) 40 | if isTroop == false then 41 | return "Atlas/CardMagic/CardMagic" 42 | else 43 | return "Atlas/CardTroopEquip/CardTroopEquip" 44 | end 45 | end 46 | 47 | 48 | function getItemFrameSpriteNameByQualityV6(itemQuality) 49 | local spriteName = "" 50 | if itemQuality == 1 then 51 | spriteName = "BG-wupin-bai" 52 | elseif itemQuality == 2 then 53 | spriteName = "BG-wupin-lv" 54 | elseif itemQuality == 3 then 55 | spriteName = "BG-wupin-lan" 56 | elseif itemQuality == 4 then 57 | spriteName = "BG-wupin-zi" 58 | elseif itemQuality == 5 then 59 | spriteName = "BG-wupin-cheng" 60 | elseif itemQuality == 0 then 61 | spriteName = "BG-wupin-wu" 62 | end 63 | 64 | return spriteName 65 | end 66 | 67 | 68 | function isArmFrameLackByType(itemType) 69 | if itemType == bagBB.itemType.token or itemType == bagBB.itemType.generalEquip or itemType == bagBB.itemType.cardSoul or 70 | itemType == bagBB.itemType.ordnancePiece or itemType == bagBB.itemType.ordnanceDrawings then 71 | return true 72 | end 73 | return false 74 | end 75 | 76 | 77 | -- 获取物品缺角品质框和非缺角品质框 78 | function getArmFrameSpriteNameByQualityType(itemQuality,itemType) 79 | local spriteName = "" 80 | if isArmFrameLackByType(itemType) == true then 81 | if itemQuality == 1 then 82 | spriteName = "BG-wupin-bai" 83 | --"card-bai" 84 | elseif itemQuality == 2 then 85 | spriteName = "BG-wupin-lv" 86 | --"card-lv" 87 | elseif itemQuality == 3 then 88 | spriteName = "BG-wupin-lan" 89 | --"card-lan" 90 | elseif itemQuality == 4 then 91 | spriteName = "BG-wupin-zi" 92 | --"card-zi" 93 | elseif itemQuality == 5 then 94 | spriteName = "BG-wupin-cheng" 95 | --"card-cheng" 96 | end 97 | return spriteName 98 | else 99 | spriteName = getItemFrameSpriteNameByQualityV6(itemQuality) 100 | return spriteName 101 | end 102 | end 103 | 104 | 105 | function getSubQualitySprite(itemQuality) 106 | if itemQuality == 2 then 107 | return "BG-wupin-lv+" 108 | elseif itemQuality == 3 then 109 | return "BG-wupin-lan+" 110 | elseif itemQuality == 4 then 111 | return "BG-wupin-zi+" 112 | elseif itemQuality == 5 then 113 | return "BG-wupin-cheng+" 114 | else 115 | return "" 116 | end 117 | end 118 | 119 | 120 | function getCardTroopSkill(iconAtlas) 121 | if iconAtlas == "CardTroopSkill1" then 122 | return "Atlas/CardTroopSkill1/CardTroopSkill1" 123 | elseif iconAtlas == "CardTroopSkill2" then 124 | return "Atlas/CardTroopSkill2/CardTroopSkill2" 125 | else 126 | return "" 127 | end 128 | end -------------------------------------------------------------------------------- /LuaScript/framework/loader/listLoader.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : listLoader.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-13 6 | -- Comment : 顺序载入器, 进入场景后,这个要不要释放值得商榷, 因为这里可能需要保持一些引用 7 | -- *************************************************************** 8 | 9 | 10 | ListLoader = BaseClass() 11 | 12 | 13 | function ListLoader:ctor() 14 | self.waitList = {} 15 | self.assetListT = {} 16 | self.loadTaskList = {} 17 | self.callbackLoadComplete = nil 18 | self.lastWait = nil 19 | 20 | self.loadTotal = 0 --总下载队列数量 21 | self.loadCount = 0 --剩余还在下载的数量 22 | 23 | self.combProgress = 0 24 | self.removeTaskList = {} 25 | end 26 | 27 | 28 | function ListLoader:putWaitLoad(waitLoadResource) 29 | table.insert(self.waitList, waitLoadResource) 30 | end 31 | 32 | 33 | --启动装载 34 | function ListLoader:load() 35 | if #self.waitList == 0 and self.callbackLoadComplete ~= nil then --检查是否有需要装载的, 没有直接回调 36 | self.callbackLoadComplete() 37 | end 38 | self.loadTotal = #self.waitList --初始化载入的数量 39 | self.loadCount = #self.waitList 40 | for i = 1, #self.waitList do 41 | local loadTask = AssetLoader.instance:asyncLoad(self.waitList[i]) --启动异步载入资源 42 | if loadTask == nil then 43 | self.loadCount = self.loadCount - 1 --如果发现这个载入为nil, 则代表这个载入可能已经完成了, 去掉一个载入的 44 | else 45 | table.insert(self.loadTaskList, loadTask) --把这个放入载入列表 46 | end 47 | if i == #self.waitList then 48 | self.lastWait = self.waitList[i] 49 | end 50 | end 51 | self.waitList = {} 52 | self.isStart = true 53 | end 54 | 55 | 56 | --启动以后每帧都去更新载入资源, 载入完成后这个对象需要被删除 57 | function ListLoader:update() 58 | if self.isStart == false then --没有开始返回 59 | return 60 | end 61 | 62 | local currentCombProgress = 0 63 | for k,v in pairs(self.loadTaskList) do 64 | local loadTask = v 65 | if loadTask:isDone() then --如果装载任务完成了 66 | local loadState = loadTask:getLoadState() 67 | if loadState == assetBB.enumLoadState.success then 68 | local assetTemp = AssetLoader.instance:getAsset(loadTask.path) 69 | if assetTemp ~= nil then 70 | assetTemp:AddRef() 71 | end 72 | table.insert(self.assetListT, assetTemp) 73 | else 74 | logInfo("加载资源失败: " .. loadTask.path .. " 失败原因:" .. loadTask.failReason) --不然失败报告失败原因 75 | end 76 | self.loadCount = self.loadCount - 1 77 | table.remove(self.loadTaskList, k) --如果载入完成后, 则载入数量-1 --载入完成后放入载入列表 78 | else 79 | currentCombProgress = currentCombProgress + (loadTask.progress / self.loadTotal) --调整当前的进度 80 | end 81 | end 82 | 83 | if self.loadTotal ~= 0 or currentCombProgress ~= 0 then 84 | self.combProgress = (self.loadTotal - self.loadCount) / self.loadTotal + currentCombProgress 85 | end 86 | if self.combProgress < 0 then self.combProgress = 0 end 87 | 88 | 89 | if self.loadCount == 0 and self.callbackLoadComplete ~= nil then 90 | if self.lastWait ~= nil then 91 | self.isStart = false 92 | self.callbackLoadComplete(self.lastWait) 93 | else 94 | self.isStart = false 95 | end 96 | self.combProgress = 1 97 | end 98 | end 99 | 100 | 101 | function ListLoader:setCallback(callbackFun) 102 | self.callbackLoadComplete = callbackFun 103 | end 104 | 105 | 106 | function ListLoader:dispose() 107 | if self.assetListT ~= nil then 108 | for i = 1, #self.assetListT do 109 | local asset = self.assetListT[i] 110 | asset:ReleaseRef() 111 | end 112 | self.assetListT = nil 113 | end 114 | self.callbackLoadComplete = nil 115 | end -------------------------------------------------------------------------------- /LuaScript/platform/platformResponse.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : platformResponse.lua 4 | -- Creator : zg 5 | -- Date : 2016-11-30 6 | -- Comment : 接受响应net 7 | -- *************************************************************** 8 | 9 | 10 | module("platformResponse", package.seeall) 11 | 12 | 13 | function getInfo(options) 14 | syntaxUtility.mergeTable(applicationConfig.gameConfig, options) 15 | 16 | if options.isDebug == "true" then 17 | applicationConfig.gameConfig.isDebug = true 18 | elseif options.isDebug == "false" then 19 | applicationConfig.gameConfig.isDebug = false 20 | end 21 | 22 | if applicationConfig.gameConfig.rechargePlatform == 0 then 23 | applicationConfig.gameConfig.rechargePlatform = 1 24 | if applicationConfig.macro.UNITY_ANDROID then 25 | applicationConfig.gameConfig.rechargePlatform = 1 26 | elseif applicationConfig.macro.UNITY_IOS then 27 | applicationConfig.gameConfig.rechargePlatform = 2 28 | end 29 | end 30 | 31 | startupStatusManager.httpResponse() 32 | end 33 | 34 | 35 | function login(options) 36 | print("platformResponse login success -----------------") 37 | syntaxUtility.mergeTable(applicationConfig.loginConfig, options) 38 | if applicationConfig.macro.UNITY_EDITOR then 39 | applicationConfig.loginConfig.uid = PlayerPrefs.GetString("auth_key") 40 | else 41 | if applicationConfig.loginConfig.uid and applicationConfig.loginConfig.uid ~= "" then 42 | PlayerPrefs.SetString("auth_key", applicationConfig.loginConfig.uid) 43 | end 44 | -- print(" ===========> SetString auth_key========== ",applicationConfig.loginConfig.uid, print_t(applicationConfig.loginConfig)) 45 | end 46 | 47 | LoginLayer.loginSuccess() 48 | platformRequest.loginComplete() 49 | end 50 | 51 | 52 | function logout() 53 | logInfo("____________ logout() ____________") 54 | applicationGlobal.reconnect:logout() 55 | end 56 | 57 | 58 | function pay() 59 | end 60 | 61 | 62 | function gm() 63 | 64 | end 65 | 66 | 67 | function share() 68 | 69 | end 70 | 71 | 72 | function userCenter() 73 | 74 | end 75 | 76 | 77 | function bbs() 78 | 79 | end 80 | 81 | 82 | function exit() 83 | 84 | end 85 | 86 | 87 | --讯飞登出 88 | function imLogout() 89 | 90 | end 91 | 92 | 93 | -- 协议20106307 推送过来的语音 94 | function oneVoiceIn(options) 95 | print("-----------oneVoiceIn--------") 96 | -- 找到最后一条自己的语音信息-->找到对应的语音Item : 结束上传中 状态, 填写duration ,语音文本 97 | chatBB.sendChatMsg4Android(options) 98 | end 99 | 100 | 101 | -- TODO:点击播放的时候 声音文本 102 | 103 | -- stop录音上传Anim 发协议数据 104 | function isSendRecordOK(options) 105 | --chatPanel jsonObject.put(IFlyConstant.SEND_RECORD_IS_OK, isOk);} "send_record_is_ok" true false 106 | print("-----------isSendRecordOK------------",options) 107 | print_t(options) 108 | 109 | chatBB.stopVoiceAnim(options) 110 | oneVoiceIn(options) 111 | end 112 | 113 | 114 | function stopVoiceAnim(options) 115 | chatBB.stopVoiceAnim(options) 116 | end 117 | 118 | 119 | --IOS GameCenter登录 120 | function loginGameCenter(options) 121 | print("-----------loginGameCenter------------") 122 | logInfo("-----------loginGameCenter------------") 123 | 124 | Social.localUser:Authenticate(platformResponse.loginGameCenterComplete) 125 | end 126 | 127 | 128 | function loginGameCenterComplete( success ) 129 | print("loginGameCenterComplete" .. Social.localUser.id) 130 | print(success) 131 | 132 | if success then 133 | playerInfoBB.isGameCenterLogin = true 134 | platformBridge.requestMessage(platformBridge.enumMessageType.emtLoginValidate, {uid = Social.localUser.id}) 135 | else 136 | applicationGlobal.tooltip:errorMessage(L("ex_sc_game_center_login_failed")) 137 | end 138 | end 139 | -------------------------------------------------------------------------------- /LuaScript/framework/window/windowUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowBase.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-6 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | WindowUtility = BaseClass() 11 | 12 | 13 | --初始化界面的一些元素 14 | function WindowUtility:initializeUIRoot() 15 | if WindowBase.uiRoot == nil then 16 | WindowBase.uiRoot = GameObject.Find("UI Root") 17 | end 18 | if WindowBase.windowRoot == nil then 19 | local windowRoot = GameObject("Window") 20 | GameObjectUtility.AddGameObject(WindowBase.uiRoot, windowRoot) 21 | GameObjectUtility.LocalScale(windowRoot, 1, 1, 1) 22 | WindowBase.windowRoot = windowRoot 23 | end 24 | if WindowBase.windowBackRoot == nil then 25 | local windowBackRoot = GameObject("WindowBack") 26 | GameObjectUtility.AddGameObject(WindowBase.uiRoot, windowBackRoot) 27 | GameObjectUtility.LocalScale(windowBackRoot, 1, 1, 1) 28 | WindowBase.windowBackRoot = windowBackRoot 29 | end 30 | if WindowBase.windowTempRoot == nil then 31 | local tempRoot = GameObject("WindowTemp") --存储UI缓存 32 | GameObjectUtility.AddGameObject(WindowBase.uiRoot, tempRoot) 33 | GameObjectUtility.LocalScale(tempRoot, 1, 1, 1) 34 | WindowBase.windowTempRoot = tempRoot 35 | end 36 | end 37 | 38 | 39 | --对所有的窗口进行排序 40 | function WindowUtility:sortWindow(windowList) 41 | self.sortList = windowList 42 | self.lastSortId = 0 43 | for i=1, #self.sortList do 44 | local window = self.sortList[i] 45 | window.sortId = self.lastSortId 46 | self.lastSortId = self.lastSortId + 1 47 | end 48 | end 49 | 50 | 51 | --调整层次 52 | function WindowUtility:applyAdjustment() 53 | if self.sortList == nil then 54 | return 55 | end 56 | 57 | local baseDepth = WindowLayerDefinition.wldUILayer.layerIndex 58 | local panelDepth = 0 59 | 60 | for i = 1, #self.sortList do 61 | local window = self.sortList[i] 62 | if window ~= nil then 63 | panelDepth = baseDepth + window.sortId * 100 64 | WindowUtility.instance:adjustmentPanelDepth(window.gameObject, panelDepth) 65 | end 66 | end 67 | end 68 | 69 | 70 | --调整面板深度 71 | function WindowUtility:adjustmentPanelDepth(panelGo, panelBaseDepth) 72 | 73 | local originalBaseDepth = panelBaseDepth 74 | local panelArray = GameObjectUtility.GetComponentsInChildren(panelGo, "UIPanel", true) 75 | local panels = panelArray 76 | table.sort(panels, function(a, b) 77 | if a.depth < b.depth then 78 | return true 79 | end 80 | return false 81 | end) 82 | 83 | local maskPanel = nil 84 | for i = 1, #panels do 85 | if panels[i].gameObject.name ~= "WindowMaskPanel(Clone)" then 86 | panels[i].depth = panelBaseDepth 87 | panelBaseDepth = panelBaseDepth + 1 88 | else 89 | maskPanel = panels[i] 90 | end 91 | end 92 | if maskPanel then 93 | maskPanel.depth = originalBaseDepth - 1 94 | end 95 | end 96 | 97 | 98 | --得到适配的大小 99 | function WindowUtility:getAutoAdpateSize() 100 | local ret = 1 101 | if Screen.width / Screen.height < 1280 / 720 then 102 | local logicWidth = Screen.width * 720 / Screen.height 103 | local factor = logicWidth / 1280 104 | ret = factor 105 | end 106 | return ret 107 | end 108 | 109 | 110 | --创建窗口实例 111 | function WindowUtility:windowRes(resourcePath, id, openEffectType, closeEffectType, guassianBlurType) 112 | local res = {} 113 | res.resourcePath = resourcePath 114 | res.id = id 115 | res.openEffectType = openEffectType 116 | res.closeEffectType = closeEffectType 117 | res.guassianBlurType = guassianBlurType 118 | return res 119 | end 120 | 121 | 122 | WindowUtility.instance = WindowUtility.new() -------------------------------------------------------------------------------- /LuaScript/utility/shaderUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : shaderUtility.lua 4 | -- Creator : zg 5 | -- Date : 2016-12-27 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("shaderUtility", package.seeall) 11 | 12 | 13 | shaderRef = nil 14 | allShader = {} 15 | 16 | 17 | function loadShader(callback) 18 | AssetLoader.instance:asyncLoad("Script/graphics", function (asset) 19 | loadShaderComplete(asset) 20 | callback() 21 | end) 22 | end 23 | 24 | 25 | function loadShaderComplete(asset) 26 | shaderRef = asset 27 | shaderRef:AddRef() 28 | local shaderVariantCollection = shaderRef.mainObject 29 | if shaderVariantCollection ~= nil then 30 | shaderVariantCollection:WarmUp() 31 | end 32 | 33 | local assets = shaderRef.assetBundle:LoadAllAssets() 34 | for i=1,#assets do 35 | allShader[assets[i].name] = assets[i] 36 | end 37 | 38 | -- print("打印allShader所有。。。。。。。。。。。。。。。。。。") 39 | -- print_t(allShader) 40 | end 41 | 42 | 43 | function getShader(shaderName) 44 | if applicationConfig.macro.UNITY_EDITOR then 45 | return Shader.Find(shaderName) 46 | else 47 | local shader = allShader[shaderName] 48 | if shader == nil then 49 | -- logInfo("allShader缓存中找不到指定的shader: "..shaderName) 50 | shader = Shader.Find(shaderName) 51 | end 52 | if shader == nil then 53 | -- logInfo("Shader.Find也找不到指定的shader: "..shaderName) 54 | shader = shaderRef.assetBundle:LoadAsset(shaderName) 55 | end 56 | if shader == nil then 57 | logInfo("shaderRef.assetBundle:LoadAsset也找不到指定的shader: "..shaderName) 58 | end 59 | return shader 60 | end 61 | end 62 | 63 | 64 | --重新赋上shader 仅编辑器生效 65 | function resetShader(gameObject) 66 | if not applicationConfig.macro.UNITY_EDITOR then 67 | return 68 | end 69 | if gameObject == nil then 70 | return 71 | end 72 | 73 | local renderers = GameObjectUtility.GetComponentsInChildren(gameObject, "UnityEngine.Renderer,UnityEngine", true) 74 | for i=1, #renderers do 75 | local renderer = renderers[i] 76 | if renderer.sharedMaterials ~= nil and #renderer.sharedMaterials > 0 then 77 | for i = 1, #renderer.sharedMaterials do 78 | if renderer.sharedMaterials[i] ~= nil then 79 | renderer.sharedMaterials[i].shader = Shader.Find(renderer.sharedMaterials[i].shader.name) 80 | end 81 | end 82 | end 83 | end 84 | 85 | local particleRenderers = GameObjectUtility.GetComponentsInChildren(gameObject, "UnityEngine.ParticleSystemRenderer,UnityEngine", true) 86 | for i = 1, #particleRenderers do 87 | local particleRenderer = particleRenderers[i] 88 | if particleRenderer.sharedMaterials ~= nil and #particleRenderer.sharedMaterials > 0 then 89 | for i = 1, #particleRenderer.sharedMaterials do 90 | if particleRenderer.sharedMaterials[i] ~= nil then 91 | particleRenderer.sharedMaterials[i].shader = Shader.Find(particleRenderer.sharedMaterials[i].shader.name) 92 | end 93 | end 94 | end 95 | end 96 | 97 | local meshRenders = GameObjectUtility.GetComponentsInChildren(gameObject, "UnityEngine.MeshRenderer,UnityEngine", true) 98 | for i = 1, #meshRenders do 99 | local meshRenderer = meshRenders[i] 100 | if meshRenderer.sharedMaterials ~= nil and #meshRenderer.sharedMaterials > 0 then 101 | for i = 1, #meshRenderer.sharedMaterials do 102 | if meshRenderer.sharedMaterials[i] ~= nil then 103 | meshRenderer.sharedMaterials[i].shader = Shader.Find(meshRenderer.sharedMaterials[i].shader.name) 104 | end 105 | end 106 | end 107 | end 108 | end -------------------------------------------------------------------------------- /LuaScript/framework/audio/audioConfig.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : audioConfig.lua 4 | -- Creator : zg 5 | -- Date : 2016-12-16 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("audioConfig", package.seeall) 11 | 12 | -- 背景音乐 13 | Audio_Normal_Background_music_1 = "20001" -- 背景音效(平时1) 14 | -- Audio_Normal_Background_music_2 = "20002" --背景音效(平时2) 15 | Audio_Battle_Background_music_1 = "20003" -- 背景音效(战斗1) 16 | -- Audio_Battle_Background_music_2 = "20004" -- 背景音效(战斗2) 17 | -- Audio_Battle_Background_music_3 = "20005" -- 背景音效(战斗3) 18 | -- Audio_Battle_Background_music_4 = "20006" -- 背景音效(战斗4) 19 | Audio_Normal_Background_music_5 = "20007" -- 星际远征1 20 | Audio_Normal_Background_music_6 = "20008" -- 银河联赛 21 | Audio_Normal_Background_music_7 = "20009" -- 星际远征2 22 | Audio_Normal_Background_music_8 = "20010" -- 军团背景 23 | Audio_Normal_Background_music_9 = "20011" -- 联赛匹配界面1 24 | Audio_Normal_Background_music_10 = "20012" -- 联赛匹配界面2 25 | -- end 26 | 27 | -- 系统音效 28 | Audio_Click_Tips = "10001" --通用点击音效:通用按钮点击触发/战斗时操作兵种单位触发 29 | Audio_Return_Tips = "10002" --通用返回音效:通用返回按钮点击触发 30 | Audio_Warn_Tips = "10003" --无效点击:点击按钮无效并反馈相应飘字触发 31 | Audio_PopUp_Tips = "10004" --提示点击:点弹出确认弹窗触发 32 | Audio_Interface_Tips = "10005" --打开2级界面:2级界面打开时触发/军械合成界面弹出触发 33 | Audio_CloseInterface_Tips = "10006" --关闭2级界面:2级界面关闭时触发 34 | Audio_LeftLabel_Switching = "10007" -- 左侧标签切换:左侧标签按钮点击触发 35 | Audio_TopLabel_Switching = "10008" -- 顶部标签切换:顶部标签按钮点击触发 36 | Audio_Roll_Switching = "10009" -- 滚动入位:卡牌列表,任务列表,钻石副本列表滚动入位时触发 37 | Audio_Reward_Switching = "10010" -- 领取:任务&成就奖励领取按钮触发 38 | Audio_CancelCard_Switching = "10011" -- 撤回卡牌:编队界面中,点击撤回出战卡牌触发 39 | Audio_IntoCard_Switching = "10012" -- 上阵卡牌:编队界面中,点击添加出战卡牌触发 40 | Audio_ComposeEquip_Switching = "10013" -- 合成军械:点击军械合成按钮触发 41 | Audio_ApparelEquip_Switching = "10014" -- 装备军械:点击军械装备按钮触发 42 | Audio_ClickCard_Switching = "10015" -- 点击手牌:战斗中点击手牌触发 43 | Audio_DevelopTalk_Switching = "10016" -- 展开聊天栏:聊天栏展开时触发 44 | Audio_CloseTalk_Switching = "10017" -- 收起聊天栏:聊天栏收起时触发 45 | Audio_IntoGalaxy_Switching = "10018" -- 进入星系:点击有效星系图标(星系已解锁)并进入时触发 46 | Audio_IntoCelestialBody_Switching = "10019" -- 进入星球:点击有效星球图标(星球已解锁)并进入时触发 47 | Audio_Panel_CommonTreasure = "10027" -- 通用开启宝箱动画 48 | -- end 49 | 50 | -- 舰长音效 51 | Audio_Captain_Skill_LevelUp = "10021" -- 舰长技能升级时触发 52 | Audio_Captain_Exp_Add = "10022" -- 舰长吃经验书时触发 53 | Audio_Captain_LevelUp = "10023" -- 舰长升级时触发 54 | Audio_Captain_StarUp = "10024" -- 舰长升星时触发 55 | --end 56 | 57 | -- 战斗结算 58 | Audio_BattleResult_Win = "10025" -- 战斗胜利结算界面触发 59 | Audio_BattleResult_Fail = "10026" -- 战斗失败结算界面触发 60 | --end 61 | 62 | Audio_AwardCard_Get = "10029" -- 卡牌获得背景音效 63 | 64 | 65 | -- 战斗相关音效 66 | Audio_No_Energy = "810007" -- 能量不足 67 | Audio_Converge = "810008" -- 集火 68 | 69 | 70 | Audio_Qualifying_AddStar = "10030" --联赛结算升星音效 71 | Audio_Qualifying_ReduceStar = "10031" --联赛结算降星音效 72 | Audio_Qualifying_Promote = "10023" --联赛结算军衔晋升音效 73 | Audio_Qualifying_Result = "10033" --联赛结算(弹出胜负)音效 -------------------------------------------------------------------------------- /LuaScript/framework/library/LuaXml.lua: -------------------------------------------------------------------------------- 1 | require("LuaXML_lib") 2 | 3 | local base = _G 4 | local xml = xml 5 | module("xml") 6 | 7 | -- symbolic name for tag index, this allows accessing the tag by var[xml.TAG] 8 | TAG = 0 9 | 10 | -- sets or returns tag of a LuaXML object 11 | function tag(var,tag) 12 | if base.type(var)~="table" then return end 13 | if base.type(tag)=="nil" then 14 | return var[TAG] 15 | end 16 | var[TAG] = tag 17 | end 18 | 19 | -- creates a new LuaXML object either by setting the metatable of an existing Lua table or by setting its tag 20 | function new(arg) 21 | if base.type(arg)=="table" then 22 | base.setmetatable(arg,{__index=xml, __tostring=xml.str}) 23 | return arg 24 | end 25 | local var={} 26 | base.setmetatable(var,{__index=xml, __tostring=xml.str}) 27 | if base.type(arg)=="string" then var[TAG]=arg end 28 | return var 29 | end 30 | 31 | -- appends a new subordinate LuaXML object to an existing one, optionally sets tag 32 | function append(var,tag) 33 | if base.type(var)~="table" then return end 34 | local newVar = new(tag) 35 | var[#var+1] = newVar 36 | return newVar 37 | end 38 | 39 | -- converts any Lua var into an XML string 40 | function str(var,indent,tagValue) 41 | if base.type(var)=="nil" then return end 42 | local indent = indent or 0 43 | local indentStr="" 44 | for i = 1,indent do indentStr=indentStr.." " end 45 | local tableStr="" 46 | 47 | if base.type(var)=="table" then 48 | local tag = var[0] or tagValue or base.type(var) 49 | local s = indentStr.."<"..tag 50 | for k,v in base.pairs(var) do -- attributes 51 | if base.type(k)=="string" then 52 | if base.type(v)=="table" and k~="_M" then -- otherwise recursiveness imminent 53 | tableStr = tableStr..str(v,indent+1,k) 54 | else 55 | s = s.." "..k.."=\""..encode(base.tostring(v)).."\"" 56 | end 57 | end 58 | end 59 | if #var==0 and #tableStr==0 then 60 | s = s.." />\n" 61 | elseif #var==1 and base.type(var[1])~="table" and #tableStr==0 then -- single element 62 | s = s..">"..encode(base.tostring(var[1])).."\n" 63 | else 64 | s = s..">\n" 65 | for k,v in base.ipairs(var) do -- elements 66 | if base.type(v)=="string" then 67 | s = s..indentStr.." "..encode(v).." \n" 68 | else 69 | s = s..str(v,indent+1) 70 | end 71 | end 72 | s=s..tableStr..indentStr.."\n" 73 | end 74 | return s 75 | else 76 | local tag = base.type(var) 77 | return indentStr.."<"..tag.."> "..encode(base.tostring(var)).." \n" 78 | end 79 | end 80 | 81 | 82 | -- saves a Lua var as xml file 83 | function save(var,filename) 84 | if not var then return end 85 | if not filename or #filename==0 then return end 86 | local file = base.io.open(filename,"w") 87 | file:write("\n\n\n") 88 | file:write(str(var)) 89 | base.io.close(file) 90 | end 91 | 92 | 93 | -- recursively parses a Lua table for a substatement fitting to the provided tag and attribute 94 | function find(var, tag, attributeKey,attributeValue) 95 | -- check input: 96 | if base.type(var)~="table" then return end 97 | if base.type(tag)=="string" and #tag==0 then tag=nil end 98 | if base.type(attributeKey)~="string" or #attributeKey==0 then attributeKey=nil end 99 | if base.type(attributeValue)=="string" and #attributeValue==0 then attributeValue=nil end 100 | -- compare this table: 101 | if tag~=nil then 102 | if var[0]==tag and ( attributeValue == nil or var[attributeKey]==attributeValue ) then 103 | base.setmetatable(var,{__index=xml, __tostring=xml.str}) 104 | return var 105 | end 106 | else 107 | if attributeValue == nil or var[attributeKey]==attributeValue then 108 | base.setmetatable(var,{__index=xml, __tostring=xml.str}) 109 | return var 110 | end 111 | end 112 | -- recursively parse subtags: 113 | for k,v in base.ipairs(var) do 114 | if base.type(v)=="table" then 115 | local ret = find(v, tag, attributeKey,attributeValue) 116 | if ret ~= nil then return ret end 117 | end 118 | end 119 | end 120 | -------------------------------------------------------------------------------- /LuaScript/utility/syntaxUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : syntaxUtility.lua 4 | -- Creator : zg 5 | -- Date : 2016-11-13 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("syntaxUtility", package.seeall) 11 | 12 | 13 | function createEnum(tb, index) 14 | if type(tb) ~= "table" then 15 | error("Sorry, it's not table, it is " .. type(tb) .. ".") 16 | end 17 | local enumtbl = {} 18 | local enumindex = index or 0 19 | for i, v in ipairs(tb) do 20 | enumtbl[v] = enumindex + i 21 | end 22 | return enumtbl 23 | end 24 | 25 | 26 | function string2Table(str) 27 | return loadstring("return "..str) 28 | end 29 | 30 | 31 | function reverseKeyValue(tb) 32 | local tb2 = {} 33 | table.foreach(tb, function(k, v) 34 | tb2[v] = k 35 | end) 36 | end 37 | 38 | 39 | function mergeTable(tb1, tb2) 40 | table.foreach(tb2, function(k, v) 41 | tb1[k] = v 42 | end) 43 | end 44 | 45 | 46 | --深拷贝 47 | function deepCopy(object) 48 | local lookupTable = {} 49 | local function copy(object) 50 | if type(object) ~= "table" then 51 | return object 52 | elseif lookupTable[object] then 53 | return lookupTable[object] 54 | end 55 | local newTable = {} 56 | lookupTable[object] = newTable 57 | for index, value in pairs(object) do 58 | newTable[copy(index)] = copy(value) 59 | end 60 | return setmetatable(newTable, getmetatable(object)) 61 | end 62 | return copy(object) 63 | end 64 | 65 | 66 | function checkTableKey(table) 67 | 68 | end 69 | 70 | 71 | function sortById(a, b) 72 | if a.id < b.id then 73 | return true 74 | end 75 | return false 76 | end 77 | 78 | 79 | function getTrueOrFalse(num) 80 | if num == 1 then 81 | return true 82 | else 83 | return false 84 | end 85 | end 86 | 87 | 88 | function addDelegate(reftb, delegate, delegateName, callback) 89 | reftb[delegate.name .. delegateName] = callback 90 | delegate[delegateName] = {'+=', callback} 91 | end 92 | 93 | 94 | function removeDelegate(reftb, delegate, delegateName) 95 | callback = reftb[delegate.name .. delegateName] 96 | delegate[delegateName] = {'-=', callback} 97 | end 98 | 99 | 100 | --移除对象(适用list) 101 | function removeItem(list, item, isAll) 102 | local rmCount = 0 103 | for i = 1, #list do 104 | if list[i - rmCount] == item then 105 | table.remove(list, i - rmCount) 106 | if isAll then 107 | rmCount = rmCount + 1 108 | else 109 | break 110 | end 111 | end 112 | end 113 | end 114 | 115 | 116 | --获取table长度(适用key非顺序的table) 117 | function getTableCount(listTable) 118 | local count = 0 119 | if listTable ~= nil then 120 | for k,v in pairs(listTable) do 121 | count = count + 1 122 | end 123 | end 124 | 125 | return count 126 | end 127 | 128 | 129 | function createItem(parentTransform, goPrefab, scriptName) 130 | local go = Object.Instantiate(goPrefab) 131 | go:SetActive(true) 132 | local luaTabel = ScriptManager.GetInstance():WrapperWindowControl(go, scriptName) 133 | go.transform.parent = parentTransform 134 | GameObjectUtility.LocalPosition(go, 0, 0, 0) 135 | go.transform.localRotation = Quaternion.identity 136 | GameObjectUtility.LocalScale(go, 1, 1, 1) 137 | return go, luaTabel 138 | end 139 | 140 | 141 | instances = {} 142 | function getInstance(scriptRes) 143 | if type(scriptRes) ~= "string" then 144 | return 145 | end 146 | 147 | if instances[scriptRes] == nil then 148 | local go = GameObject(scriptRes) 149 | go.transform.parent = SingletonObject.Instance.ParentGameObject.transform 150 | -- print(go, scriptRes) 151 | require(scriptRes) 152 | 153 | local scriptControl = ScriptManager.GetInstance():WrapperWindowControl(go, scriptRes) 154 | scriptControl.scriptRes = scriptRes 155 | scriptControl:initialize() 156 | instances[scriptRes] = scriptControl 157 | end 158 | 159 | return instances[scriptRes] 160 | end 161 | 162 | 163 | function destroyInstance(instance) 164 | local saveInstance = instances[instance.scriptRes] 165 | 166 | if saveInstance == nil then 167 | error("destroy instance failure , not instance error : " .. instance.scriptRes) 168 | end 169 | 170 | instance:dispose() 171 | GameObject.Destroy(instance.gameObject) 172 | 173 | instances[instance.scriptRes] = nil 174 | end -------------------------------------------------------------------------------- /LuaScript/utility/debugUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : debugUtility.lua 4 | -- Creator : zg 5 | -- Date : 2016-11-10 6 | -- Comment : 调试lua 7 | -- *************************************************************** 8 | 9 | 10 | module("debugUtility", package.seeall) 11 | 12 | 13 | _print = print 14 | 15 | 16 | function _list_table(tb, table_list, level) 17 | local ret = "" 18 | local indent = string.rep(" ", level*4) 19 | 20 | for k, v in pairs(tb) do 21 | local quo = type(k) == "string" and "\"" or "" 22 | ret = ret .. indent .. "[" .. quo .. tostring(k) .. quo .. "] = " 23 | 24 | if type(v) == "table" then 25 | local t_name = table_list[v] 26 | if t_name then 27 | ret = ret .. tostring(v) .. " -- > [\"" .. t_name .. "\"]\n" 28 | else 29 | table_list[v] = tostring(k) 30 | ret = ret .. "{\n" 31 | ret = ret .. _list_table(v, table_list, level+1) 32 | ret = ret .. indent .. "},\n" 33 | end 34 | elseif type(v) == "string" then 35 | ret = ret .. "\"" .. tostring(v) .. "\"" .. "," .. "\n" 36 | --"\"" .. tostring(v) .. "\"n" 37 | else 38 | ret = ret .. tostring(v) .. "," .. "\n" 39 | end 40 | end 41 | 42 | -- local mt = getmetatable(tb) 43 | -- if mt then 44 | -- ret = ret .. "\n" 45 | -- local t_name = table_list[mt] 46 | -- ret = ret .. indent .. " = " 47 | 48 | -- if t_name then 49 | -- ret = ret .. tostring(mt) .. " -- > [\"" .. t_name .. "\"]\n" 50 | -- else 51 | -- ret = ret .. "{\n" 52 | -- ret = ret .. _list_table(mt, table_list, level+1) 53 | -- ret = ret .. indent .. "}\n" 54 | -- end 55 | 56 | -- end 57 | 58 | return ret 59 | end 60 | 61 | 62 | function _tableToString(tb) 63 | if type(tb) ~= "table" then 64 | error("Sorry, it's not table, it is " .. type(tb) .. ".") 65 | end 66 | 67 | local ret = " = {\n" 68 | local table_list = {} 69 | table_list[tb] = "root table" 70 | ret = ret .. _list_table(tb, table_list, 1) 71 | ret = ret .. "}" 72 | return ret 73 | end 74 | 75 | 76 | function printTable(tb) 77 | _print(tostring(tb) .. _tableToString(tb)) 78 | end 79 | 80 | 81 | function getPrintTable(tb) 82 | return tostring(tb) .. _tableToString(tb) 83 | end 84 | 85 | 86 | function printCallStack() 87 | local startLevel = 2 --0表示getinfo本身,1表示调用getinfo的函数(printCallStack),2表示调用printCallStack的函数,可以想象一个getinfo(0级)在顶的栈. 88 | local maxLevel = 10 --最大递归10层 89 | 90 | for level = startLevel, maxLevel do 91 | -- 打印堆栈每一层 92 | local info = debug.getinfo( level, "nSl") 93 | if info == nil then break end 94 | _print( string.format("[ line : %-4d] %-20s :: %s", info.currentline, info.name or "", info.source or "" ) ) 95 | 96 | -- 打印该层的参数与局部变量 97 | local index = 1 --1表示第一个参数或局部变量, 依次类推 98 | while true do 99 | local name, value = debug.getlocal( level, index ) 100 | if name == nil then break end 101 | 102 | local valueType = type( value ) 103 | local valueStr 104 | if valueType == 'string' then 105 | valueStr = value 106 | elseif valueType == "number" then 107 | valueStr = string.format("%.2f", value) 108 | end 109 | if valueStr ~= nil then 110 | _print( string.format( "\t%s = %s\n", name, value ) ) 111 | end 112 | index = index + 1 113 | end 114 | end 115 | end 116 | 117 | 118 | enumColor = 119 | { 120 | R = "", 121 | G = "", 122 | B = "", 123 | W = "", 124 | Y = "" 125 | } 126 | 127 | 128 | function printColor(...) 129 | local arg = {...} 130 | if #arg == 1 then 131 | _print(...) 132 | return 133 | end 134 | 135 | local c = arg[#arg] 136 | local color = enumColor[c] 137 | if color ~= nil then 138 | _print(color, unpack(arg), "") 139 | else 140 | _print(...) 141 | end 142 | end 143 | 144 | 145 | _G['print_t'] = printTable 146 | 147 | --_G['print'] = printColor -------------------------------------------------------------------------------- /LuaScript/utility/uiAssetCache.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : uiAssetCache.lua 4 | -- Creator : liyibao 5 | -- Date : 2017-08-25 6 | -- Comment : 用于处理UI上的子UI预设创建和缓存 7 | -- *************************************************************** 8 | 9 | 10 | module("uiAssetCache", package.seeall) 11 | 12 | 13 | --获取一个资源 14 | function getAsset(uiScript, abPath, parentGo, panelGo, offsetDepth, call, scriptName) 15 | local script = nil 16 | local go = nil 17 | 18 | --加载完成 19 | local loadComplete = function(script) 20 | local depth = panelGo:GetComponent("UIPanel").depth + offsetDepth 21 | GameObjectUtility.SetParent(script.gameObject, parentGo, false) 22 | WindowUtility.instance:adjustmentPanelDepth(script.gameObject, depth) --调整层次 23 | 24 | script.gameObject:SetActive(true) 25 | call(script) 26 | end 27 | 28 | if uiScript._scriptList == nil then 29 | uiScript._scriptList = {} 30 | end 31 | if uiScript._assetList == nil then 32 | uiScript._assetList = {} 33 | end 34 | if uiScript._assetList[abPath] == nil then 35 | AssetLoader.instance:asyncLoad(abPath, function(asset) 36 | --父节点隐藏了 37 | if uiScript == nil or parentGo == nil or panelGo == nil or parentGo.activeInHierarchy == false then 38 | return 39 | end 40 | --如果两个在同时加载,第二个直接返回 41 | if uiScript._scriptList[abPath] ~= nil then 42 | loadComplete(uiScript._scriptList[abPath]) 43 | return 44 | end 45 | 46 | uiScript._assetList[abPath] = asset 47 | asset:AddRef() 48 | 49 | go = GameObjectUtility.AddGameObjectPrefab(parentGo, asset.mainObject) 50 | go.name = asset.mainObject.name 51 | script = ScriptManager.GetInstance():WrapperWindowControl(go, scriptName) 52 | script.rootScript = uiScript 53 | uiScript._scriptList[abPath] = script 54 | 55 | if script.init ~= nil then 56 | script:init() 57 | end 58 | loadComplete(script) 59 | end) 60 | else 61 | loadComplete(uiScript._scriptList[abPath]) 62 | end 63 | end 64 | 65 | 66 | --卸载资源 67 | function destroyAssets(uiScript) 68 | if uiScript._assetList ~= nil then 69 | for k, v in pairs(uiScript._assetList) do 70 | if v ~= nil then 71 | v:ReleaseRef() 72 | v = nil 73 | end 74 | end 75 | uiScript._assetList = {} 76 | end 77 | end 78 | 79 | 80 | --GameObject缓存(缓存创建对象,子节点必须有一个对象,没有会创建空对象) 81 | function createGameObjectsSub(goParent, goName, goNumber) 82 | local goItem = GameObjectUtility.Find(goName, goParent) 83 | 84 | --隐藏所有 85 | if goItem ~= nil then 86 | goItem:SetActive(false) 87 | end 88 | 89 | local index = 1 90 | local goTemp = GameObjectUtility.Find(goName .. index, goParent) 91 | while goTemp ~= nil do 92 | goTemp:SetActive(false) 93 | index = index + 1 94 | goTemp = GameObjectUtility.Find(goName .. index, goParent) 95 | end 96 | 97 | local gos = {} 98 | if goNumber > 0 then 99 | local go = createGameObject(goParent, goName, goItem) 100 | go:SetActive(true) 101 | table.insert(gos, go) 102 | end 103 | 104 | for i=1, goNumber-1 do 105 | local go = createGameObject(goParent, goName .. i, goItem) 106 | go:SetActive(true) 107 | table.insert(gos, go) 108 | end 109 | 110 | return gos 111 | end 112 | 113 | 114 | --GameObject缓存(使用预设对象创建缓存) 115 | function createGameObjects(goParent, goName, goItem, goNumber) 116 | --隐藏所有 117 | local index = 1 118 | local goTemp = GameObjectUtility.Find(goName .. index, goParent) 119 | while goTemp ~= nil do 120 | goTemp:SetActive(false) 121 | index = index + 1 122 | goTemp = GameObjectUtility.Find(goName .. index, goParent) 123 | end 124 | 125 | local gos = {} 126 | for i=1, goNumber do 127 | local go = createGameObject(goParent, goName .. i, goItem) 128 | go:SetActive(true) 129 | table.insert(gos, go) 130 | end 131 | 132 | return gos 133 | end 134 | 135 | 136 | --创建缓存节点 137 | function createGameObject(goParent, goName, goItem) 138 | local go = GameObjectUtility.Find(goName, goParent) 139 | 140 | if go == nil then 141 | if goItem ~= nil then 142 | go = GameObjectUtility.AddGameObjectPrefab(goParent, goItem) 143 | else 144 | go = GameObject(goName) 145 | GameObjectUtility.SetParent(go, goParent, false) 146 | end 147 | layerUtility.setLayer(go, goParent.layer) 148 | go.name = goName 149 | end 150 | go:SetActive(true) 151 | 152 | return go 153 | end -------------------------------------------------------------------------------- /LuaScript/reader/dataReader.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : dataReader.lua 4 | -- Creator : zg 5 | -- Date : 2016-11-10 6 | -- Comment : 配置读取 7 | -- *************************************************************** 8 | 9 | 10 | module("dataReader", package.seeall) 11 | 12 | conf_radio = 0.8 13 | conf_proto_radio = 0.9 14 | per_add = 10 15 | globalLuaScripts = {} 16 | 17 | function loadConf() 18 | local luaPaths = nil 19 | local battleLuaPaths = nil 20 | local addHead = nil 21 | local addHead2 = nil 22 | 23 | if applicationConfig.macro.UNITY_EDITOR then 24 | local path = PathUtility.LuaPath .. '/conf' 25 | luaPaths = FileUtility.GetAllFileInPathWithSearchPattern(path, '*.lua') 26 | local battlePath = PathUtility.LuaPath .. '/battle/conf' 27 | battleLuaPaths= FileUtility.GetAllFileInPathWithSearchPattern(battlePath, '*.lua') 28 | addHead = 'conf' 29 | addHead2 = 'battle/conf' 30 | else 31 | luaPaths = ScriptManager.GetInstance():GetListFiles("conf/") 32 | battleLuaPaths = ScriptManager.GetInstance():GetListFiles("battle/conf/") 33 | addHead = "" 34 | addHead2 = "" 35 | end 36 | 37 | local c = coroutine.create(function() 38 | local progressLen = luaPaths.Length + battleLuaPaths.Length 39 | for i=1, luaPaths.Length do 40 | luaPath = luaPaths[i] 41 | luaPath = fileUtility.getPathAndNotPrefix(luaPath, 'LuaScript/conf') 42 | require(addHead..luaPath) 43 | 44 | GameProgress.Instance:SetProgressTxt(startupLocalization.getLocal("login_loading_script"), "", (i / progressLen) * conf_radio) 45 | if i % per_add == 0 then 46 | --UnityEngine.Yield(WaitForEndOfFrame()) 47 | Yield() 48 | end 49 | end 50 | 51 | for i=1, battleLuaPaths.Length do 52 | battleLuaPath = battleLuaPaths[i] 53 | battleLuaPath = fileUtility.getPathAndNotPrefix(battleLuaPath, 'LuaScript/battle/conf') 54 | require(addHead2..battleLuaPath) 55 | GameProgress.Instance:SetProgressTxt(startupLocalization.getLocal("login_loading_script"), "", ((luaPaths.Length + i) / progressLen) * conf_radio) 56 | if i % per_add == 0 then 57 | --UnityEngine.Yield(WaitForEndOfFrame()) 58 | Yield() 59 | end 60 | end 61 | -- reload("applicationLoad") 62 | -- reload("applicationLoadAfter") 63 | startupStatusManager.dataReaderComplete() 64 | end 65 | ) 66 | coroutine.resume(c) 67 | end 68 | 69 | 70 | function addData(tbName, tb) 71 | if data[tbName] == nil then 72 | data[tbName] = tb 73 | else 74 | syntaxUtility.mergeTable(data[tbName], tb) 75 | end 76 | end 77 | 78 | 79 | function loadProtocal() 80 | local luaPaths = nil 81 | local addHead = nil 82 | if applicationConfig.macro.UNITY_EDITOR then 83 | local path = PathUtility.LuaPath .. '/protocal' 84 | luaPaths = FileUtility.GetAllFileInPathWithSearchPattern(path, '*.lua') 85 | addHead = 'protocal' 86 | else 87 | luaPaths = ScriptManager.GetInstance():GetListFiles("protocal/") 88 | addHead = "" 89 | end 90 | local c = coroutine.create(function() 91 | for i=1, luaPaths.Length do 92 | luaPath = luaPaths[i] 93 | luaPath = fileUtility.getPathAndNotPrefix(luaPath, 'LuaScript/protocal') 94 | local content = require(addHead..luaPath) 95 | NetProtocal.Instance:ReadProtocalStr(content) 96 | GameProgress.Instance:SetProgressTxt(startupLocalization.getLocal("login_loading_script"),"", conf_radio + (i / luaPaths.Length) * (conf_proto_radio - conf_radio)) 97 | if i % per_add == 0 then 98 | --UnityEngine.Yield(WaitForEndOfFrame()) 99 | Yield() 100 | end 101 | end 102 | startupStatusManager.protocalReaderComplete() 103 | end) 104 | coroutine.resume(c) 105 | end 106 | 107 | 108 | -- 读取 applicationLoad 和 applicationAfterLoad 文件 109 | function loadGlobalLua() 110 | local c = coroutine.create(function() 111 | local count = #globalLuaScripts 112 | logInfo("loadGlobalLua count = "..count) 113 | for i=1, count do 114 | reload(globalLuaScripts[i]) 115 | GameProgress.Instance:SetProgressTxt(startupLocalization.getLocal("login_loading_script"),"", conf_proto_radio + (i / count) * 0.1) 116 | if i % per_add == 0 then 117 | --UnityEngine.Yield(WaitForEndOfFrame()) 118 | Yield() 119 | end 120 | end 121 | logInfo("loadGlobalLua finish") 122 | startupStatusManager.globalLuaReaderComplete() 123 | end) 124 | coroutine.resume(c) 125 | end 126 | 127 | 128 | -------------------------------------------------------------------------------- /LuaScript/framework/window/effect/windowEffect.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowEffect.lua 4 | -- Creator : zg 5 | -- Date : 2017-1-6 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | --效果基类 11 | WindowEffect = BaseClass() 12 | 13 | 14 | function WindowEffect:ctor() 15 | self.window = nil 16 | end 17 | 18 | 19 | function WindowEffect:initialize() 20 | 21 | end 22 | 23 | 24 | function WindowEffect:execute() 25 | 26 | end 27 | 28 | 29 | function WindowEffect:complete() 30 | 31 | end 32 | 33 | 34 | --关闭的时候没有任何效果 35 | WindowCloseNullEffect = BaseClass(WindowEffect) 36 | 37 | 38 | function WindowCloseNullEffect:execute() 39 | self:complete() 40 | end 41 | 42 | 43 | function WindowCloseNullEffect:complete() 44 | WindowStack.instance:onCloseWindow(self.window) 45 | end 46 | 47 | 48 | --打开的时候没有任何效果 49 | WindowOpenNullEffect = BaseClass(WindowEffect) 50 | 51 | 52 | function WindowOpenNullEffect:execute() 53 | self:complete() 54 | end 55 | 56 | 57 | function WindowOpenNullEffect:complete() 58 | WindowStack.instance:afterOpenWindow(self.window) 59 | end 60 | 61 | 62 | --打开的时候进行透明度 63 | WindowOpenAlphaEffect = BaseClass(WindowEffect) 64 | 65 | 66 | function WindowOpenAlphaEffect:initialize() 67 | self.duration = 0.3 68 | end 69 | 70 | 71 | function WindowOpenAlphaEffect:execute() 72 | local tweenAlpha = GameObjectUtility.GetIfNotAdd(self.window.panelObject.gameObject, "TweenAlpha") 73 | tweenAlpha.from = 0.5 74 | tweenAlpha.to = 1 75 | tweenAlpha.method = UITweener.Method.Linear 76 | tweenAlpha.style = UITweener.Style.Once 77 | tweenAlpha.duration = self.duration 78 | tweenAlpha:ResetToBeginning() 79 | tweenAlpha:PlayForward() 80 | tweenAlpha:SetOnFinished(function() 81 | self:complete() 82 | end) 83 | end 84 | 85 | 86 | function WindowOpenAlphaEffect:complete() 87 | WindowStack.instance:afterOpenWindow(self.window) 88 | end 89 | 90 | 91 | --关闭的时候进行缩放 92 | WindowOpenSecondScaleEffect = BaseClass(WindowEffect) 93 | 94 | 95 | function WindowOpenSecondScaleEffect:execute() 96 | self:complete() 97 | end 98 | 99 | 100 | function WindowOpenSecondScaleEffect:complete() 101 | WindowStack.instance:afterOpenWindow(self.window) 102 | end 103 | 104 | 105 | --打开的时候进行背景模糊 106 | WindowBgGuassianBlurEffect = BaseClass(WindowEffect) 107 | 108 | 109 | function WindowBgGuassianBlurEffect:execute() 110 | if PlayerPrefs.GetInt("rapidBlur", 1) == 0 then 111 | return 112 | end 113 | layerUtility.setLayer(self.window.gameObject, 16) 114 | 115 | local camera = WindowCamera.instance:getUICamera().gameObject 116 | local rapidBlurEffect = ScriptManager.GetInstance():WrapperWindowControl(camera, 'framework/window/windowRapidBlurEffect') 117 | if rapidBlurEffect ~= nil then 118 | rapidBlurEffect:enableRapidBlurEffect() 119 | end 120 | end 121 | 122 | 123 | function WindowBgGuassianBlurEffect:complete() 124 | WindowStack.instance:afterOpenWindow(self.window) 125 | end 126 | 127 | 128 | --打开的时候闪一个特效并且缩放打开 129 | WindowOpenEffectScaleEffect = BaseClass(WindowEffect) 130 | 131 | 132 | function WindowOpenEffectScaleEffect:execute() 133 | GameObjectUtility.LocalScale(self.window.panelObject.gameObject, 0, 0, 0) 134 | 135 | --显示特效 136 | self:playEffect(self.window.panelObject.gameObject, function() self:complete() end) 137 | end 138 | 139 | 140 | function WindowOpenEffectScaleEffect:complete() 141 | WindowStack.instance:afterOpenWindow(self.window) 142 | end 143 | 144 | 145 | function WindowOpenEffectScaleEffect:playEffect(go, completeCall) 146 | --显示特效 147 | AssetLoader.instance:asyncLoad("Effect/UI/ui_dakai_02", function(asset) 148 | local effectGo = GameObject.Instantiate(asset.mainObject) 149 | effectGo.name = "uiOpenEffect" 150 | GameObjectUtility.AddGameObject(go, effectGo) 151 | GameObjectUtility.LocalScale(effectGo, 1, 1, 1) 152 | 153 | local co1 = coroutine.create(function () 154 | Yield(WaitForSeconds(0.2)) 155 | GameObject.Destroy(effectGo) 156 | end) 157 | coroutine.resume(co1) 158 | 159 | --显示动画 160 | local anim = GameObjectUtility.GetIfNotAdd(go, "UnityEngine.Animator") 161 | if anim.runtimeAnimatorController ~= nil then 162 | anim:Play("open_effect") 163 | else 164 | AssetLoader.instance:asyncLoad("Effect/UI/ui_dakai_01", function(asset) 165 | anim.runtimeAnimatorController = asset.mainObject:GetComponent(Animator).runtimeAnimatorController 166 | end) 167 | end 168 | 169 | local co2 = coroutine.create(function () 170 | Yield(WaitForSeconds(0.4)) 171 | if completeCall ~= nil then 172 | completeCall() 173 | end 174 | end) 175 | coroutine.resume(co2) 176 | end) 177 | end -------------------------------------------------------------------------------- /LuaScript/framework/loader/assetLoadTask.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : assetLoader.lua 4 | -- Creator : sf 5 | -- Date : 2017-5-8 6 | -- Comment : 7 | -- *************************************************************** 8 | AssetLoadTask = BaseClass() 9 | 10 | 11 | function AssetLoadTask:ctor() 12 | self.callbackList2 = {} 13 | self.callbackList = {} 14 | self.progress = 0 15 | self.state = assetBB.enumLoadState.notStartLoad 16 | self.failReason = "" 17 | end 18 | 19 | 20 | --通过AssetLoader的loadingCheck调用 21 | function AssetLoadTask:update() 22 | if self.state == assetBB.enumLoadState.notStartLoad then 23 | local readPath = AssetUtil.instance:getAssetWWWPath(self.path) 24 | self.state = assetBB.enumLoadState.wwwStart 25 | self.www = UnityEngine.WWW(readPath) 26 | elseif self.state == assetBB.enumLoadState.wwwStart then 27 | if self.www.isDone then 28 | if self.www.error ~= nil then 29 | self.state = assetBB.enumLoadState.failed 30 | self.failReason = self.www.error 31 | Debug.LogError("progress:" .. self.progress .. " path:" .. self.path .. " failed:" .. self.failReason) 32 | else 33 | self:WWWLoadDoneDeal() 34 | end 35 | else 36 | self.progress = self.www.progress 37 | end 38 | end 39 | end 40 | 41 | 42 | function AssetLoadTask:WWWLoadDoneDeal() 43 | self.state = assetBB.enumLoadState.success 44 | self.assetBundle = self.www.assetBundle 45 | self.progress = 1 46 | 47 | if AssetLoader.instance:containAsset(self.path) then 48 | self.state = assetBB.enumLoadState.failed 49 | self.failReason = "asset already exsits" 50 | return 51 | end 52 | if self.assetBundle == nil then 53 | self.state = assetBB.enumLoadState.failed 54 | self.failReason = "error cannot not create assetbundle" 55 | end 56 | end 57 | 58 | 59 | function AssetLoadTask:isDone() 60 | if self.state == assetBB.enumLoadState.success or self.state == assetBB.enumLoadState.failed then 61 | return true 62 | end 63 | return false 64 | end 65 | 66 | 67 | function AssetLoadTask:getLoadState() 68 | return self.state 69 | end 70 | 71 | 72 | function AssetLoadTask:addcallbackAsset(funCallBack) 73 | table.insert(self.callbackList, funCallBack) 74 | end 75 | 76 | 77 | function AssetLoadTask:addcallbackObject(funCallBack) 78 | table.insert(self.callbackList2, funCallBack) 79 | end 80 | 81 | 82 | function AssetLoadTask:find(loadList, path) 83 | if loadList == nil then 84 | return nil 85 | end 86 | for i, v in pairs(loadList) do 87 | 88 | if v.path == path then 89 | return v 90 | end 91 | end 92 | return nil 93 | end 94 | 95 | 96 | 97 | --资源判断 98 | AssetJudge = BaseClass() 99 | 100 | 101 | function AssetJudge:getneverDestroyList() 102 | if self.neverDestroyList == nil then 103 | self.neverDestroyList = {} 104 | table.insert(self.neverDestroyList, "UI/Reconnect/ReConnectPanel") 105 | table.insert(self.neverDestroyList, "UI/Tooltip/TooltipPanel") 106 | table.insert(self.neverDestroyList, "Prefabs/Common/WindowMask") 107 | end 108 | return self.neverDestroyList 109 | end 110 | 111 | 112 | function AssetJudge:getSceneTypes() 113 | if self.sceneTypes == nil then 114 | self.sceneTypes = {} 115 | table.insert(self.sceneTypes, "Scene") 116 | end 117 | return self.sceneTypes 118 | end 119 | 120 | 121 | function AssetJudge:isScene(path) 122 | local parts = stringUtility.split(path, "/") 123 | for i ,v in pairs(parts) do 124 | if v == "Scene" then 125 | return true 126 | end 127 | end 128 | return false 129 | end 130 | 131 | 132 | function AssetJudge:getonceList() 133 | if self.onceList == nil then 134 | self.onceList= {} 135 | table.insert(self.onceList, "Texture/bigmap2") 136 | end 137 | return self.onceList 138 | end 139 | 140 | 141 | function AssetJudge:isOnceList(path) 142 | 143 | local tstr = path 144 | local idx = path:match(".+()%.%w+$") 145 | if idx then 146 | tstr = tstr:sub(1, idx - 1) 147 | end 148 | 149 | for i, v in pairs(self:getonceList()) do 150 | if string.find(path, v) ~= nil then 151 | return true 152 | end 153 | end 154 | 155 | return false 156 | end 157 | 158 | 159 | function AssetJudge:neverDestroyListPath(path) 160 | for i, v in pairs(self:getneverDestroyList()) do 161 | if string.find(v, path) then 162 | return true 163 | end 164 | end 165 | return false 166 | end 167 | 168 | 169 | function AssetJudge:getGCType(path) 170 | if self:neverDestroyListPath(path) then --常驻内存 的 171 | return AssetGCType.actForever--0 172 | end 173 | if self:isOnceList(path) then 174 | return AssetGCType.actOnce--3 175 | end 176 | if self:isScene(path) then 177 | return AssetGCType.actCustom--4 178 | end 179 | return AssetGCType.actRefCounted--1 180 | 181 | end 182 | 183 | AssetJudge.instance = AssetJudge.new() 184 | -------------------------------------------------------------------------------- /LuaScript/utility/gameUtils.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : gameUtils.lua 4 | -- Creator : lxy 5 | -- Date : 2017-2-21 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("gameUtils", package.seeall) 11 | 12 | 13 | --取简体一到十 14 | function getBigSimpleChineseNumber(num) 15 | if num == 1 then 16 | return L("file_cs_GameUtils_11") 17 | elseif num == 2 then 18 | return L("file_cs_GameUtils_12") 19 | elseif num == 3 then 20 | return L("file_cs_GameUtils_13") 21 | elseif num == 4 then 22 | return L("file_cs_GameUtils_14") 23 | elseif num == 5 then 24 | return L("file_cs_GameUtils_15") 25 | elseif num == 6 then 26 | return L("file_cs_GameUtils_16") 27 | elseif num == 7 then 28 | return L("file_cs_GameUtils_17") 29 | elseif num == 8 then 30 | return L("file_cs_GameUtils_18") 31 | elseif num == 9 then 32 | return L("file_cs_GameUtils_19") 33 | elseif num == 10 then 34 | return L("file_cs_GameUtils_20") 35 | else 36 | return nil 37 | end 38 | end 39 | 40 | 41 | -- 00:00 42 | function getStringHourTime(second, length) 43 | local hour = math.floor(second / 3600) 44 | local min = math.floor((second % 3600) / 60) 45 | local sec = second % 60 46 | return gameUtils. getIntNumber(hour, length) .. ":" .. gameUtils.getIntNumber(min, length) .. ":" .. gameUtils.getIntNumber(sec, length) 47 | end 48 | 49 | 50 | function getIntNumber(num, median) 51 | local tstr = tostring(num) 52 | local dis = median - #tstr 53 | 54 | for i = 1, dis do 55 | tstr = "0" .. tstr 56 | end 57 | return tstr 58 | end 59 | 60 | 61 | -- 根据errorCode获取错误信息 62 | function getErrorInfoByCode(errorCode) 63 | local str = "" 64 | for k,v in pairs(conf.errorCode) do 65 | if v.code == errorCode then 66 | str = string.gsub(v.tip,"#","") 67 | break 68 | end 69 | end 70 | return str 71 | end 72 | 73 | 74 | -- 时间常量 75 | Minute2Second = 60 76 | Hour2Minute = 60 77 | Minute2MillionSecond = 60000 78 | Second2MillionSecond = 1000 79 | Hour2MillionSecond = 3600000 80 | 81 | Hour2Second = 3600 82 | Day2Minute = 1440 83 | Day2Second = 86400 84 | Day2MillionSecond = 86400000 85 | 86 | 87 | -- 00天00时00分 [startsecond 结束时间 毫秒数 , length 88 | function getStringDateTime(endsecond, length) 89 | local msecond = endsecond - timeManagerUtility.getServerTimeMs() 90 | if msecond <= 0 then 91 | return "--" .. L("activity_tian") .. "--"..L("activity_shi") .. "--" .. L("activity_fen") 92 | end 93 | 94 | local second = math.floor(msecond / 1000) 95 | local day = math.floor(second / Day2Second) 96 | local hour = math.floor((second % Day2Second) / Hour2Second) 97 | local min = math.floor((second % Hour2Second) / Minute2Second) 98 | return getIntNumber(day, length)..L("activity_tian") .. getIntNumber(hour, length) .. L("activity_shi")..getIntNumber(min, length) .. L("activity_fen") 99 | end 100 | 101 | 102 | function getIntNumber(num, median) 103 | local str = tostring(num) 104 | local dis = median - #str 105 | for i = 1, dis do 106 | str = "0"..str 107 | end 108 | return str 109 | end 110 | 111 | 112 | --static DateTime UTC_BEIJING = new DateTime(1970, 1, 1, 8, 0, 0) 113 | -- 暂未添加 时区 114 | function getShortDateByTimeStamp(t) 115 | return os.date("%Y.%m.%d",t/1000) 116 | end 117 | 118 | 119 | -- msecond 毫秒数 length 120 | function getStringHourTime2(msecond, length) 121 | if msecond <= 0 then 122 | return "--" .. L("activity_tian") .. "--" .. L("activity_shi") .. "--" .. L("activity_fen") 123 | end 124 | local second = math.floor(msecond / 1000) 125 | -- print("--------second-------",second) 126 | local hour = math.floor(second / Hour2Second) 127 | local min = (second % Hour2Second) / Minute2Second 128 | min = math.floor(min) 129 | local second2 = second % 60 130 | 131 | local x = string.format(stringUtility.rejuctSymbol(L("nvshensongbao_05")), getIntNumber(hour, length), getIntNumber(min, length), getIntNumber(second2, length)) 132 | return x 133 | end 134 | 135 | -- n:n秒, 返回ms 136 | function getRemindTime(endTime,n) 137 | local time = endTime - n*1000 138 | if time < 0 then return -1 end 139 | return time 140 | end 141 | 142 | 143 | --删除table里key为value的项,数组需要为1开始的连续数组 144 | function removeTabKey(tab, key, value) 145 | for i=1, #tab do 146 | if tab[i][key] == value then 147 | table.remove(tab, i) 148 | end 149 | end 150 | end 151 | 152 | 153 | function setIPXAdaptive(cameraComponent) 154 | if Screen.width == 2436 and Screen.height == 1125 then 155 | cameraComponent.rect = Rect(0.03, 0, 0.97, 1) 156 | end 157 | end -------------------------------------------------------------------------------- /LuaScript/framework/scene/sceneSwitchManager.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : sceneSwitchManager.lua 4 | -- Creator : zg 5 | -- Date : 2016-12-16 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | --场景切换事件 11 | SceneSwitchEvent = 12 | { 13 | seNull = 1, 14 | seCreate = 2, 15 | seExit = 3, 16 | seDestory = 4, 17 | seInto = 5, 18 | } 19 | 20 | 21 | --场景切换的类型 22 | SceneSwitchType = 23 | { 24 | sstLogin = 1, -- 登录 25 | sstBigmap = 2, 26 | sstBattle = 3, 27 | sstHouse = 4, 28 | sstLoginSwitch = 5, 29 | sstMainUI = 6, 30 | sstUniverse = 7, -- 宇宙图 31 | sstOwnPlanet = 8, -- 我的星球 32 | sstTower = 9, -- 先祖遗迹 33 | } 34 | 35 | 36 | --场景loader需要先加载的资源 37 | SceneLoaderRes = 38 | { 39 | commonLoader = "UI/Loader/CommonLoader", 40 | pvpLoader = "UI/Loader/PvpLoadingPanel", 41 | } 42 | 43 | 44 | SceneSwitchManager = BaseClass() 45 | SceneSwitchManager.instance = nil 46 | 47 | 48 | function SceneSwitchManager:initialize() 49 | end 50 | 51 | 52 | function SceneSwitchManager:ctor() 53 | self.listeners = {} -- 监听器 54 | self.lastSceneRes = nil -- 上一次场景资源 55 | self.lastSceneInstance = nil -- 上一次载入的场景实例 56 | self.currentSceneInstance = nil -- 当前载入的场景实例 57 | self.lastSceneWindow = nil -- 进入战斗需要记录打开上一次的模块id 58 | SceneSwitchManager.instance = self 59 | self.delayDestroy = false -- 延迟销毁 60 | end 61 | 62 | 63 | --添加场景监听器 64 | function SceneSwitchManager:addListener(listener) 65 | table.insert(self.listeners, listener) 66 | end 67 | 68 | 69 | --删除场景监听器 70 | function SceneSwitchManager:removeListener(listener) 71 | print("SceneSwitchManager----removeListener--------") 72 | -- table.remove(self.listeners, listener) 73 | for i=1, #self.listeners do 74 | if self.listeners[i] == listener then 75 | table.remove(self.listeners, i) 76 | break 77 | end 78 | end 79 | end 80 | 81 | 82 | --通告场景监听器事件 83 | function SceneSwitchManager:notify(evtType, sceneInstance) 84 | for _, listener in ipairs(self.listeners) do 85 | listener(evtType, sceneInstance) 86 | end 87 | end 88 | 89 | 90 | --进入场景 91 | function SceneSwitchManager:enterScene(sceneRes) 92 | logInfo("SceneSwitchManager:enterScene:" .. sceneRes.sceneType) 93 | 94 | AssetDelayDownloadManager.instance:doWhenSwitchScene(sceneRes) 95 | 96 | if self.currentSceneInstance ~= nil then 97 | if self.currentSceneInstance.sceneRes.sceneType == sceneRes.sceneType then 98 | self.delayDestroy = false 99 | else 100 | self.delayDestroy = true --需要延迟销毁 101 | end 102 | self:notify(SceneSwitchEvent.seExit, self.currentSceneInstance) 103 | self.currentSceneInstance:exitScene() 104 | self.lastSceneInstance = self.currentSceneInstance 105 | 106 | if not self.delayDestroy then 107 | self:delayDestoryScene() --不需要延迟销毁的场景立即执行销毁 108 | end 109 | self:destroySceneNow() 110 | end 111 | 112 | self:createScene(sceneRes) 113 | end 114 | 115 | 116 | --创建一个场景 117 | function SceneSwitchManager:createScene(sceneRes) 118 | logInfo("SceneSwitchManager:createScene:" .. sceneRes.sceneType) 119 | GameObjectUtility.ClearChildGameObject(self.gameObject, true) 120 | local sceneGo = GameObjectUtility.CreateNullGameObject(self.gameObject, sceneRes.sceneType) 121 | self.currentSceneInstance = ScriptManager.GetInstance():WrapperWindowControl(sceneGo, sceneRes.sceneScript) 122 | self:notify(SceneSwitchEvent.seCreate, self.currentSceneInstance) 123 | self.currentSceneInstance:initialize() 124 | self.currentSceneInstance.sceneRes = sceneRes 125 | 126 | self.currentSceneInstance:startScene() 127 | 128 | self.currentSceneInstance.currentSceneDefine = sceneRes 129 | if self.lastSceneInstance ~= nil then --保存上一次场景资源 130 | self.lastSceneRes = self.lastSceneInstance.sceneRes 131 | self.currentSceneInstance.lastSceneDefine = self.lastSceneInstance.currentSceneDefine 132 | end 133 | end 134 | 135 | 136 | -- 立刻销毁场景(有些需要立即销毁的东西放下这里) 137 | function SceneSwitchManager:destroySceneNow() 138 | if self.lastSceneInstance ~= nil then 139 | self.lastSceneInstance:destroySceneNow() 140 | end 141 | end 142 | 143 | 144 | --延迟销毁场景 145 | function SceneSwitchManager:delayDestoryScene() 146 | if self.lastSceneInstance ~= nil then 147 | logInfo("SceneSwitchManager:delayDestoryScene:" .. self.lastSceneInstance.sceneRes.sceneType) 148 | self:notify(SceneSwitchEvent.seDestory, self.lastSceneInstance) 149 | self.lastSceneInstance:destoryScene() 150 | self.lastSceneInstance:dispose() 151 | GameObjectUtility.DestroyGameObject(self.lastSceneInstance.gameObject, false) 152 | end 153 | AssetLoader.instance:clearAssets() 154 | Resources.UnloadUnusedAssets() 155 | 156 | System.GC.Collect() 157 | collectgarbage("collect") 158 | end 159 | 160 | -------------------------------------------------------------------------------- /LuaScript/module/alert/alertMessagePanel.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : alertMessagePanel.lua 4 | -- Creator : zg 5 | -- Date : 2016-12-22 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | AlertMessagePanel = BaseClass(WindowLayerBase) 11 | 12 | 13 | AlertMessagePanel.constAlertType = {"eatSingleButton", "eatTwoButton"} 14 | AlertMessagePanel.enumAlertType = syntaxUtility.createEnum(AlertMessagePanel.constAlertType) 15 | 16 | 17 | function AlertMessagePanel:initialize() 18 | 19 | end 20 | 21 | 22 | function AlertMessagePanel:clickButton(go, btnName) 23 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Button_Click) 24 | self.gameObject:SetActive(false) 25 | if btnName == "btn_ok_1" then 26 | if self.callback ~= nil then 27 | self:callback() 28 | end 29 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Click_Tips) 30 | elseif btnName == "btn_ok_2" then 31 | if self.callback1 ~= nil then 32 | self:callback1() 33 | end 34 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Click_Tips) 35 | elseif btnName == "btn_cancel_2" then 36 | if self.callback2 ~= nil then 37 | self:callback2() 38 | end 39 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Click_Tips) 40 | end 41 | end 42 | 43 | 44 | --显示只有一个确定按钮的提示框 45 | function AlertMessagePanel:alertSingle(title, message, callback, btnName) 46 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Warn_Tips) 47 | self.alertType = AlertMessagePanel.enumAlertType.eatSingleButton 48 | self.varCache.label_teletext.gameObject:SetActive(false) 49 | self.callback = callback 50 | self.varCache.lbl_title.text = title 51 | self.varCache.lbl_message.text = message 52 | self.varCache.lbl_message.gameObject:SetActive(true) 53 | if btnName ~= nil then 54 | self.varCache.lbl_ok_1.text = btnName 55 | end 56 | self:showGameObject(self.alertType) 57 | end 58 | 59 | 60 | --显示有两个按钮的提示框 61 | function AlertMessagePanel:alertTwo(title, message, callback1, callback2, btnNam1, btnName2) 62 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Warn_Tips) 63 | self.alertType = AlertMessagePanel.enumAlertType.eatTwoButton 64 | self.varCache.label_teletext.gameObject:SetActive(false) 65 | self.callback1 = callback1 66 | self.callback2 = callback2 67 | self.varCache.lbl_message.text = message 68 | self.varCache.lbl_message.gameObject:SetActive(true) 69 | if btnNam1 ~= nil then 70 | self.varCache.lbl_ok_2.text = btnNam1 71 | else 72 | self.varCache.lbl_ok_2.text = L("common_button_1") 73 | end 74 | if btnName2 ~= nil then 75 | self.varCache.lbl_cancel_2.text = btnName2 76 | else 77 | self.varCache.lbl_cancel_2.text = L("common_button_2") 78 | end 79 | self.varCache.lbl_title.text = title 80 | self:showGameObject(self.alertType) 81 | end 82 | 83 | 84 | --显示有两个按钮的图文提示框 85 | function AlertMessagePanel:alertTwoTeletext(title, message, callback1, callback2, btnNam1, btnName2) 86 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Warn_Tips) 87 | self.varCache.lbl_message.gameObject:SetActive(false) 88 | self.alertType = AlertMessagePanel.enumAlertType.eatTwoButton 89 | self.callback1 = callback1 90 | self.callback2 = callback2 91 | 92 | if btnNam1 ~= nil then 93 | self.varCache.lbl_ok_2.text = btnNam1 94 | else 95 | self.varCache.lbl_ok_2.text = L("common_button_1") 96 | end 97 | 98 | if btnName2 ~= nil then 99 | self.varCache.lbl_cancel_2.text = btnName2 100 | else 101 | self.varCache.lbl_cancel_2.text = L("common_button_2") 102 | end 103 | 104 | self.varCache.lbl_title.text = title 105 | self.varCache.label_teletext.text = message 106 | self.varCache.label_teletext.gameObject:SetActive(true) 107 | self:showGameObject(self.alertType) 108 | 109 | self.teletextScript = ScriptManager.GetInstance():WrapperWindowControl(self.varCache.label_teletext.gameObject, nil) 110 | if self.teletextScript ~= nil then 111 | self.teletextScript:removeSelfImage() 112 | self.teletextScript:setOffset(5, 35) 113 | -- local splitColor = string.gsub(message, "ef8a1d", "") --stringUtility.replaceStr(message, "[ef8a1d]", "") 114 | -- splitColor = string.gsub(splitColor, "-", "") 115 | -- splitColor = string.gsub(splitColor, "%[]", "") 116 | self.teletextScript:addItem(message) 117 | self.teletextScript:setCenter() 118 | end 119 | end 120 | 121 | 122 | --根据提示类型, 调整大小 123 | function AlertMessagePanel:showGameObject(alertType) 124 | self:hideButton() 125 | 126 | if alertType == AlertMessagePanel.enumAlertType.eatSingleButton then 127 | self.varCache.go_single:SetActive(true); 128 | elseif alertType == AlertMessagePanel.enumAlertType.eatTwoButton then 129 | self.varCache.go_two:SetActive(true) 130 | end 131 | end 132 | 133 | 134 | --调整2层背景大小 135 | function AlertMessagePanel:setFrameObjectSize(w, h, iw, ih) 136 | self.varCache.sp_background.width = w 137 | self.varCache.sp_background.height = h 138 | end 139 | 140 | 141 | function AlertMessagePanel:hideButton() 142 | self.varCache.go_single:SetActive(false) 143 | self.varCache.go_two:SetActive(false) 144 | end 145 | -------------------------------------------------------------------------------- /LuaScript/framework/window/windowMask.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowMask.lua 4 | -- Creator : lxy 5 | -- Date : 2017-2-27 10:45 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | WindowMask = BaseClass() 11 | 12 | WindowMask.MASK_RESOURCE_NAME = "UI/Background/WindowMaskPanel" 13 | WindowMask.maskGameObject = nil 14 | WindowMask.panelNameDicClickClose = {} -- panel允许点击关闭记录表(只记录允许关闭的panelName) 15 | 16 | 17 | --设置遮罩可以点击关闭 add lxy 2017-3-11 18 | function WindowMask:setMaskClickClosed(goPanel) 19 | if goPanel then 20 | local panelName = goPanel.name -- goPanel: NoticePanel(Clone) 21 | if nil == self.panelNameDicClickClose[panelName] then 22 | self.panelNameDicClickClose[panelName] = true 23 | end 24 | end 25 | end 26 | 27 | 28 | -- 关闭时移除 29 | function WindowMask:removeClickablePanel(goPanel) 30 | if goPanel then 31 | local panelName = goPanel.name 32 | if self.panelNameDicClickClose[panelName] then 33 | self.panelNameDicClickClose[panelName] = nil 34 | 35 | end 36 | end 37 | end 38 | 39 | 40 | -- 添加Masks,并setDepth 41 | function WindowMask:dealwithUiMask(go) 42 | if go == nil then return end 43 | self:addMask(go) 44 | if #WindowStack.instance.windowBaseList > 0 then 45 | self:adjustDepth(WindowStack.instance.windowBaseList[#WindowStack.instance.windowBaseList]) 46 | end 47 | end 48 | 49 | 50 | -- 生成遮罩Mask 51 | function WindowMask:addMask(go) 52 | if go == nil or Slua.IsNull(go) then return end 53 | self:destoryMaskGameObject() 54 | 55 | if string.find(go.name, "UniverseDungeonPanel") ~= nil then return end --此panel 遮挡星球导致星球变暗 56 | self:getMaskGameObject() 57 | GameObjectUtility.AddGameObject(go, self.maskGameObject) 58 | end 59 | 60 | 61 | function WindowMask:adjustDepth(window) 62 | if window == nil or Slua.IsNull(window.transform) or window.transform.childCount < 1 then return end 63 | 64 | local nowPanelTrans = window.transform:GetChild(0) 65 | local nowPanel 66 | if nowPanelTrans then 67 | nowPanel = nowPanelTrans.gameObject:GetComponentInChildren(UIPanel, true) 68 | local windowMaskPanel = window.transform:Find("WindowMaskPanel(Clone)") 69 | if windowMaskPanel then 70 | self:setWindowMask(windowMaskPanel.gameObject, nowPanel.depth - 2) 71 | end 72 | end 73 | end 74 | 75 | 76 | -- destroy window的遮罩Mask 77 | function WindowMask:destroyMaskOfWindow(window) 78 | if window then 79 | local windowMaskPanel = window.transform:Find("WindowMaskPanel(Clone)") 80 | if windowMaskPanel then 81 | GameObjectUtility.DestroyGameObject(windowMaskPanel.gameObject,true) 82 | end 83 | end 84 | end 85 | 86 | 87 | function WindowMask:setWindowMask(goWindowMask,depth) 88 | local maskPanel = goWindowMask:GetComponentInChildren(UIPanel, true) 89 | if maskPanel then 90 | maskPanel.depth = depth 91 | end 92 | end 93 | 94 | 95 | function WindowMask:getMaskGameObject() 96 | if self.maskGameObject == nil then 97 | self.maskGameObject = ResourceLoader.Instantiate(self.MASK_RESOURCE_NAME) --尚未设置父节点 98 | assert(self.maskGameObject ~= nil) 99 | UIEventListener.Get(self.maskGameObject.transform:Find("WindowMask").gameObject).onClick = function() self:onClickMask(self.maskGameObject) end 100 | local maskSprite = self.maskGameObject.transform:Find("WindowMask").gameObject:GetComponent("UISprite") 101 | if PlayerPrefs.GetInt("rapidBlur", 1) == 0 then 102 | maskSprite.color = Color(1, 1, 1, 0.8) 103 | else 104 | maskSprite.color = Color(1, 1, 1, 0.5) 105 | end 106 | end 107 | end 108 | 109 | 110 | function WindowMask:destoryMaskGameObject() 111 | if self.maskGameObject ~= nil then 112 | GameObjectUtility.DestroyGameObject(self.maskGameObject, true) -- destoryGameObject(go, isImmediate) 113 | self.maskGameObject = nil 114 | end 115 | end 116 | 117 | 118 | function WindowMask:onClickMask(goParent) 119 | local topwindow = WindowStack.instance.windowBaseList[#WindowStack.instance.windowBaseList] 120 | 121 | -- 判断最顶层的windowPanel 的 Dic value是否存在 122 | if nil == topwindow then return end 123 | if topwindow.panelObject == nil then print("----- error: topwindow.panelObject is nil -----"); return end 124 | local panelName = topwindow.panelObject.name 125 | if self.panelNameDicClickClose[panelName] then 126 | -- 关闭父窗体 127 | for i = 1, goParent.transform.parent.childCount do 128 | local window = goParent.transform.parent:GetChild(i - 1) 129 | if window.gameObject.name ~= "WindowMaskPanel(Clone)" then 130 | local luaScriptOnGo = ScriptManager.GetInstance():WrapperWindowControl(window.gameObject, nil) 131 | luaScriptOnGo:close() 132 | 133 | -- 关闭时播放音效 134 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_CloseInterface_Tips) 135 | return 136 | end 137 | end 138 | end 139 | end 140 | 141 | 142 | WindowMask.instance = WindowMask.new() -------------------------------------------------------------------------------- /LuaScript/framework/window/windowQueueRegister.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : windowQueueRegister.lua 4 | -- Creator : xiewenjian 5 | -- Date : 2017-4-11 6 | -- Comment : 回退队列 7 | -- *************************************************************** 8 | 9 | 10 | WindowQueueRegister = BaseClass() 11 | 12 | enumWindowSourceType = 13 | { 14 | wstGangShop = 1, --工会商店 15 | wstFairPlayingPanel = 2, --公平竞技 16 | wstCruciataPanel = 5, --舰长试炼 17 | wstConquestPanel = 7, --银河联赛 18 | wstCardBagPanel = 8, 19 | wstEscortPanel = 9, --星空护送 20 | wstScoopDiamondPanel = 10, 21 | wstPyramidMapPanel = 11, 22 | wstColosseumPanel = 12, 23 | wstVipShopPanel = 13, 24 | wstCruciataShadowPanel = 14, 25 | wstVipPanel = 15, 26 | wstActivityPanel = 16, --活动界面 27 | wstGangPanel = 17, 28 | wstStorePanel = 18, 29 | wstDungeonSweepPanel = 19, --星球扫荡 30 | wstCitySweepPanel = 20, 31 | wstFairPlayingShop = 21, 32 | wstGangShop = 22, 33 | wstGoldShop = 23, 34 | wstDepotgShop = 24, -- 补给站 35 | wstMilkyWayShop = 25, 36 | wstUniverseDungeonPanel = 26, 37 | wstTowerShop = 27, -- 先祖遗迹商店 38 | 39 | } 40 | 41 | 42 | function WindowQueueRegister:initialize() 43 | self:registerGoto(enumWindowSourceType.wstCruciataPanel, windowResId.cruciataPanel) 44 | self:registerGoto(enumWindowSourceType.wstConquestPanel, windowResId.qualifyingPanel) 45 | self:registerGoto(enumWindowSourceType.wstCardBagPanel, windowResId.cardBagPanel) 46 | self:registerGoto(enumWindowSourceType.wstGangPanel, windowResId.gangPanel) 47 | self:registerGoto(enumWindowSourceType.wstVipPanel, windowResId.vipPanel) 48 | self:registerGoto(enumWindowSourceType.wstFairPlayingPanel, windowResId.fairPlayingPanel) 49 | self:registerGoto(enumWindowSourceType.wstActivityPanel, windowResId.activityPanel) 50 | 51 | self:registerGoto(enumWindowSourceType.wstScoopDiamondPanel, windowResId.scoopDiamondPanel) 52 | self:registerGoto(enumWindowSourceType.wstPyramidMapPanel, windowResId.pyramidMapPanel) 53 | self:registerGoto(enumWindowSourceType.wstColosseumPanel, windowResId.colosseumPanel) 54 | self:registerGoto(enumWindowSourceType.wstVipShopPanel, windowResId.vipShopPanel) 55 | self:registerGoto(enumWindowSourceType.wstEscortPanel, windowResId.escortPanel) 56 | self:registerGoto(enumWindowSourceType.wstCruciataShadowPanel, windowResId.cruciataShadowPanel) 57 | self:registerGoto(enumWindowSourceType.wstCitySweepPanel, windowResId.commonSweepPanel) 58 | self:registerGoto(enumWindowSourceType.wstStorePanel, windowResId.storePanel) 59 | 60 | self:registerGoto(enumWindowSourceType.wstUniverseDungeonPanel, windowResId.universeDungeonPanel) 61 | -- shopPanel 62 | -- ustRecharge = 1, --充值商品 63 | -- ustGold = 2, --金币商品 64 | -- ustMilkyWay = 3, --银河商会 65 | -- ustGang = 4, --军团商店 66 | -- ustFairPlay = 5, --公平竞技商店 67 | -- ustDepotg = 6, --补给站商店 68 | self:registerGoto(enumWindowSourceType.wstFairPlayingShop, windowResId.shopPanel, shopBB.uiShopType.ustFairPlay) 69 | self:registerGoto(enumWindowSourceType.wstGangShop, windowResId.shopPanel, shopBB.uiShopType.ustGang) 70 | -- self:registerGoto(enumWindowSourceType.wstGoldShop, windowResId.shopPanel, shopBB.uiShopType.ustGold) 71 | self:registerGoto(enumWindowSourceType.wstMilkyWayShop, windowResId.shopPanel, shopBB.uiShopType.ustMilkyWay) 72 | self:registerGoto(enumWindowSourceType.wstTowerShop, windowResId.shopPanel, shopBB.uiShopType.ustTower) 73 | 74 | self:registerDungenSweep() 75 | self:registerExceptiond() 76 | end 77 | 78 | 79 | function WindowQueueRegister:registerGoto(windowSourceType, windowResId, uiShopType) 80 | local conquestQueue = WindowQueue.new() 81 | local targetPanelPath = 82 | { 83 | eventType = enumWindowEventType.wetWindow, 84 | window = windowResId, 85 | lastWindow = false, 86 | uiShopType = uiShopType, --add lxy 9.19 87 | } 88 | conquestQueue:addQueuePath(targetPanelPath) 89 | 90 | local targetConditionPath = 91 | { 92 | eventType = enumWindowEventType.wetWindow, 93 | window = windowResId, 94 | } 95 | conquestQueue:addConditionPath(targetConditionPath) 96 | 97 | WindowQueueManager.instance:register(windowSourceType, conquestQueue) 98 | end 99 | 100 | --add sweep 101 | function WindowQueueRegister:registerDungenSweep() 102 | local dungenSweepQueue = WindowQueue.new() 103 | 104 | local universeScenePath = 105 | { 106 | eventType = enumWindowEventType.wetScene, 107 | nextSceneDefine = sceneSwitchRes.universeScene, 108 | } 109 | dungenSweepQueue:addQueuePath(universeScenePath) 110 | 111 | local commonSweepPanelPath = 112 | { 113 | eventType = enumWindowEventType.wetWindow, 114 | window = windowResId.commonSweepPanel, 115 | } 116 | dungenSweepQueue:addQueuePath(commonSweepPanelPath) 117 | 118 | local universeSceneConditionPath = 119 | { 120 | eventType = enumWindowEventType.wetScene, 121 | lastSceneDefine = sceneSwitchRes.universeScene, 122 | nextSceneDefine = sceneSwitchRes.mainUiScene, 123 | } 124 | dungenSweepQueue:addConditionPath(universeSceneConditionPath) 125 | 126 | WindowQueueManager.instance:register(enumWindowSourceType.wstDungeonSweepPanel, dungenSweepQueue) 127 | end 128 | 129 | 130 | function WindowQueueRegister:registerExceptiond() 131 | local res = {} 132 | table.insert(res, windowResId.goldenTouchPanel) 133 | table.insert(res, windowResId.shopPanel) 134 | 135 | for i = 1, #res do 136 | WindowQueueManager.instance:registerException(res[i]) 137 | end 138 | end -------------------------------------------------------------------------------- /LuaScript/utility/stringUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : stringUtility.lua 4 | -- Creator : lyf 5 | -- Date : 2016-12-26 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("stringUtility", package.seeall) 11 | 12 | ----分割字符串 13 | function split(szFullString, szSeparator) 14 | local nFindStartIndex = 1 15 | local nSplitIndex = 1 16 | local nSplitArray = {} 17 | while true do 18 | local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex) 19 | if not nFindLastIndex then 20 | nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString)) 21 | break 22 | end 23 | nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1) 24 | nFindStartIndex = nFindLastIndex + string.len(szSeparator) 25 | nSplitIndex = nSplitIndex + 1 26 | end 27 | return nSplitArray 28 | end 29 | 30 | 31 | ----剔除{0}这样的符号 32 | function rejuctSymbol(fullStr) 33 | local tempStr = split(fullStr,"{") 34 | local allStr ="" 35 | for i,k in ipairs(tempStr) do 36 | local str = split(k,"}") 37 | if table.getn(str)>1 then 38 | str[1] = "%s" 39 | allStr =allStr .. str[1] .. str[2] 40 | else 41 | allStr =allStr .. k 42 | end 43 | end 44 | 45 | return allStr 46 | end 47 | 48 | 49 | -- -- 检查是否又敏感词汇 50 | -- function hasSensitiveWord(str) 51 | -- local isFind = false 52 | -- for k,v in pairs(conf.filterNameString) do 53 | -- if string.find(str,v.info) ~=nil then 54 | -- isFind=true 55 | -- break 56 | -- end 57 | -- end 58 | -- return isFind 59 | -- end 60 | 61 | 62 | function hasSensitiveWord(str) 63 | for k,v in pairs(conf.filterNameString) do 64 | local isFind2 = true 65 | local tStr = v.info 66 | 67 | if string.find(tStr, "%[") ~= nil then 68 | tStr = string.gsub(tStr, "%[", " ") 69 | end 70 | if string.find(tStr, "%]") ~= nil then 71 | tStr = string.gsub(tStr, "%]", " ") 72 | end 73 | if string.find(tStr, "%%") ~= nil then 74 | tStr = string.gsub(tStr, "%%", " ") 75 | end 76 | 77 | 78 | local n=string.len(tStr) 79 | local list1 = {} 80 | for i=1,n do 81 | list1[i]=string.sub(tStr,i,i) 82 | end 83 | 84 | local findIndex = 1 85 | for i=1,n do 86 | if list1[i] == "(" then 87 | if string.find(str, "%(") == nil then 88 | isFind2 = false 89 | end 90 | elseif list1[i] == ")" then 91 | if string.find(str, "%)") == nil then 92 | isFind2 = false 93 | end 94 | else 95 | local tStart, tEnd = string.find(str, list1[i], findIndex) 96 | if tStart == nil then 97 | isFind2 = false 98 | else 99 | findIndex = tEnd 100 | end 101 | end 102 | end 103 | 104 | if isFind2 == true then 105 | return true 106 | end 107 | 108 | end 109 | return false 110 | end 111 | 112 | 113 | ---依次替换目标字符串 114 | function replaceStr(source, rStr, replacements) 115 | for i=1, #replacements do 116 | source = string.gsub(source,rStr,replacements[i], 1) 117 | end 118 | return source 119 | end 120 | 121 | 122 | -- 获取字符串的宽度 123 | function strlen(str, fontSize) 124 | local curByte = string.byte(str, i) 125 | local byteCount = 1; 126 | if curByte>0 and curByte<=127 then 127 | byteCount = 1 128 | elseif curByte>=192 and curByte<223 then 129 | byteCount = 2 130 | elseif curByte>=224 and curByte<239 then 131 | byteCount = 3 132 | elseif curByte>=240 and curByte<=247 then 133 | byteCount = 4 134 | end 135 | 136 | if byteCount == 1 then 137 | width = fontSize * 0.5 138 | else 139 | width = fontSize 140 | end 141 | 142 | return width --13.29一个字符的宽度,C#直接用NGUIText.GetGlyphWidth(string.byte(' '), 0) 143 | end 144 | 145 | 146 | --数字转换字符串格式 147 | function num2str(num) 148 | local numStr = "" 149 | 150 | if num >= 0 and num < 1000 then 151 | numStr = "" 152 | elseif num >= 1000 and num < 1000000 then 153 | num = (num/1000) 154 | numStr = "K" 155 | elseif num >= 1000000 then 156 | num = (num/1000000) 157 | numStr = "M" 158 | end 159 | 160 | num = num - num%0.01 161 | 162 | return num .. numStr 163 | end 164 | 165 | 166 | -- 计算字符串宽度,中文两个位置,英文一个位置 167 | function length(inputstr) 168 | inputstr = tostring(inputstr) 169 | 170 | local lenInByte = #inputstr 171 | local width = 0 172 | local i = 1 173 | while (i<=lenInByte) 174 | do 175 | local curByte = string.byte(inputstr, i) 176 | local byteCount = 1; 177 | if curByte>0 and curByte<=127 then 178 | byteCount = 1 --1字节字符 179 | elseif curByte>=192 and curByte<223 then 180 | byteCount = 2 --双字节字符 181 | elseif curByte>=224 and curByte<239 then 182 | byteCount = 3 --汉字 183 | elseif curByte>=240 and curByte<=247 then 184 | byteCount = 4 --4字节字符 185 | end 186 | 187 | local char = string.sub(inputstr, i, i+byteCount-1) 188 | i = i + byteCount -- 重置下一字节的索引 189 | 190 | if byteCount == 1 then 191 | width = width + 1 -- 字符的个数(长度) 192 | else 193 | width = width + 2 -- 字符的个数(长度) 194 | end 195 | end 196 | 197 | return width 198 | end -------------------------------------------------------------------------------- /LuaScript/module/bag/bagAA.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : bagAA.lua 4 | -- Creator : panyuhuan 5 | -- Date : 2017-1-14 6 | -- Comment : 后端背包数据回调 7 | -- *************************************************************** 8 | 9 | 10 | module("bagAA", package.seeall) 11 | 12 | 13 | -- 返回背包信息 14 | NetClient.Add(20231002, function(data) 15 | if data.status == 0 then 16 | bagBB.getBagData() 17 | 18 | -- 添加红点 19 | mainUIBB.setFunctionRed(mainUIBB.enumSpriteHint.Bag, bagBB.getRedByType(-1)) 20 | else 21 | applicationGlobal.tooltip:errorMessage(errorInfo.getInfo(data.status)) 22 | end 23 | end) 24 | 25 | 26 | -- 更新道具数量推送 27 | NetClient.Add(20231003, function(data) 28 | -- print("-----------------------------------更新道具数量推送-----------------------------------------") 29 | -- print_t(data) 30 | if data.status == 0 then 31 | -- local currScene = applicationGlobal.sceneSwitchManager.currentSceneInstance 32 | -- if currScene ~= nil and isSuper(currScene, MainUiInstance) and currScene.guideNewLayer ~= nil then 33 | -- currScene.guideNewLayer:updateItemNum(data.itemId) -- 引导 34 | -- end 35 | 36 | bagBB.updateBagItem(data) 37 | -- local itemData = bagBB.updateBagItem(data) -- 更新数据 38 | -- if itemData ~= nil then 39 | -- local newItemData = {} 40 | -- newItemData.id = itemData.itemModelId 41 | -- newItemData.count = data.delta 42 | -- CommonAwardPopupWindow.instance:showNewItem(newItemData) 43 | -- end 44 | local bagPanel = WindowStack.instance:getWindow(windowResId.bagPanel) 45 | if bagPanel ~= nil and bagPanel.window.isShow then 46 | bagPanel:updateItemNum(data) 47 | end 48 | else 49 | applicationGlobal.tooltip:errorMessage(errorInfo.getInfo(data.status)) 50 | end 51 | end) 52 | 53 | 54 | -- 新增道具推送 55 | NetClient.Add(20231004, function(data) 56 | -- print("-------------------------------新增道具推送----------------------------") 57 | -- print_t(data) 58 | if data.status == 0 then 59 | bagBB.addNewItem(data) 60 | 61 | -- local newItemData = {} 62 | -- newItemData.id = data.itemModelId 63 | -- newItemData.count = data.numb 64 | -- CommonAwardPopupWindow.instance:showNewItem(newItemData) 65 | 66 | local bagPanel = WindowStack.instance:getWindow(windowResId.bagPanel) 67 | if bagPanel ~= nil and bagPanel.window.isShow then 68 | bagPanel:addNewItem(data) 69 | end 70 | 71 | -- local currScene = applicationGlobal.sceneSwitchManager.currentSceneInstance 72 | -- if currScene ~= nil and isSuper(currScene, MainUiInstance) and currScene.guideNewLayer ~= nil then 73 | -- currScene.guideNewLayer:addItem(nil) -- 引导 74 | -- end 75 | 76 | -- 添加红点 77 | mainUIBB.setFunctionRed(mainUIBB.enumSpriteHint.Bag, bagBB.getRedByType(-1)) 78 | 79 | --create by liyang 2017-4-14,新增道具检测将军府红点 80 | -- mainUIBB.setFunctionRed(mainUIBB.enumSpriteHint.General, strategosBB.checkAllRedTip()) 81 | local sceneInstance = applicationGlobal.sceneSwitchManager.currentSceneInstance 82 | if sceneInstance ~= nil and isSuper(sceneInstance, MainUiInstance) and sceneInstance.mainUILayer ~= nil then 83 | if sceneInstance.mainUILayer.mainUIButton ~= nil then 84 | sceneInstance.mainUILayer.mainUIButton:setRedHint("captain", strategosBB.checkAllRedTip()) 85 | end 86 | end 87 | 88 | -- 添加阵法红点 by lxy 2017-5-16 89 | mainUIBB.setFunctionRed(mainUIBB.enumSpriteHint.StoneMatrix, stoneMatrixBB.checkRedTips()) 90 | else 91 | applicationGlobal.tooltip:errorMessage(errorInfo.getInfo(data.status)) 92 | end 93 | end) 94 | 95 | 96 | -- 删除道具推送 97 | NetClient.Add(20231005, function(data) 98 | if data.status == 0 then 99 | bagBB.removeItemData(data) 100 | local bagPanel = WindowStack.instance:getWindow(windowResId.bagPanel) 101 | if bagPanel ~= nil and bagPanel.window.isShow then 102 | bagPanel:removeItem(data) 103 | end 104 | 105 | -- 添加红点 106 | mainUIBB.setFunctionRed(mainUIBB.enumSpriteHint.Bag, bagBB.getRedByType(-1)) 107 | 108 | -- 添加阵法红点 by lxy 2017-5-16 109 | mainUIBB.setFunctionRed(mainUIBB.enumSpriteHint.StoneMatrix, stoneMatrixBB.checkRedTips()) 110 | else 111 | applicationGlobal.tooltip:errorMessage(errorInfo.getInfo(data.status)) 112 | end 113 | end) 114 | 115 | 116 | -- 出售道具返回 117 | NetClient.Add(20231009, function(data) 118 | if data.status == 0 then 119 | local bagPanel = WindowStack.instance:getWindow(windowResId.bagPanel) 120 | if bagPanel ~= nil and bagPanel.window.isShow then 121 | bagPanel:sellOrUseCallBack(data.itemId, 1) 122 | end 123 | 124 | local bagHandlerPanel = WindowStack.instance:getWindow(windowResId.bagHandlerPanel) 125 | if bagHandlerPanel ~= nil and bagHandlerPanel.window.isShow then 126 | bagHandlerPanel:sellCallBack() 127 | end 128 | else 129 | applicationGlobal.tooltip:errorMessage(errorInfo.getInfo(data.status)) 130 | end 131 | end) 132 | 133 | 134 | -- 道具使用返回 135 | NetClient.Add(20231011, function(data) 136 | if data.status == 0 then 137 | local bagPanel = WindowStack.instance:getWindow(windowResId.bagPanel) 138 | if bagPanel ~= nil and bagPanel.window.isShow then 139 | bagPanel:sellOrUseCallBack(data.itemId, 2) 140 | end 141 | 142 | local noPowerTipPanel = WindowStack.instance:getWindow(windowResId.noPowerTipPanel) 143 | if noPowerTipPanel ~= nil and noPowerTipPanel.window.isShow then 144 | noPowerTipPanel:useItemCallBack() 145 | end 146 | 147 | local bagHandlerPanel = WindowStack.instance:getWindow(windowResId.bagHandlerPanel) 148 | if bagHandlerPanel ~= nil and bagHandlerPanel.window.isShow then 149 | bagHandlerPanel:useCallBack() 150 | end 151 | else 152 | applicationGlobal.tooltip:errorMessage(errorInfo.getInfo(data.status)) 153 | end 154 | end) -------------------------------------------------------------------------------- /LuaScript/framework/logger/loggerManager.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : LoggerManager.lua 4 | -- Creator : zg 5 | -- Date : 2017-5-9 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | LoggerManager = BaseClass() 11 | 12 | 13 | function LoggerManager:initialize() 14 | 15 | end 16 | 17 | 18 | --此函数输出的日志不能打印到控制台, 只能显示 19 | function LoggerManager:interceptMessage(condition, stackTrace, errType) 20 | -- 错误和异常日志,写入日志文件,上传到性能监控 21 | if errType == 'Error' then 22 | local errorStr = "[Error:] " .. condition .. " " .. stackTrace 23 | if not applicationConfig.macro.UNITY_EDITOR then 24 | self:errorToServer(json.encode(errorStr)) 25 | end 26 | LogUtility.Log(errorStr) 27 | 28 | elseif errType == 'Exception' then 29 | local errorStr = "[Exception:] " .. condition .. " " .. stackTrace 30 | if not applicationConfig.macro.UNITY_EDITOR then 31 | self:errorToServer(json.encode(errorStr)) 32 | end 33 | LogUtility.Log(errorStr) 34 | 35 | elseif errType == 'Warning' then 36 | local errorStr = "[Warning:] " .. condition .. " " .. stackTrace 37 | LogUtility.Log(errorStr) 38 | else 39 | -- 打印日志,不写入日志文件 40 | 41 | end 42 | end 43 | 44 | 45 | function LoggerManager:errorToServer(error) 46 | local httpUrl = applicationConfig.gameConfig.serverErrorUrl .. 47 | "&uid=" .. applicationConfig.loginConfig.uid .. 48 | "&gameid=" .. applicationConfig.gameConfig.gameId .. 49 | "&sdkid=" .. applicationConfig.gameConfig.sdkid .. 50 | "&channelid=" .. applicationConfig.gameConfig.channelId .. 51 | "&serverid=" .. applicationConfig.loginConfig.zoneid .. 52 | "&mac=" .. applicationConfig.gameConfig.macAddress .. 53 | "&exception=" .. error .. 54 | "&time=" .. math.ceil(UnityEngine.Time.realtimeSinceStartup*1000) .. 55 | "&key=" .. Md5Utility.GetMd5Str(applicationConfig.loginConfig.uid..applicationConfig.gameConfig.gameId 56 | .. applicationConfig.gameConfig.sdkid..applicationConfig.gameConfig.channelId..applicationConfig.loginConfig.zoneid 57 | .. applicationConfig.gameConfig.macAddress..error) .. 58 | "&version=" .. self:getVersion() 59 | 60 | local c = coroutine.create( 61 | function() 62 | local www = UnityEngine.WWW(httpUrl) 63 | UnityEngine.Yield(www) 64 | if www.error == nil then 65 | -- local go = GameObject(Slua.ToString(www.bytes)) 66 | -- print(Slua.ToString(www.bytes)) 67 | else 68 | local go = GameObject(www.error) 69 | end 70 | end) 71 | coroutine.resume(c) 72 | end 73 | 74 | 75 | --在一帧内只发送一次 76 | function LoggerManager:debug(bugId, logId, logMessage) 77 | self:bugLogToServer(bugId, logId, logMessage) 78 | end 79 | 80 | 81 | function LoggerManager:bugLogToServer(bugId, logId, logMessage) 82 | local httpUrl = applicationConfig.gameConfig.serverErrorUrl .. 83 | "&gameid=" .. applicationConfig.gameConfig.gameId .. 84 | "&sdkid=" .. applicationConfig.gameConfig.sdkid .. 85 | "&channelId=" .. applicationConfig.gameConfig.channelId .. 86 | "&mac=" .. applicationConfig.gameConfig.macAddress .. 87 | "&serverid=" .. applicationConfig.loginConfig.zoneid .. 88 | "&uid=" .. applicationConfig.loginConfig.uid .. 89 | "&bugId=" .. bugId .. 90 | "&logId=" .. logId .. 91 | "&logMessage=" .. logMessage 92 | local c = coroutine.create( 93 | function() 94 | local www = UnityEngine.WWW(httpUrl) 95 | UnityEngine.Yield(www) 96 | if www.error == nil then 97 | -- local go = GameObject(Slua.ToString(www.bytes)) 98 | -- print(Slua.ToString(www.bytes)) 99 | else 100 | -- local go = GameObject(www.error) 101 | end 102 | end) 103 | coroutine.resume(c) 104 | end 105 | 106 | 107 | --提交客户端本地日志文件 108 | function LoggerManager:sendAllLogsToServer(valData) 109 | local time = valData.time 110 | local playerId = valData.playerId 111 | local sign = valData.sign 112 | local url = valData.url 113 | 114 | local logFiles = LogUtility.GetLogFilesName() 115 | if logFiles.Length == 0 then 116 | return 117 | end 118 | 119 | local c = coroutine.create(function() 120 | for i=1, logFiles.Length do 121 | local filePath = logFiles[i] 122 | local content = FileUtility.GetBytes(filePath) 123 | 124 | local wwwForm = UnityEngine.WWWForm() 125 | wwwForm:AddField("time", tostring(time)) 126 | wwwForm:AddField("playerId", tostring(playerId)) 127 | wwwForm:AddField("sign", tostring(sign)) 128 | local fileName = System.IO.Path.GetFileName(filePath) 129 | fileName = string.sub(fileName, 5, fileName.length) 130 | 131 | wwwForm:AddBinaryData("file", content, fileName, "multipart / form - data") 132 | local www = UnityEngine.WWW(url, wwwForm) 133 | UnityEngine.Yield(www) 134 | if www.error == nil and www.text == "0" then 135 | logInfo("LoggerManager:sendAllLogsToServer: 上传日志成功") 136 | else 137 | local go = GameObject(www.error) 138 | logInfo("LoggerManager:sendAllLogsToServer: 上传日志失败") 139 | end 140 | end 141 | end) 142 | coroutine.resume(c) 143 | end 144 | 145 | 146 | function LoggerManager:getVersion() 147 | local version = AssetStatusManager.instance.localConfProject.version -- 版本信息 1.0.0-100 148 | return version 149 | end -------------------------------------------------------------------------------- /LuaScript/utility/gameObjectUtility.lua: -------------------------------------------------------------------------------- 1 | -- -- *************************************************************** 2 | -- -- Copyright(c) Yeto 3 | -- -- FileName : gameObjectUtility.lua 4 | -- -- Creator : zg 5 | -- -- Date : 2016-12-30 6 | -- -- Comment : 7 | -- -- *************************************************************** 8 | 9 | 10 | -- module("gameObjectUtility", package.seeall) 11 | 12 | 13 | -- function findInParents(go, clazz) 14 | -- if go == nil then 15 | -- return 16 | -- end 17 | 18 | -- local comp = go:GetComponent(clazz) 19 | -- if comp == nil then 20 | -- local t = go.transform.parent 21 | -- while t ~= nil and comp == nil do 22 | -- comp = t.gameObject:GetComponent(clazz) 23 | -- t = t.parent 24 | -- end 25 | -- end 26 | 27 | -- return comp 28 | -- end 29 | 30 | 31 | -- function findAndGet(path, parentGo, clazz) 32 | -- local bindGo = find(path, parentGo, false) 33 | -- if bindGo == nil then 34 | -- error("gameobject utility find error , path : " + path) 35 | -- end 36 | -- return bindGo:GetComponent(clazz) 37 | -- end 38 | 39 | 40 | -- function findAndAdd(path, parentGo, clazz) 41 | -- local bindGo = find(path, parentGo, false) 42 | -- if bindGo == nil then 43 | -- error("gameobject utility find error , path : " + path) 44 | -- end 45 | -- return bindGo:AddComponent(clazz) 46 | -- end 47 | 48 | 49 | -- function getIfNotAdd(bindGo, clazz) 50 | -- local component = bindGo:GetComponent(clazz) 51 | -- if component == nil then 52 | -- component = bindGo:AddComponent(clazz) 53 | -- end 54 | -- return component 55 | -- end 56 | 57 | 58 | -- function find(path, parentGo, isThrow) 59 | -- if parentGo == nil then 60 | -- local go = GameObject.Find(path) 61 | -- else 62 | -- local trans = parentGo.transform:Find(path) 63 | -- if trans ~= nil then 64 | -- return trans.gameObject 65 | -- end 66 | -- end 67 | -- if isThrow == true and go == nil then 68 | -- error("gameobject utility find error , path : " + path) 69 | -- end 70 | -- return go 71 | -- end 72 | 73 | 74 | -- function findAndAddChild(path, parentGo, childName, clazz) 75 | -- local bindGo = find(path, parentGo) 76 | -- if bindGo == nil then 77 | -- error("gameobject utility find error , path : " + path) 78 | -- end 79 | -- local childGo = GameObject() 80 | -- if childName ~= nil then 81 | -- childGo.name = childName 82 | -- end 83 | -- childGo.transform.parent = bindGo.transform 84 | -- childGo.transform.localPosition = Vector3.zero 85 | -- childGo.transform.localScale = Vector3.one 86 | -- childGo.transform.localRotation = Quaternion.identity 87 | -- return childGo:AddComponent(clazz) 88 | -- end 89 | 90 | 91 | -- function addGameObject(parentGo, childGo) 92 | -- childGo.transform.parent = parentGo.transform 93 | -- if string.find(childGo.gameObject.name, "ChatPanel") ~= nil then 94 | -- childGo.transform.localPosition = Vector3(-700, 0, 0) 95 | -- else 96 | -- childGo.transform.localPosition = Vector3.zero 97 | -- end 98 | -- childGo.transform.localScale = Vector3(1, 1, 1) 99 | -- childGo.transform.localRotation = Quaternion.identity 100 | -- return childGo 101 | -- end 102 | 103 | 104 | -- function addGameObjectPrefab(parent, prefab) 105 | -- local go = nil 106 | -- if prefab.activeSelf == true then 107 | -- go = GameObject.Instantiate(prefab) 108 | -- else 109 | -- prefab:SetActive(true) 110 | -- go = GameObject.Instantiate(prefab) 111 | -- prefab:SetActive(false) 112 | -- end 113 | 114 | -- if go ~= nil and parent ~= nil then 115 | -- local t = go.transform 116 | -- t.parent = parent.transform 117 | -- t.localPosition = Vector3.zero 118 | -- t.localRotation = Quaternion.identity 119 | -- t.localScale = Vector3.one 120 | -- go.layer = parent.layer 121 | -- end 122 | -- return go 123 | -- end 124 | 125 | 126 | -- function addGameObjectFix(parentGo, childGo) 127 | -- childGo.transform.parent = parentGo.transform 128 | -- return childGo 129 | -- end 130 | 131 | 132 | -- function createGameObject(name, clazz) 133 | -- local go = GameObject() 134 | -- if name ~= nil and clazz(name) == "string" then 135 | -- go.name = name 136 | -- end 137 | -- return go:AddComponent(clazz) 138 | -- end 139 | 140 | 141 | -- function createNilGameObject(parentGo, name) 142 | -- local go = GameObject() 143 | -- if name ~= nil then 144 | -- go.name = name 145 | -- end 146 | -- if parentGo ~= nil then 147 | -- go.transform.parent = parentGo.transform 148 | -- end 149 | 150 | -- go.transform.localScale = Vector3.one 151 | -- go.transform.localPosition = Vector3.zero 152 | -- return go 153 | -- end 154 | 155 | 156 | -- function removeGameObject(childGo) 157 | -- childGo.transform.parent = nil 158 | -- end 159 | 160 | 161 | -- function destoryGameObject(go, isImmediate) 162 | -- if isImmediate == false then 163 | -- UnityEngine.Object.DestroyObject(go) 164 | -- else 165 | -- UnityEngine.Object.DestroyImmediate(go) 166 | -- end 167 | -- end 168 | 169 | 170 | -- function clearChildGameObject(parentGo, isImmediate) 171 | -- local parentTrans = parentGo.transform 172 | -- for i = parentTrans.childCount-1, 0, -1 do 173 | -- local childTrans = parentTrans:GetChild(i) 174 | -- destoryGameObject(childTrans.gameObject, isImmediate) 175 | -- end 176 | -- end 177 | 178 | 179 | -- function isExistsChildGameObject(parentGo) 180 | -- if parentGo.transform.childCount ~= 0 then 181 | -- return true 182 | -- end 183 | -- return false 184 | -- end 185 | 186 | 187 | -- function getChildGameObject(parentGo) 188 | -- local childList = {} 189 | -- for i=0, parentGo.transform.childCount - 1 do 190 | -- local trans = parentGo.transform:GetChild(i) 191 | -- table.insert(childList, trans.gameObject) 192 | -- end 193 | -- return childList 194 | -- end 195 | 196 | -------------------------------------------------------------------------------- /LuaScript/framework/audio/audioPlay.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : audioPlay.lua 4 | -- Creator : zg 5 | -- Date : 2016-12-16 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | AudioPlay = BaseClass() 11 | 12 | 13 | function AudioPlay:initialize() 14 | self.allAudioList = {} 15 | self.audioCache = {} 16 | self.audioAsset = {} 17 | self.audioKeyIndex = 0 18 | self.currBgMusic = nil 19 | self.lastBgMusic = nil 20 | self.guideAudioId = nil 21 | self.bgMusicVolume = PlayerPrefs.GetFloat("bgMusicvolume", 0.5) 22 | self.otherVolume = PlayerPrefs.GetFloat("otherVolume", 0.5) 23 | 24 | self.gameObject:AddComponent(AudioListener) 25 | end 26 | 27 | 28 | --允许播放 29 | function AudioPlay:allowSound() 30 | self.allowPlay = true 31 | end 32 | 33 | 34 | --禁止声音 35 | function AudioPlay:forbidSound() 36 | self.allowPlay = false 37 | self.stopAllAudio() 38 | end 39 | 40 | 41 | --播放一个声音片段 42 | function AudioPlay:playAudio(key) 43 | if type(key) ~= "string" or self.allowPlay == false then return end 44 | if data.audio == nil then return end 45 | local audioData = data.audio[key] 46 | if audioData == nil then return end 47 | local aduioItem = self:getAudioItem(key) 48 | aduioItem:playAudio() 49 | end 50 | 51 | 52 | function AudioPlay:getAudioItem(key) 53 | local audioItem = nil 54 | if self.audioCache[key] ~= nil and #self.audioCache[key] > 0 then 55 | audioItem = self.audioCache[key][1] 56 | table.remove(self.audioCache[key], 1) 57 | audioItem.gameObject:SetActive(true) 58 | return audioItem 59 | end 60 | 61 | local audioData = data.audio[key] 62 | audioItem = self:createAudioItem(key, audioData) 63 | return audioItem 64 | end 65 | 66 | 67 | function AudioPlay:createAudioItem(key, audioData) 68 | local go = GameObject(key) 69 | go.transform.parent = self.transform 70 | local audioScript = ScriptManager.GetInstance():WrapperWindowControl(go, 'framework/audio/audioItem') 71 | audioScript:initialize(audioData) 72 | 73 | if self.allAudioList[key] == nil then 74 | self.allAudioList[key] = {} 75 | end 76 | table.insert(self.allAudioList[key], audioScript) 77 | return audioScript 78 | end 79 | 80 | 81 | function AudioPlay:getAudioAsset(key) 82 | return self.audioAsset[key] 83 | end 84 | 85 | 86 | function AudioPlay:addAudioAsset(key, asset) 87 | if self.audioAsset[key] == nil then 88 | self.audioAsset[key] = asset 89 | self.audioAsset[key]:AddRef() 90 | end 91 | end 92 | 93 | 94 | function AudioPlay:releaseAudioItem(key, audioItem) 95 | audioItem.gameObject:SetActive(false) 96 | if self.audioCache[key] == nil then 97 | self.audioCache[key] = {} 98 | end 99 | table.insert(self.audioCache[key], audioItem) 100 | end 101 | 102 | 103 | --删除声音 104 | function AudioPlay:stopAudio(key) 105 | if key == nil or type(key) ~= "string" then 106 | return 107 | end 108 | 109 | local audioItems = self.allAudioList[key] 110 | if audioItems == nil then 111 | return 112 | end 113 | 114 | for _, audioItem in pairs(audioItems) do 115 | audioItem:onDestroy() 116 | GameObjectUtility.DestroyGameObject(audioItem.gameObject, false) 117 | end 118 | 119 | self.audioCache[key] = {} 120 | self.allAudioList[key] = {} 121 | end 122 | 123 | 124 | --停止所有声音 125 | function AudioPlay:stopAllAudio() 126 | for k, v in pairs(self.allAudioList) do 127 | self:stopAudio(k) 128 | end 129 | 130 | for _, asset in pairs(self.audioAsset) do 131 | asset:ReleaseRef() 132 | end 133 | 134 | self.audioCache = {} 135 | self.allAudioList = {} 136 | self.audioAsset = {} 137 | end 138 | 139 | 140 | function AudioPlay:playBgMusic(key,isBattle) 141 | if isBattle == false then 142 | if self.currBgMusic ~= nil then 143 | if self.currBgMusic ~= key then 144 | self:stopAudio(self.currBgMusic) 145 | self:playAudio(key) 146 | self.currBgMusic = key 147 | end 148 | else 149 | self:playAudio(key) 150 | self.currBgMusic = key 151 | end 152 | else 153 | self:playAudio(key) 154 | self.currBgMusic = key 155 | end 156 | end 157 | 158 | 159 | function AudioPlay:playGuideMusic(key) 160 | self:stopAudio(self.guideAudioId) 161 | self:playAudio(key) 162 | self.guideAudioId = key 163 | end 164 | 165 | 166 | function AudioPlay:stopBgMusic() 167 | if self.currBgMusic ~= nil then 168 | self:stopAudio(self.currBgMusic) 169 | self.currBgMusic = nil 170 | end 171 | end 172 | 173 | 174 | function AudioPlay:getRandomBgMusic(isBattle) 175 | if isBattle == nil then isBattle = false end 176 | 177 | local musicList = self.bgMusicList 178 | if isBattle == true then 179 | musicList = self.battleMusicList 180 | end 181 | 182 | if musicList == nil then 183 | if isBattle == true then 184 | self.battleMusicList = { audioConfig.Audio_Battle_Background_music_1 } 185 | -- for i = 3, 3 do 186 | -- table.insert(self.battleMusicList, audioConfig["Audio_Battle_Background_music_" .. i]) 187 | -- end 188 | musicList = self.battleMusicList 189 | else 190 | self.bgMusicList = { audioConfig.Audio_Normal_Background_music_1 } 191 | musicList = self.bgMusicList 192 | end 193 | end 194 | local musicIndex = math.random(1, #musicList) 195 | return musicList[musicIndex] 196 | end 197 | 198 | 199 | function AudioPlay:playGeneralTroopAudio(generalOrTroopId) 200 | -- print(generalOrTroopId) 201 | local audioData = conf.roleAudio[tostring(generalOrTroopId)] 202 | --print_t(audioData) 203 | if audioData == nil then 204 | return 205 | end 206 | 207 | local randomAudioListData = audioData.audio 208 | if randomAudioListData == nil then 209 | return 210 | end 211 | 212 | local randomAudioList = stringUtility.split(randomAudioListData, ",") 213 | --print(musicList[math.random(1, #randomAudioList)) 214 | 215 | applicationGlobal.audioPlay:playAudio(randomAudioList[math.random(1, #randomAudioList)]) 216 | end 217 | 218 | 219 | function AudioPlay:setSoundVolume(key, value) 220 | local isBackground = false 221 | if key == "bgMusicvolume" then 222 | self.bgMusicVolume = value 223 | isBackground = true 224 | else 225 | self.otherVolume = value 226 | end 227 | PlayerPrefs.SetFloat(key, value) 228 | for key, audioItemList in pairs(self.allAudioList) do 229 | for _, audioItem in pairs(audioItemList) do 230 | if audioItem:isBgMusic() == isBackground then 231 | audioItem:setVolume(value) 232 | end 233 | end 234 | end 235 | end 236 | 237 | 238 | function AudioPlay:dispose() 239 | 240 | end 241 | 242 | 243 | -------------------------------------------------------------------------------- /LuaScript/module/bag/bagHandlerPanel.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : bagHandlerPanel.lua 4 | -- Creator : panyuhuan 5 | -- Date : 2017-1-14 6 | -- Comment : 使用或购买物品弹框 7 | -- *************************************************************** 8 | 9 | 10 | BagHandlerPanel = BaseClass(WindowPanel) 11 | 12 | 13 | function BagHandlerPanel:initialize() 14 | self.varCache.lbl_max.text = L("bag_button_3") 15 | self.varCache.lbl_getTip.text = L("bag_tishi_2") 16 | 17 | self.num = 1 18 | --self.moneyType2SprName = { "icon-jinbi", "icon-", "icon-physical strength", "icon-kapaitujian" } 19 | 20 | self.itemPrefab = civilCommonItem.addCommonItem(self.gameObject, Vector3(-2, 174, 0)) 21 | GameObjectUtility.LocalScale(self.itemPrefab, 1.2, 1.2, 1) 22 | self.itemScript = ScriptManager.GetInstance():WrapperWindowControl(self.itemPrefab, nil) 23 | self.itemScript:updateDepth(10) 24 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Interface_Tips) 25 | end 26 | 27 | 28 | function BagHandlerPanel:resetUI() 29 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Interface_Tips) 30 | end 31 | 32 | 33 | function BagHandlerPanel:clickButton(go, btnName) 34 | if btnName == "btn_mask" then 35 | self:close() 36 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_CloseInterface_Tips) 37 | elseif btnName == "btn_sell" then 38 | self:sellItem() 39 | -- applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Click_Tips) 40 | elseif btnName == "btn_add" then 41 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Click_Tips) 42 | self:clickAddHandler() 43 | elseif btnName == "btn_sub" then 44 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Click_Tips) 45 | self:clickSubHandler() 46 | elseif btnName == "btn_min" then 47 | self:clickMinHandler() 48 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Click_Tips) 49 | end 50 | end 51 | 52 | 53 | function BagHandlerPanel:setPanelData() 54 | self.itemValue = bagBB.curSelectItemData 55 | if self.itemValue == nil then 56 | return 57 | end 58 | 59 | self.num = self.itemValue.numb 60 | self.operationType = bagBB.curOperationType --1是出售,2是使用 61 | 62 | if self.operationType == bagBB.bagHandleType.sell then 63 | self.varCache.lbl_getMoney.text = tostring(self.itemValue.sell_price * self.num) 64 | self.varCache.lbl_sell.text = L("bag_handle_1") 65 | self.varCache.go_canGetGo:SetActive(true) 66 | elseif self.operationType == bagBB.bagHandleType.use then 67 | self.varCache.lbl_getMoney.text = tostring(self.itemValue.use_effect_num * self.num) 68 | self.varCache.lbl_sell.text = L("bag_handle_3") 69 | self.varCache.go_canGetGo:SetActive(false) 70 | end 71 | 72 | if (self.itemValue.use_effect_num > 0 and self.operationType == bagBB.bagHandleType.use) or self.operationType == bagBB.bagHandleType.sell then 73 | if self.operationType == bagBB.bagHandleType.sell then 74 | self.varCache.sp_getMoney.spriteName = bagBB.bagSellIconType[tostring(self.itemValue.money_type)] 75 | elseif self.operationType == bagBB.bagHandleType.use then 76 | self.varCache.sp_getMoney.spriteName = bagBB.bagSellIconType[tostring(self.itemValue.use_effect_type)] 77 | end 78 | else 79 | self.varCache.sp_getMoney.spriteName = "" 80 | self.varCache.lbl_getMoney.text = L("bag_handle_5") 81 | end 82 | 83 | self.varCache.lbl_sellNum.text = string.format(stringUtility.rejuctSymbol("{0}/{1}"), self.num, self.itemValue.numb) 84 | self.itemScript:setItemData(self.itemValue.itemModelId, nil, nil, nil, nil, nil, false) 85 | self.varCache.lbl_name.text = string.format(stringUtility.rejuctSymbol("[{0}]{1}[-]"), colorUtility.getColorByQuality(self.itemValue.quality), self.itemValue.name) 86 | end 87 | 88 | 89 | function BagHandlerPanel:clickMinHandler() 90 | self.num = 1 91 | 92 | self:updateItemPrice() 93 | end 94 | 95 | 96 | function BagHandlerPanel:clickAddHandler() 97 | if self.num >= self.itemValue.numb then 98 | return 99 | end 100 | 101 | self.num = self.num + 1 102 | self:updateItemPrice() 103 | end 104 | 105 | 106 | function BagHandlerPanel:clickSubHandler() 107 | if self.num <= 1 then 108 | return 109 | end 110 | 111 | self.num = self.num - 1 112 | self:updateItemPrice() 113 | end 114 | 115 | 116 | function BagHandlerPanel:sellItem() 117 | if self.operationType == bagBB.bagHandleType.sell then 118 | local condition = stringUtility.split(conf.functionOpen["112"].condition, ",") 119 | -- 还没达到出售物品的开放等级 120 | if playerInfoBB.playerInfo.level < tonumber(condition[2]) then 121 | applicationGlobal.tooltip:errorMessage(L("system_needLevel") .. condition[2]) 122 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_Warn_Tips) 123 | else 124 | NetClient.Send(20231008, {itemId = self.itemValue.itemId, num = self.num}) 125 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_CloseInterface_Tips) 126 | end 127 | elseif self.operationType == bagBB.bagHandleType.use then 128 | NetClient.Send(20231010, {itemId = self.itemValue.itemId, number = self.num}) 129 | applicationGlobal.audioPlay:playAudio(audioConfig.Audio_CloseInterface_Tips) 130 | end 131 | end 132 | 133 | 134 | function BagHandlerPanel:updateItemPrice() 135 | if self.operationType == bagBB.bagHandleType.sell then 136 | self.varCache.lbl_getMoney.text = tostring(self.itemValue.sell_price * self.num) 137 | elseif self.operationType == bagBB.bagHandleType.use then 138 | self.varCache.lbl_getMoney.text = tostring(self.itemValue.use_effect_num * self.num) 139 | end 140 | 141 | self.varCache.lbl_sellNum.text = string.format(stringUtility.rejuctSymbol("{0}/{1}"), self.num, self.itemValue.numb) 142 | end 143 | 144 | 145 | function BagHandlerPanel:sellCallBack() 146 | self:sellOrUseSucceedEffect(self.itemValue.money_type) 147 | self:close() 148 | end 149 | 150 | 151 | function BagHandlerPanel:useCallBack() 152 | self:sellOrUseSucceedEffect(self.itemValue.use_effect_type) 153 | self:close() 154 | end 155 | 156 | 157 | function BagHandlerPanel:sellOrUseSucceedEffect(typeIndex) 158 | local currScene = applicationGlobal.sceneSwitchManager.currentSceneInstance 159 | if currScene ~= nil and isSuper(currScene, MainUiInstance) and currScene.sceneEffectPanel ~= nil then 160 | currScene.sceneEffectPanel.sceneEffectResObtain.obtainResPoint = self.varCache.sp_getMoney.transform.position 161 | if typeIndex == 0 then 162 | currScene.sceneEffectPanel.sceneEffectResObtain:addEffectMove(sceneEffectBB.enumObtainType.otGold) 163 | elseif typeIndex == 1 then 164 | currScene.sceneEffectPanel.sceneEffectResObtain:addEffectMove(sceneEffectBB.enumObtainType.otDiamond) 165 | end 166 | end 167 | end -------------------------------------------------------------------------------- /LuaScript/framework/library/eventLib.lua: -------------------------------------------------------------------------------- 1 | -- EventLib - An event library in pure lua (uses standard coroutine library) 2 | -- License: WTFPL 3 | -- Author: Elijah Frederickson 4 | -- Version: 1.0 5 | -- Copyright (C) 2012 LoDC 6 | 7 | local _M = { } 8 | _M._VERSION = "1.0" 9 | _M._M = _M 10 | _M._AUTHOR = "Elijah Frederickson" 11 | _M._COPYRIGHT = "Copyright (C) 2012 LoDC" 12 | 13 | local function spawn(f) 14 | return coroutine.resume(coroutine.create(function() 15 | f() 16 | end)) 17 | end 18 | _M.Spawn = spawn 19 | _M.spawn = spawn 20 | 21 | function _M:new(name) 22 | assert(self ~= nil and type(self) == "table" and self == _M, "Invalid EventLib table (make sure you're using ':' not '.')") 23 | local s = { } 24 | s.handlers = { } 25 | s.waiter = false 26 | s.args = nil 27 | s.waiters = 0 28 | s.EventName = name or "" 29 | s.executing = false 30 | return setmetatable(s, { __index = self }) 31 | end 32 | _M.CreateEvent = _M.new 33 | 34 | function _M:Connect(handler) 35 | assert(self ~= nil and type(self) == "table", "Invalid Event (make sure you're using ':' not '.')") 36 | assert(type(handler) == "function", "Invalid handler. Expected function got " .. type(handler)) 37 | assert(self.handlers, "Invalid Event") 38 | table.insert(self.handlers, handler) 39 | local t = { } 40 | t.Disconnect = function() 41 | return self:Disconnect(handler) 42 | end 43 | t.disconnect = t.Disconnect 44 | return t 45 | end 46 | _M.connect = _M.Connect 47 | 48 | function _M:Disconnect(handler) 49 | assert(self ~= nil and type(self) == "table", "Invalid Event (make sure you're using ':' not '.')") 50 | assert(type(handler) == "function" or type(handler) == "nil", "Invalid handler. Expected function or nil, got " .. type(handler)) 51 | if not handler then 52 | self.handlers = { } 53 | else 54 | for k, v in pairs(self.handlers) do 55 | if v == handler then 56 | self.handlers[k] = nil 57 | return k 58 | end 59 | end 60 | end 61 | end 62 | _M.disconnect = _M.Disconnect 63 | 64 | function _M:DisconnectAll() 65 | assert(self ~= nil and type(self) == "table", "Invalid Event (make sure you're using ':' not '.')") 66 | self:Disconnect() 67 | end 68 | 69 | function _M:Fire(...) 70 | assert(self ~= nil and type(self) == "table", "Invalid Event (make sure you're using ':' not '.')") 71 | self.args = { ... } 72 | self.executing = true 73 | --[[ 74 | if self.waiter then 75 | self.waiter = false 76 | for k, v in pairs(self.waiters) do 77 | coroutine.resume(v) 78 | end 79 | end]] 80 | self.waiter = false 81 | local i = 0 82 | assert(self.handlers, "no handler table") 83 | for k, v in pairs(self.handlers) do 84 | i = i + 1 85 | spawn(function() 86 | v(unpack(self.args)) 87 | i = i - 1 88 | if i == 0 then self.executing = false end 89 | end) 90 | end 91 | self:WaitForWaiters() 92 | self.args = nil 93 | --self.executing = false 94 | end 95 | _M.Simulate = _M.Fire 96 | _M.fire = _M.Fire 97 | 98 | function _M:Wait() 99 | assert(self ~= nil and type(self) == "table", "Invalid Event (make sure you're using ':' not '.')") 100 | self.waiter = true 101 | self.waiters = self.waiters + 1 102 | --[[ 103 | local c = coroutine.create(function() 104 | coroutine.yield() 105 | return unpack(self.args) 106 | end) 107 | 108 | table.insert(self.waiters, c) 109 | coroutine.resume(c) 110 | ]] 111 | 112 | while self.waiter or not self.args do if wait then wait() end end 113 | self.waiters = self.waiters - 1 114 | return unpack(self.args) 115 | end 116 | _M.wait = _M.Wait 117 | 118 | function _M:ConnectionCount() 119 | assert(self ~= nil and type(self) == "table", "Invalid Event (make sure you're using ':' not '.')") 120 | return #self.handlers 121 | end 122 | 123 | function _M:Destroy() 124 | assert(self ~= nil and type(self) == "table", "Invalid Event (make sure you're using ':' not '.')") 125 | self:DisconnectAll() 126 | for k, v in pairs(self) do 127 | self[k] = nil 128 | end 129 | setmetatable(self, { }) 130 | end 131 | _M.destroy = _M.Destroy 132 | _M.Remove = _M.Destroy 133 | _M.remove = _M.Destroy 134 | 135 | function _M:WaitForCompletion() 136 | assert(self ~= nil and type(self) == "table", "Invalid Event (make sure you're using ':' not '.')") 137 | while self.executing do if wait then wait() end end 138 | while self.waiters > 0 do if wait then wait() end end 139 | end 140 | 141 | function _M:IsWaiting() 142 | assert(self ~= nil and type(self) == "table", "Invalid Event (make sure you're using ':' not '.')") 143 | return self.waiter or self.waiters > 0 144 | end 145 | 146 | function _M:WaitForWaiters() 147 | assert(self ~= nil and type(self) == "table", "Invalid Event (make sure you're using ':' not '.')") 148 | while self.waiters > 0 do if wait then wait() end end 149 | end 150 | 151 | -- Tests 152 | if false then 153 | local e = _M:new("test") 154 | local f = function(...) print("| Fired!", ...) end 155 | local e2 = e:connect(f) 156 | e:fire("arg1", 5, { }) 157 | -- Would work in a ROBLOX Script, but not on Lua 5.1... 158 | if script ~= nil and failhorribly then 159 | spawn(function() print("Wait() results", e:wait()) print"|- done waiting!" end) 160 | end 161 | e:fire(nil, "x") 162 | print("Disconnected events index:", e:disconnect(f)) 163 | print("Couldn't disconnect an already disconnected handler?", e2:disconnect()==nil) 164 | print("Connections:", e:ConnectionCount()) 165 | assert(e:ConnectionCount() == 0 and e:ConnectionCount() == #e.handlers) 166 | e:connect(f) 167 | e:connect(function() print"Throwing error... " error("...") end) 168 | e:fire("Testing throwing an error...") 169 | e:disconnect() 170 | e:Simulate() 171 | f("plain function call") 172 | assert(e:ConnectionCount() == 0) 173 | 174 | if wait then 175 | e:connect(function() wait(2, true) print'fired after waiting' end) 176 | e:Fire() 177 | e:WaitForCompletion() 178 | print'Done!' 179 | end 180 | 181 | local failhorribly = false 182 | if failhorribly then -- causes an eternal loop in the WaitForCompletion call 183 | e:connect(function() e:WaitForCompletion() print'done with connected function' end) 184 | e:Fire() 185 | print'done' 186 | end 187 | 188 | e:Destroy() 189 | assert(not e.EventName and not e.Fire and not e.Connect) 190 | end 191 | 192 | if shared and Instance then -- ROBLOX support 193 | shared.EventLib = _M 194 | _G.EventLib = _M 195 | end 196 | 197 | return _M 198 | -------------------------------------------------------------------------------- /LuaScript/utility/colorUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : colorUtility.lua 4 | -- Creator : zg 5 | -- Date : 2016-12-6 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("colorUtility", package.seeall) 11 | 12 | 13 | color = 14 | { 15 | white = Color.white, 16 | black = Color.black, 17 | naturals = Color(219 / 255, 205 / 255, 160 / 255), 18 | gray = Color(190 / 255, 190 / 255, 190 / 255), 19 | brown = Color(81 / 255, 48 / 255, 33 / 255), 20 | red = Color(242 / 255, 16 / 255, 10 / 255), 21 | orange = Color(255 / 255, 64 / 255, 0), 22 | purple = Color(251 / 255, 123 / 255, 198 / 255), 23 | blue = Color(0, 210 / 255, 255 / 255), 24 | green = Color(71 / 255, 212 / 255, 74 / 255), 25 | tab = Color(127 / 255, 100 / 255, 73 / 255), 26 | titleGray = Color(163 / 255, 163 / 255, 163 / 255), 27 | titleChoose = Color(248 / 255, 191 / 255, 96 / 255), 28 | auntRed = Color(170 / 255, 55 / 255, 55 / 255), 29 | chat = Color(30 / 255, 30 / 255, 30 / 255), 30 | yellow = Color(255 / 255, 255 / 255, 0 / 255) 31 | } 32 | 33 | 34 | colorType = 35 | { 36 | ["White"] = 0, 37 | ["Black"] = 1, 38 | ["LightBlue"] = 2, 39 | ["Red"] = 3, 40 | ["Green"] = 4, 41 | ["Yellow"] = 5, 42 | ["Orange"] = 6, 43 | ["Brown"] = 7, 44 | ["Khaki"] = 8, 45 | ["Normal"] = 9, 46 | ["Unique"]= 10, 47 | ["Scarce"] = 11, 48 | ["History"] = 12, 49 | ["Tale"] = 13, 50 | ["ThinYellow"] = 14, 51 | ["OrangeYellow"] = 15, 52 | ["Gray"] = 16, 53 | ["LightGreen"] = 17, 54 | ["Purple"] = 18 55 | } 56 | 57 | 58 | --字符串转换颜色 59 | function str2color(colorStr) 60 | local colorStrs = stringUtility.split(colorStr, ",") 61 | local color = Color(colorStrs[1]/255,colorStrs[2]/255,colorStrs[3]/255, 1) 62 | if colorStrs[4] ~= nil then 63 | color.a = colorStrs[4] / 255 64 | end 65 | 66 | return color 67 | end 68 | 69 | 70 | -- 获取颜色 71 | function getStringColor(strValue, type) 72 | local strColor = tostring(strValue) 73 | if type == colorType.White then 74 | strColor = string.format("[dee0e6]%s[-]", strValue) 75 | elseif type == colorType.Black then 76 | strColor = string.format("[000000]%s[-]", strValue) 77 | elseif type == colorType.LightBlue then 78 | strColor = string.format("[80f1ff]%s[-]", strValue) 79 | elseif type == colorType.Red then 80 | strColor = string.format("[fc2319]%s[-]", strValue) 81 | elseif type == colorType.Green then 82 | strColor = string.format("[49d718]%s[-]", strValue) 83 | elseif type == colorType.LightGreen then 84 | strColor = string.format("[4fe31c]%s[-]", strValue) 85 | elseif type == colorType.Blue then 86 | strColor = string.format("[0000ff]%s[-]", strValue) 87 | elseif type == colorType.Yellow then 88 | strColor = string.format("[ffff00]%s[-]", strValue) 89 | elseif type == colorType.Orange then 90 | strColor = string.format("[e9967a]%s[-]", strValue) 91 | elseif type ==colorType.Brown then 92 | strColor = string.format("[513021]%s[-]", strValue) 93 | elseif type == colorType.Khaki then 94 | strColor = string.format("[dbcda0]%s[-]", strValue) 95 | elseif type == colorType.Normal then 96 | strColor = string.format("[ffffff]%s[-]", strValue) 97 | elseif type == colorType.Unique then 98 | strColor = string.format("[00ff22]%s[-]", strValue) 99 | elseif type == colorType.Scarce then 100 | strColor = string.format("[096fff]%s[-]", strValue) 101 | elseif type == colorType.History then 102 | strColor = string.format("[d42de3]%s[-]", strValue) 103 | elseif type == colorType.Tale then 104 | strColor = string.format("[ff6600]%s[-]", strValue) 105 | elseif type == colorType.ThinYellow then 106 | strColor = string.format("[f6eabb]%s[-]", strValue) 107 | elseif type == colorType.Gray then 108 | strColor = string.format("[aea4a4]%s[-]", strValue) 109 | elseif type == colorType.Purple then 110 | strColor = string.format("[F42ED3FF]%s[-]", strValue) 111 | end 112 | return strColor 113 | end 114 | 115 | 116 | --获取物品缺角品质框和非缺角品质框 117 | function getArmFrameSpriteNameByQualityType(itemQuality) 118 | local spriteName = "" 119 | if itemQuality == 1 then 120 | spriteName = "Frame-suipianbox-bai" 121 | elseif itemQuality == 2 then 122 | spriteName = "Frame-suipianbox-lv" 123 | elseif itemQuality == 3 then 124 | spriteName = "Frame-suipianbox-lan" 125 | elseif itemQuality == 4 then 126 | spriteName = "Frame-suipianbox-zi" 127 | elseif itemQuality == 5 then 128 | spriteName = "Frame-suipianbox-chengse" 129 | end 130 | return spriteName 131 | end 132 | 133 | 134 | --获取物品完整品质框 135 | function getBoxFrameSpriteNameByQualityType(itemQuality) 136 | local spriteName = "" 137 | if itemQuality == 1 then 138 | spriteName = "Frame-box-bai" 139 | elseif itemQuality == 2 then 140 | spriteName = "Frame-box-lv" 141 | elseif itemQuality == 3 then 142 | spriteName = "Frame-box-lan" 143 | elseif itemQuality == 4 then 144 | spriteName = "Frame-box-zi" 145 | elseif itemQuality == 5 then 146 | spriteName = "Frame-box-chengse" 147 | end 148 | return spriteName 149 | end 150 | 151 | 152 | -- 根据品质得到色码 153 | function getColorByQuality(quality) 154 | if quality == 1 then 155 | return "ffffff" 156 | elseif quality == 2 then 157 | return "00ff22" 158 | elseif quality == 3 then 159 | return "096fff" 160 | elseif quality == 4 then 161 | return "d42de3" 162 | elseif quality == 5 then 163 | return "ff6600" 164 | end 165 | return "ffffff" 166 | end 167 | 168 | 169 | --根据品质获取颜色 170 | function getColorByQuality2(content, quality) 171 | if quality == 1 then 172 | return string.format("[eaeaea]%s[-]", content) 173 | elseif quality == 2 then 174 | return string.format("[4fe31c]%s[-]", content) 175 | elseif quality == 3 then 176 | return string.format("[1bc1ff]%s[-]", content) 177 | elseif quality == 4 then 178 | return string.format("[fd59ff]%s[-]", content) 179 | elseif quality == 5 then 180 | return string.format("[ffcd21]%s[-]", content) 181 | else 182 | return string.format("[ffffff]%s[-]", content) 183 | end 184 | end 185 | 186 | 187 | fightIconQualitySprNameV5 = 188 | { 189 | "BG-wupin-bai", 190 | "BG-wupin-lv", 191 | "BG-wupin-lan", 192 | "BG-wupin-zi", 193 | "BG-wupin-cheng" 194 | } 195 | 196 | 197 | -- 卡牌品质 198 | function getV5FightIconSpriteNameByQuality(quality) 199 | return fightIconQualitySprNameV5[quality] 200 | end -------------------------------------------------------------------------------- /LuaScript/applicationLoadAfter.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : applicationLoadAfter.lua 4 | -- Creator : zg 5 | -- Date : 2016-12-3 6 | -- Comment : 这里只装载AA、BB 7 | -- *************************************************************** 8 | 9 | 10 | delayLoadGlobalLua("battle/battleAA") 11 | delayLoadGlobalLua("battle/battleBB") 12 | delayLoadGlobalLua("battle/battleCC") 13 | 14 | delayLoadGlobalLua("module/localization/localizationBB") 15 | 16 | delayLoadGlobalLua("module/login/loginAA") 17 | delayLoadGlobalLua("module/login/loginBB") 18 | 19 | delayLoadGlobalLua("module/playerInfo/playerInfoAA") 20 | delayLoadGlobalLua("module/playerInfo/playerInfoBB") 21 | 22 | delayLoadGlobalLua("module/bigMap/bigMapAA") 23 | delayLoadGlobalLua("module/bigMap/bigMapBB") 24 | 25 | delayLoadGlobalLua("module/mainUi/mainUIAA") 26 | delayLoadGlobalLua("module/mainUi/mainUIBB") 27 | 28 | delayLoadGlobalLua("module/city/cityAA") 29 | delayLoadGlobalLua("module/city/cityBB") 30 | delayLoadGlobalLua("module/city/cityRole/cityPathData") 31 | 32 | delayLoadGlobalLua("module/vip/vipAA") 33 | delayLoadGlobalLua("module/vip/vipBB") 34 | 35 | delayLoadGlobalLua("module/monthCard/monthCardBB") 36 | delayLoadGlobalLua("module/monthCard/monthCardAA") 37 | 38 | delayLoadGlobalLua("module/email/emailAA") 39 | delayLoadGlobalLua("module/email/emailBB") 40 | 41 | delayLoadGlobalLua("module/gang/gangAA") 42 | delayLoadGlobalLua("module/gang/gangBB") 43 | -- delayLoadGlobalLua("module/gang/guideListenerViewActivity") 44 | 45 | delayLoadGlobalLua("module/store/storeBB") 46 | delayLoadGlobalLua("module/store/storeAA") 47 | 48 | delayLoadGlobalLua("module/rank/rankAA") 49 | delayLoadGlobalLua("module/rank/rankBB") 50 | 51 | delayLoadGlobalLua("module/bag/bagAA") 52 | delayLoadGlobalLua("module/bag/bagBB") 53 | 54 | delayLoadGlobalLua("module/patrol/patrolAA") 55 | 56 | -- delayLoadGlobalLua("module/bigSail/bigSailAA") 57 | -- delayLoadGlobalLua("module/bigSail/bigSailBB") 58 | 59 | delayLoadGlobalLua("module/card/cardAA") 60 | delayLoadGlobalLua("module/card/cardBB") 61 | 62 | 63 | delayLoadGlobalLua("module/strategos/strategosAA") 64 | delayLoadGlobalLua("module/strategos/strategosBB") 65 | 66 | delayLoadGlobalLua("module/chat/chatAA") 67 | delayLoadGlobalLua("module/chat/chatBB") 68 | 69 | delayLoadGlobalLua("module/cruciata/cruciataAA") 70 | delayLoadGlobalLua("module/cruciata/cruciataBB") 71 | 72 | delayLoadGlobalLua("module/depot/depotAA") 73 | delayLoadGlobalLua("module/depot/depotBB") 74 | 75 | delayLoadGlobalLua("module/friend/friendAA") 76 | delayLoadGlobalLua("module/friend/friendBB") 77 | 78 | 79 | delayLoadGlobalLua("module/battleLineup/battleLineupAA") 80 | delayLoadGlobalLua("module/battleLineup/battleLineupBB") 81 | 82 | delayLoadGlobalLua("module/outputGoto/outputGotoAA") 83 | delayLoadGlobalLua("module/outputGoto/outputGotoBB") 84 | --产出数据 85 | delayLoadGlobalLua("module/output/outputBB") 86 | 87 | delayLoadGlobalLua("module/colosseum/colosseumAA") 88 | delayLoadGlobalLua("module/colosseum/colosseumBB") 89 | 90 | delayLoadGlobalLua("module/pyramidMap/pyramidMapAA") 91 | delayLoadGlobalLua("module/pyramidMap/pyramidMapBB") 92 | 93 | delayLoadGlobalLua("module/escort/escortAA") 94 | delayLoadGlobalLua("module/escort/escortBB") 95 | 96 | delayLoadGlobalLua("module/city/cityDiscovery/cityDiscoveryBB") 97 | 98 | delayLoadGlobalLua("module/missionDialogue/missionDialogueAA") 99 | delayLoadGlobalLua("module/missionDialogue/missionDialogueBB") 100 | delayLoadGlobalLua("module/missionDialogue/missionDialogueVo") 101 | 102 | delayLoadGlobalLua("module/stoneMatrix/stoneMatrixAA") 103 | delayLoadGlobalLua("module/stoneMatrix/stoneMatrixBB") 104 | 105 | delayLoadGlobalLua("module/qualifying/qualifyingAA") 106 | delayLoadGlobalLua("module/qualifying/qualifyingBB") 107 | delayLoadGlobalLua("module/qualifying/qualifyingSeason/qualifyingSeasonBB") 108 | 109 | -- delayLoadGlobalLua("battle/base/scene") 110 | -- delayLoadGlobalLua("battle/sceneObject/sceneObjectManager") 111 | -- delayLoadGlobalLua("battle/base/objectData") 112 | -- delayLoadGlobalLua("battle/base/player") 113 | 114 | delayLoadGlobalLua("battle/sceneObject/unilt/bloodBar") 115 | 116 | delayLoadGlobalLua("module/goldenTouch/goldenTouchAA") 117 | delayLoadGlobalLua("module/goldenTouch/goldenTouchBB") 118 | 119 | delayLoadGlobalLua("module/shop/shopAA") 120 | delayLoadGlobalLua("module/shop/shopBB") 121 | 122 | delayLoadGlobalLua("module/scoopDiamond/scoopDiamondAA") 123 | delayLoadGlobalLua("module/scoopDiamond/scoopDiamondBB") 124 | 125 | delayLoadGlobalLua("battle/battleUI/mainUI/drop/dropBB") 126 | 127 | delayLoadGlobalLua("module/activity/activityAA") 128 | delayLoadGlobalLua("module/activity/activityBB") 129 | delayLoadGlobalLua("module/rechargeGift/rechargeGiftAA") 130 | delayLoadGlobalLua("module/rechargeGift/rechargeGiftBB") 131 | 132 | delayLoadGlobalLua("module/bigMap/sceneEffect/sceneEffectBB") 133 | 134 | -- 引导相关 135 | -- delayLoadGlobalLua("module/guideNew/guideNewStageControl") 136 | -- delayLoadGlobalLua("module/guideNew/guideNewAA") 137 | -- delayLoadGlobalLua("module/guideNew/guideNewBB") 138 | 139 | delayLoadGlobalLua("module/guide/guideStep") 140 | delayLoadGlobalLua("module/guide/guideBB") 141 | delayLoadGlobalLua("module/guide/guideAA") 142 | 143 | delayLoadGlobalLua("module/universe/universeAA") 144 | delayLoadGlobalLua("module/universe/universeBB") 145 | 146 | delayLoadGlobalLua("module/createRole/createRoleAA") 147 | 148 | delayLoadGlobalLua("module/fog/fogBB") 149 | 150 | delayLoadGlobalLua("module/awardBattle/awardBattleAA") 151 | delayLoadGlobalLua("module/awardBattle/awardBattleBB") 152 | 153 | --巡逻 154 | delayLoadGlobalLua("module/patrol/patrolAA") 155 | delayLoadGlobalLua("module/patrol/patrolBB") 156 | 157 | delayLoadGlobalLua("module/loader/commonLoaderBB") 158 | 159 | --任务 160 | delayLoadGlobalLua("module/mission/missionAA") 161 | delayLoadGlobalLua("module/mission/missionBB") 162 | 163 | --通用购买 164 | delayLoadGlobalLua("module/civilBuy/civilBuyBB") 165 | 166 | --录像 167 | delayLoadGlobalLua("battle/battleUI/videoUI/videoBB") 168 | delayLoadGlobalLua("battle/battleUI/videoUI/videoAA") 169 | 170 | --首冲 171 | delayLoadGlobalLua("module/firstRecharge/firstRechargeAA") 172 | delayLoadGlobalLua("module/firstRecharge/firstRechargeBB") 173 | 174 | --看录像 175 | delayLoadGlobalLua("module/lookVideo/lookVideoAA") 176 | delayLoadGlobalLua("module/lookVideo/lookVideoBB") 177 | 178 | --预览宝箱 179 | delayLoadGlobalLua("module/boxTreasureLook/boxTreasureLookBB") 180 | 181 | --赛事 182 | delayLoadGlobalLua("module/fightEnterInfo/fightEnterInfoAA") 183 | 184 | --公平竞技 185 | delayLoadGlobalLua("module/fairPlaying/fairPlayingAA") 186 | delayLoadGlobalLua("module/fairPlaying/fairPlayingBB") 187 | 188 | -- 我的星球 189 | delayLoadGlobalLua("module/ownPlanet/ownPlanetAA") 190 | delayLoadGlobalLua("module/ownPlanet/ownPlanetBB") 191 | 192 | -- 通用宝箱开启 193 | delayLoadGlobalLua("module/commonTreasure/commonTreasureBB") 194 | 195 | --竞技场 196 | delayLoadGlobalLua("module/arena/arenaAA") 197 | delayLoadGlobalLua("module/arena/arenaBB") 198 | 199 | --战神传记 200 | delayLoadGlobalLua("module/godWar/godWarAA") 201 | delayLoadGlobalLua("module/godWar/godWarBB") 202 | 203 | --战斗录像 204 | delayLoadGlobalLua("module/record/recordAA") 205 | delayLoadGlobalLua("module/record/recordBB") 206 | 207 | --星际探索 208 | delayLoadGlobalLua("module/galaxyExplore/galaxyExploreAA") 209 | delayLoadGlobalLua("module/galaxyExplore/galaxyExploreBB") 210 | 211 | --七日活动 212 | delayLoadGlobalLua("module/noobWeek/noobWeekAA") 213 | delayLoadGlobalLua("module/noobWeek/noobWeekBB") 214 | 215 | 216 | --遗迹(爬塔) 217 | delayLoadGlobalLua("module/tower/towerAA") 218 | delayLoadGlobalLua("module/tower/towerBB") 219 | 220 | 221 | -- 商城 222 | delayLoadGlobalLua("module/mall/mallAA") 223 | delayLoadGlobalLua("module/mall/mallBB") -------------------------------------------------------------------------------- /LuaScript/utility/timeUtility.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : timeUtility.lua 4 | -- Creator : zg 5 | -- Date : 2017-2-17 6 | -- Comment : 7 | -- *************************************************************** 8 | 9 | 10 | module("timeUtility", package.seeall) 11 | 12 | 13 | --得到特定格式的时间 00:00 14 | function formatTimeToMinSec(time) 15 | local min = math.floor(time / 60) 16 | local sec = time % 60 17 | if sec < 10 then 18 | return min .. ':0' .. sec 19 | end 20 | return min .. ':' .. sec 21 | end 22 | 23 | 24 | function formatSecTime(Tr, typeId) --Tr单位毫秒 25 | local formatTime = "" 26 | local day = math.floor(Tr / (24 * 1000 * 60 * 60)) 27 | local hour = math.floor(((Tr - day * (24 * 1000 * 60 * 60)) / (1000 * 60 * 60))) 28 | local min = math.floor(((Tr - day * (24 * 1000 * 60 * 60) - hour * (1000 * 60 * 60)) / (1000 * 60))) 29 | local sec = math.floor(((Tr - day * (24 * 1000 * 60 * 60) - hour * (1000 * 60 * 60) - min * (1000 * 60))) / 1000) 30 | if typeId == 1 then 31 | formatTime = sec .. '' 32 | elseif typeId == 2 then 33 | formatTime = ((min > 9 and min .. '') or "0" .. min) .. ":" .. ((sec > 9 and sec .. '') or "0" .. sec) 34 | elseif typeId == 3 then 35 | formatTime = ((hour > 9 and hour.. '') or "0" .. hour) .. ":" .. ((min > 9 and min .. '') or "0" .. min) .. ":" .. ((sec > 9 and sec .. '') or "0" .. sec) 36 | elseif typeId == 4 then --赛季倒计时 37 | formatTime = ((day > 9 and day .. '') or "0" .. day) .. L("common_titel_8") .. ((hour > 9 and hour.. '') or "0" .. hour) .. L("common_titel_9") .. ((min > 9 and min .. '') or "0" .. min) .. L("common_titel_10") --.. ((sec > 9 and sec .. '') or "0" .. sec) 38 | elseif typeId == 5 then --礼包倒计时 39 | local count = 0 --显示的个数 40 | if day > 0 then 41 | formatTime = formatTime .. day .. L("common_titel_8") 42 | count = count + 1 43 | end 44 | 45 | if hour > 0 and count < 2 then 46 | formatTime = formatTime .. hour .. L("common_titel_9") 47 | count = count + 1 48 | end 49 | 50 | if min > 0 and count < 2 then 51 | formatTime = formatTime .. min .. L("common_titel_10") 52 | count = count + 1 53 | end 54 | 55 | if sec > 0 and count < 2 then 56 | formatTime = formatTime .. sec .. L("common_titel_11") 57 | end 58 | end 59 | return formatTime 60 | end 61 | 62 | 63 | 64 | 65 | 66 | function getTimeStamp(t) 67 | local tableTime = os.date("*t", t/1000) 68 | return tableTime.month .. "/" .. tableTime.day .. " " .. tableTime.hour .. ":" .. tableTime.min 69 | end 70 | 71 | function nowTimeSpan(Tr, tp) 72 | local dt_1970 = TimeZone.CurrentTimeZone.ToLocalTime(DateTime(1970, 1, 1)) 73 | local tricks_1970 = dt_1970.Ticks--1970年1月1日刻度 74 | local time_tricks = tricks_1970 + Tr * 10000--日志日期刻度 75 | local now_tricks = tricks_1970 + TimeManager.Instance.ServerTimeNow * 10000--当前日期刻度 76 | local timeSpan = TimeSpan(time_tricks) 77 | local timeSpanNow = TimeSpan(now_tricks) 78 | return timeSpanNow - timeSpan 79 | end 80 | 81 | 82 | function getTime(t) 83 | local hour = mathUtility.getIntNum(t / (1000 * 60 * 60)) 84 | local min = mathUtility.getIntNum(((t - hour * (1000 * 60 * 60)) / (1000 * 60))) 85 | local sec = mathUtility.getIntNum((t - hour * (1000 * 60 * 60) - min * (1000 * 60)) / 1000) 86 | local timeString = ((hour > 9 and hour.. '') or "0" .. hour) .. ":" .. ((min > 9 and min .. '') or "0" .. min) .. ":" .. ((sec > 9 and sec .. '') or "0" .. sec) 87 | 88 | return timeString 89 | end 90 | 91 | 92 | -- 延迟多少s后点击 93 | buttonTime = 0 94 | function checkBtnIsClick(delayTime) 95 | if Time.time - buttonTime < delayTime then 96 | return false 97 | end 98 | 99 | buttonTime = Time.time 100 | 101 | return true 102 | end 103 | 104 | 105 | -- 00:00 106 | function getStringHourTime(second, length) 107 | local hour = math.floor(second / 3600) 108 | local min = math.floor((second % 3600) / 60) 109 | local sec = math.floor(second % 60) 110 | return getIntNumber(hour, length) .. ":" .. getIntNumber(min, length) .. ":" .. getIntNumber(sec, length) 111 | end 112 | 113 | 114 | function getIntNumber(num, median) 115 | local tstr = tostring(num) 116 | local dis = median - #tstr 117 | 118 | for i = 1, dis do 119 | tstr = "0" .. tstr 120 | end 121 | return tstr 122 | end 123 | 124 | 125 | --秒转换成00:00:00格式 126 | function secToStr(secCount) 127 | local hour = math.floor(secCount/3600) 128 | local minute = math.fmod(math.floor(secCount/60), 60) 129 | local second = math.fmod(secCount, 60) 130 | 131 | local str = "[b]" .. string.format("%02d", hour) .. ":" .. string.format("%02d", minute) .. ":" .. string.format("%02d", second) .. "[/b]" 132 | 133 | return str 134 | end 135 | 136 | 137 | --月日转换成xx月xx日格式 138 | function mdToStr(month, day) 139 | return string.format(stringUtility.rejuctSymbol(L("gang_info_75")), string.format("%02d", month), string.format("%02d", day)) 140 | end 141 | 142 | 143 | --判断现在时间是否在当天时间段内,weeks单位为星期(1-7) 144 | function isScheduledTime(stratTime, endTime, weeks) 145 | local serverTime = timeManagerUtility.getServerTimeNow() 146 | serverTime = serverTime * 0.001 147 | local timeNow_t = os.date("*t", serverTime) 148 | 149 | local startTime_t = stringUtility.split(stratTime, ":") 150 | local endTime_t = stringUtility.split(endTime, ":") 151 | 152 | local timeNow = serverTime 153 | --转化得到时间戳(秒) 154 | local startTime = os.time({year = timeNow_t.year, month = timeNow_t.month, day = timeNow_t.day, hour = startTime_t[1], min = startTime_t[2], sec = startTime_t[3]}) 155 | local endTime = os.time({year = timeNow_t.year, month = timeNow_t.month, day = timeNow_t.day, hour = endTime_t[1], min = endTime_t[2], sec = endTime_t[3]}) 156 | 157 | local week = timeNow_t.wday - 1 158 | local isWeek = false 159 | for i=1, #weeks do 160 | if weeks[i].week == 7 then 161 | weeks[i].week = 0 162 | end 163 | if weeks[i].week == week then 164 | isWeek = true 165 | break 166 | end 167 | end 168 | 169 | if isWeek then 170 | if endTime == "24:00:00" and timeNow >= startTime then 171 | return true 172 | end 173 | 174 | if timeNow >= startTime and timeNow < endTime then 175 | return true 176 | end 177 | end 178 | 179 | return false 180 | end 181 | 182 | 183 | --判断当天是否在安排的日期内,weeks单位为星期(1-7) 184 | --参数(字符串“1,3,5” 或者 表{1, 3, 5}) 185 | function isScheduledWday(weeks) 186 | if type(weeks) == "string" then 187 | weeks = stringUtility.split(weeks, ",") 188 | end 189 | local serverTime = timeManagerUtility.getServerTimeBySes() -- 暂时用本地时间,到时候统一换成服务器时间 190 | serverTime = serverTime / 1000 191 | local serverTime_t = os.date("*t", serverTime) 192 | 193 | local wday = serverTime_t.wday - 1 194 | if wday == 0 then 195 | wday = 7 196 | end 197 | 198 | for i=1, #weeks do 199 | if tonumber(weeks[i]) == tonumber(wday) then 200 | return true 201 | end 202 | end 203 | 204 | return false 205 | end 206 | 207 | 208 | --获取距离当天24:00的秒杀 209 | function getZeroSec() 210 | local serverTime = timeManagerUtility.getServerTimeBySes() -- 暂时用本地时间,到时候统一换成服务器时间 211 | serverTime = serverTime / 1000 212 | local timeNow_t = os.date("*t", serverTime) 213 | 214 | local endTime = os.time({year = timeNow_t.year, month = timeNow_t.month, day = timeNow_t.day, hour = 0, min = 0, sec = 0}) 215 | endTime = endTime + 24*60*60 216 | 217 | return endTime - serverTime 218 | end -------------------------------------------------------------------------------- /LuaScript/applicationLoad.lua: -------------------------------------------------------------------------------- 1 | -- *************************************************************** 2 | -- Copyright(c) Yeto 3 | -- FileName : applicationLoad.lua 4 | -- Creator : zg 5 | -- Date : 2016-11-10 6 | -- Comment : 装载非AA、BB的lua脚本 7 | -- *************************************************************** 8 | 9 | 10 | module("applicationLoad", package.seeall) 11 | 12 | 13 | --功能开放 14 | delayLoadGlobalLua("module/system/functionOpend") 15 | 16 | delayLoadGlobalLua("utility/colorUtility") 17 | delayLoadGlobalLua("utility/gameUtils") 18 | delayLoadGlobalLua("utility/vipBuyTipsUtility") 19 | delayLoadGlobalLua("utility/timeUtility") 20 | delayLoadGlobalLua("utility/attributeUtility") 21 | delayLoadGlobalLua("utility/stoneMatrixPropsUtility") 22 | delayLoadGlobalLua("utility/errorInfo") 23 | delayLoadGlobalLua("utility/jumpUtility") 24 | delayLoadGlobalLua("utility/collectionUtility") 25 | delayLoadGlobalLua("utility/timeManagerUtility") 26 | delayLoadGlobalLua("utility/textResolve") 27 | delayLoadGlobalLua("utility/shaderUtility") 28 | delayLoadGlobalLua("utility/uiAssetCache") 29 | delayLoadGlobalLua("utility/mathBit") 30 | delayLoadGlobalLua("utility/windowContentEffectUtility") 31 | 32 | delayLoadGlobalLua("framework/actionPriority") 33 | 34 | delayLoadGlobalLua("framework/uiComponent/uiListLayoutBase") 35 | delayLoadGlobalLua("framework/uiComponent/uiListLayoutList") 36 | delayLoadGlobalLua("framework/uiComponent/uiListLayoutTiled") 37 | delayLoadGlobalLua("framework/uiComponent/uiScriptBehaviour") 38 | delayLoadGlobalLua("framework/uiComponent/uiListLayoutChatList") 39 | 40 | delayLoadGlobalLua("utility/spriteProxy") 41 | delayLoadGlobalLua("framework/loader/asyncObject") 42 | 43 | --窗口相关 44 | delayLoadGlobalLua("framework/window/effect/windowEffectManager") 45 | delayLoadGlobalLua("framework/window/effect/windowEffect") 46 | delayLoadGlobalLua("framework/window/control/windowControl") 47 | delayLoadGlobalLua("framework/window/control/windowPanel") 48 | delayLoadGlobalLua("framework/window/windowBase") 49 | 50 | delayLoadGlobalLua("framework/window/windowMask") 51 | delayLoadGlobalLua("framework/window/windowCamera") 52 | delayLoadGlobalLua("framework/window/windowStack") 53 | delayLoadGlobalLua("framework/window/windowQueue") 54 | delayLoadGlobalLua("framework/window/windowQueueRegister") 55 | delayLoadGlobalLua("framework/window/windowResId") 56 | delayLoadGlobalLua("framework/window/windowModelManager") 57 | delayLoadGlobalLua("framework/window/windowRapidBlurEffect") 58 | 59 | 60 | delayLoadGlobalLua("module/component/commonUITop") --add lxy 6.8 61 | 62 | --战斗相关 63 | delayLoadGlobalLua("battle/map/mapManager") 64 | 65 | -- 通用道具类 66 | delayLoadGlobalLua("module/component/civilCommonItem") 67 | delayLoadGlobalLua("module/component/componentCardPrefabInfo") 68 | delayLoadGlobalLua("module/component/componentGangFlag") 69 | delayLoadGlobalLua("module/component/commonRedTip") 70 | delayLoadGlobalLua("module/commonAward/commonAwardPopupWindow") 71 | delayLoadGlobalLua("module/loader/commonLoader") 72 | 73 | -- 74 | delayLoadGlobalLua("battle/effect/bezier") 75 | -- delayLoadGlobalLua("framework/manager/effect/effectManager") 76 | 77 | delayLoadGlobalLua("battle/base/scene") 78 | delayLoadGlobalLua("battle/base/objectData") 79 | delayLoadGlobalLua("battle/base/player") 80 | delayLoadGlobalLua("battle/battleUI/mainUI/dragAndDrop/dragAndDropManager") 81 | delayLoadGlobalLua("battle/battleUI/mainUI/dragAndDrop/dropTargetArea") 82 | delayLoadGlobalLua("battle/battleUI/mainUI/dragAndDrop/dragRegion") 83 | 84 | delayLoadGlobalLua("battle/battleUI/mainUI/skill/mainUISkillPanelBB") 85 | 86 | delayLoadGlobalLua("battle/camera/cameraShadowProjector") 87 | delayLoadGlobalLua("battle/camera/cameraCBOutline") 88 | delayLoadGlobalLua("battle/camera/cameraMove") 89 | delayLoadGlobalLua("battle/camera/cameraShock") 90 | 91 | --场景对象 92 | delayLoadGlobalLua("battle/sceneObject/sceneObject") 93 | delayLoadGlobalLua("battle/sceneObject/modelObject") 94 | delayLoadGlobalLua("battle/sceneObject/moveableObject") 95 | delayLoadGlobalLua("battle/sceneObject/sceneObjectNotify") 96 | 97 | --动画系统 98 | delayLoadGlobalLua("battle/sceneObject/anim/animModel") 99 | delayLoadGlobalLua("battle/sceneObject/anim/animRenderer") 100 | delayLoadGlobalLua("battle/sceneObject/anim/animEvent") 101 | 102 | 103 | --技能系统 104 | delayLoadGlobalLua("battle/skill/skill") 105 | delayLoadGlobalLua("battle/skill/skillImpact") 106 | delayLoadGlobalLua("battle/skill/skillEffectFactory") 107 | delayLoadGlobalLua("battle/skill/skillEffect/skillEffect") 108 | delayLoadGlobalLua("battle/skill/skillEffect/skillEffectPath") 109 | delayLoadGlobalLua("battle/skill/skillEffect/skillEffectTarget") 110 | delayLoadGlobalLua("battle/skill/skillEffect/skillEffectScaleLaser") 111 | delayLoadGlobalLua("battle/skill/skillEffect/skillEffectLR") 112 | delayLoadGlobalLua("battle/skill/skillEffect/skillEffectLRLaser") 113 | delayLoadGlobalLua("battle/skill/skillEffect/skillEffectBulletLaster") 114 | 115 | --身上的小组件 116 | delayLoadGlobalLua("battle/sceneObject/unilt/haloManager") 117 | delayLoadGlobalLua("battle/sceneObject/unilt/shieldManager") 118 | 119 | --效果 120 | delayLoadGlobalLua("battle/effect/effectCache") 121 | delayLoadGlobalLua("battle/effect/effectObject") 122 | 123 | --输入系统 124 | delayLoadGlobalLua("battle/input/inputLockControll") 125 | delayLoadGlobalLua("battle/input/inputManager") 126 | delayLoadGlobalLua("battle/input/inputObject") 127 | 128 | delayLoadGlobalLua("battle/utility/materialUtility") 129 | 130 | -- 战斗掉落 131 | delayLoadGlobalLua("battle/sceneDrop/sceneDropBB") 132 | delayLoadGlobalLua("battle/sceneDrop/sceneDropManager") 133 | 134 | delayLoadGlobalLua("battle/base/chief") 135 | delayLoadGlobalLua("module/mainUi/mainUIWindowListener") 136 | 137 | -- 行为树 138 | delayLoadGlobalLua("battle/btree/behaviorTreeBase") 139 | delayLoadGlobalLua("battle/btree/behaviorTreeAction") 140 | delayLoadGlobalLua("battle/btree/behaviorTreeCondition") 141 | delayLoadGlobalLua("battle/btree/behaviorTreeAIUtil") 142 | delayLoadGlobalLua("battle/btree/behaviorTreeAI") 143 | delayLoadGlobalLua("battle/btree/behaviorTreeAIFactory") 144 | delayLoadGlobalLua("battle/btree/behaviorTreeState") 145 | 146 | delayLoadGlobalLua("module/login/loginRandomName") 147 | 148 | -- 公会战相关 149 | -- delayLoadGlobalLua("module/gang/gangWar/dijstraFind") 150 | -- delayLoadGlobalLua("module/gang/gangWar/characterIdlePathData") 151 | 152 | --战斗引导 153 | delayLoadGlobalLua("battle/battleUI/guideUI/guideActionBase") 154 | delayLoadGlobalLua("battle/battleUI/guideUI/guideActionDialogue") 155 | delayLoadGlobalLua("battle/battleUI/guideUI/guideActionCard") 156 | delayLoadGlobalLua("battle/battleUI/guideUI/guideActionSelectTroop") 157 | delayLoadGlobalLua("battle/battleUI/guideUI/guideActionMoveTroop") 158 | delayLoadGlobalLua("battle/battleUI/guideUI/guideActionSkill") 159 | delayLoadGlobalLua("battle/battleUI/guideUI/guideActionCardHint") 160 | delayLoadGlobalLua("battle/battleUI/guideUI/guideActionShowGenralSkill") 161 | delayLoadGlobalLua("battle/battleUI/guideUI/guideActionChangeCard") 162 | 163 | -- 战斗中断线重连 164 | delayLoadGlobalLua("battle/battleUI/receover/guideReceover") 165 | delayLoadGlobalLua("battle/battleUI/receover/troopReceover") 166 | delayLoadGlobalLua("battle/battleUI/receover/uiCardReceover") 167 | delayLoadGlobalLua("battle/battleUI/receover/battleReceoverManager") 168 | 169 | --战斗结算相关 170 | -- delayLoadGlobalLua("battle/battleUI/battleResult/battleResultManager") 171 | 172 | -- 星际远征相关 173 | delayLoadGlobalLua("module/universe/universeMaterialUtil") 174 | delayLoadGlobalLua("module/universe/universeUtil") 175 | delayLoadGlobalLua("module/universe/universeInstance") 176 | delayLoadGlobalLua("module/universe/dungeon/universeDungeonPanel") 177 | delayLoadGlobalLua("module/universe/planet/planetSplitScreen") 178 | 179 | --我的星球 180 | delayLoadGlobalLua("module/ownPlanet/module/input/ownPlanetinputCamera") 181 | delayLoadGlobalLua("module/ownPlanet/module/utility/gridUtility") 182 | 183 | -- 引导监听器 184 | -- delayLoadGlobalLua("module/guide/guideListenerViewActivity") 185 | 186 | --------------------------------------------------------------------------------