2020-08-25 15:46:38 +08:00
|
|
|
|
-- Lua中的继承
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function Inherit(tbParent, tbChild)
|
|
|
|
|
if not tbParent then
|
|
|
|
|
local o = tbChild or {}
|
|
|
|
|
setmetatable(o, { __index = o })
|
|
|
|
|
return o
|
|
|
|
|
else
|
|
|
|
|
local tb = tbChild or {}
|
|
|
|
|
tbParent.__index = tbParent
|
|
|
|
|
--local super_mt = getmetatable(tbParent)
|
|
|
|
|
setmetatable(tb, tbParent)
|
|
|
|
|
tb.super = setmetatable({}, tbParent)
|
|
|
|
|
return tb
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RandomList(arr)
|
|
|
|
|
if not arr or #arr <= 1 then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local index
|
|
|
|
|
for i = #arr, 1, -1 do
|
|
|
|
|
index = math.random(1, i)
|
|
|
|
|
arr[i], arr[index] = arr[index], arr[i]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--查找对象--
|
|
|
|
|
function find(str)
|
|
|
|
|
return GameObject.Find(str)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function destroy(obj)
|
|
|
|
|
GameObject.DestroyImmediate(obj)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function newObject(prefab)
|
|
|
|
|
return GameObject.Instantiate(prefab)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--适配
|
|
|
|
|
function screenAdapte(go)
|
|
|
|
|
--if Screen.width > 1080 or Screen.height > 1920 then
|
|
|
|
|
-- local scale = math.max(Screen.width / 1080, Screen.height / 1920)
|
|
|
|
|
-- go.transform.localScale = Vector3.one * scale
|
|
|
|
|
--end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function effectAdapte(go)
|
|
|
|
|
local scale = Screen.width / Screen.height / 1080 * 1920
|
|
|
|
|
--local scale = Screen.width / 1080
|
|
|
|
|
--local scale = 1920 / Screen.height
|
|
|
|
|
--Log("scale:"..scale)
|
|
|
|
|
local v3 = go.transform.localScale
|
|
|
|
|
if scale <= 1 then
|
|
|
|
|
Util.SetParticleScale(go, scale)
|
|
|
|
|
end
|
|
|
|
|
go.transform.localScale = v3
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--创建面板--
|
|
|
|
|
function createPanel(name)
|
|
|
|
|
PanelManager:CreatePanel(name)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function child(str)
|
|
|
|
|
return transform:FindChild(str)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function subGet(childNode, typeName)
|
|
|
|
|
return child(childNode):GetComponent(typeName)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function findPanel(str)
|
|
|
|
|
local obj = find(str)
|
|
|
|
|
if obj == nil then
|
|
|
|
|
error(str .. " is null")
|
|
|
|
|
return nil
|
|
|
|
|
end
|
|
|
|
|
return obj:GetComponent("BaseLua")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReloadFile(file_path)
|
|
|
|
|
package.loaded[file_path] = nil -- 消除载入记录
|
|
|
|
|
return require(file_path) -- 重新加载lua文件
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function UnLoadLuaFiles(config)
|
|
|
|
|
for i, v in ipairs(config) do
|
|
|
|
|
package.loaded[v] = nil
|
|
|
|
|
package.preload[v] = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function LoadLuaFiles(config)
|
|
|
|
|
for i, v in ipairs(config) do
|
|
|
|
|
require(v)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--播放指定音效,在同一时刻点击音效不播放
|
|
|
|
|
function PlaySoundWithoutClick(sound)
|
|
|
|
|
SoundManager.PlaySound(sound)
|
|
|
|
|
Framework.PlayClickSoundThisTime = false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 连续弹出文字
|
|
|
|
|
-- 1 -- 使用正常Tip
|
|
|
|
|
-- 2 -- 使用带颜色的
|
|
|
|
|
function PopupText(strTable, delayTime, type)
|
|
|
|
|
local index = 1
|
|
|
|
|
local timer
|
|
|
|
|
timer = Timer.New(function()
|
|
|
|
|
if index == #strTable + 1 then
|
|
|
|
|
timer:Stop()
|
|
|
|
|
else
|
|
|
|
|
if type == 1 then
|
|
|
|
|
PopupTipPanel.ShowTip(strTable[index])
|
|
|
|
|
elseif type == 2 then
|
|
|
|
|
PopupTipPanel.ShowColorTip(strTable[index].name, strTable[index].icon, strTable[index].num)
|
|
|
|
|
end
|
|
|
|
|
index = index + 1
|
|
|
|
|
end
|
|
|
|
|
end, delayTime, #strTable * delayTime * 2)
|
|
|
|
|
timer:Start()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Util_SetHeadImage(url, image, isSelf)
|
|
|
|
|
if image == nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if url == nil then
|
|
|
|
|
Util_SetToDefaultHeadImage(image)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if url == "" or url == "/0" then
|
|
|
|
|
Util_SetToDefaultHeadImage(image)
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
imageDownloadMgr:SetImage_Image(url, image, isSelf)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Util_SetToDefaultHeadImage(image)
|
|
|
|
|
if image == nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local bundleName = "normal_asset"
|
|
|
|
|
local assetName = "Avatar"
|
|
|
|
|
|
|
|
|
|
local sprite = Util.LoadSprite("Platform", assetName)
|
|
|
|
|
image.sprite = sprite
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TextHelper_Get24HourTimeStr(time)
|
|
|
|
|
if time < 10 then
|
|
|
|
|
return "0" .. time
|
|
|
|
|
else
|
|
|
|
|
return time
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function PrintWanNum(num)
|
|
|
|
|
if num >= 100000000 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return string.format("%.1f", num / 100000000) .. Language[12100]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif num >= 1000000 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return tostring(math.floor(num / 10000)) .. Language[10042]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
|
|
|
|
return tostring(num)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
function PrintWanNum2(num)
|
|
|
|
|
if num >= 100000000 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return string.format("%.1f", num / 100000000) .. Language[12100]
|
2020-07-28 23:25:43 +08:00
|
|
|
|
elseif num >= 100000 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return tostring(math.floor(num / 10000)) .. Language[10042]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--return tostring(math.floor(num / 1000)/10) .. "万"
|
|
|
|
|
else
|
|
|
|
|
return tostring(num)
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-05-25 19:16:23 +08:00
|
|
|
|
function PrintWanNum3(num)
|
|
|
|
|
if num >= 100000000 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return string.format("%.2f", num / 100000000) .. Language[12100]
|
2020-07-28 23:25:43 +08:00
|
|
|
|
elseif num >= 100000 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return string.format("%.2f",num / 10000) .. Language[10042]
|
2020-05-25 19:16:23 +08:00
|
|
|
|
else
|
|
|
|
|
return tostring(num)
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--判断两个时间在同一天
|
|
|
|
|
function Util_Check_insameday(time1, time2)
|
|
|
|
|
local date1 = os.date("*t", time1)
|
|
|
|
|
local date2 = os.date("*t", time2)
|
|
|
|
|
if date1.year == date2.year and date1.month == date2.month and date1.day == date2.day then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--判断两个时间在同一个月
|
|
|
|
|
function Util_Check_insamemonth(time1, time2)
|
|
|
|
|
local date1 = os.date("*t", time1)
|
|
|
|
|
local date2 = os.date("*t", time2)
|
|
|
|
|
if date1.year == date2.year and date1.month == date2.month then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--判断两个时间在同一星期
|
|
|
|
|
function Util_Check_insameweek(time1, time2)
|
|
|
|
|
local week_second = 7 * 24 * 3600
|
|
|
|
|
local time_zero = os.time { year = 2015, month = 1, day = 5, hour = 0, min = 0, sec = 0 }
|
|
|
|
|
local time1_tran = time1 - time_zero
|
|
|
|
|
local time2_tran = time2 - time_zero
|
|
|
|
|
local week1 = math.floor(time1_tran / week_second)
|
|
|
|
|
local week2 = math.floor(time2_tran / week_second)
|
|
|
|
|
|
|
|
|
|
if week1 == week2 then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
--秒转换成文字对应时间
|
|
|
|
|
function GetTimeStrBySeconds(_seconds)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return os.date(Language[10779], _seconds)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
--秒转换成文字对应时间 只有分秒
|
|
|
|
|
function GetTimeMaoHaoStrBySeconds(_seconds)
|
|
|
|
|
return os.date("%M:%S", _seconds)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function PrintTable(root)
|
|
|
|
|
local cache = { [root] = "." }
|
|
|
|
|
local function _dump(t, space, name)
|
|
|
|
|
if type(t) == "table" then
|
|
|
|
|
local temp = {}
|
|
|
|
|
for k, v in pairs(t) do
|
|
|
|
|
local key = tostring(k)
|
|
|
|
|
if cache[v] then
|
|
|
|
|
tinsert(temp, "+" .. key .. " {" .. cache[v] .. "}")
|
|
|
|
|
elseif type(v) == "table" then
|
|
|
|
|
local new_key = name .. "." .. key
|
|
|
|
|
cache[v] = new_key
|
|
|
|
|
tinsert(temp, "+" .. key .. _dump(v, space .. (next(t, k) and "|" or " ") .. srep(" ", #key), new_key))
|
|
|
|
|
else
|
|
|
|
|
tinsert(temp, "+" .. key .. " [" .. tostring(v) .. "]")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return tconcat(temp, "\n" .. space)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
print(_dump(root, "", ""))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local isPcall = true
|
|
|
|
|
--用于查找错误用
|
|
|
|
|
function MyPCall(func)
|
|
|
|
|
if not isPcall then
|
|
|
|
|
func()
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local flag, msg = pcall(func)
|
|
|
|
|
if not flag then
|
|
|
|
|
Util.LogError(msg)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function PlayUIAnims(gameObject, callback)
|
|
|
|
|
local anims = gameObject:GetComponentsInChildren(typeof(PlayFlyAnim))
|
|
|
|
|
if anims.Length > 0 then
|
|
|
|
|
for i = 0, anims.Length - 1 do
|
|
|
|
|
anims[i]:PlayAnim(false, callback)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function PlayUIAnimBacks(gameObject, callback)
|
|
|
|
|
local anims = gameObject:GetComponentsInChildren(typeof(PlayFlyAnim))
|
|
|
|
|
if anims.Length > 0 then
|
|
|
|
|
for i = 0, anims.Length - 1 do
|
|
|
|
|
anims[i]:PlayHideAnim(callback)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function PlayUIAnim(gameObject, callback)
|
|
|
|
|
local anim = gameObject:GetComponent(typeof(PlayFlyAnim))
|
|
|
|
|
if anim then
|
|
|
|
|
anim:PlayAnim(false, callback)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-09-25 14:11:05 +08:00
|
|
|
|
function SecTorPlayAnim(prefabList,_scale)
|
|
|
|
|
local scale = 0.05
|
|
|
|
|
if _scale then
|
|
|
|
|
scale = _scale
|
|
|
|
|
end
|
|
|
|
|
for i, node in ipairs(prefabList) do
|
|
|
|
|
Timer.New(function ()
|
|
|
|
|
node.gameObject:SetActive(true)
|
|
|
|
|
PlayUIAnim(node.gameObject)
|
|
|
|
|
end,scale*(i-1)):Start()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
function SecTorPlayAnimByScroll(scroll,_scale)
|
|
|
|
|
local scale = 0.05
|
|
|
|
|
if _scale then
|
|
|
|
|
scale = _scale
|
|
|
|
|
end
|
|
|
|
|
scroll:ForeachItemGO(function (index, go)
|
|
|
|
|
Timer.New(function ()
|
|
|
|
|
go.gameObject:SetActive(true)
|
|
|
|
|
PlayUIAnim(go.gameObject)
|
|
|
|
|
end, scale*(index-1)):Start()
|
|
|
|
|
end)
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function PlayUIAnimBack(gameObject, callback)
|
|
|
|
|
--local anim = gameObject:GetComponent(typeof(PlayFlyAnim))
|
|
|
|
|
local anim = gameObject:GetComponent("PlayFlyAnim")
|
|
|
|
|
if anim then
|
|
|
|
|
anim:PlayHideAnim(callback)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--地图uv坐标
|
|
|
|
|
function Map_UV2Pos(u, v)
|
|
|
|
|
return u * 256 + v
|
|
|
|
|
end
|
|
|
|
|
--地图uv坐标
|
|
|
|
|
function Map_Pos2UV(pos)
|
|
|
|
|
return math.floor(pos / 256), pos % 256
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 公会地图坐标精细化处理
|
|
|
|
|
function GuildMap_UV2Pos(u, v)
|
|
|
|
|
-- return u * 256 + v
|
|
|
|
|
local _u = math.floor(u *100)
|
|
|
|
|
local _v = math.floor(v *100)
|
|
|
|
|
return _u * 25600 + _v
|
|
|
|
|
end
|
|
|
|
|
function GuildMap_Pos2UV(pos)
|
|
|
|
|
-- return math.floor(pos / 256), pos % 256
|
|
|
|
|
local _u = math.floor(pos/25600)/100
|
|
|
|
|
local _v = pos%25600/100
|
|
|
|
|
return math.round(_u), math.round(_v), _u, _v
|
|
|
|
|
end
|
|
|
|
|
|
2020-07-24 20:03:06 +08:00
|
|
|
|
--把英雄星级父对象和星级传过来 type 1 第6-11个预设 type 2 第12-16个预设
|
2020-07-28 18:38:19 +08:00
|
|
|
|
function SetHeroStars(starGrid, star, type,_starSize,_scale,_pivot,rotation)
|
2020-07-24 20:03:06 +08:00
|
|
|
|
local starSize = Vector2(35,35)
|
|
|
|
|
if _starSize then
|
|
|
|
|
starSize = _starSize
|
|
|
|
|
end
|
|
|
|
|
local scale = -17.78
|
|
|
|
|
if _scale then
|
|
|
|
|
scale = _scale
|
|
|
|
|
end
|
2020-07-25 14:21:33 +08:00
|
|
|
|
local pivot = Vector2.zero
|
|
|
|
|
if _pivot then
|
|
|
|
|
pivot = _pivot
|
|
|
|
|
end
|
2020-07-24 20:03:06 +08:00
|
|
|
|
local starPre
|
|
|
|
|
if Util.GetGameObject(starGrid, "starGrid(Clone)") then
|
|
|
|
|
starPre = Util.GetGameObject(starGrid, "starGrid(Clone)")
|
|
|
|
|
else
|
|
|
|
|
starPre = poolManager:LoadAsset("starGrid", PoolManager.AssetType.GameObject)
|
|
|
|
|
end
|
|
|
|
|
local size = starPre:GetComponent("RectTransform").sizeDelta
|
|
|
|
|
size.y = starSize.y
|
|
|
|
|
starPre.transform.sizeDelta = size
|
|
|
|
|
starPre.transform:SetParent(starGrid.transform)
|
|
|
|
|
starPre:GetComponent("RectTransform").localPosition = Vector3.zero
|
|
|
|
|
starPre:GetComponent("RectTransform").localScale = Vector3.New(1,1,1)
|
|
|
|
|
starPre.transform:SetAsFirstSibling()
|
2020-07-25 14:21:33 +08:00
|
|
|
|
starPre:GetComponent("LayoutGroup").spacing = scale
|
|
|
|
|
starPre:GetComponent("RectTransform").pivot = pivot
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if star < 6 then
|
2020-07-24 20:03:06 +08:00
|
|
|
|
for i = 1, 17 do
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if i <= star then
|
2020-07-24 20:03:06 +08:00
|
|
|
|
starPre.transform:GetChild(i - 1):GetComponent("Image").sprite = Util.LoadSprite(GetHeroStarImage[1])
|
|
|
|
|
starPre.transform:GetChild(i - 1):GetComponent("RectTransform").sizeDelta = starSize
|
2020-07-28 18:38:19 +08:00
|
|
|
|
if rotation then
|
|
|
|
|
starPre.transform:GetChild(i - 1):GetComponent("RectTransform").rotation = Quaternion.Euler(rotation)
|
|
|
|
|
end
|
2020-07-24 20:03:06 +08:00
|
|
|
|
starPre.transform:GetChild(i - 1).gameObject:SetActive(true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-07-24 20:03:06 +08:00
|
|
|
|
starPre.transform:GetChild(i - 1).gameObject:SetActive(false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-07-24 20:03:06 +08:00
|
|
|
|
elseif star > 5 and star < 10 then
|
|
|
|
|
for i = 1, 17 do
|
|
|
|
|
if i <= star - 5 then
|
|
|
|
|
starPre.transform:GetChild(i - 1):GetComponent("Image").sprite = Util.LoadSprite(GetHeroStarImage[2])
|
|
|
|
|
starPre.transform:GetChild(i - 1):GetComponent("RectTransform").sizeDelta = starSize
|
2020-07-28 18:38:19 +08:00
|
|
|
|
if rotation then
|
|
|
|
|
starPre.transform:GetChild(i - 1):GetComponent("RectTransform").rotation = Quaternion.Euler(rotation)
|
|
|
|
|
end
|
2020-07-24 20:03:06 +08:00
|
|
|
|
starPre.transform:GetChild(i - 1).gameObject:SetActive(true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-07-24 20:03:06 +08:00
|
|
|
|
starPre.transform:GetChild(i - 1).gameObject:SetActive(false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-07-24 20:03:06 +08:00
|
|
|
|
elseif star > 9 then
|
|
|
|
|
if type and type == 1 then
|
|
|
|
|
for i = 1, 17 do
|
|
|
|
|
if i == star - 4 then
|
|
|
|
|
starPre.transform:GetChild(i - 1).gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
starPre.transform:GetChild(i - 1).gameObject:SetActive(false)
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-07-24 20:03:06 +08:00
|
|
|
|
elseif type and type == 2 then
|
|
|
|
|
for i = 1, 17 do
|
|
|
|
|
if i > 11 and i == star + 2 then
|
|
|
|
|
starPre.transform:GetChild(i - 1).gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
starPre.transform:GetChild(i - 1).gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
for i = 1, 17 do
|
|
|
|
|
if i == star - 4 then
|
|
|
|
|
starPre.transform:GetChild(i - 1).gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
starPre.transform:GetChild(i - 1).gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-07-25 13:21:30 +08:00
|
|
|
|
|
|
|
|
|
function SetHeroBg(bg,cardBg,star,quality)
|
2020-07-28 15:06:47 +08:00
|
|
|
|
local hong = Util.GetGameObject(bg,"Effect_UI_yansekuang_HongSe")
|
|
|
|
|
local bai = Util.GetGameObject(bg,"Effect_UI_yansekuang_BaiSe")
|
2020-07-25 13:21:30 +08:00
|
|
|
|
if star <= 5 then
|
|
|
|
|
bg:GetComponent("Image").sprite = Util.LoadSprite(GetHeroCardStarImage[1])
|
2020-07-31 15:40:43 +08:00
|
|
|
|
cardBg:GetComponent("Image").sprite = Util.LoadSprite(GetHeroCardQuantityImage[star])
|
2020-07-28 15:06:47 +08:00
|
|
|
|
if hong then
|
|
|
|
|
hong.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
if bai then
|
|
|
|
|
bai.gameObject:SetActive(false)
|
2020-07-28 15:08:24 +08:00
|
|
|
|
end
|
2020-07-25 13:21:30 +08:00
|
|
|
|
elseif star <= 10 then
|
2020-07-28 15:06:47 +08:00
|
|
|
|
bg:GetComponent("Image").sprite = Util.LoadSprite(GetHeroCardStarImage[2])
|
2020-07-25 13:21:30 +08:00
|
|
|
|
cardBg:GetComponent("Image").sprite = Util.LoadSprite(GetHeroCardQuantityImage[10])
|
2020-07-28 15:06:47 +08:00
|
|
|
|
if hong then
|
2020-07-28 16:57:12 +08:00
|
|
|
|
hong.gameObject:SetActive(false)
|
2020-07-28 15:06:47 +08:00
|
|
|
|
end
|
|
|
|
|
if bai then
|
|
|
|
|
bai.gameObject:SetActive(false)
|
|
|
|
|
end
|
2020-07-25 13:21:30 +08:00
|
|
|
|
else
|
|
|
|
|
bg:GetComponent("Image").sprite = Util.LoadSprite(GetHeroCardStarImage[3])
|
|
|
|
|
cardBg:GetComponent("Image").sprite = Util.LoadSprite(GetHeroCardQuantityImage[11])
|
2020-07-28 15:06:47 +08:00
|
|
|
|
if hong then
|
|
|
|
|
hong.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
if bai then
|
2020-07-28 16:57:12 +08:00
|
|
|
|
bai.gameObject:SetActive(false)
|
2020-07-28 15:06:47 +08:00
|
|
|
|
end
|
2020-07-25 13:21:30 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--把英雄星级父对象和星级传过来
|
|
|
|
|
local star2index = {
|
|
|
|
|
[1] = {3},
|
|
|
|
|
[2] = {2, 4},
|
|
|
|
|
[3] = {2, 3, 4},
|
|
|
|
|
[4] = {1, 2, 4, 5},
|
|
|
|
|
[5] = {1, 2, 3, 4, 5}
|
|
|
|
|
}
|
|
|
|
|
function SetCardStars(starGrid, star)
|
|
|
|
|
for i = 1, 15 do
|
|
|
|
|
starGrid.transform:GetChild(i - 1).gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
if star < 6 then
|
|
|
|
|
for _, i in ipairs(star2index[star]) do
|
|
|
|
|
starGrid.transform:GetChild(i - 1).gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
elseif star > 5 and star < 10 then
|
|
|
|
|
for _, i in ipairs(star2index[star-5]) do
|
|
|
|
|
starGrid.transform:GetChild(5 + i - 1).gameObject:SetActive(true)
|
|
|
|
|
end
|
2020-07-25 13:21:30 +08:00
|
|
|
|
elseif star > 9 then
|
2020-07-25 22:58:55 +08:00
|
|
|
|
starGrid.transform:GetChild(star).gameObject:SetActive(true)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 在给定节点下加载预设, 返回实例化的预设
|
|
|
|
|
function newObjToParent(prefab, parent)
|
|
|
|
|
local go = newObject(prefab)
|
|
|
|
|
go.transform:SetParent(parent.transform)
|
|
|
|
|
go.transform.localScale = Vector3.one
|
|
|
|
|
go.transform.localPosition = Vector3.zero
|
|
|
|
|
go:SetActive(true)
|
|
|
|
|
return go
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 清除节点下所有的子节点
|
|
|
|
|
function ClearChild(parent)
|
|
|
|
|
Util.ClearChild(parent.transform)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 加载一个商店使用的item
|
|
|
|
|
function AddShopItem(parent, itemId, shopType)
|
|
|
|
|
local item = SubUIManager.Open(SubUIConfig.ShopItemView, parent.transform)
|
|
|
|
|
item:OnOpen(itemId, shopType)
|
|
|
|
|
return item
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 根据ID返回物品的Icon,配置数据在artResourceConfig中
|
|
|
|
|
function SetIcon(id)
|
|
|
|
|
if not id or id == 0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[12101])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local icon = nil
|
|
|
|
|
local resId = itemConfig[id].ResourceID
|
|
|
|
|
if not resId then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[12102])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local resPath = GetResourcePath(resId)
|
|
|
|
|
if not resPath then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[12103])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
icon = Util.LoadSprite(resPath)
|
|
|
|
|
return icon
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SetFrame(id)
|
|
|
|
|
if not id or id == 0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[12101])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local icon = nil
|
|
|
|
|
local resId = itemConfig[id].Quantity
|
|
|
|
|
if not resId then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
Log(Language[12102])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
icon = Util.LoadSprite(GetQuantityImageByquality(resId))
|
|
|
|
|
return icon
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--属性表ID转换表
|
|
|
|
|
function GetProIndexByProId(proId)
|
|
|
|
|
local proIndex = 0
|
|
|
|
|
if proId == 1 then
|
|
|
|
|
-- 最大生命
|
|
|
|
|
proIndex = 3
|
|
|
|
|
elseif proId == 2 then
|
|
|
|
|
-- 攻击力
|
|
|
|
|
proIndex = 4
|
|
|
|
|
elseif proId == 3 then
|
|
|
|
|
-- 护甲
|
|
|
|
|
proIndex = 5
|
|
|
|
|
elseif proId == 4 then
|
|
|
|
|
-- 魔抗
|
|
|
|
|
proIndex = 6
|
|
|
|
|
elseif proId == 5 then
|
|
|
|
|
-- 速度
|
|
|
|
|
proIndex = 7
|
|
|
|
|
elseif proId == 6 or proId == 67 or proId == 68 then
|
|
|
|
|
-- 当前生命值
|
|
|
|
|
proIndex = 2
|
|
|
|
|
elseif proId == 51 then
|
|
|
|
|
-- 伤害加成
|
|
|
|
|
proIndex = 8
|
|
|
|
|
elseif proId == 52 then
|
|
|
|
|
-- 伤害减免
|
|
|
|
|
proIndex = 9
|
|
|
|
|
elseif proId == 53 then
|
|
|
|
|
-- 效果命中
|
|
|
|
|
proIndex = 10
|
|
|
|
|
elseif proId == 54 then
|
|
|
|
|
-- 效果抵抗
|
|
|
|
|
proIndex = 11
|
|
|
|
|
elseif proId == 55 then
|
|
|
|
|
-- 暴击率
|
|
|
|
|
proIndex = 12
|
|
|
|
|
elseif proId == 56 then
|
|
|
|
|
-- 暴伤
|
|
|
|
|
proIndex = 13
|
|
|
|
|
elseif proId == 57 then
|
|
|
|
|
-- 回复率
|
|
|
|
|
proIndex = 14
|
|
|
|
|
elseif proId == 101 then
|
|
|
|
|
-- 火焰伤害
|
|
|
|
|
proIndex = 15
|
|
|
|
|
elseif proId == 102 then
|
|
|
|
|
-- 狂风伤害
|
|
|
|
|
proIndex = 16
|
|
|
|
|
elseif proId == 103 then
|
|
|
|
|
-- 碧水伤害
|
|
|
|
|
proIndex = 17
|
|
|
|
|
elseif proId == 104 then
|
|
|
|
|
-- 大地伤害
|
|
|
|
|
proIndex = 18
|
|
|
|
|
elseif proId == 105 then
|
|
|
|
|
-- 神圣伤害
|
|
|
|
|
elseif proId == 106 then
|
|
|
|
|
-- 黑暗伤害
|
|
|
|
|
elseif proId == 107 then
|
|
|
|
|
-- 火焰抗性
|
|
|
|
|
elseif proId == 108 then
|
|
|
|
|
-- 狂风抗性
|
|
|
|
|
elseif proId == 109 then
|
|
|
|
|
-- 碧水抗性
|
|
|
|
|
elseif proId == 110 then
|
|
|
|
|
-- 大地抗性
|
|
|
|
|
elseif proId == 111 then
|
|
|
|
|
-- 神圣抗性
|
|
|
|
|
elseif proId == 112 then
|
|
|
|
|
-- 黑暗抗性
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return proIndex
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--逐渐显示对应文字内容,若在此期间点击屏幕,则立刻显示完文字内容
|
|
|
|
|
function ShowText(go, str, duration, callBack)
|
|
|
|
|
local text = go:GetComponent("Text")
|
|
|
|
|
text.text = ""
|
|
|
|
|
local tween = text:DOText(str, duration)
|
|
|
|
|
local isClick = false
|
|
|
|
|
tween:OnUpdate(function()
|
|
|
|
|
if Input.GetMouseButtonDown(0) then
|
|
|
|
|
isClick = true
|
|
|
|
|
end
|
|
|
|
|
if isClick then
|
|
|
|
|
if tween then
|
|
|
|
|
tween:Kill()
|
|
|
|
|
go:GetComponent("Text").text = str
|
|
|
|
|
if callBack then
|
|
|
|
|
callBack()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
tween:OnComplete(callBack)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 将秒转换成分:秒格式返回
|
|
|
|
|
function SetTimeFormation(seconds)
|
|
|
|
|
|
|
|
|
|
local str = ""
|
|
|
|
|
local ten_minute = math.modf(seconds / 600)
|
|
|
|
|
local minute = math.modf(seconds / 60) % 10
|
|
|
|
|
local ten_second = math.modf(seconds / 10) % 6
|
|
|
|
|
local second = seconds % 10
|
|
|
|
|
str = ten_minute .. minute .. " : " .. ten_second .. second
|
|
|
|
|
return str
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Dump(data, showMetatable, lastCount)
|
|
|
|
|
if type(data) == "table" then
|
|
|
|
|
--Format
|
|
|
|
|
local count = lastCount or 0
|
|
|
|
|
count = count + 1
|
|
|
|
|
|
|
|
|
|
local B2 = ""
|
|
|
|
|
for i = 1, count do
|
|
|
|
|
B2 = B2 .. " "
|
|
|
|
|
end
|
|
|
|
|
Log(B2 .. "{\n")
|
|
|
|
|
--Metatable
|
|
|
|
|
if showMetatable then
|
|
|
|
|
local blank = " "
|
|
|
|
|
for i = 1, count do
|
|
|
|
|
blank = blank .. " "
|
|
|
|
|
end
|
|
|
|
|
local mt = getmetatable(data)
|
|
|
|
|
Log(blank .. "\"__metatable\" = ")
|
|
|
|
|
|
|
|
|
|
Dump(mt, showMetatable, count)
|
|
|
|
|
end
|
|
|
|
|
--Key
|
|
|
|
|
for key, value in pairs(data) do
|
|
|
|
|
local blank = " "
|
|
|
|
|
for i = 1, count do
|
|
|
|
|
blank = blank .. " "
|
|
|
|
|
end
|
|
|
|
|
if type(key) == "string" then
|
|
|
|
|
Log(blank .. "\"" .. key .. "\" = " .. GetStr(value))
|
|
|
|
|
|
|
|
|
|
elseif type(key) == "number" then
|
|
|
|
|
Log(blank .. "[" .. key .. "] = " .. GetStr(value))
|
|
|
|
|
else
|
|
|
|
|
Log(blank .. string.format("%s", key) .. GetStr(value))
|
|
|
|
|
end
|
|
|
|
|
Dump(value, showMetatable, count)
|
|
|
|
|
end
|
|
|
|
|
--Format
|
|
|
|
|
local B0 = " "
|
|
|
|
|
for i = 1, lastCount or 0 do
|
|
|
|
|
B0 = B0 .. " "
|
|
|
|
|
end
|
|
|
|
|
Log(B0 .. "}")
|
|
|
|
|
end
|
|
|
|
|
--Format
|
|
|
|
|
if not lastCount then
|
|
|
|
|
Log("\n")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GetStr(data)
|
|
|
|
|
local str = ""
|
|
|
|
|
if type(data) ~= "table" then
|
|
|
|
|
--Value
|
|
|
|
|
if type(data) == "string" then
|
|
|
|
|
str = ("\"" .. data .. "\"")
|
|
|
|
|
elseif data == nil then
|
|
|
|
|
str = "nil"
|
|
|
|
|
else
|
|
|
|
|
str = (string.format("%s", data))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return str
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--通过item稀有度读取背景框
|
2020-07-25 20:04:02 +08:00
|
|
|
|
function GetQuantityImageByquality(quality,star)
|
2020-07-31 15:40:43 +08:00
|
|
|
|
if star then--and star > 5
|
|
|
|
|
if star == 1 then
|
2020-07-28 18:38:19 +08:00
|
|
|
|
return "r_characterbg_gray"
|
|
|
|
|
elseif star == 2 then
|
|
|
|
|
return "r_characterbg_green"
|
|
|
|
|
elseif star == 3 then
|
|
|
|
|
return "r_characterbg_blue"
|
|
|
|
|
elseif star == 4 then
|
|
|
|
|
return "r_characterbg_purple"
|
|
|
|
|
elseif star == 5 then
|
|
|
|
|
return "r_characterbg_goden"
|
|
|
|
|
elseif star >= 6 and star <=10 then
|
|
|
|
|
return "r_characterbg_gules"
|
|
|
|
|
elseif star > 10 then
|
2020-11-09 20:05:51 +08:00
|
|
|
|
return "t_tongyong_topkaung"
|
2020-07-28 18:38:19 +08:00
|
|
|
|
end
|
2020-07-31 15:40:43 +08:00
|
|
|
|
else
|
|
|
|
|
if quality == 0 or quality == 1 then
|
|
|
|
|
return "r_characterbg_gray"
|
|
|
|
|
elseif quality == 2 then
|
|
|
|
|
return "r_characterbg_green"
|
|
|
|
|
elseif quality == 3 then
|
|
|
|
|
return "r_characterbg_blue"
|
|
|
|
|
elseif quality == 4 then
|
|
|
|
|
return "r_characterbg_purple"
|
|
|
|
|
elseif quality == 5 then
|
|
|
|
|
return "r_characterbg_goden"
|
|
|
|
|
elseif quality == 6 then
|
|
|
|
|
return "r_characterbg_gules"
|
|
|
|
|
elseif quality >= 7 then
|
|
|
|
|
return "t_tongyong_topkaung"
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--通过item稀有度读取背景框
|
2020-07-25 20:04:02 +08:00
|
|
|
|
function GetQuantityImageByqualityPoint(quality)
|
2020-07-25 20:02:24 +08:00
|
|
|
|
if quality == 1 then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return "r_hunyin_zise"
|
|
|
|
|
elseif quality == 2 then
|
|
|
|
|
return "r_hunyin_zise"
|
|
|
|
|
elseif quality == 3 then
|
|
|
|
|
return "r_hunyin_zise"
|
|
|
|
|
elseif quality == 4 then
|
|
|
|
|
return "r_hunyin_zise"
|
|
|
|
|
elseif quality == 5 then
|
|
|
|
|
return "r_hunyin_chengse"
|
|
|
|
|
elseif quality == 6 then
|
|
|
|
|
return "r_hunyin_hongse"
|
|
|
|
|
elseif quality == 7 then
|
|
|
|
|
return "r_hunyin_caise"
|
|
|
|
|
else
|
|
|
|
|
return "r_hunyin_caise"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--通过item稀有度读取背景框
|
|
|
|
|
function GetQuantityStrByquality(quality)
|
|
|
|
|
if quality == 1 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10198]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif quality == 2 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10197]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif quality == 3 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10196]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif quality == 4 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10195]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif quality == 5 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10194]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif quality == 6 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10193]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif quality == 7 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10192]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10198]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--通过Hero稀有度读取碎片遮罩(小)
|
|
|
|
|
function GetHeroChipQuantityImageByquality(quality)
|
|
|
|
|
if quality == 1 then
|
2020-06-19 20:19:35 +08:00
|
|
|
|
return "PieceMask_white"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif quality == 2 then
|
2020-06-19 20:19:35 +08:00
|
|
|
|
return "PieceMask_green"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif quality == 3 then
|
|
|
|
|
return "PieceMask_blue"
|
|
|
|
|
elseif quality == 4 then
|
|
|
|
|
return "PieceMask_purple"
|
|
|
|
|
elseif quality == 5 then
|
2020-06-19 20:19:35 +08:00
|
|
|
|
return "PieceMask_goden"
|
|
|
|
|
elseif quality >= 6 then
|
|
|
|
|
return "PieceMask_red"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--通过Hero稀有度读取背景框(小)
|
2020-07-25 15:18:07 +08:00
|
|
|
|
function GetHeroQuantityImageByquality(quality,star)
|
2020-07-31 15:40:43 +08:00
|
|
|
|
if star then--and star > 5
|
|
|
|
|
if star == 1 then
|
|
|
|
|
return "r_characterbg_gray"
|
|
|
|
|
elseif star == 2 then
|
|
|
|
|
return "r_characterbg_green"
|
|
|
|
|
elseif star == 3 then
|
|
|
|
|
return "r_characterbg_blue"
|
|
|
|
|
elseif star == 4 then
|
|
|
|
|
return "r_characterbg_purple"
|
|
|
|
|
elseif star == 5 then
|
|
|
|
|
return "r_characterbg_goden"
|
2020-07-28 18:38:19 +08:00
|
|
|
|
elseif star >= 6 and star <=10 then
|
|
|
|
|
return "r_characterbg_gules"
|
|
|
|
|
elseif star > 10 then
|
2020-11-09 20:05:51 +08:00
|
|
|
|
return "t_tongyong_topkaung"
|
2020-07-31 15:40:43 +08:00
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if quality == 0 or quality == 1 then
|
|
|
|
|
return "r_characterbg_gray"
|
|
|
|
|
elseif quality == 2 then
|
|
|
|
|
return "r_characterbg_green"
|
|
|
|
|
elseif quality == 3 then
|
|
|
|
|
return "r_characterbg_blue"
|
|
|
|
|
elseif quality == 4 then
|
|
|
|
|
return "r_characterbg_purple"
|
|
|
|
|
elseif quality == 5 then
|
|
|
|
|
return "r_characterbg_goden"
|
|
|
|
|
elseif quality == 6 then
|
|
|
|
|
return "r_characterbg_gules"
|
|
|
|
|
elseif quality >= 7 then
|
|
|
|
|
return "t_tongyong_topkaung"
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--通过Hero稀有度读取背景框(卡库)外框
|
|
|
|
|
function GetHeroCardQuantityWaiImageByquality(quality)
|
|
|
|
|
if quality <= 3 then
|
|
|
|
|
return "r_hero_lankuang"
|
|
|
|
|
elseif quality == 4 then
|
|
|
|
|
return "r_hero_zikuang"
|
|
|
|
|
elseif quality == 5 then
|
|
|
|
|
return "r_hero_huangkuang"
|
|
|
|
|
elseif quality > 5 then
|
|
|
|
|
return "r_hero_huangkuang"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--通过Hero或异妖稀有度读取资质框
|
|
|
|
|
function GetQuantityImage(quality)
|
|
|
|
|
local sprite
|
|
|
|
|
if quality<11 then
|
|
|
|
|
sprite=Util.LoadSprite(AptitudeQualityFrame[1])
|
|
|
|
|
elseif quality>=11 and quality<13 then
|
|
|
|
|
sprite=Util.LoadSprite(AptitudeQualityFrame[2])
|
|
|
|
|
elseif quality>=13 and quality<15 then
|
|
|
|
|
sprite=Util.LoadSprite(AptitudeQualityFrame[3])
|
|
|
|
|
elseif quality>=15 and quality<17 then
|
|
|
|
|
sprite=Util.LoadSprite(AptitudeQualityFrame[4])
|
|
|
|
|
elseif quality>=17 and quality<19 then
|
|
|
|
|
sprite=Util.LoadSprite(AptitudeQualityFrame[5])
|
|
|
|
|
end
|
|
|
|
|
return sprite
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--通过装备位置获得装备位置类型字符串
|
|
|
|
|
function GetEquipPosStrByEquipPosNum(_index)
|
|
|
|
|
if _index == 1 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10427]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 2 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12104]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 3 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10429]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 4 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12105]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 5 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12106]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 6 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12107]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--通过职业获取职业字符串
|
|
|
|
|
function GetJobStrByJobNum(_index)
|
|
|
|
|
if _index == 0 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12108]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 1 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12038]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 2 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12039]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 3 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12040]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 4 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12041]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 5 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12042]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--通过职业获取职业字符串
|
|
|
|
|
function GetJobSpriteStrByJobNum(_index)
|
2020-06-18 20:39:29 +08:00
|
|
|
|
if _index == 1 then
|
|
|
|
|
return "r_hero_huo 1"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 2 then
|
2020-06-18 20:39:29 +08:00
|
|
|
|
return "r_hero_feng 1"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 3 then
|
2020-06-18 20:39:29 +08:00
|
|
|
|
return "r_hero_shui 1"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 4 then
|
2020-06-18 20:39:29 +08:00
|
|
|
|
return "r_hero_dadi 1"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 5 then
|
2020-06-18 20:39:29 +08:00
|
|
|
|
return "r_hero_dadi 1"
|
|
|
|
|
elseif _index == 6 then
|
|
|
|
|
return "r_hero_dadi 1"
|
|
|
|
|
else
|
|
|
|
|
return "r_hero_huo 1"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--角色定位ID 获取角色定位背景图片
|
|
|
|
|
function GetHeroPosBgStr(_i)
|
|
|
|
|
if _i==1 then
|
|
|
|
|
return "r_hero_roudundi"
|
|
|
|
|
elseif _i==2 then
|
|
|
|
|
return "r_hero_shuchudi"
|
|
|
|
|
elseif _i==3 then
|
|
|
|
|
return "r_hero_kongzhidi"
|
|
|
|
|
elseif _i==4 then
|
|
|
|
|
return "r_hero_fuzhudi"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--根据角色定位Id 获取角色定位图
|
|
|
|
|
function GetHeroPosStr(_i)
|
|
|
|
|
if _i==1 then
|
|
|
|
|
return "r_hero_roudunbiao"
|
|
|
|
|
elseif _i==2 then
|
|
|
|
|
return "r_hero_shuchubiao"
|
|
|
|
|
elseif _i==3 then
|
|
|
|
|
return "r_hero_konghzibiao"
|
|
|
|
|
elseif _i==4 then
|
|
|
|
|
return "r_hero_fuzhubiao"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--获取技能类型 data 当前技能数据
|
|
|
|
|
function GetSkillType(data)
|
|
|
|
|
local SkillIconType={"r_hero_pu","r_hero_jue","r_hero_bei"}
|
|
|
|
|
if data.skillConfig.Type == SkillType.Pu then
|
|
|
|
|
return SkillIconType[SkillType.Pu]--普技
|
|
|
|
|
elseif data.skillConfig.Type == SkillType.Jue then
|
|
|
|
|
return SkillIconType[SkillType.Jue]--绝技
|
|
|
|
|
elseif data.skillConfig.Type == SkillType.Bei then
|
|
|
|
|
return SkillIconType[SkillType.Bei]--被动技
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--通过角色属性获取角色属性图标
|
|
|
|
|
function GetProStrImageByProNum(_index)
|
|
|
|
|
if _index == 1 then
|
|
|
|
|
return "r_hero_huo 1"
|
|
|
|
|
elseif _index == 2 then
|
|
|
|
|
return "r_hero_feng 1"
|
|
|
|
|
elseif _index == 3 then
|
|
|
|
|
return "r_hero_shui 1"
|
|
|
|
|
elseif _index == 4 then
|
|
|
|
|
return "r_hero_dadi 1"
|
|
|
|
|
elseif _index == 5 then
|
2020-06-18 20:39:29 +08:00
|
|
|
|
return "r_hero_dadi 1"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _index == 6 then
|
2020-06-18 20:39:29 +08:00
|
|
|
|
return "r_hero_dadi 1"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-08-06 18:34:04 +08:00
|
|
|
|
return "z_icon_01"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--通过装备位置获得装备位置类型字符串
|
|
|
|
|
function GetQuaStringByEquipQua(_Qua)
|
|
|
|
|
--
|
|
|
|
|
if _Qua == 1 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12109]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _Qua == 2 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12110]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _Qua == 3 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12111]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _Qua == 4 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12112]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _Qua == 5 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12113]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _Qua == 6 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12114]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
elseif _Qua == 7 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[12115]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--通过item稀有度获取改颜色的文字
|
|
|
|
|
function GetStringByEquipQua(_Qua, _Str)
|
|
|
|
|
if _Qua == 1 then
|
|
|
|
|
return string.format("<color=#FCF5D3FF>%s</color>", _Str)
|
|
|
|
|
elseif _Qua == 2 then
|
|
|
|
|
return string.format("<color=#529764FF>%s</color>", _Str)
|
|
|
|
|
elseif _Qua == 3 then
|
|
|
|
|
return string.format("<color=#6398c9FF>%s</color>", _Str)
|
|
|
|
|
elseif _Qua == 4 then
|
|
|
|
|
return string.format("<color=#9358bdFF>%s</color>", _Str)
|
|
|
|
|
elseif _Qua == 5 then
|
|
|
|
|
return string.format("<color=#fcb24eFF>%s</color>", _Str)
|
|
|
|
|
elseif _Qua == 6 then
|
|
|
|
|
return string.format("<color=#C66366FF>%s</color>", _Str)
|
|
|
|
|
elseif _Qua == 7 then
|
|
|
|
|
return string.format("<color=#FFEDA1FF>%s</color>", _Str)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--冒险通过区域序号取得区域名称美术字图标
|
|
|
|
|
function GetAreaNameIconByAreaNumer(index)
|
|
|
|
|
if index == 1 then
|
|
|
|
|
return "r_guaji_qiyuanzhidi"
|
|
|
|
|
elseif index == 2 then
|
|
|
|
|
return "r_guaji_yiwangzhilu"
|
|
|
|
|
elseif index == 3 then
|
|
|
|
|
return "r_guaji_houhuizhishi"
|
|
|
|
|
elseif index == 4 then
|
|
|
|
|
return "r_guaji_zuifashengdian"
|
|
|
|
|
elseif index == 5 then
|
|
|
|
|
return "r_guaji_qidaoshengsuo"
|
|
|
|
|
elseif index == 6 then
|
|
|
|
|
return "r_guaji_youjieyehuo"
|
|
|
|
|
elseif index == 7 then
|
|
|
|
|
return "r_guaji_wushengmishi"
|
|
|
|
|
elseif index == 8 then
|
|
|
|
|
return "r_guaji_wanshenghuanghun"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- N钟,N时,N天
|
|
|
|
|
function GetLeftTimeStrByDeltaTime(deltaTime)
|
|
|
|
|
if deltaTime > 86400 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return math.floor(deltaTime / 86400) .. Language[10021]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
if deltaTime > 3600 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return math.floor(deltaTime / 3600) .. Language[12116]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
if deltaTime > 60 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return math.floor(deltaTime / 60) .. Language[12117]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return math.floor(deltaTime)..Language[10364]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
function GetLeftTimeStrByDeltaTime2(second)
|
|
|
|
|
local day = math.floor(second / (24 * 3600))
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = math.floor(second % 60)
|
|
|
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
|
|
|
|
if second > 86400 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return day .. Language[10021]..hour ..Language[10993]
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
if second > 3600 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return hour..Language[10993]..minute .. Language[12117]
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return minute .. Language[12117] .. sec .. Language[10364]
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--- 获取经历的时间字符串
|
|
|
|
|
--- 刚刚,N分钟前,N小时前,N天前
|
|
|
|
|
function GetDeltaTimeStrByDeltaTime(deltaTime)
|
|
|
|
|
if deltaTime > 86400 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return math.floor(deltaTime / 86400) .. Language[10827]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
if deltaTime > 3600 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return math.floor(deltaTime / 3600) .. Language[10826]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
if deltaTime > 60 then
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return math.floor(deltaTime / 60) .. Language[10825]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return Language[10824]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
function GetDeltaTimeStr(timestamp)
|
|
|
|
|
local curTimeStemp = GetTimeStamp()
|
|
|
|
|
local deltaTime = curTimeStemp - timestamp
|
|
|
|
|
return GetDeltaTimeStrByDeltaTime(deltaTime)
|
|
|
|
|
end
|
|
|
|
|
--- 计算公式 a*x^3 + b*x^2 + c*x +d
|
|
|
|
|
--- 1、 CalculateCostCount(x, a, b, c, d)
|
|
|
|
|
--- 2、 CalculateCostCount(x, array)
|
|
|
|
|
--- array 为按顺序存储a, b, c, d值的数组
|
|
|
|
|
---
|
|
|
|
|
function CalculateCostCount(x, ...)
|
|
|
|
|
if not x then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local args = { ... }
|
|
|
|
|
if type(args[1]) == "table" then
|
|
|
|
|
args = args[1]
|
|
|
|
|
end
|
|
|
|
|
if type(args[1]) ~= "number" then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local a = args[1]
|
|
|
|
|
local b = args[2]
|
|
|
|
|
local c = args[3]
|
|
|
|
|
local d = args[4]
|
|
|
|
|
local cost = math.pow(x, 3) * a + math.pow(x, 2) * b + x * c + d
|
|
|
|
|
return cost
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 获取当前时间戳
|
|
|
|
|
function GetTimeStamp()
|
|
|
|
|
return PlayerManager.serverTime
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 获取当前时间到一天中某时的剩余时间(24小时制)
|
|
|
|
|
function CalculateSecondsNowTo_N_OClock(n)
|
|
|
|
|
local curTimeStemp = GetTimeStamp()
|
|
|
|
|
--- 标准时间戳从1970年1月1日8点开始,加上八个小时的秒数,使其从0点开始
|
|
|
|
|
--- 8*60*60 = 28800
|
|
|
|
|
--- 24*60*60 = 86400
|
|
|
|
|
local todayPassSeconds = (curTimeStemp + 28800) % 86400
|
|
|
|
|
local targetSeconds = n * 3600 --- 60*60 = 3600
|
|
|
|
|
if todayPassSeconds <= targetSeconds then
|
|
|
|
|
return targetSeconds - todayPassSeconds
|
|
|
|
|
else
|
|
|
|
|
-- 如果已经过去了,则计算到第二天这个时间点需要的秒数
|
|
|
|
|
return targetSeconds + 86400 - todayPassSeconds
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-10-24 18:23:50 +08:00
|
|
|
|
function TimeToFelaxible(second)--大于一天用多少天多少小时,小于一天用00:00:00
|
|
|
|
|
if second <= 86400 then
|
|
|
|
|
if not second or second < 0 then
|
|
|
|
|
return "00:00:00"
|
|
|
|
|
end
|
|
|
|
|
local _sec = second % 60
|
|
|
|
|
local allMin = math.floor(second / 60)
|
|
|
|
|
local _min = allMin % 60
|
|
|
|
|
local _hour = math.floor(allMin / 60)
|
|
|
|
|
return string.format("%02d:%02d:%02d", _hour, _min, _sec), _hour, _min, _sec
|
|
|
|
|
elseif second > 86400 then
|
|
|
|
|
local day = math.floor(second / (24 * 3600))
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = second % 60
|
|
|
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
|
|
|
|
return string.format(Language[12278],day, hour)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--- 将一段时间转换为天时分秒
|
|
|
|
|
function TimeToDHMS(second)
|
|
|
|
|
local day = math.floor(second / (24 * 3600))
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = second % 60
|
|
|
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return string.format(Language[10548],day, hour, minute, sec)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-07-14 11:05:47 +08:00
|
|
|
|
|
2020-09-27 16:38:44 +08:00
|
|
|
|
--- 将一段时间转换为天时分
|
|
|
|
|
function TimeToDHM(second)
|
|
|
|
|
local day = math.floor(second / (24 * 3600))
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = second % 60
|
|
|
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
|
|
|
|
return string.format("%d天%02d时%02d分",day, hour, minute)
|
|
|
|
|
end
|
|
|
|
|
|
2020-07-14 11:05:47 +08:00
|
|
|
|
--- 将一段时间转换为天时
|
|
|
|
|
function TimeToDH(second)
|
|
|
|
|
local day = math.floor(second / (24 * 3600))
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = second % 60
|
|
|
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
2020-07-25 20:42:11 +08:00
|
|
|
|
return string.format(Language[12278],day, hour)
|
2020-07-14 11:05:47 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-08-28 17:46:07 +08:00
|
|
|
|
|
|
|
|
|
--- 将一段时间转换为时
|
|
|
|
|
function TimeToH(second)
|
|
|
|
|
local day = math.floor(second / (24 * 3600))
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = second % 60
|
|
|
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
2020-08-25 15:46:38 +08:00
|
|
|
|
return string.format(Language[11751], hour)
|
2020-08-28 17:46:07 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--- 将一段时间转换为时分秒
|
|
|
|
|
function TimeToHMS(t)
|
|
|
|
|
if not t or t < 0 then
|
|
|
|
|
return "00:00:00"
|
|
|
|
|
end
|
|
|
|
|
local _sec = t % 60
|
|
|
|
|
local allMin = math.floor(t / 60)
|
|
|
|
|
local _min = allMin % 60
|
|
|
|
|
local _hour = math.floor(allMin / 60)
|
|
|
|
|
return string.format("%02d:%02d:%02d", _hour, _min, _sec), _hour, _min, _sec
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 将一段时间转换为分秒
|
|
|
|
|
function TimeToMS(t)
|
|
|
|
|
if not t or t < 0 then
|
|
|
|
|
return "00:00"
|
|
|
|
|
end
|
|
|
|
|
local _sec = t % 60
|
|
|
|
|
local _min = math.floor(t / 60)
|
|
|
|
|
return string.format("%02d:%02d", _min, _sec)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 获取今天某时间点时间戳
|
|
|
|
|
function Today_N_OClockTimeStamp(n)
|
|
|
|
|
local currentTime = math.floor(GetTimeStamp())
|
|
|
|
|
local tab = os.date("*t", currentTime)
|
|
|
|
|
tab.hour = n
|
|
|
|
|
tab.min = 0
|
|
|
|
|
tab.sec = 0
|
|
|
|
|
local N_TimeStamp = os.time(tab)
|
|
|
|
|
return N_TimeStamp
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
----- 时效类时间(服务器按照每天凌晨的5点为起始的一天)
|
|
|
|
|
function GetTimePass(timeValue)
|
|
|
|
|
local tab = os.date("*t", timeValue)
|
|
|
|
|
tab.hour = 0
|
|
|
|
|
tab.min = 0
|
|
|
|
|
tab.sec = 0
|
|
|
|
|
|
|
|
|
|
local tab2 = os.date("*t", timeValue)
|
|
|
|
|
tab2.hour = 5
|
|
|
|
|
tab2.min = 0
|
|
|
|
|
tab2.sec = 0
|
|
|
|
|
local timeStartSum = os.time(tab2)
|
|
|
|
|
--0点
|
|
|
|
|
local forwardDay
|
|
|
|
|
local zeroTimeStamp = os.time(tab)
|
|
|
|
|
if timeValue > zeroTimeStamp and timeValue < timeStartSum then
|
|
|
|
|
forwardDay = 1
|
|
|
|
|
else
|
|
|
|
|
forwardDay = 0
|
|
|
|
|
end
|
|
|
|
|
local dayPass = math.ceil((GetTimeStamp() - timeStartSum) / 86400)
|
|
|
|
|
return (dayPass + forwardDay) > 3 and 3 or (dayPass + forwardDay)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
---时间格式化接口
|
|
|
|
|
function GetTimeShow(data)
|
|
|
|
|
local year = math.floor(os.date("%Y", data))
|
|
|
|
|
local month = math.floor(os.date("%m", data))
|
|
|
|
|
local day = math.floor(os.date("%d", data))
|
|
|
|
|
local time = year .. "." .. month .. "." .. day
|
|
|
|
|
return time
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---obj必须是userdata(c#对象)
|
|
|
|
|
function IsNull(obj)
|
|
|
|
|
return obj == nil or obj:Equals(nil)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
------- 红点相关 ----------
|
|
|
|
|
-- 绑定红点物体
|
|
|
|
|
function BindRedPointObject(rpType, rpObj)
|
|
|
|
|
RedpotManager.BindObject(rpType, rpObj)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 清除红点上绑定的所有物体
|
|
|
|
|
function ClearRedPointObject(rpType, rpObj)
|
|
|
|
|
RedpotManager.ClearObject(rpType, rpObj)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 强制改变红点状态(不建议使用)
|
|
|
|
|
function ChangeRedPointStatus(rpType, state)
|
|
|
|
|
RedpotManager.SetRedPointStatus(rpType, state)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 重置服务器红点状态到隐藏状态
|
|
|
|
|
function ResetServerRedPointStatus(rpType)
|
|
|
|
|
RedpotManager.SetServerRedPointStatus(rpType, RedPointStatus.Hide)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 检测红点显示
|
|
|
|
|
function CheckRedPointStatus(rpType)
|
|
|
|
|
RedpotManager.CheckRedPointStatus(rpType)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-------------------------
|
|
|
|
|
--统用属性展示
|
|
|
|
|
function GetPropertyFormatStr(type, value)
|
|
|
|
|
if type == 1 then
|
|
|
|
|
return value
|
|
|
|
|
else
|
|
|
|
|
if value % 100 == 0 then
|
|
|
|
|
return string.format("%d%%", value / 100)
|
|
|
|
|
else
|
|
|
|
|
return string.format("%.2f%%", value / 100)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--统用属性展示
|
|
|
|
|
function GetPropertyFormatStrOne(type, value)
|
|
|
|
|
if type == 1 then
|
|
|
|
|
return value
|
|
|
|
|
else
|
|
|
|
|
if value % 100 == 0 then
|
|
|
|
|
return string.format("%d%%", value / 100)
|
|
|
|
|
else
|
|
|
|
|
return string.format("%.1f%%", value / 100)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--装备专属属性展示
|
|
|
|
|
function GetEquipPropertyFormatStr(type, value)
|
|
|
|
|
if type == 1 then
|
|
|
|
|
return value
|
|
|
|
|
else
|
|
|
|
|
if value / 100 > 1 then
|
|
|
|
|
return string.format("%d%%", value / 100)
|
|
|
|
|
else
|
|
|
|
|
return string.format("%d%%", 1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- 将秒转换成显示使用的时间
|
|
|
|
|
function FormatSecond(second)
|
|
|
|
|
local day = math.floor(second / (24 * 3600))
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = second % 60
|
|
|
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return string.format(Language[12118], day, hour, minute, sec)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 将时间戳转换为用于显示的日期字符串
|
|
|
|
|
function TimeStampToDateStr(timestamp)
|
|
|
|
|
local date = os.date("*t", timestamp)
|
|
|
|
|
local cdate = os.date("*t", GetTimeStamp())
|
|
|
|
|
if date.year == cdate.year and date.month == cdate.month and date.day == cdate.day then
|
|
|
|
|
return string.format("%02d:%02d", date.hour, date.min)
|
|
|
|
|
end
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return string.format(Language[12119], date.year, date.month, date.day, date.hour, date.min)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
-- 将时间戳转换为用于显示的日期字符串(时分秒)
|
|
|
|
|
function TimeStampToDateStr3(second)
|
|
|
|
|
local minute = math.floor(second / 60) % 60
|
|
|
|
|
local sec = second % 60
|
|
|
|
|
local hour = math.floor(math.floor(second - sec - minute * 60) / 3600)
|
|
|
|
|
|
|
|
|
|
return string.format("%02d:%02d:%02d", hour, minute, sec)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 根据id获取资源
|
|
|
|
|
function GetResourcePath(id)
|
|
|
|
|
return ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig, id).Name
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 获取玩家头像资源
|
|
|
|
|
function GetPlayerHeadSprite(headId)
|
|
|
|
|
if headId == 0 then headId = 71000 end
|
|
|
|
|
local head = ConfigManager.GetConfigData(ConfigName.ItemConfig, headId)
|
|
|
|
|
return Util.LoadSprite(GetResourcePath(head.ResourceID))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 获取玩家头像框资源
|
|
|
|
|
function GetPlayerHeadFrameSprite(frameId)
|
2020-09-28 17:34:39 +08:00
|
|
|
|
if frameId == 0 then frameId = 80000 end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local frame = ConfigManager.GetConfigData(ConfigName.ItemConfig, frameId)
|
|
|
|
|
return Util.LoadSprite(GetResourcePath(frame.ResourceID))
|
|
|
|
|
end
|
|
|
|
|
|
2020-09-25 21:19:01 +08:00
|
|
|
|
--- 获取玩家头像框资源
|
|
|
|
|
function GetPlayerHeadFrameEffect(frameId)
|
2020-09-27 19:04:17 +08:00
|
|
|
|
if frameId == 80004 then
|
2020-09-25 21:19:01 +08:00
|
|
|
|
return "UI_Effect_TouXiang_Lanlong", 1.1, Vector3.New(-8, -5, 0)
|
|
|
|
|
elseif frameId == 80005 then
|
|
|
|
|
return "UI_Effect_TouXiang_QingLong", 1.15, Vector3.New(-9, 5, 0)
|
|
|
|
|
elseif frameId == 80006 then
|
|
|
|
|
return "UI_Effect_TouXiang_BaiHu", 1.15, Vector3.New(-3, -8, 0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--是否弹出快捷购买面板
|
|
|
|
|
function PopQuickPurchasePanel(type, needNum)
|
|
|
|
|
local ownNumber = BagManager.GetItemCountById(type)
|
|
|
|
|
if ownNumber >= needNum then
|
|
|
|
|
return false
|
|
|
|
|
else
|
|
|
|
|
UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = type })
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
----- SDK数据上报
|
|
|
|
|
----- @param context
|
|
|
|
|
---- {
|
|
|
|
|
---- type, -- required, 调用时机
|
|
|
|
|
---- }
|
|
|
|
|
function SubmitExtraData(context)
|
2020-07-25 16:23:04 +08:00
|
|
|
|
if not AppConst.isSDKLogin then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
2020-07-15 13:44:37 +08:00
|
|
|
|
local params = SDK.SDKSubmitExtraDataArgs.New()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
params.dataType = context.type
|
|
|
|
|
params.serverID = tonumber(PlayerManager.serverInfo.server_id)
|
|
|
|
|
params.serverName = PlayerManager.serverInfo.name
|
2020-08-22 15:31:14 +08:00
|
|
|
|
params.zoneID = tostring(PlayerManager.serverInfo.server_id)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
params.zoneName = PlayerManager.serverInfo.name
|
|
|
|
|
params.roleID = tostring(PlayerManager.uid)
|
|
|
|
|
params.roleName = PlayerManager.nickName
|
|
|
|
|
params.roleLevel = tostring(PlayerManager.level)
|
|
|
|
|
params.guildID = PlayerManager.familyId
|
|
|
|
|
params.Vip = tostring(VipManager.GetVipLevel())
|
|
|
|
|
params.moneyNum = BagManager.GetItemCountById(16)
|
|
|
|
|
params.roleCreateTime = DateUtils.GetDateTime(PlayerManager.userCreateTime)
|
|
|
|
|
params.roleLevelUpTime = context.roleLevelUpTime and DateUtils.GetDateTime(context.roleLevelUpTime) or ""
|
2020-07-15 13:44:37 +08:00
|
|
|
|
SDKMgr:SubmitExtraData(params)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- context = {
|
|
|
|
|
-- title = "",
|
|
|
|
|
-- content = "",
|
|
|
|
|
-- confirmCallback = function() end,
|
|
|
|
|
-- cancelCallback = function() end,
|
|
|
|
|
-- confirmText = "确认",
|
|
|
|
|
-- cancelText = "取消",
|
|
|
|
|
-- type, -- 单双按钮
|
|
|
|
|
-- extra --额外操作
|
|
|
|
|
-- }
|
|
|
|
|
function ShowConfirmPanel(context)
|
|
|
|
|
UIManager.OpenPanel(UIName.CommonConfirmPanel, context)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 检测某一面板关闭再抛相应的事件
|
|
|
|
|
function CallBackOnPanelClose(uiPanel, func)
|
|
|
|
|
if UIManager.IsOpen(uiPanel) then
|
|
|
|
|
local triggerCallBack
|
|
|
|
|
triggerCallBack = function (panelType, panel)
|
|
|
|
|
if panelType == uiPanel then
|
|
|
|
|
if func then func() end
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack)
|
|
|
|
|
else
|
|
|
|
|
if func then func() end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 检测某一面板打开再抛相应的事件
|
|
|
|
|
function CallBackOnPanelOpen(uiPanel, func)
|
|
|
|
|
if not UIManager.IsOpen(uiPanel) then
|
|
|
|
|
local triggerCallBack
|
|
|
|
|
triggerCallBack = function (panelType, panel)
|
|
|
|
|
if panelType == uiPanel then
|
|
|
|
|
if func then func() end
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnOpen, triggerCallBack)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.UI.OnOpen, triggerCallBack)
|
|
|
|
|
else
|
|
|
|
|
if func then func() end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 通过地图坐标设置物体在UI平面的位置
|
|
|
|
|
function SetObjPosByUV(pos)
|
|
|
|
|
local u, v = Map_Pos2UV(pos)
|
|
|
|
|
local v2 = RectTransformUtility.WorldToScreenPoint(TileMapView.GetCamera(), TileMapView.GetLiveTilePos(u, v))
|
2020-09-05 12:15:58 +08:00
|
|
|
|
v2.x = (v2.x)/Screen.width*UIManager.UIWidth - UIManager.Offset.Left
|
|
|
|
|
v2.y = (v2.y)/Screen.height*UIManager.UIHeight - UIManager.Offset.Bottom
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return v2
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--获取技能描述
|
|
|
|
|
function GetSkillConfigDesc(cfg)
|
|
|
|
|
if cfg.DescColor then
|
|
|
|
|
local ss = {}
|
|
|
|
|
for i=1, #cfg.DescColor do
|
|
|
|
|
local str
|
|
|
|
|
if cfg.DescColor[i] == 1 then
|
|
|
|
|
str=string.format("<color=#4c805eFF>%s</color>", cfg.DescValue[i])
|
|
|
|
|
elseif cfg.DescColor[i] == 2 then
|
|
|
|
|
str=string.format("<color=#b4595eFF>%s</color>", cfg.DescValue[i])
|
|
|
|
|
else
|
|
|
|
|
str=cfg.DescValue[i]
|
|
|
|
|
end
|
|
|
|
|
ss[i] = str
|
|
|
|
|
end
|
|
|
|
|
return string.format(cfg.Desc, unpack(ss))
|
|
|
|
|
end
|
|
|
|
|
return cfg.Desc
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 设置排名所需要的数字框
|
|
|
|
|
function SetRankNumFrame(rankNum)
|
|
|
|
|
local rankNumRes = {
|
|
|
|
|
[1] = "r_Dungeon_001",
|
|
|
|
|
[2] = "r_Dungeon_002",
|
|
|
|
|
[3] = "r_Dungeon_003",
|
|
|
|
|
[4] = "r_hero_zhuangbeidi",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local resPath = rankNum > 3 and rankNumRes[4] or rankNumRes[rankNum]
|
|
|
|
|
local icon = Util.LoadSprite(resPath)
|
|
|
|
|
return icon
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-02 09:16:45 +08:00
|
|
|
|
function SetSoulEffect(quality,root)
|
|
|
|
|
local effect = Util.GetGameObject(root,"UI_Effect_Kuang_JinSe")
|
|
|
|
|
local effect1 = Util.GetGameObject(root,"UI_Effect_jinkuang_Fang")
|
|
|
|
|
local effect2 = Util.GetGameObject(root,"UI_Effect_jinkuang_Yuan")
|
2020-08-03 16:11:04 +08:00
|
|
|
|
-- if quality >= 7 then
|
|
|
|
|
-- effect1.gameObject:SetActive(true)
|
|
|
|
|
-- effect2.gameObject:SetActive(true)
|
|
|
|
|
-- effect.gameObject:SetActive(false)
|
|
|
|
|
-- else
|
|
|
|
|
-- effect1.gameObject:SetActive(false)
|
|
|
|
|
-- effect2.gameObject:SetActive(false)
|
|
|
|
|
-- effect.gameObject:SetActive(true)
|
|
|
|
|
-- end
|
|
|
|
|
effect1.gameObject:SetActive(false)
|
|
|
|
|
effect2.gameObject:SetActive(false)
|
|
|
|
|
effect.gameObject:SetActive(true)
|
2020-08-02 09:16:45 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
--- 本方法适用滚动条中 生成item的使用 (主要适用每条滚动条item数量不定的滚动条中)
|
|
|
|
|
--- itemview重设复用 1根节点 2生成到父节点 3item容器 4容器上限 5缩放 6层级 7根据数据类型生成 8不定参数据...
|
2020-06-08 13:57:30 +08:00
|
|
|
|
--- type=true 针对表数据为一维数据 type=false 针对表数据为二维数据
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function ResetItemView(root,rewardRoot,itemList,max,scale,sortingOrder,type,...)
|
|
|
|
|
local args={...}
|
|
|
|
|
local data1=args[1]
|
|
|
|
|
local data2=args[2]
|
|
|
|
|
|
|
|
|
|
if itemList[root] then -- 存在
|
|
|
|
|
for i = 1, max do
|
|
|
|
|
itemList[root][i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
if type then
|
|
|
|
|
itemList[root][1]:OnOpen(false, {data1,data2},scale,false,false,false,sortingOrder)
|
|
|
|
|
itemList[root][1].gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
for i = 1, #data1 do
|
|
|
|
|
if itemList[root][i] then
|
|
|
|
|
itemList[root][i]:OnOpen(false, {data1[i][1],data1[i][2]},scale,false,false,false,sortingOrder)
|
|
|
|
|
itemList[root][i]:Reset({data1[i][1],data1[i][2]},ItemType.Hero,{false,true,true,true})
|
|
|
|
|
itemList[root][i].gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else -- 不存在 新建
|
|
|
|
|
itemList[root]={}
|
|
|
|
|
for i = 1, max do
|
|
|
|
|
itemList[root][i] = SubUIManager.Open(SubUIConfig.ItemView, rewardRoot)
|
|
|
|
|
itemList[root][i].gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
if type then
|
|
|
|
|
itemList[root][1]:OnOpen(false, {data1,data2},scale,false,false,false,sortingOrder)
|
|
|
|
|
itemList[root][1].gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
for i = 1, #data1 do
|
|
|
|
|
itemList[root][i]:OnOpen(false, {data1[i][1],data1[i][2]},scale,false,false,false,sortingOrder)
|
|
|
|
|
itemList[root][i]:Reset({data1[i][1],data1[i][2]},ItemType.Hero,{false,true,true,true})
|
|
|
|
|
itemList[root][i].gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-08-28 18:37:16 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--计算字符串长度
|
|
|
|
|
function LengthString(inputstr)
|
|
|
|
|
-- 计算字符串宽度
|
|
|
|
|
-- 可以计算出字符宽度,用于显示使用
|
|
|
|
|
local lenInByte = #inputstr
|
|
|
|
|
local width = 0
|
|
|
|
|
local i = 1
|
|
|
|
|
while (i<=lenInByte)
|
|
|
|
|
do
|
|
|
|
|
local curByte = string.byte(inputstr, i)
|
|
|
|
|
local byteCount = 1;
|
|
|
|
|
if curByte>0 and curByte<=127 then
|
|
|
|
|
byteCount = 1 --1字节字符
|
|
|
|
|
elseif curByte>=192 and curByte<223 then
|
|
|
|
|
byteCount = 2 --双字节字符
|
|
|
|
|
elseif curByte>=224 and curByte<239 then
|
|
|
|
|
byteCount = 3 --汉字
|
|
|
|
|
elseif curByte>=240 and curByte<=247 then
|
|
|
|
|
byteCount = 4 --4字节字符
|
|
|
|
|
end
|
|
|
|
|
local char = string.sub(inputstr, i, i+byteCount-1)
|
|
|
|
|
-- print(char)
|
|
|
|
|
i = i + byteCount -- 重置下一字节的索引
|
|
|
|
|
width = width + 1 -- 字符的个数(长度)
|
|
|
|
|
end
|
|
|
|
|
return width
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SubString(inputstr,num)
|
|
|
|
|
local num = num and num or 0
|
|
|
|
|
local str = ""
|
|
|
|
|
local lenInByte = #inputstr
|
|
|
|
|
local width = 0
|
|
|
|
|
local i = 1
|
|
|
|
|
while (i<=lenInByte)
|
|
|
|
|
do
|
|
|
|
|
local curByte = string.byte(inputstr, i)
|
|
|
|
|
local byteCount = 1;
|
|
|
|
|
if curByte>0 and curByte<=127 then
|
|
|
|
|
byteCount = 1 --1字节字符
|
|
|
|
|
elseif curByte>=192 and curByte<223 then
|
|
|
|
|
byteCount = 2 --双字节字符
|
|
|
|
|
elseif curByte>=224 and curByte<239 then
|
|
|
|
|
byteCount = 3 --汉字
|
|
|
|
|
elseif curByte>=240 and curByte<=247 then
|
|
|
|
|
byteCount = 4 --4字节字符
|
|
|
|
|
end
|
|
|
|
|
local char = string.sub(inputstr, i, i+byteCount-1)
|
|
|
|
|
-- print(char)
|
|
|
|
|
str = str..char
|
|
|
|
|
i = i + byteCount -- 重置下一字节的索引
|
|
|
|
|
width = width + 1 -- 字符的个数(长度)
|
|
|
|
|
if width == num then
|
|
|
|
|
return (str)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return str
|
2020-11-06 09:37:27 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SetHeroIcon(heroData,icon,heroConfig)
|
|
|
|
|
LogGreen("heroData.skinId:"..tostring(heroData.skinId))
|
|
|
|
|
if not heroData.skinId or heroData.skinId == 0 then
|
|
|
|
|
icon.sprite = Util.LoadSprite(GetResourcePath(heroConfig.Icon))
|
|
|
|
|
else
|
|
|
|
|
local heroSkinconfig = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",heroData.skinId)
|
|
|
|
|
icon.sprite = Util.LoadSprite(GetResourcePath(heroSkinconfig.Icon))
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|