Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,203 @@
|
||||
local M = {}
|
||||
local deferred = {}
|
||||
deferred.__index = deferred
|
||||
local PENDING = 0
|
||||
local RESOLVING = 1
|
||||
local REJECTING = 2
|
||||
local RESOLVED = 3
|
||||
local REJECTED = 4
|
||||
local finish = function(deferred, state)
|
||||
state = state or REJECTED
|
||||
for i, f in ipairs(deferred.queue) do
|
||||
if state == RESOLVED then
|
||||
f:resolve(deferred.value)
|
||||
else
|
||||
f:reject(deferred.value)
|
||||
end
|
||||
end
|
||||
deferred.state = state
|
||||
end
|
||||
local isfunction = function(f)
|
||||
if type(f) == "table" then
|
||||
local mt = getmetatable(f)
|
||||
return mt ~= nil and type(mt.__call) == "function"
|
||||
end
|
||||
return type(f) == "function"
|
||||
end
|
||||
local promise = function(deferred, next, success, failure, nonpromisecb)
|
||||
if type(deferred) == "table" and type(deferred.value) == "table" and isfunction(next) then
|
||||
local called = false
|
||||
local ok, err = pcall(next, deferred.value, function(v)
|
||||
if called then
|
||||
return
|
||||
end
|
||||
called = true
|
||||
deferred.value = v
|
||||
success()
|
||||
end, function(v)
|
||||
if called then
|
||||
return
|
||||
end
|
||||
called = true
|
||||
deferred.value = v
|
||||
failure()
|
||||
end)
|
||||
if not ok and not called then
|
||||
deferred.value = err
|
||||
failure()
|
||||
end
|
||||
else
|
||||
nonpromisecb()
|
||||
end
|
||||
end
|
||||
local function fire(deferred)
|
||||
local next
|
||||
if type(deferred.value) == "table" then
|
||||
next = deferred.value.next
|
||||
end
|
||||
promise(deferred, next, function()
|
||||
deferred.state = RESOLVING
|
||||
fire(deferred)
|
||||
end, function()
|
||||
deferred.state = REJECTING
|
||||
fire(deferred)
|
||||
end, function()
|
||||
local ok, v
|
||||
if deferred.state == RESOLVING and isfunction(deferred.success) then
|
||||
ok, v = pcall(deferred.success, deferred.value)
|
||||
elseif deferred.state == REJECTING and isfunction(deferred.failure) then
|
||||
ok, v = pcall(deferred.failure, deferred.value)
|
||||
if ok then
|
||||
deferred.state = RESOLVING
|
||||
end
|
||||
end
|
||||
if ok ~= nil then
|
||||
if ok then
|
||||
deferred.value = v
|
||||
else
|
||||
deferred.value = v
|
||||
return finish(deferred)
|
||||
end
|
||||
end
|
||||
if deferred.value == deferred then
|
||||
deferred.value = pcall(error, "resolving promise with itself")
|
||||
return finish(deferred)
|
||||
else
|
||||
promise(deferred, next, function()
|
||||
finish(deferred, RESOLVED)
|
||||
end, function(state)
|
||||
finish(deferred, state)
|
||||
end, function()
|
||||
finish(deferred, deferred.state == RESOLVING and RESOLVED)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end
|
||||
local resolve = function(deferred, state, value)
|
||||
if deferred.state == 0 then
|
||||
deferred.value = value
|
||||
deferred.state = state
|
||||
fire(deferred)
|
||||
end
|
||||
return deferred
|
||||
end
|
||||
function deferred:resolve(value)
|
||||
return resolve(self, RESOLVING, value)
|
||||
end
|
||||
function deferred:reject(value)
|
||||
return resolve(self, REJECTING, value)
|
||||
end
|
||||
function M.new(options)
|
||||
if isfunction(options) then
|
||||
local d = M.new()
|
||||
local ok, err = pcall(options, d)
|
||||
if not ok then
|
||||
d:reject(err)
|
||||
end
|
||||
return d
|
||||
end
|
||||
options = options or {}
|
||||
local d
|
||||
d = {
|
||||
next = function(self, success, failure)
|
||||
local next = M.new({
|
||||
success = success,
|
||||
failure = failure,
|
||||
extend = options.extend
|
||||
})
|
||||
if d.state == RESOLVED then
|
||||
next:resolve(d.value)
|
||||
elseif d.state == REJECTED then
|
||||
next:reject(d.value)
|
||||
else
|
||||
table.insert(d.queue, next)
|
||||
end
|
||||
return next
|
||||
end,
|
||||
state = 0,
|
||||
queue = {},
|
||||
success = options.success,
|
||||
failure = options.failure
|
||||
}
|
||||
d = setmetatable(d, deferred)
|
||||
if isfunction(options.extend) then
|
||||
options.extend(d)
|
||||
end
|
||||
return d
|
||||
end
|
||||
function M.all(args)
|
||||
local d = M.new()
|
||||
if #args == 0 then
|
||||
return d:resolve({})
|
||||
end
|
||||
local method = "resolve"
|
||||
local pending = #args
|
||||
local results = {}
|
||||
local synchronizer = function(i, resolved)
|
||||
return function(value)
|
||||
results[i] = value
|
||||
if not resolved then
|
||||
method = "reject"
|
||||
end
|
||||
pending = pending - 1
|
||||
if pending == 0 then
|
||||
d[method](d, results)
|
||||
end
|
||||
return value
|
||||
end
|
||||
end
|
||||
for i = 1, pending do
|
||||
args[i]:next(synchronizer(i, true), synchronizer(i, false))
|
||||
end
|
||||
return d
|
||||
end
|
||||
function M.map(args, fn)
|
||||
local d = M.new()
|
||||
local results = {}
|
||||
local function donext(i)
|
||||
if i > #args then
|
||||
d:resolve(results)
|
||||
else
|
||||
fn(args[i]):next(function(res)
|
||||
table.insert(results, res)
|
||||
donext(i + 1)
|
||||
end, function(err)
|
||||
d:reject(err)
|
||||
end)
|
||||
end
|
||||
end
|
||||
donext(1)
|
||||
return d
|
||||
end
|
||||
function M.first(args)
|
||||
local d = M.new()
|
||||
for _, v in ipairs(args) do
|
||||
v:next(function(res)
|
||||
d:resolve(res)
|
||||
end, function(err)
|
||||
d:reject(err)
|
||||
end)
|
||||
end
|
||||
return d
|
||||
end
|
||||
return M
|
||||
@@ -0,0 +1,89 @@
|
||||
local tableconcat = table.concat
|
||||
local stringformat = string.format
|
||||
local StringBuilder = {}
|
||||
function StringBuilder:new(sep)
|
||||
local object = {}
|
||||
setmetatable(object, self)
|
||||
self.__index = self
|
||||
object.sep = sep
|
||||
object.buffer = {}
|
||||
return object
|
||||
end
|
||||
function StringBuilder:Append(str)
|
||||
self.buffer[#self.buffer + 1] = str
|
||||
end
|
||||
function StringBuilder:AppendFormat(format, ...)
|
||||
self:Append(stringformat(format, ...))
|
||||
end
|
||||
function StringBuilder:AppendLine(str)
|
||||
self:Append(str)
|
||||
self:Append("\r\n")
|
||||
end
|
||||
function StringBuilder:ToString()
|
||||
return tableconcat(self.buffer, self.sep)
|
||||
end
|
||||
function StringBuilder:Clear()
|
||||
local count = #self.buffer
|
||||
for i = 1, count do
|
||||
self.buffer[i] = nil
|
||||
end
|
||||
end
|
||||
local function __printTable(tb, sb, name, aPreText, bLast)
|
||||
if tb == nil then
|
||||
return
|
||||
end
|
||||
if bLast == nil then
|
||||
bLast = false
|
||||
end
|
||||
name = name or ""
|
||||
local preText = aPreText or ""
|
||||
local subPreText = ""
|
||||
if aPreText == nil then
|
||||
sb:AppendLine("[ROOT]")
|
||||
else
|
||||
if bLast then
|
||||
subPreText = preText .. " "
|
||||
else
|
||||
subPreText = preText .. "│ "
|
||||
end
|
||||
if type(tb) == "table" then
|
||||
if bLast then
|
||||
sb:AppendLine(string.format("%s└─[%s]", preText, name))
|
||||
else
|
||||
sb:AppendLine(string.format("%s├─[%s]", preText, name))
|
||||
end
|
||||
elseif bLast then
|
||||
sb:AppendLine(string.format("%s└─%s= %s", preText, name, tostring(tb)))
|
||||
else
|
||||
sb:AppendLine(string.format("%s├─%s= %s", preText, name, tostring(tb)))
|
||||
end
|
||||
end
|
||||
if type(tb) == "table" then
|
||||
local counter = 0
|
||||
local count = 0
|
||||
for _, _ in pairs(tb) do
|
||||
count = count + 1
|
||||
end
|
||||
for key, obj in pairs(tb) do
|
||||
counter = counter + 1
|
||||
__printTable(obj, sb, key, subPreText, counter == count)
|
||||
end
|
||||
end
|
||||
if bLast then
|
||||
sb:AppendLine(preText)
|
||||
end
|
||||
end
|
||||
function PrintTable(tb, filename)
|
||||
local sb = StringBuilder:new()
|
||||
__printTable(tb, sb)
|
||||
local str = sb:ToString()
|
||||
if filename then
|
||||
local f = io.open(filename, "w")
|
||||
if f ~= nil then
|
||||
f:write(str)
|
||||
f:close()
|
||||
end
|
||||
else
|
||||
print(str)
|
||||
end
|
||||
end
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
local unpack = unpack or table.unpack
|
||||
local M = {}
|
||||
M.WILDCARD = "*"
|
||||
M.DEFERRED = 0
|
||||
M.SUCCEEDED = 1
|
||||
M.NO_TRANSITION = 2
|
||||
M.PENDING = 3
|
||||
M.CANCELLED = 4
|
||||
local do_callback = function(handler, args)
|
||||
if handler then
|
||||
return handler(unpack(args))
|
||||
end
|
||||
end
|
||||
local before_event = function(self, event, _from, _to, args)
|
||||
local specific = do_callback(self["on_before_" .. event], args)
|
||||
local general = do_callback(self.on_before_event, args)
|
||||
if specific == false or general == false then
|
||||
return false
|
||||
end
|
||||
end
|
||||
local leave_state = function(self, _event, from, _to, args)
|
||||
local specific = do_callback(self["on_leave_" .. from], args)
|
||||
local general = do_callback(self.on_leave_state, args)
|
||||
if specific == false or general == false then
|
||||
return false
|
||||
end
|
||||
if specific == M.DEFERRED or general == M.DEFERRED then
|
||||
return M.DEFERRED
|
||||
end
|
||||
end
|
||||
local enter_state = function(self, _event, _from, to, args)
|
||||
do_callback(self["on_enter_" .. to] or self["on_" .. to], args)
|
||||
do_callback(self.on_enter_state or self.on_state, args)
|
||||
end
|
||||
local after_event = function(self, event, _from, _to, args)
|
||||
do_callback(self["on_after_" .. event] or self["on_" .. event], args)
|
||||
do_callback(self.on_after_event or self.on_event, args)
|
||||
end
|
||||
local build_transition = function(self, event, states)
|
||||
return function(...)
|
||||
local from = self.current
|
||||
local to = states[from] or states[M.WILDCARD] or from
|
||||
local args = {
|
||||
self,
|
||||
event,
|
||||
from,
|
||||
to,
|
||||
...
|
||||
}
|
||||
assert(not self.is_pending(), "previous transition still pending")
|
||||
assert(self.can(event), "invalid transition from state '" .. from .. "' with event '" .. event .. "'")
|
||||
local before = before_event(self, event, from, to, args)
|
||||
if before == false then
|
||||
return M.CANCELLED
|
||||
end
|
||||
if from == to then
|
||||
after_event(self, event, from, to, args)
|
||||
return M.NO_TRANSITION
|
||||
end
|
||||
function self.confirm()
|
||||
self.confirm = nil
|
||||
self.cancel = nil
|
||||
self.current = to
|
||||
enter_state(self, event, from, to, args)
|
||||
after_event(self, event, from, to, args)
|
||||
return M.SUCCEEDED
|
||||
end
|
||||
function self.cancel()
|
||||
self.confirm = nil
|
||||
self.cancel = nil
|
||||
after_event(self, event, from, to, args)
|
||||
return M.CANCELLED
|
||||
end
|
||||
local leave = leave_state(self, event, from, to, args)
|
||||
if leave == false then
|
||||
return M.CANCELLED
|
||||
end
|
||||
if leave == M.DEFERRED then
|
||||
return M.PENDING
|
||||
end
|
||||
if self.confirm then
|
||||
return self.confirm()
|
||||
end
|
||||
end
|
||||
end
|
||||
function M.create(cfg, target)
|
||||
local self = target or {}
|
||||
local initial = cfg.initial
|
||||
initial = type(initial) == "string" and {state = initial} or initial
|
||||
local initial_event = initial and initial.event or "startup"
|
||||
local terminal = cfg.terminal
|
||||
local events = cfg.events or {}
|
||||
local callbacks = cfg.callbacks or {}
|
||||
local states_for_event = {}
|
||||
local events_for_state = {}
|
||||
local add = function(e)
|
||||
local from = type(e.from) == "table" and e.from or e.from and {
|
||||
e.from
|
||||
} or {
|
||||
M.WILDCARD
|
||||
}
|
||||
local to = e.to
|
||||
local event = e.name
|
||||
states_for_event[event] = states_for_event[event] or {}
|
||||
for _, fr in ipairs(from) do
|
||||
events_for_state[fr] = events_for_state[fr] or {}
|
||||
table.insert(events_for_state[fr], event)
|
||||
states_for_event[event][fr] = to or fr
|
||||
end
|
||||
end
|
||||
if initial then
|
||||
add({
|
||||
name = initial_event,
|
||||
from = "none",
|
||||
to = initial.state
|
||||
})
|
||||
end
|
||||
for _, event in ipairs(events) do
|
||||
add(event)
|
||||
end
|
||||
for event, states in pairs(states_for_event) do
|
||||
self[event] = build_transition(self, event, states)
|
||||
end
|
||||
for name, callback in pairs(callbacks) do
|
||||
self[name] = callback
|
||||
end
|
||||
self.current = "none"
|
||||
function self.is(state)
|
||||
if type(state) == "table" then
|
||||
for _, s in ipairs(state) do
|
||||
if self.current == s then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
return self.current == state
|
||||
end
|
||||
function self.can(event)
|
||||
local states = states_for_event[event]
|
||||
local to = states[self.current] or states[M.WILDCARD]
|
||||
return to ~= nil
|
||||
end
|
||||
function self.cannot(event)
|
||||
return not self.can(event)
|
||||
end
|
||||
function self.transitions()
|
||||
return events_for_state[self.current]
|
||||
end
|
||||
function self.is_pending()
|
||||
return self.confirm ~= nil
|
||||
end
|
||||
function self.is_finished()
|
||||
return self.is(terminal)
|
||||
end
|
||||
if initial and not initial.defer then
|
||||
self[initial_event]()
|
||||
end
|
||||
return self
|
||||
end
|
||||
return M
|
||||
@@ -0,0 +1,515 @@
|
||||
function clone(object)
|
||||
local lookup_table = {}
|
||||
local function _copy(object)
|
||||
if type(object) ~= "table" then
|
||||
return object
|
||||
elseif lookup_table[object] then
|
||||
return lookup_table[object]
|
||||
end
|
||||
local new_table = {}
|
||||
lookup_table[object] = new_table
|
||||
for key, value in pairs(object) do
|
||||
new_table[_copy(key)] = _copy(value)
|
||||
end
|
||||
return setmetatable(new_table, getmetatable(object))
|
||||
end
|
||||
return _copy(object)
|
||||
end
|
||||
function class(classname, super)
|
||||
local superType = type(super)
|
||||
local cls
|
||||
if superType ~= "function" and superType ~= "table" then
|
||||
superType = nil
|
||||
end
|
||||
if superType == "function" or super and super.__ctype == 1 then
|
||||
cls = {}
|
||||
if superType == "table" then
|
||||
for k, v in pairs(super) do
|
||||
cls[k] = v
|
||||
end
|
||||
cls.__create = super.__create
|
||||
cls.super = super
|
||||
else
|
||||
cls.__create = super
|
||||
end
|
||||
function cls.ctor()
|
||||
end
|
||||
cls.__cname = classname
|
||||
cls.__ctype = 1
|
||||
function cls.new(...)
|
||||
local instance = cls.__create(...)
|
||||
for k, v in pairs(cls) do
|
||||
instance[k] = v
|
||||
end
|
||||
instance.class = cls
|
||||
instance:ctor(...)
|
||||
return instance
|
||||
end
|
||||
else
|
||||
if super then
|
||||
cls = clone(super)
|
||||
cls.super = super
|
||||
else
|
||||
cls = {
|
||||
ctor = function(...)
|
||||
end
|
||||
}
|
||||
end
|
||||
cls.__cname = classname
|
||||
cls.__ctype = 2
|
||||
cls.__index = cls
|
||||
function cls.new(...)
|
||||
local instance = setmetatable({}, cls)
|
||||
instance.class = cls
|
||||
instance:ctor(...)
|
||||
return instance
|
||||
end
|
||||
end
|
||||
return cls
|
||||
end
|
||||
function import(moduleName, currentModuleName)
|
||||
local currentModuleNameParts
|
||||
local moduleFullName = moduleName
|
||||
local offset = 1
|
||||
while true do
|
||||
if string.byte(moduleName, offset) ~= 46 then
|
||||
moduleFullName = string.sub(moduleName, offset)
|
||||
if currentModuleNameParts and 0 < #currentModuleNameParts then
|
||||
moduleFullName = table.concat(currentModuleNameParts, ".") .. "." .. moduleFullName
|
||||
end
|
||||
break
|
||||
end
|
||||
offset = offset + 1
|
||||
if not currentModuleNameParts then
|
||||
if not currentModuleName then
|
||||
local n, v = debug.getlocal(3, 1)
|
||||
currentModuleName = v
|
||||
end
|
||||
currentModuleNameParts = string.split(currentModuleName, ".")
|
||||
end
|
||||
table.remove(currentModuleNameParts, #currentModuleNameParts)
|
||||
end
|
||||
return require(moduleFullName)
|
||||
end
|
||||
function handler(obj, method, uiComponent)
|
||||
return function(...)
|
||||
if uiComponent == nil then
|
||||
return method(obj, ...)
|
||||
else
|
||||
return method(obj, uiComponent, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ui_handler(obj, method, uiComponent, nIndex)
|
||||
return function(...)
|
||||
if type(nIndex) == "number" then
|
||||
return method(obj, uiComponent, nIndex, ...)
|
||||
else
|
||||
return method(obj, uiComponent, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
function dotween_callback_handler(obj, method, ...)
|
||||
local tbParameter = {}
|
||||
for i = 1, select("#", ...) do
|
||||
local param = select(i, ...)
|
||||
table.insert(tbParameter, param)
|
||||
end
|
||||
return function()
|
||||
if obj ~= nil and type(method) == "function" then
|
||||
local ok, error = pcall(method, obj, table.unpack(tbParameter))
|
||||
if not ok then
|
||||
printError(error)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function safe_call_cs_func(cs_func, ...)
|
||||
local tbParameter = {}
|
||||
for i = 1, select("#", ...) do
|
||||
local param = select(i, ...)
|
||||
table.insert(tbParameter, param)
|
||||
end
|
||||
local ok, result = pcall(cs_func, table.unpack(tbParameter))
|
||||
if not ok then
|
||||
printError(result)
|
||||
else
|
||||
return result
|
||||
end
|
||||
end
|
||||
function safe_call_cs_func2(cs_func, ...)
|
||||
local tbParameter = {}
|
||||
for i = 1, select("#", ...) do
|
||||
local param = select(i, ...)
|
||||
table.insert(tbParameter, param)
|
||||
end
|
||||
local tbResult = {
|
||||
pcall(cs_func, table.unpack(tbParameter))
|
||||
}
|
||||
if not tbResult[1] then
|
||||
printError(tbResult[2])
|
||||
else
|
||||
table.remove(tbResult, 1)
|
||||
return table.unpack(tbResult)
|
||||
end
|
||||
end
|
||||
function table.nums(t)
|
||||
local count = 0
|
||||
for k, v in pairs(t) do
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
function table.keys(hashtable)
|
||||
local keys = {}
|
||||
for k, v in pairs(hashtable) do
|
||||
keys[#keys + 1] = k
|
||||
end
|
||||
return keys
|
||||
end
|
||||
function table.values(hashtable)
|
||||
local values = {}
|
||||
for k, v in pairs(hashtable) do
|
||||
if v ~= json.null then
|
||||
values[#values + 1] = v
|
||||
end
|
||||
end
|
||||
return values
|
||||
end
|
||||
function table.merge(dest, src)
|
||||
for k, v in pairs(src) do
|
||||
dest[k] = v
|
||||
end
|
||||
end
|
||||
function table.insertto(dest, src, begin)
|
||||
begin = checkint(begin)
|
||||
if begin <= 0 then
|
||||
begin = #dest + 1
|
||||
end
|
||||
local len = #src
|
||||
for i = 0, len - 1 do
|
||||
dest[i + begin] = src[i + 1]
|
||||
end
|
||||
end
|
||||
function checknumber(value, base)
|
||||
return tonumber(value, base) or 0
|
||||
end
|
||||
function checkint(value)
|
||||
return math.round(checknumber(value))
|
||||
end
|
||||
function math.round(value)
|
||||
value = checknumber(value)
|
||||
return math.floor(value + 0.5)
|
||||
end
|
||||
function checkbool(value)
|
||||
return value ~= nil and value ~= false
|
||||
end
|
||||
function checktable(value)
|
||||
if type(value) ~= "table" then
|
||||
value = {}
|
||||
end
|
||||
return value
|
||||
end
|
||||
function isset(hashtable, key)
|
||||
local t = type(hashtable)
|
||||
return (t == "table" or t == "userdata") and hashtable[key] ~= nil
|
||||
end
|
||||
function table.indexof(array, value, begin)
|
||||
for i = begin or 1, #array do
|
||||
if array[i] == value then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
function table.keyof(hashtable, value)
|
||||
for k, v in pairs(hashtable) do
|
||||
if v == value then
|
||||
return k
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
function table.removebyvalue(array, value, removeall)
|
||||
local c, i, max = 0, 1, #array
|
||||
while i <= max do
|
||||
if array[i] == value then
|
||||
table.remove(array, i)
|
||||
c = c + 1
|
||||
i = i - 1
|
||||
max = max - 1
|
||||
if not removeall then
|
||||
break
|
||||
end
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
return c
|
||||
end
|
||||
function table.map(t, fn)
|
||||
for k, v in pairs(t) do
|
||||
t[k] = fn(v, k)
|
||||
end
|
||||
end
|
||||
function table.walk(t, fn)
|
||||
for k, v in pairs(t) do
|
||||
fn(v, k)
|
||||
end
|
||||
end
|
||||
function table.shuffle(t)
|
||||
local n = #t
|
||||
while 2 < n do
|
||||
local k = math.random(n)
|
||||
t[n], t[k] = t[k], t[n]
|
||||
n = n - 1
|
||||
end
|
||||
return t
|
||||
end
|
||||
function table.filter(t, fn)
|
||||
for k, v in pairs(t) do
|
||||
if not fn(v, k) then
|
||||
t[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
function table.unique(t, bArray)
|
||||
local check = {}
|
||||
local n = {}
|
||||
local idx = 1
|
||||
for k, v in pairs(t) do
|
||||
if not check[v] then
|
||||
if bArray then
|
||||
n[idx] = v
|
||||
idx = idx + 1
|
||||
else
|
||||
n[k] = v
|
||||
end
|
||||
check[v] = true
|
||||
end
|
||||
end
|
||||
return n
|
||||
end
|
||||
function string.htmlspecialchars(input)
|
||||
for k, v in pairs(string._htmlspecialchars_set) do
|
||||
input = string.gsub(input, k, v)
|
||||
end
|
||||
return input
|
||||
end
|
||||
function string.restorehtmlspecialchars(input)
|
||||
for k, v in pairs(string._htmlspecialchars_set) do
|
||||
input = string.gsub(input, v, k)
|
||||
end
|
||||
return input
|
||||
end
|
||||
function string.nl2br(input)
|
||||
return string.gsub(input, "\n", "<br />")
|
||||
end
|
||||
function string.text2html(input)
|
||||
input = string.gsub(input, "\t", " ")
|
||||
input = string.htmlspecialchars(input)
|
||||
input = string.gsub(input, " ", " ")
|
||||
input = string.nl2br(input)
|
||||
return input
|
||||
end
|
||||
function string.split(input, delimiter)
|
||||
input = tostring(input)
|
||||
delimiter = tostring(delimiter)
|
||||
if delimiter == "" then
|
||||
return false
|
||||
end
|
||||
local pos, arr = 0, {}
|
||||
for st, sp in function()
|
||||
return string.find(input, delimiter, pos, true)
|
||||
end, nil, nil do
|
||||
table.insert(arr, string.sub(input, pos, st - 1))
|
||||
pos = sp + 1
|
||||
end
|
||||
table.insert(arr, string.sub(input, pos))
|
||||
return arr
|
||||
end
|
||||
function string.ltrim(input)
|
||||
return string.gsub(input, "^[ \t\n\r]+", "")
|
||||
end
|
||||
function string.rtrim(input)
|
||||
return string.gsub(input, "[ \t\n\r]+$", "")
|
||||
end
|
||||
function string.trim(input)
|
||||
input = string.gsub(input, "^[ \t\n\r]+", "")
|
||||
return string.gsub(input, "[ \t\n\r]+$", "")
|
||||
end
|
||||
function string.ucfirst(input)
|
||||
return string.upper(string.sub(input, 1, 1)) .. string.sub(input, 2)
|
||||
end
|
||||
local urlencodechar = function(char)
|
||||
return "%" .. string.format("%02X", string.byte(char))
|
||||
end
|
||||
function string.urlencode(input)
|
||||
input = string.gsub(tostring(input), "\n", "\r\n")
|
||||
input = string.gsub(input, "([^%w%.%- ])", urlencodechar)
|
||||
return string.gsub(input, " ", "+")
|
||||
end
|
||||
function string.urldecode(input)
|
||||
input = string.gsub(input, "+", " ")
|
||||
input = string.gsub(input, "%%(%x%x)", function(h)
|
||||
return string.char(checknumber(h, 16))
|
||||
end)
|
||||
input = string.gsub(input, "\r\n", "\n")
|
||||
return input
|
||||
end
|
||||
function string.utf8len(input)
|
||||
local len = string.len(input)
|
||||
local left = len
|
||||
local cnt = 0
|
||||
local arr = {
|
||||
0,
|
||||
192,
|
||||
224,
|
||||
240,
|
||||
248,
|
||||
252
|
||||
}
|
||||
while left ~= 0 do
|
||||
local tmp = string.byte(input, -left)
|
||||
local i = #arr
|
||||
while arr[i] do
|
||||
if tmp >= arr[i] then
|
||||
left = left - i
|
||||
break
|
||||
end
|
||||
i = i - 1
|
||||
end
|
||||
cnt = cnt + 1
|
||||
end
|
||||
return cnt
|
||||
end
|
||||
function string.formatnumberthousands(num)
|
||||
local formatted = tostring(checknumber(num))
|
||||
local k
|
||||
while true do
|
||||
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", "%1,%2")
|
||||
if k == 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
return formatted
|
||||
end
|
||||
function string.append_all(buffer, ...)
|
||||
for i = 1, select("#", ...) do
|
||||
table.insert(buffer, (select(i, ...)))
|
||||
end
|
||||
end
|
||||
function print_dump(data, showMetatable, lastCount)
|
||||
if type(data) ~= "table" then
|
||||
if type(data) == "string" then
|
||||
print("\"", data, "\"")
|
||||
else
|
||||
print(tostring(data))
|
||||
end
|
||||
else
|
||||
local count = lastCount or 0
|
||||
count = count + 1
|
||||
print("{\n")
|
||||
if showMetatable then
|
||||
for i = 1, count do
|
||||
print("\t")
|
||||
end
|
||||
local mt = getmetatable(data)
|
||||
print("\"__metatable\" = ")
|
||||
print_dump(mt, showMetatable, count)
|
||||
print(",\n")
|
||||
end
|
||||
for key, value in pairs(data) do
|
||||
for i = 1, count do
|
||||
print("\t")
|
||||
end
|
||||
if type(key) == "string" then
|
||||
print("\"", key, "\" = ")
|
||||
elseif type(key) == "number" then
|
||||
print("[", key, "] = ")
|
||||
else
|
||||
print(tostring(key))
|
||||
end
|
||||
print_dump(value, showMetatable, count)
|
||||
print(",\n")
|
||||
end
|
||||
for i = 1, lastCount or 0 do
|
||||
print("\t")
|
||||
end
|
||||
print("}")
|
||||
end
|
||||
if not lastCount then
|
||||
print("\n")
|
||||
end
|
||||
end
|
||||
function setfenv(fn, env)
|
||||
local i = 1
|
||||
while true do
|
||||
local name = debug.getupvalue(fn, i)
|
||||
if name == "_ENV" then
|
||||
debug.upvaluejoin(fn, i, function()
|
||||
return env
|
||||
end, 1)
|
||||
break
|
||||
elseif not name then
|
||||
break
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
return fn
|
||||
end
|
||||
function getfenv(fn)
|
||||
local i = 1
|
||||
while true do
|
||||
local name, val = debug.getupvalue(fn, i)
|
||||
if name == "_ENV" then
|
||||
return val
|
||||
elseif not name then
|
||||
break
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
function run_with_env(env, fn, ...)
|
||||
setfenv(fn, env)
|
||||
fn(...)
|
||||
end
|
||||
local sortedKeys = function(t)
|
||||
local keys = {}
|
||||
for k in pairs(t) do
|
||||
if type(k) == "number" then
|
||||
table.insert(keys, k)
|
||||
end
|
||||
end
|
||||
table.sort(keys)
|
||||
return keys
|
||||
end
|
||||
function ipairsSorted(t)
|
||||
local keys = sortedKeys(t)
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
if keys[i] then
|
||||
return keys[i], t[keys[i]]
|
||||
end
|
||||
end
|
||||
end
|
||||
function orderedFormat(formatStr, ...)
|
||||
local args = {
|
||||
...
|
||||
}
|
||||
return (formatStr:gsub("{(%d+)}", function(index)
|
||||
index = tonumber(index) + 1
|
||||
return tostring(args[index])
|
||||
end))
|
||||
end
|
||||
function clearFloat(a)
|
||||
local floor = math.floor(a)
|
||||
local ceil = math.ceil(a)
|
||||
if math.abs(a - floor) < 1.0E-10 then
|
||||
return floor
|
||||
end
|
||||
if math.abs(a - ceil) < 1.0E-10 then
|
||||
return ceil
|
||||
end
|
||||
return a
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,755 @@
|
||||
local BubbleVoiceManager = {}
|
||||
local File = CS.System.IO.File
|
||||
local RapidJson = require("rapidjson")
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local PlayerBaseData = PlayerData.Base
|
||||
local map_BubbleData = {}
|
||||
local map_BubbleOffset = {}
|
||||
local map_VoResLen = {}
|
||||
local mapDisplayData = {
|
||||
{
|
||||
0,
|
||||
"",
|
||||
""
|
||||
},
|
||||
{
|
||||
0,
|
||||
"",
|
||||
""
|
||||
},
|
||||
{
|
||||
0,
|
||||
"",
|
||||
""
|
||||
},
|
||||
{
|
||||
0,
|
||||
"",
|
||||
""
|
||||
}
|
||||
}
|
||||
local mapDisplayOffset = {
|
||||
left = true,
|
||||
x = 0,
|
||||
y = 0,
|
||||
cgLeft = true,
|
||||
cgX = 0,
|
||||
cgY = 0
|
||||
}
|
||||
local nCurTxtLanIndex = GetLanguageIndex(Settings.sCurrentTxtLanguage)
|
||||
local sLanFolder = GetLanguageSurfixByIndex(nCurTxtLanIndex)
|
||||
local sPath_BubbleData = ""
|
||||
local sPath_BubbleOffset = ""
|
||||
local sPath_VoResLen = ""
|
||||
local InUnityEditor = NovaAPI.IsEditorPlatform()
|
||||
local bLoaded = false
|
||||
local LoadAll = function()
|
||||
if InUnityEditor == true then
|
||||
sPath_BubbleData = NovaAPI.ApplicationDataPath .. "/../../GameDataTables/text_data/bubble/" .. sLanFolder .. "/BubbleData.json"
|
||||
sPath_BubbleOffset = NovaAPI.ApplicationDataPath .. "/../../GameDataTables/text_data/bubble/BubbleOffset.json"
|
||||
sPath_VoResLen = NovaAPI.ApplicationDataPath .. "/../../GameDataTables/text_data/bubble/VoResLen.json"
|
||||
elseif RUNNING_BBV_EDITOR == true then
|
||||
sPath_BubbleData = NovaAPI.StreamingAssetsPath .. "/../../../" .. sLanFolder .. "/BBV/BubbleData.json"
|
||||
sPath_BubbleOffset = NovaAPI.StreamingAssetsPath .. "/../../../_cn/BBV/BubbleOffset.json"
|
||||
sPath_VoResLen = NovaAPI.StreamingAssetsPath .. "/../../../_cn/BBV/VoResLen.json"
|
||||
else
|
||||
sPath_BubbleData = "bubble/" .. sLanFolder .. "/BubbleData.json"
|
||||
sPath_BubbleOffset = "bubble/BubbleOffset.json"
|
||||
sPath_VoResLen = "bubble/VoResLen.json"
|
||||
end
|
||||
local sJsonText
|
||||
if InUnityEditor == true or RUNNING_BBV_EDITOR == true then
|
||||
sJsonText = File.ReadAllText(sPath_BubbleData)
|
||||
map_BubbleData = RapidJson.decode(sJsonText)
|
||||
sJsonText = File.ReadAllText(sPath_BubbleOffset)
|
||||
map_BubbleOffset = RapidJson.decode(sJsonText)
|
||||
sJsonText = File.ReadAllText(sPath_VoResLen)
|
||||
map_VoResLen = RapidJson.decode(sJsonText)
|
||||
else
|
||||
sJsonText = NovaAPI.LoadTextData(sPath_BubbleData)
|
||||
map_BubbleData = RapidJson.decode(sJsonText)
|
||||
sJsonText = NovaAPI.LoadTextData(sPath_BubbleOffset)
|
||||
map_BubbleOffset = RapidJson.decode(sJsonText)
|
||||
sJsonText = NovaAPI.LoadTextData(sPath_VoResLen)
|
||||
map_VoResLen = RapidJson.decode(sJsonText)
|
||||
end
|
||||
bLoaded = true
|
||||
end
|
||||
local map_BubbleData_Cn, map_BubbleData_Jp
|
||||
local LoadSpecificData = function(sLanFolder)
|
||||
local sPath
|
||||
if InUnityEditor == true then
|
||||
sPath = NovaAPI.ApplicationDataPath .. "/../../GameDataTables/text_data/bubble/" .. sLanFolder .. "/BubbleData.json"
|
||||
elseif RUNNING_BBV_EDITOR == true then
|
||||
sPath = NovaAPI.StreamingAssetsPath .. "/../../../" .. sLanFolder .. "/BBV/BubbleData.json"
|
||||
else
|
||||
sPath = "text_data/bubble/" .. sLanFolder .. "/BubbleData.json"
|
||||
end
|
||||
local sJsonText
|
||||
if InUnityEditor == true or RUNNING_BBV_EDITOR == true then
|
||||
sJsonText = File.ReadAllText(sPath)
|
||||
else
|
||||
sJsonText = NovaAPI.LoadTableData(sPath)
|
||||
end
|
||||
return RapidJson.decode(sJsonText)
|
||||
end
|
||||
local tbCheckOrder, _sVoLan, _bIsMale
|
||||
function GetCheckOrder()
|
||||
local sVoLan = Settings.sCurrentVoLanguage
|
||||
local bIsMale = PlayerBaseData:GetPlayerSex()
|
||||
if _sVoLan ~= sVoLan or _bIsMale ~= bIsMale then
|
||||
_sVoLan = sVoLan
|
||||
_bIsMale = bIsMale
|
||||
tbCheckOrder = nil
|
||||
end
|
||||
if tbCheckOrder == nil then
|
||||
local sTextLan = Settings.sCurrentTxtLanguage
|
||||
local tbTemp = {}
|
||||
if sTextLan == AllEnum.Language.CN then
|
||||
table.insert(tbTemp, "female_cn")
|
||||
if bIsMale == true then
|
||||
table.insert(tbTemp, "male_cn")
|
||||
end
|
||||
if sVoLan == AllEnum.Language.JP then
|
||||
table.insert(tbTemp, "female_jp")
|
||||
if bIsMale == true then
|
||||
table.insert(tbTemp, "male_jp")
|
||||
end
|
||||
end
|
||||
elseif sTextLan == AllEnum.Language.JP then
|
||||
table.insert(tbTemp, "female_jp")
|
||||
if bIsMale == true then
|
||||
table.insert(tbTemp, "male_jp")
|
||||
end
|
||||
elseif sTextLan == AllEnum.Language.TW or sTextLan == AllEnum.Language.EN or sTextLan == AllEnum.Language.KR then
|
||||
table.insert(tbTemp, "female_jp")
|
||||
if bIsMale == true then
|
||||
table.insert(tbTemp, "male_jp")
|
||||
end
|
||||
if sVoLan == AllEnum.Language.CN then
|
||||
table.insert(tbTemp, "female_cn")
|
||||
if bIsMale == true then
|
||||
table.insert(tbTemp, "male_cn")
|
||||
end
|
||||
end
|
||||
end
|
||||
tbCheckOrder = {}
|
||||
for i = #tbTemp, 1, -1 do
|
||||
table.insert(tbCheckOrder, tbTemp[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
local tbDefaultText = {
|
||||
"error",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
}
|
||||
local GetText = function(mapTextData)
|
||||
local nCheckTotal = #tbCheckOrder
|
||||
for i = 1, nCheckTotal do
|
||||
local _sKey = tbCheckOrder[i]
|
||||
local _tbText = mapTextData[_sKey]
|
||||
if type(_tbText) == "table" and type(_tbText[1]) == "string" and _tbText[1] ~= "" then
|
||||
return _tbText
|
||||
end
|
||||
end
|
||||
return tbDefaultText
|
||||
end
|
||||
local tbDefaultTime = {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
}
|
||||
local GetTime = function(mapTimeData)
|
||||
local nCheckTotal = #tbCheckOrder
|
||||
for i = 1, nCheckTotal do
|
||||
local _sKey = tbCheckOrder[i]
|
||||
local _tbTime = mapTimeData[_sKey]
|
||||
if type(_tbTime) == "table" and type(_tbTime[1]) == "number" and _tbTime[1] > 0 then
|
||||
return _tbTime
|
||||
end
|
||||
end
|
||||
return tbDefaultTime
|
||||
end
|
||||
local tbDefaultAnim = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
}
|
||||
local GetAnim = function(mapAnimData)
|
||||
local func_Available = function(_tb)
|
||||
if type(_tb) == "table" then
|
||||
for ii, vv in ipairs(_tb) do
|
||||
if type(vv) == "string" and vv ~= "" then
|
||||
return _tb
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local nCheckTotal = #tbCheckOrder
|
||||
for i = 1, nCheckTotal do
|
||||
local _sKey = tbCheckOrder[i]
|
||||
local _tbAnim = mapAnimData[_sKey]
|
||||
_tbAnim = func_Available(_tbAnim)
|
||||
if _tbAnim ~= nil then
|
||||
return _tbAnim
|
||||
end
|
||||
end
|
||||
return tbDefaultAnim
|
||||
end
|
||||
local GetBubbleData = function(sVoResName, nCharSkinId, bTextOnly)
|
||||
if bLoaded ~= true then
|
||||
LoadAll()
|
||||
end
|
||||
GetCheckOrder()
|
||||
local data = map_BubbleData[sVoResName]
|
||||
if data == nil then
|
||||
printError("气泡语音 数据未配置:" .. sVoResName)
|
||||
return false
|
||||
end
|
||||
local tbTextData = GetText(data.text)
|
||||
if bTextOnly == true then
|
||||
return true, tbTextData
|
||||
end
|
||||
local tbTimeData = GetTime(data.time)
|
||||
local tbAnimData = GetAnim(data.anim)
|
||||
for i = 1, 4 do
|
||||
mapDisplayData[i][1] = 1 < i and tbTimeData[i] - tbTimeData[i - 1] or tbTimeData[i]
|
||||
mapDisplayData[i][2] = tbTextData[i]
|
||||
mapDisplayData[i][3] = tbAnimData[i]
|
||||
end
|
||||
local offset, offset_
|
||||
if type(nCharSkinId) == "number" then
|
||||
offset = map_BubbleOffset[tostring(nCharSkinId)]
|
||||
local mapCfgData_CharacterSkin = ConfigTable.GetData("CharacterSkin", nCharSkinId)
|
||||
if mapCfgData_CharacterSkin ~= nil and mapCfgData_CharacterSkin.Type == GameEnum.skinType.ADVANCE then
|
||||
local mapCfgData_Character = ConfigTable.GetData("Character", mapCfgData_CharacterSkin.CharId)
|
||||
if mapCfgData_Character ~= nil then
|
||||
local nCharDefaultSkinId = mapCfgData_Character.DefaultSkinId
|
||||
if type(nCharDefaultSkinId) == "number" then
|
||||
offset_ = map_BubbleOffset[tostring(nCharDefaultSkinId)]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
mapDisplayOffset.left = offset == nil and true or offset.left
|
||||
mapDisplayOffset.x = offset == nil and 0 or offset.x
|
||||
mapDisplayOffset.y = offset == nil and 0 or offset.y
|
||||
mapDisplayOffset.cgLeft = offset == nil and true or offset.cgLeft
|
||||
mapDisplayOffset.cgX = offset == nil and 0 or offset.cgX
|
||||
mapDisplayOffset.cgY = offset == nil and 0 or offset.cgY
|
||||
if offset_ ~= nil then
|
||||
mapDisplayOffset.cgLeft = offset_.cgLeft
|
||||
mapDisplayOffset.cgX = offset_.cgX
|
||||
mapDisplayOffset.cgY = offset_.cgY
|
||||
end
|
||||
return true
|
||||
end
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
local CheckEnable = function()
|
||||
local sBool = LocalData.GetPlayerLocalData("BubbleVoiceEnable")
|
||||
return sBool == nil or sBool == "true"
|
||||
end
|
||||
local anim, TMP, nCurIndex, timer, nCharIdx
|
||||
local function SetBubble()
|
||||
if anim == nil or TMP == nil then
|
||||
return
|
||||
end
|
||||
local bBubbleDone = false
|
||||
nCurIndex = nCurIndex + 1
|
||||
local tbData = mapDisplayData[nCurIndex]
|
||||
if tbData ~= nil then
|
||||
local nTime = tbData[1]
|
||||
local sText = tbData[2]
|
||||
local sAnim = tbData[3]
|
||||
if sText ~= "" and 0 < nTime then
|
||||
sText = string.gsub(sText, "==RT==", "\n")
|
||||
sText = string.gsub(sText, "==PLAYER_NAME==", PlayerBaseData:GetPlayerNickName())
|
||||
NovaAPI.SetTMPText(TMP, sText)
|
||||
anim:Play("bb_in", -1, 0)
|
||||
if sAnim ~= "" then
|
||||
if RUNNING_BBV_EDITOR == true then
|
||||
Actor2DManager.PlayL2DAnim_InBBVEditor(sAnim)
|
||||
else
|
||||
Actor2DManager.PlayAnim(sAnim, true, nCharIdx)
|
||||
end
|
||||
end
|
||||
timer = TimerManager.Add(1, nTime, nil, SetBubble, true, true, true, nil)
|
||||
else
|
||||
bBubbleDone = true
|
||||
end
|
||||
else
|
||||
bBubbleDone = true
|
||||
end
|
||||
if bBubbleDone == true then
|
||||
anim:Play("bb_out", -1, 0)
|
||||
anim = nil
|
||||
TMP = nil
|
||||
timer = nil
|
||||
end
|
||||
end
|
||||
function BubbleVoiceManager.Init(bEditor)
|
||||
if bEditor == true then
|
||||
LoadAll()
|
||||
if Settings.sCurrentTxtLanguage ~= AllEnum.Language.CN and Settings.sCurrentTxtLanguage ~= AllEnum.Language.JP then
|
||||
map_BubbleData_Cn = LoadSpecificData("_cn")
|
||||
map_BubbleData_Jp = LoadSpecificData("_jp")
|
||||
end
|
||||
end
|
||||
end
|
||||
function BubbleVoiceManager.PlayBubbleAnim(goBubbleRoot, sVoResName, nCharSkinId, bIsCG, nCharIndex)
|
||||
if nCharIndex == nil then
|
||||
nCharIndex = 1
|
||||
end
|
||||
nCharIdx = nCharIndex
|
||||
if CheckEnable() == false then
|
||||
return
|
||||
end
|
||||
BubbleVoiceManager.StopBubbleAnim(true)
|
||||
if goBubbleRoot == nil or goBubbleRoot:IsNull() == true then
|
||||
return
|
||||
end
|
||||
if GetBubbleData(sVoResName, nCharSkinId) == true then
|
||||
local tr
|
||||
local bIsLeft = false
|
||||
if bIsCG == true then
|
||||
bIsLeft = mapDisplayOffset.cgLeft
|
||||
else
|
||||
bIsLeft = mapDisplayOffset.left
|
||||
end
|
||||
local n = bIsLeft == true and 0 or 1
|
||||
for i = 0, 1 do
|
||||
local trBubble = goBubbleRoot.transform:GetChild(i)
|
||||
trBubble.gameObject:SetActive(i == n)
|
||||
if i == n then
|
||||
tr = trBubble
|
||||
end
|
||||
end
|
||||
if tr ~= nil then
|
||||
local x = bIsCG == true and mapDisplayOffset.cgX or mapDisplayOffset.x
|
||||
local y = bIsCG == true and mapDisplayOffset.cgY or mapDisplayOffset.y
|
||||
local rt = goBubbleRoot:GetComponent("RectTransform")
|
||||
rt.anchoredPosition = Vector2(x, y)
|
||||
anim = tr:GetComponent("Animator")
|
||||
TMP = tr:GetComponentInChildren(typeof(CS.TMPro.TMP_Text))
|
||||
nCurIndex = 0
|
||||
SetBubble()
|
||||
end
|
||||
end
|
||||
end
|
||||
function BubbleVoiceManager.StopBubbleAnim(bNoAnim)
|
||||
if CheckEnable() == false then
|
||||
return
|
||||
end
|
||||
if anim ~= nil then
|
||||
if bNoAnim ~= true then
|
||||
anim:Play("bb_out", -1, 0)
|
||||
end
|
||||
anim = nil
|
||||
end
|
||||
if timer ~= nil then
|
||||
timer:Cancel()
|
||||
timer = nil
|
||||
end
|
||||
TMP = nil
|
||||
Actor2DManager.PlayAnim("idle", true, nCharIdx)
|
||||
end
|
||||
function BubbleVoiceManager.PauseBubbleAnim()
|
||||
if CheckEnable() == false then
|
||||
return
|
||||
end
|
||||
if timer ~= nil then
|
||||
timer:Pause(true)
|
||||
end
|
||||
end
|
||||
function BubbleVoiceManager.ResumeBubbleAnim()
|
||||
if CheckEnable() == false then
|
||||
return
|
||||
end
|
||||
if timer ~= nil then
|
||||
timer:Pause(false)
|
||||
end
|
||||
end
|
||||
function BubbleVoiceManager.PlayFixedBubbleAnim(goBubbleRoot, sVoResName, nCharIndex)
|
||||
if nCharIndex == nil then
|
||||
nCharIndex = 1
|
||||
end
|
||||
nCharIdx = nCharIndex
|
||||
if CheckEnable() == false then
|
||||
return
|
||||
end
|
||||
BubbleVoiceManager.StopBubbleAnim(true)
|
||||
if goBubbleRoot == nil or goBubbleRoot:IsNull() == true then
|
||||
return
|
||||
end
|
||||
if GetBubbleData(sVoResName) == true then
|
||||
anim = goBubbleRoot:GetComponent("Animator")
|
||||
TMP = goBubbleRoot:GetComponentInChildren(typeof(CS.TMPro.TMP_Text))
|
||||
nCurIndex = 0
|
||||
SetBubble()
|
||||
end
|
||||
end
|
||||
function BubbleVoiceManager.GetBubbleText(sVoResName)
|
||||
local tb = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
}
|
||||
if type(sVoResName) == "string" and sVoResName ~= "" then
|
||||
if CacheTable.GetData("_CharGetLines", "vo_103_ui_gachaNew_001") == nil then
|
||||
local func_Parse_CharGetLines = function(mapData)
|
||||
CacheTable.SetData("_CharGetLines", mapData.voResource, mapData)
|
||||
end
|
||||
ForEachTableLine(DataTable.CharGetLines, func_Parse_CharGetLines)
|
||||
end
|
||||
local mapData = CacheTable.GetData("_CharGetLines", sVoResName)
|
||||
if mapData ~= nil then
|
||||
local sContent = mapData.Lines
|
||||
local sContent = string.gsub(sContent, "==PLAYER_NAME==", PlayerBaseData:GetPlayerNickName())
|
||||
tb[1] = sContent
|
||||
return tb
|
||||
end
|
||||
end
|
||||
return tb
|
||||
end
|
||||
function BubbleVoiceManager.GetVoResLen(sVoResName)
|
||||
if type(map_VoResLen) == "table" then
|
||||
local nCurTxtLanIndex = GetLanguageIndex(Settings.sCurrentTxtLanguage)
|
||||
local sLanFolder = GetLanguageSurfixByIndex(nCurTxtLanIndex)
|
||||
local nDuration = map_VoResLen[sVoResName .. sLanFolder]
|
||||
if nDuration == nil then
|
||||
nDuration = 0
|
||||
end
|
||||
return nDuration
|
||||
end
|
||||
end
|
||||
local mapDisplayData_EX = {
|
||||
{
|
||||
0,
|
||||
"",
|
||||
""
|
||||
},
|
||||
{
|
||||
0,
|
||||
"",
|
||||
""
|
||||
},
|
||||
{
|
||||
0,
|
||||
"",
|
||||
""
|
||||
},
|
||||
{
|
||||
0,
|
||||
"",
|
||||
""
|
||||
}
|
||||
}
|
||||
local mapDisplayOffset_EX = {
|
||||
left = true,
|
||||
x = 0,
|
||||
y = 0,
|
||||
cgLeft = true,
|
||||
cgX = 0,
|
||||
cgY = 0
|
||||
}
|
||||
local anim_EX, TMP_EX, nCurIndex_EX, timer_EX
|
||||
local GetBubbleData_EX = function(sVoResName, nCharSkinId, bTextOnly)
|
||||
if bLoaded ~= true then
|
||||
LoadAll()
|
||||
end
|
||||
GetCheckOrder()
|
||||
local data = map_BubbleData[sVoResName]
|
||||
if data == nil then
|
||||
printError("气泡语音 数据未配置:" .. sVoResName)
|
||||
return false
|
||||
end
|
||||
local tbTextData = GetText(data.text)
|
||||
if bTextOnly == true then
|
||||
return true, tbTextData
|
||||
end
|
||||
local tbTimeData = GetTime(data.time)
|
||||
local tbAnimData = GetAnim(data.anim)
|
||||
for i = 1, 4 do
|
||||
mapDisplayData_EX[i][1] = 1 < i and tbTimeData[i] - tbTimeData[i - 1] or tbTimeData[i]
|
||||
mapDisplayData_EX[i][2] = tbTextData[i]
|
||||
mapDisplayData_EX[i][3] = tbAnimData[i]
|
||||
end
|
||||
local offset
|
||||
if type(nCharSkinId) == "number" then
|
||||
offset = map_BubbleOffset[tostring(nCharSkinId)]
|
||||
end
|
||||
mapDisplayOffset_EX.left = offset == nil and true or offset.left
|
||||
mapDisplayOffset_EX.x = offset == nil and 0 or offset.x
|
||||
mapDisplayOffset_EX.y = offset == nil and 0 or offset.y
|
||||
mapDisplayOffset_EX.cgLeft = offset == nil and true or offset.cgLeft
|
||||
mapDisplayOffset_EX.cgX = offset == nil and 0 or offset.cgX
|
||||
mapDisplayOffset_EX.cgY = offset == nil and 0 or offset.cgY
|
||||
return true
|
||||
end
|
||||
local function SetBubble_EX()
|
||||
if anim_EX == nil or TMP_EX == nil then
|
||||
return
|
||||
end
|
||||
local bBubbleDone = false
|
||||
nCurIndex_EX = nCurIndex_EX + 1
|
||||
local tbData = mapDisplayData_EX[nCurIndex_EX]
|
||||
if tbData ~= nil then
|
||||
local nTime = tbData[1]
|
||||
local sText = tbData[2]
|
||||
local sAnim = tbData[3]
|
||||
if sText ~= "" and 0 < nTime then
|
||||
sText = string.gsub(sText, "==RT==", "\n")
|
||||
sText = string.gsub(sText, "==PLAYER_NAME==", PlayerBaseData:GetPlayerNickName())
|
||||
NovaAPI.SetTMPText(TMP_EX, sText)
|
||||
anim_EX:Play("bb_in", -1, 0)
|
||||
if sAnim ~= "" then
|
||||
if RUNNING_BBV_EDITOR == true then
|
||||
Actor2DManager.PlayL2DAnim_InBBVEditor(sAnim)
|
||||
else
|
||||
Actor2DManager.PlayAnim(sAnim, true, 2)
|
||||
end
|
||||
end
|
||||
timer_EX = TimerManager.Add(1, nTime, nil, SetBubble_EX, true, true, true, nil)
|
||||
else
|
||||
bBubbleDone = true
|
||||
end
|
||||
else
|
||||
bBubbleDone = true
|
||||
end
|
||||
if bBubbleDone == true then
|
||||
anim_EX:Play("bb_out", -1, 0)
|
||||
anim_EX = nil
|
||||
TMP_EX = nil
|
||||
timer_EX = nil
|
||||
end
|
||||
end
|
||||
function BubbleVoiceManager.PlayFixedBubbleAnim_EX(goBubbleRoot, sVoResName)
|
||||
if CheckEnable() == false then
|
||||
return
|
||||
end
|
||||
sVoResName = sVoResName .. "_EX"
|
||||
BubbleVoiceManager.StopBubbleAnim_EX(true)
|
||||
if goBubbleRoot == nil or goBubbleRoot:IsNull() == true then
|
||||
return
|
||||
end
|
||||
if GetBubbleData_EX(sVoResName) == true then
|
||||
anim_EX = goBubbleRoot:GetComponent("Animator")
|
||||
TMP_EX = goBubbleRoot:GetComponentInChildren(typeof(CS.TMPro.TMP_Text))
|
||||
nCurIndex_EX = 0
|
||||
SetBubble_EX()
|
||||
end
|
||||
end
|
||||
function BubbleVoiceManager.StopBubbleAnim_EX(bNoAnim)
|
||||
if CheckEnable() == false then
|
||||
return
|
||||
end
|
||||
if anim_EX ~= nil then
|
||||
if bNoAnim ~= true then
|
||||
anim_EX:Play("bb_out", -1, 0)
|
||||
end
|
||||
anim_EX = nil
|
||||
end
|
||||
if timer_EX ~= nil then
|
||||
timer_EX:Cancel()
|
||||
timer_EX = nil
|
||||
end
|
||||
TMP_EX = nil
|
||||
Actor2DManager.PlayAnim("idle", true, 2)
|
||||
end
|
||||
local WriteToJsonFile = function(sPath, sJsonText)
|
||||
local fs = CS.System.IO.FileStream(sPath, CS.System.IO.FileMode.Create)
|
||||
local sw = CS.System.IO.StreamWriter(fs, CS.System.Text.UTF8Encoding(false))
|
||||
sw:Write(sJsonText)
|
||||
sw:Close()
|
||||
fs:Close()
|
||||
end
|
||||
local sEditingVoResName
|
||||
function BubbleVoiceManager.GetBubbleData_All(sVoResName)
|
||||
sEditingVoResName = sVoResName
|
||||
local mapEditingData = map_BubbleData[sVoResName]
|
||||
local bIsNewData = mapEditingData == nil
|
||||
if bIsNewData == true then
|
||||
mapEditingData = {
|
||||
text = {
|
||||
male_cn = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
},
|
||||
female_cn = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
},
|
||||
male_jp = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
},
|
||||
female_jp = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
}
|
||||
},
|
||||
time = {
|
||||
male_cn = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
},
|
||||
female_cn = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
},
|
||||
male_jp = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
},
|
||||
female_jp = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
}
|
||||
},
|
||||
anim = {
|
||||
male_cn = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
},
|
||||
female_cn = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
},
|
||||
male_jp = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
},
|
||||
female_jp = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
return mapEditingData, bIsNewData
|
||||
end
|
||||
function BubbleVoiceManager.GetReuseData(sLan)
|
||||
if sEditingVoResName == nil then
|
||||
return
|
||||
end
|
||||
if sLan == AllEnum.Language.CN then
|
||||
return map_BubbleData_Cn[sEditingVoResName]
|
||||
elseif sLan == AllEnum.Language.JP then
|
||||
return map_BubbleData_Jp[sEditingVoResName]
|
||||
end
|
||||
end
|
||||
function BubbleVoiceManager.DoSaveData(_mapData)
|
||||
if type(sEditingVoResName) == "string" and sEditingVoResName ~= "" then
|
||||
map_BubbleData[sEditingVoResName] = _mapData
|
||||
for k, v in pairs(map_BubbleData) do
|
||||
for kk, vv in pairs(v.text) do
|
||||
for i, sContent in ipairs(vv) do
|
||||
sContent = string.gsub(sContent, "\r==RT==", "==RT==")
|
||||
sContent = string.gsub(sContent, "\r", "==RT==")
|
||||
vv[i] = sContent
|
||||
end
|
||||
end
|
||||
end
|
||||
local sJsonText = RapidJson.encode(map_BubbleData, {
|
||||
pretty = true,
|
||||
sort_keys = true,
|
||||
empty_table_as_array = true
|
||||
})
|
||||
WriteToJsonFile(sPath_BubbleData, sJsonText)
|
||||
end
|
||||
end
|
||||
function BubbleVoiceManager.BBVEditor_GetBBPos(nCharSkinId, bIsCG)
|
||||
local bIsLeft, x, y
|
||||
local mapOffset = map_BubbleOffset[tostring(nCharSkinId)]
|
||||
if mapOffset == nil then
|
||||
mapOffset = {
|
||||
left = true,
|
||||
x = 0,
|
||||
y = 0,
|
||||
cgLeft = true,
|
||||
cgX = 0,
|
||||
cgY = 0
|
||||
}
|
||||
end
|
||||
bIsLeft = bIsCG == true and mapOffset.cgLeft or mapOffset.left
|
||||
x = bIsCG == true and mapOffset.cgX or mapOffset.x
|
||||
y = bIsCG == true and mapOffset.cgY or mapOffset.y
|
||||
return bIsLeft, x, y
|
||||
end
|
||||
function BubbleVoiceManager.DoSaveOffset(nCharSkinId, bIsCG, bIsLeft, x, y)
|
||||
local mapOffset = map_BubbleOffset[tostring(nCharSkinId)]
|
||||
if mapOffset == nil then
|
||||
mapOffset = {
|
||||
left = true,
|
||||
x = 0,
|
||||
y = 0,
|
||||
cgLeft = true,
|
||||
cgX = 0,
|
||||
cgY = 0
|
||||
}
|
||||
end
|
||||
if bIsCG == true then
|
||||
mapOffset.cgX = x
|
||||
mapOffset.cgY = y
|
||||
mapOffset.cgLeft = bIsLeft
|
||||
else
|
||||
mapOffset.x = x
|
||||
mapOffset.y = y
|
||||
mapOffset.left = bIsLeft
|
||||
end
|
||||
map_BubbleOffset[tostring(nCharSkinId)] = mapOffset
|
||||
local sJsonText = RapidJson.encode(map_BubbleOffset, {
|
||||
pretty = true,
|
||||
sort_keys = true,
|
||||
empty_table_as_array = true
|
||||
})
|
||||
WriteToJsonFile(sPath_BubbleOffset, sJsonText)
|
||||
end
|
||||
function BubbleVoiceManager.HasNewDataToSave(tbVoResName)
|
||||
local bResult = false
|
||||
for i, v in ipairs(tbVoResName) do
|
||||
if BubbleVoiceManager.IsNew(v) == true then
|
||||
printLog(v)
|
||||
bResult = true
|
||||
end
|
||||
end
|
||||
return bResult
|
||||
end
|
||||
function BubbleVoiceManager.IsNew(sVoResName)
|
||||
if type(sVoResName) == "string" and sVoResName ~= "" then
|
||||
return map_BubbleData[sVoResName] == nil
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
return BubbleVoiceManager
|
||||
@@ -0,0 +1,653 @@
|
||||
local Actor2DEditorCtrl = class("Actor2DEditorCtrl", BaseCtrl)
|
||||
local PanelDefine = require("GameCore.UI.PanelDefine")
|
||||
local AvgPreset = require("Game.UI.Avg.AvgPreset")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local GameResourceLoader = require("Game.Common.Resource.GameResourceLoader")
|
||||
local ResType = GameResourceLoader.ResType
|
||||
local ListString = CS.System.Collections.Generic.List(CS.System.String)
|
||||
local Directory = CS.System.IO.Directory
|
||||
local SearchOption = CS.System.IO.SearchOption
|
||||
local Actor2DOffsetData = CS.Actor2DOffsetData
|
||||
local EventTrigger = CS.UnityEngine.EventSystems.EventTrigger
|
||||
local EventTriggerType = CS.UnityEngine.EventSystems.EventTriggerType
|
||||
local ConfigActor2DEditor = CS.ConfigActor2DEditor
|
||||
local typeof = typeof
|
||||
Actor2DEditorCtrl._mapNodeConfig = {
|
||||
trUIInsRoot = {
|
||||
sNodeName = "-- ui in root --",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
eventTriggerEditPos = {
|
||||
sNodeName = "et_pos",
|
||||
sComponentName = "EventTrigger"
|
||||
},
|
||||
imgEditPos = {sNodeName = "et_pos", sComponentName = "Image"},
|
||||
sldScale = {
|
||||
sNodeName = "sld_scale",
|
||||
sComponentName = "Slider",
|
||||
callback = "OnValueChanged_SliderScale"
|
||||
},
|
||||
inputScale = {
|
||||
sNodeName = "input_scale",
|
||||
sComponentName = "InputField_onEndEdit",
|
||||
callback = "OnEditEnd_InputScale"
|
||||
},
|
||||
togEditEmoji = {
|
||||
sNodeName = "tog_edit_emoji",
|
||||
sComponentName = "Toggle",
|
||||
callback = "OnTog_EditEmoji"
|
||||
},
|
||||
togMirrorEmoji = {
|
||||
sNodeName = "tog_mirror_emoji",
|
||||
sComponentName = "Toggle",
|
||||
callback = "OnTog_MirrorEmoji"
|
||||
},
|
||||
ddSelectChannel = {
|
||||
sNodeName = "dd_select_game_channel",
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnDD_SelectChannel"
|
||||
},
|
||||
ddSelectPngLive2D = {
|
||||
sNodeName = "dd_select_png_live2d",
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnDD_SelectPngLive2D"
|
||||
},
|
||||
ddSelectPanel = {
|
||||
sNodeName = "dd_select_panel",
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnDD_SelectPanel"
|
||||
},
|
||||
ddSelectActor = {
|
||||
sNodeName = "dd_char",
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnDD_SelectActor"
|
||||
},
|
||||
ddSelectPose = {
|
||||
sNodeName = "dd_pose",
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnDD_SelectPose"
|
||||
},
|
||||
ddSelectEmoji = {
|
||||
sNodeName = "ddEmoji",
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnDD_SelectEmoji"
|
||||
},
|
||||
ddSelectFullOrHalf = {
|
||||
sNodeName = "dd_full_half",
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnDD_SelectFullOrHalf"
|
||||
},
|
||||
ddSelectAvgCharHeadFrame = {
|
||||
sNodeName = "dd_select_avg_char_head_frame",
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnDD_SelectAvgCharFrame"
|
||||
},
|
||||
btnReset = {
|
||||
sNodeName = "btn_reset",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Reset"
|
||||
},
|
||||
btnRefresh = {
|
||||
sNodeName = "btn_refresh",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Refresh"
|
||||
},
|
||||
btnSave = {
|
||||
sNodeName = "btn_save",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Save"
|
||||
}
|
||||
}
|
||||
Actor2DEditorCtrl._mapEventConfig = {}
|
||||
local tbPanelPreference = {}
|
||||
local ECharType = {
|
||||
Char = 0,
|
||||
AvgChar = 1,
|
||||
Npc = 2,
|
||||
CharNpc = 3
|
||||
}
|
||||
function Actor2DEditorCtrl:Awake()
|
||||
local tr = GameObject.Find("==== UI ROOT ====/----Actor2D_OffScreen_Renderer----/----Renderer----/1").transform
|
||||
self.trRendererActorOffset = tr:Find("animator/panel_offset/free_drag/actor_offset")
|
||||
self.trActorOffset = nil
|
||||
self.trEmojiOffset = nil
|
||||
local goFPSCounter = GameObject.Find("==== UI ROOT ====/---- UI OVERLAY ----/_FPSCounter")
|
||||
goFPSCounter:SetActive(false)
|
||||
self:CacheActor2DEditorConfig()
|
||||
self.tbAllPose = {}
|
||||
for _, sPose in ipairs(AvgPreset.CharPose_0) do
|
||||
table.insert(self.tbAllPose, sPose)
|
||||
end
|
||||
for _, sPose in ipairs(AvgPreset.CharPose_1) do
|
||||
table.insert(self.tbAllPose, sPose)
|
||||
end
|
||||
self.nAvgCharHeadMirrorFactor = 1
|
||||
end
|
||||
function Actor2DEditorCtrl:OnEnable()
|
||||
self.tbCallback = {}
|
||||
self._mapNode.ddSelectPngLive2D.gameObject:SetActive(false)
|
||||
local nIndex = 0
|
||||
nIndex = nIndex + 1
|
||||
self.tbCallback[nIndex] = ui_handler(self, self.OnBeginDrag, self._mapNode.eventTriggerEditPos)
|
||||
local entryBegin = EventTrigger.Entry()
|
||||
entryBegin.eventID = EventTriggerType.BeginDrag
|
||||
entryBegin.callback:AddListener(self.tbCallback[nIndex])
|
||||
self._mapNode.eventTriggerEditPos.triggers:Add(entryBegin)
|
||||
nIndex = nIndex + 1
|
||||
self.tbCallback[nIndex] = ui_handler(self, self.OnDrag, self._mapNode.eventTriggerEditPos)
|
||||
local entryDrag = EventTrigger.Entry()
|
||||
entryDrag.eventID = EventTriggerType.Drag
|
||||
entryDrag.callback:AddListener(self.tbCallback[nIndex])
|
||||
self._mapNode.eventTriggerEditPos.triggers:Add(entryDrag)
|
||||
nIndex = nIndex + 1
|
||||
self.tbCallback[nIndex] = ui_handler(self, self.OnEndDrag, self._mapNode.eventTriggerEditPos)
|
||||
local entryEnd = EventTrigger.Entry()
|
||||
entryEnd.eventID = EventTriggerType.EndDrag
|
||||
entryEnd.callback:AddListener(self.tbCallback[nIndex])
|
||||
self._mapNode.eventTriggerEditPos.triggers:Add(entryEnd)
|
||||
self:SetUIList()
|
||||
self:OnDD_SelectPanel(self._mapNode.ddSelectPanel)
|
||||
self:SetPoseList()
|
||||
self:SetEmojiList()
|
||||
self:SetEditable(false)
|
||||
end
|
||||
function Actor2DEditorCtrl:OnDisable()
|
||||
local nIndex = 0
|
||||
nIndex = nIndex + 1
|
||||
local cb_begindrag = self.tbCallback[nIndex]
|
||||
nIndex = nIndex + 1
|
||||
local cb_drag = self.tbCallback[nIndex]
|
||||
nIndex = nIndex + 1
|
||||
local cb_enddrag = self.tbCallback[nIndex]
|
||||
local nCount = self._mapNode.eventTriggerEditPos.triggers.Count - 1
|
||||
for i = nCount, 0, -1 do
|
||||
local entry = self._mapNode.eventTriggerEditPos.triggers[i]
|
||||
if entry.eventID == EventTriggerType.BeginDrag then
|
||||
entry.callback:RemoveListener(cb_begindrag)
|
||||
elseif entry.eventID == EventTriggerType.Drag then
|
||||
entry.callback:RemoveListener(cb_drag)
|
||||
elseif entry.eventID == EventTriggerType.EndDrag then
|
||||
entry.callback:RemoveListener(cb_enddrag)
|
||||
end
|
||||
self._mapNode.eventTriggerEditPos.triggers:Remove(entry)
|
||||
end
|
||||
self.tbCallback = nil
|
||||
end
|
||||
function Actor2DEditorCtrl:CacheActor2DEditorConfig()
|
||||
local assetConfig = GameResourceLoader.LoadAsset(ResType.Any, "Assets/AssetBundles/UI/CommonEx/Preference/Actor2DEditor.asset", typeof(ConfigActor2DEditor))
|
||||
local nLen = assetConfig.arrData.Length - 1
|
||||
for i = 0, nLen do
|
||||
local data = assetConfig.arrData[i]
|
||||
local nPanelId = assetConfig:GetPanelId(i)
|
||||
local nReusePanelId = assetConfig:GetReusePanelId(i)
|
||||
local _nCharType = assetConfig:GetCharType(i)
|
||||
table.insert(tbPanelPreference, {
|
||||
nId = nPanelId,
|
||||
nReuse = nReusePanelId,
|
||||
nCharType = _nCharType,
|
||||
bInUI = data.InUI,
|
||||
bFull = data.CanEditFull,
|
||||
bEmoji = data.CanEditEmoji,
|
||||
bPose = data.CanEditPose,
|
||||
sName = data.UIName,
|
||||
nSpIdx = data.PrefabIndex,
|
||||
sNodePath = data.NodePath
|
||||
})
|
||||
end
|
||||
end
|
||||
function Actor2DEditorCtrl:SetUIList()
|
||||
local listUIName = ListString()
|
||||
for i, v in ipairs(tbPanelPreference) do
|
||||
listUIName:Add(v.sName)
|
||||
end
|
||||
NovaAPI.ClearDropDownOptions(self._mapNode.ddSelectPanel)
|
||||
NovaAPI.DropDownAddOptions(self._mapNode.ddSelectPanel, listUIName)
|
||||
NovaAPI.SetDropDownValue(self._mapNode.ddSelectPanel, 0)
|
||||
end
|
||||
function Actor2DEditorCtrl:SetActorList(mapPreference)
|
||||
local listActor2D = ListString()
|
||||
local func_CollectChar = function(sPath)
|
||||
local tbActorIdFolders = Directory.GetDirectories(self:GetABRootPath() .. sPath, "*.*", SearchOption.TopDirectoryOnly)
|
||||
local nCount = tbActorIdFolders.Length - 1
|
||||
for i = 0, nCount do
|
||||
local tb = string.split(tbActorIdFolders[i], "/")
|
||||
local sFolderName = tb[#tb]
|
||||
listActor2D:Add(sFolderName)
|
||||
end
|
||||
end
|
||||
if mapPreference.nCharType == ECharType.Char then
|
||||
func_CollectChar("Actor2D/Character/")
|
||||
elseif mapPreference.nCharType == ECharType.AvgChar then
|
||||
func_CollectChar("Actor2D/CharacterAvg/")
|
||||
elseif mapPreference.nCharType == ECharType.Npc then
|
||||
func_CollectChar("Actor2D/NPC/")
|
||||
elseif mapPreference.nCharType == ECharType.CharNpc then
|
||||
func_CollectChar("Actor2D/Character/")
|
||||
func_CollectChar("Actor2D/NPC/")
|
||||
end
|
||||
NovaAPI.ClearDropDownOptions(self._mapNode.ddSelectActor)
|
||||
NovaAPI.DropDownAddOptions(self._mapNode.ddSelectActor, listActor2D)
|
||||
NovaAPI.SetDropDownValue(self._mapNode.ddSelectActor, 0)
|
||||
end
|
||||
function Actor2DEditorCtrl:SetPoseList()
|
||||
local nAllCount = #self.tbAllPose
|
||||
local listPose = ListString()
|
||||
for i = 1, nAllCount do
|
||||
listPose:Add(self.tbAllPose[i])
|
||||
end
|
||||
NovaAPI.ClearDropDownOptions(self._mapNode.ddSelectPose)
|
||||
NovaAPI.DropDownAddOptions(self._mapNode.ddSelectPose, listPose)
|
||||
NovaAPI.SetDropDownValue(self._mapNode.ddSelectPose, 0)
|
||||
end
|
||||
function Actor2DEditorCtrl:SetEmojiList()
|
||||
self.tbEmojiPrefabPath = {}
|
||||
local tbCharEmoji = AvgPreset.CharEmoji
|
||||
local nAllCount = #tbCharEmoji
|
||||
local listEmoji = ListString()
|
||||
for i = 3, nAllCount do
|
||||
local mapEmoji = tbCharEmoji[i]
|
||||
listEmoji:Add(mapEmoji[2])
|
||||
table.insert(self.tbEmojiPrefabPath, mapEmoji[3])
|
||||
end
|
||||
NovaAPI.ClearDropDownOptions(self._mapNode.ddSelectEmoji)
|
||||
NovaAPI.DropDownAddOptions(self._mapNode.ddSelectEmoji, listEmoji)
|
||||
NovaAPI.SetDropDownValue(self._mapNode.ddSelectEmoji, 0)
|
||||
end
|
||||
function Actor2DEditorCtrl:SetEditable(bCanEdit, bPreferSetEmoji)
|
||||
NovaAPI.SetImageRaycastTarget(self._mapNode.imgEditPos, bCanEdit == true)
|
||||
NovaAPI.SetSliderInteractable(self._mapNode.sldScale, bCanEdit == true)
|
||||
NovaAPI.SetInputFieldInteractable(self._mapNode.inputScale, bCanEdit == true)
|
||||
if bPreferSetEmoji == nil then
|
||||
NovaAPI.SetToggleInteractable(self._mapNode.togEditEmoji, bCanEdit == true)
|
||||
NovaAPI.SetToggleInteractable(self._mapNode.togMirrorEmoji, bCanEdit == true)
|
||||
else
|
||||
NovaAPI.SetToggleInteractable(self._mapNode.togEditEmoji, bCanEdit == true and bPreferSetEmoji == true)
|
||||
NovaAPI.SetToggleInteractable(self._mapNode.togMirrorEmoji, bCanEdit == true and bPreferSetEmoji == true)
|
||||
end
|
||||
end
|
||||
function Actor2DEditorCtrl:GetABRootPath()
|
||||
local nSelectedChannel = NovaAPI.GetDropDownValue(self._mapNode.ddSelectChannel)
|
||||
local sABRootPath = "Assets/AssetBundles"
|
||||
if nSelectedChannel == 0 then
|
||||
sABRootPath = sABRootPath .. "/"
|
||||
elseif nSelectedChannel == 1 then
|
||||
sABRootPath = sABRootPath .. "_cen/"
|
||||
end
|
||||
return sABRootPath
|
||||
end
|
||||
function Actor2DEditorCtrl:GetCharEmojiIndex(sEmoji)
|
||||
for i, v in ipairs(AvgPreset.CharEmoji) do
|
||||
if v[3] == sEmoji then
|
||||
return v[1]
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
function Actor2DEditorCtrl:IsAvgCharInTalkFrameBg(sPose, sAvgCharId)
|
||||
if sAvgCharId ~= "avg3_100" and sAvgCharId ~= "avg3_101" then
|
||||
return false
|
||||
end
|
||||
local nCount = 2
|
||||
local nAllCount = #self.tbAllPose
|
||||
local bMatch = false
|
||||
for i = 1, nCount do
|
||||
if self.tbAllPose[nAllCount] == sPose then
|
||||
bMatch = true
|
||||
break
|
||||
end
|
||||
nAllCount = nAllCount - 1
|
||||
end
|
||||
return bMatch
|
||||
end
|
||||
function Actor2DEditorCtrl:GetAvgCharHeadFrameIndex(nValue)
|
||||
local nIdx = nValue
|
||||
if nIdx == 2 then
|
||||
nIdx = 3
|
||||
end
|
||||
return nIdx
|
||||
end
|
||||
function Actor2DEditorCtrl:ClearAll()
|
||||
Actor2DManager.UnsetActor2D_ForActor2DEditor()
|
||||
if self.trEmojiOffset ~= nil then
|
||||
delChildren(self.trEmojiOffset)
|
||||
self.trEmojiOffset = nil
|
||||
end
|
||||
delChildren(self._mapNode.trUIInsRoot.gameObject)
|
||||
self:SetEditable(false)
|
||||
self.Offset = nil
|
||||
self.nCurPanelId = 0
|
||||
self.nReusePanelId = 0
|
||||
self.bInUI = false
|
||||
self._mapNode.ddSelectPngLive2D.gameObject:SetActive(NovaAPI.GetDropDownValue(self._mapNode.ddSelectPanel) == 2 and NovaAPI.GetDropDownValue(self._mapNode.ddSelectFullOrHalf) == 1)
|
||||
self._mapNode.ddSelectAvgCharHeadFrame.gameObject:SetActive(NovaAPI.GetDropDownValue(self._mapNode.ddSelectPanel) == 0)
|
||||
self.nAvgCharHeadMirrorFactor = 1
|
||||
end
|
||||
function Actor2DEditorCtrl:CreatePanelTempIns(nIndex)
|
||||
self:ClearAll()
|
||||
local mapPreference = tbPanelPreference[nIndex]
|
||||
if mapPreference == nil then
|
||||
return
|
||||
end
|
||||
local nSpIdx = mapPreference.nSpIdx or 1
|
||||
local panel = require(PanelDefine[mapPreference.nId])
|
||||
local sPanelPrefabPath = Settings.AB_ROOT_PATH .. "UI/" .. panel._tbDefine[nSpIdx].sPrefabPath
|
||||
local objPrefab = GameResourceLoader.LoadAsset(ResType.Any, sPanelPrefabPath, typeof(Object))
|
||||
local goIns = instantiate(objPrefab, self._mapNode.trUIInsRoot)
|
||||
goIns.transform.localScale = Vector3.one
|
||||
local rt = goIns:GetComponent("RectTransform")
|
||||
rt.anchoredPosition = Vector2.zero
|
||||
rt.pivot = Vector2(0.5, 0.5)
|
||||
rt.anchorMin = Vector2.zero
|
||||
rt.anchorMax = Vector2.one
|
||||
local sTargetPath = mapPreference.sNodePath
|
||||
local bEditAvgHeadFrame = false
|
||||
if mapPreference.nId == PanelId.AvgST then
|
||||
bEditAvgHeadFrame = NovaAPI.GetDropDownValue(self._mapNode.ddSelectAvgCharHeadFrame) > 0
|
||||
goIns.transform:Find("----Full_Rect----/--char_head_frame--").gameObject:SetActive(bEditAvgHeadFrame)
|
||||
NovaAPI.SetImageSprite(goIns.transform:Find("----Full_Rect----/BG"):GetComponent("Image"), "Assets/AssetBundles/ImageAvg/AvgBg/city_street_daylight.png")
|
||||
if bEditAvgHeadFrame == true then
|
||||
local sIndex = tostring(NovaAPI.GetDropDownValue(self._mapNode.ddSelectAvgCharHeadFrame))
|
||||
goIns.transform:Find(string.format("----Full_Rect----/--char_head_frame--/rtFrame_%s", sIndex)).gameObject:SetActive(true)
|
||||
sTargetPath = string.format("----Full_Rect----/--char_head_frame--/rtFrame_%s/rtFrameOffset/rtFramePos/goCharMask/rtCharOffset_%s/----Actor2D_PNG----", sIndex, sIndex)
|
||||
NovaAPI.SetToggleIsOn(self._mapNode.togEditEmoji, false)
|
||||
local nValue = NovaAPI.GetDropDownValue(self._mapNode.ddSelectAvgCharHeadFrame)
|
||||
if nValue == 1 or nValue == 5 then
|
||||
self.nAvgCharHeadMirrorFactor = -1
|
||||
end
|
||||
end
|
||||
end
|
||||
local trRawImg = goIns.transform:Find(sTargetPath)
|
||||
trRawImg.gameObject:SetActive(true)
|
||||
local rawImg = trRawImg:GetComponent("RawImage")
|
||||
local goEmojiRoot = GameObject("trEmojiOffset")
|
||||
self.trEmojiOffset = goEmojiRoot.transform
|
||||
self.trEmojiOffset:SetParent(trRawImg.parent)
|
||||
self.trEmojiOffset.localPosition = Vector3.zero
|
||||
self.trEmojiOffset.localScale = Vector3.one
|
||||
self:SetEditable(0 >= mapPreference.nReuse, mapPreference.bEmoji == true and bEditAvgHeadFrame == false)
|
||||
self.nCurPanelId = mapPreference.nId
|
||||
self.nCharType = mapPreference.nCharType
|
||||
self.nReusePanelId = mapPreference.nReuse
|
||||
self.bInUI = mapPreference.bInUI
|
||||
self:ProcFadeInUI(goIns)
|
||||
return trRawImg, rawImg
|
||||
end
|
||||
function Actor2DEditorCtrl:ProcFadeInUI(goIns)
|
||||
if self.nCurPanelId == PanelId.MainView then
|
||||
goIns.transform:Find("----SafeAreaRoot----"):GetComponent("Animator"):SetTrigger("tLogin")
|
||||
elseif self.nCurPanelId == PanelId.CharUpPanel then
|
||||
goIns.transform:Find("----SafeAreaRoot----/----FunctionPanel----/--NodeInfo--/advancePreviewInfo").gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
function Actor2DEditorCtrl:OnDD_SelectChannel(dd)
|
||||
self:ClearAll()
|
||||
self:SetActorList()
|
||||
end
|
||||
function Actor2DEditorCtrl:OnDD_SelectPngLive2D(dd)
|
||||
self:ClearAll()
|
||||
end
|
||||
function Actor2DEditorCtrl:OnDD_SelectPanel(dd)
|
||||
self:ClearAll()
|
||||
local nValue = NovaAPI.GetDropDownValue(dd)
|
||||
local mapPreference = tbPanelPreference[nValue + 1]
|
||||
self:SetActorList(mapPreference)
|
||||
NovaAPI.SetDropDownValue(self._mapNode.ddSelectFullOrHalf, 0)
|
||||
NovaAPI.SetDDInteractable(self._mapNode.ddSelectFullOrHalf, mapPreference.bFull == true)
|
||||
NovaAPI.SetDropDownValue(self._mapNode.ddSelectEmoji, 0)
|
||||
NovaAPI.SetDDInteractable(self._mapNode.ddSelectEmoji, mapPreference.bEmoji == true)
|
||||
NovaAPI.SetToggleIsOn(self._mapNode.togEditEmoji, false)
|
||||
NovaAPI.SetToggleIsOn(self._mapNode.togMirrorEmoji, false)
|
||||
NovaAPI.SetDropDownValue(self._mapNode.ddSelectPose, 0)
|
||||
NovaAPI.SetDDInteractable(self._mapNode.ddSelectPose, mapPreference.bPose == true)
|
||||
end
|
||||
function Actor2DEditorCtrl:OnDD_SelectActor(dd)
|
||||
self:ClearAll()
|
||||
NovaAPI.SetDropDownValue(self._mapNode.ddSelectFullOrHalf, 0)
|
||||
NovaAPI.SetDropDownValue(self._mapNode.ddSelectEmoji, 0)
|
||||
NovaAPI.SetDropDownValue(self._mapNode.ddSelectPose, 0)
|
||||
end
|
||||
function Actor2DEditorCtrl:OnDD_SelectPose(dd)
|
||||
self:ClearAll()
|
||||
end
|
||||
function Actor2DEditorCtrl:OnDD_SelectEmoji(dd)
|
||||
self:ClearAll()
|
||||
end
|
||||
function Actor2DEditorCtrl:OnDD_SelectFullOrHalf(dd)
|
||||
self:ClearAll()
|
||||
end
|
||||
function Actor2DEditorCtrl:OnDD_SelectAvgCharFrame(dd)
|
||||
self:ClearAll()
|
||||
end
|
||||
local v2BeginDragPos, v3CurOffsetPos, v3DragPos
|
||||
local nFactor = 100
|
||||
function Actor2DEditorCtrl:OnBeginDrag(eventTrigger, eventData)
|
||||
v2BeginDragPos = eventData.position
|
||||
v3CurOffsetPos = self.trActorOffset.localPosition
|
||||
if NovaAPI.GetDDInteractable(self._mapNode.ddSelectEmoji) == true and NovaAPI.GetToggleIsOn(self._mapNode.togEditEmoji) == true then
|
||||
v3CurOffsetPos = self.trEmojiOffset.localPosition
|
||||
end
|
||||
nFactor = self.bInUI == true and 1 or 100
|
||||
end
|
||||
function Actor2DEditorCtrl:OnDrag(eventTrigger, eventData)
|
||||
local v2Del = eventData.position - v2BeginDragPos
|
||||
if CS.InputManager.Instance:GetKey(CS.UnityEngine.InputSystem.Key.LeftShift) == true then
|
||||
v2Del.y = 0
|
||||
end
|
||||
if CS.InputManager.Instance:GetKey(CS.UnityEngine.InputSystem.Key.LeftAlt) == true then
|
||||
v2Del.x = 0
|
||||
end
|
||||
if NovaAPI.GetDDInteractable(self._mapNode.ddSelectEmoji) == true and NovaAPI.GetToggleIsOn(self._mapNode.togEditEmoji) == true then
|
||||
v3DragPos = Vector3(v3CurOffsetPos.x + v2Del.x, v3CurOffsetPos.y + v2Del.y, 0)
|
||||
self.trEmojiOffset.localPosition = v3DragPos
|
||||
else
|
||||
if self.nCurPanelId == PanelId.AvgST then
|
||||
v3DragPos = Vector3(v3CurOffsetPos.x + v2Del.x * self.nAvgCharHeadMirrorFactor, v3CurOffsetPos.y + v2Del.y, 0)
|
||||
else
|
||||
v3DragPos = Vector3(v3CurOffsetPos.x + v2Del.x / nFactor, v3CurOffsetPos.y + v2Del.y / nFactor, 0)
|
||||
end
|
||||
self.trActorOffset.localPosition = v3DragPos
|
||||
end
|
||||
end
|
||||
function Actor2DEditorCtrl:OnEndDrag(eventTrigger, eventData)
|
||||
v2BeginDragPos = nil
|
||||
v3CurOffsetPos = nil
|
||||
v3DragPos = nil
|
||||
end
|
||||
function Actor2DEditorCtrl:OnEditEnd_InputScale()
|
||||
local nS = tonumber(NovaAPI.GetInputFieldText(self._mapNode.inputScale))
|
||||
NovaAPI.SetSliderValue(self._mapNode.sldScale, nS)
|
||||
if NovaAPI.GetToggleIsOn(self._mapNode.togEditEmoji) == true then
|
||||
local nFactor = 1
|
||||
if NovaAPI.GetToggleIsOn(self._mapNode.togMirrorEmoji) == true then
|
||||
nFactor = -1
|
||||
end
|
||||
self.trEmojiOffset.localScale = Vector3(nS * nFactor, nS, 1)
|
||||
else
|
||||
self.trActorOffset.localScale = Vector3(nS * self.nAvgCharHeadMirrorFactor, nS, 1)
|
||||
end
|
||||
end
|
||||
function Actor2DEditorCtrl:OnValueChanged_SliderScale()
|
||||
local nS = NovaAPI.GetSliderValue(self._mapNode.sldScale)
|
||||
NovaAPI.SetInputFieldText(self._mapNode.inputScale, tostring(nS))
|
||||
if NovaAPI.GetToggleIsOn(self._mapNode.togEditEmoji) == true then
|
||||
local nFactor = 1
|
||||
if NovaAPI.GetToggleIsOn(self._mapNode.togMirrorEmoji) == true then
|
||||
nFactor = -1
|
||||
end
|
||||
self.trEmojiOffset.localScale = Vector3(nS * nFactor, nS, 1)
|
||||
else
|
||||
self.trActorOffset.localScale = Vector3(nS * self.nAvgCharHeadMirrorFactor, nS, 1)
|
||||
end
|
||||
end
|
||||
function Actor2DEditorCtrl:OnTog_EditEmoji()
|
||||
if NovaAPI.GetToggleIsOn(self._mapNode.togEditEmoji) == true then
|
||||
if self.trEmojiOffset ~= nil and self.trEmojiOffset:IsNull() == false then
|
||||
NovaAPI.SetSliderValue(self._mapNode.sldScale, self.trEmojiOffset.localScale.y)
|
||||
NovaAPI.SetInputFieldText(self._mapNode.inputScale, tostring(self.trEmojiOffset.localScale.y))
|
||||
end
|
||||
elseif self.trActorOffset ~= nil and self.trActorOffset:IsNull() == false then
|
||||
NovaAPI.SetSliderValue(self._mapNode.sldScale, self.trActorOffset.localScale.y)
|
||||
NovaAPI.SetInputFieldText(self._mapNode.inputScale, tostring(self.trActorOffset.localScale.y))
|
||||
end
|
||||
end
|
||||
function Actor2DEditorCtrl:OnTog_MirrorEmoji()
|
||||
if self.trEmojiOffset ~= nil and self.trEmojiOffset:IsNull() == false then
|
||||
local v3Scale = self.trEmojiOffset.localScale
|
||||
self.trEmojiOffset.localScale = Vector3(v3Scale.x * -1, v3Scale.y, 1)
|
||||
end
|
||||
end
|
||||
function Actor2DEditorCtrl:OnBtnClick_Reset()
|
||||
if self.Offset == nil or self.nReusePanelId > 0 then
|
||||
return
|
||||
end
|
||||
NovaAPI.SetToggleIsOn(self._mapNode.togMirrorEmoji, false)
|
||||
self.trActorOffset.localPosition = Vector3.zero
|
||||
self.trActorOffset.localScale = Vector3.one
|
||||
self.trEmojiOffset.localPosition = Vector3.zero
|
||||
self.trEmojiOffset.localScale = Vector3.one
|
||||
NovaAPI.SetSliderValue(self._mapNode.sldScale, 1)
|
||||
NovaAPI.SetInputFieldText(self._mapNode.inputScale, "1")
|
||||
local sId = NovaAPI.GetCurDDOptionsText(self._mapNode.ddSelectActor)
|
||||
local sPose = "a"
|
||||
if NovaAPI.GetDDInteractable(self._mapNode.ddSelectPose) == true then
|
||||
sPose = NovaAPI.GetCurDDOptionsText(self._mapNode.ddSelectPose)
|
||||
end
|
||||
if self:IsAvgCharInTalkFrameBg(sPose, sId) == true then
|
||||
self.trActorOffset.localPosition = Vector3(0, 540, 0)
|
||||
self.trActorOffset.localScale = Vector3.one
|
||||
end
|
||||
end
|
||||
function Actor2DEditorCtrl:OnBtnClick_Refresh()
|
||||
local trRawImg, rawImg = self:CreatePanelTempIns(NovaAPI.GetDropDownValue(self._mapNode.ddSelectPanel) + 1)
|
||||
if self.nCurPanelId == PanelId.AvgST then
|
||||
self.trActorOffset = trRawImg:GetChild(0):GetChild(0)
|
||||
if 0 < NovaAPI.GetDropDownValue(self._mapNode.ddSelectAvgCharHeadFrame) then
|
||||
self.trActorOffset = trRawImg.parent
|
||||
end
|
||||
else
|
||||
self.trActorOffset = self.bInUI == true and trRawImg:GetChild(0):GetChild(0) or self.trRendererActorOffset
|
||||
end
|
||||
local sId = NovaAPI.GetCurDDOptionsText(self._mapNode.ddSelectActor)
|
||||
local bFull = NovaAPI.GetDropDownValue(self._mapNode.ddSelectFullOrHalf) == 1
|
||||
local bL2D = NovaAPI.GetDropDownValue(self._mapNode.ddSelectPngLive2D) == 1 and self._mapNode.ddSelectPngLive2D.gameObject.activeSelf == true
|
||||
local sPose = "a"
|
||||
local sFolder = ""
|
||||
local bIsNpc = false
|
||||
if self.nCharType == ECharType.Char then
|
||||
sFolder = "Actor2D/Character/"
|
||||
elseif self.nCharType == ECharType.AvgChar then
|
||||
sPose = NovaAPI.GetCurDDOptionsText(self._mapNode.ddSelectPose)
|
||||
sFolder = "Actor2D/CharacterAvg/"
|
||||
elseif self.nCharType == ECharType.Npc then
|
||||
sFolder = "Actor2D/NPC/"
|
||||
bIsNpc = true
|
||||
elseif self.nCharType == ECharType.CharNpc then
|
||||
sFolder = "Actor2D/Character/"
|
||||
end
|
||||
local sAssetPath = string.format("%s%s%s/%s.asset", self:GetABRootPath(), sFolder, sId, sId)
|
||||
self.Offset = CS.UnityEditor.AssetDatabase.LoadAssetAtPath(sAssetPath, typeof(Actor2DOffsetData))
|
||||
if self.Offset == nil and self.nCharType == ECharType.CharNpc then
|
||||
sFolder = "Actor2D/NPC/"
|
||||
sAssetPath = string.format("%s%s%s/%s.asset", self:GetABRootPath(), sFolder, sId, sId)
|
||||
self.Offset = CS.UnityEditor.AssetDatabase.LoadAssetAtPath(sAssetPath, typeof(Actor2DOffsetData))
|
||||
bIsNpc = true
|
||||
end
|
||||
CS.UnityEditor.Selection.activeObject = self.Offset
|
||||
local nX, nY, nL2DX, nL2DY = 0, 0, 0, 0
|
||||
local nPanelId = self.nCurPanelId
|
||||
if 0 < self.nReusePanelId then
|
||||
nPanelId = self.nReusePanelId
|
||||
end
|
||||
local s, x, y = self.Offset:GetOffsetData(nPanelId, indexOfPose(sPose), bFull ~= true, nX, nY)
|
||||
local l2ds, l2dx, l2dy = self.Offset:GetL2DData(nL2DX, nL2DY)
|
||||
if l2ds <= 0 then
|
||||
l2dx, l2dy, l2ds = 0, 0, 1
|
||||
end
|
||||
if self.nCurPanelId == PanelId.AvgST then
|
||||
if self:IsAvgCharInTalkFrameBg(sPose, sId) == true then
|
||||
s, x, y = 1, 0, 540
|
||||
NovaAPI.SetToggleIsOn(self._mapNode.togEditEmoji, true)
|
||||
NovaAPI.SetToggleInteractable(self._mapNode.togEditEmoji, false)
|
||||
end
|
||||
Actor2DManager.SetActor2D_PNG_ForActor2DEditor(self.nCurPanelId, trRawImg, sId, self:GetABRootPath() .. sFolder .. sId, s, x, y, sPose)
|
||||
if 0 < NovaAPI.GetDropDownValue(self._mapNode.ddSelectAvgCharHeadFrame) then
|
||||
local nFrameIndex = self:GetAvgCharHeadFrameIndex(NovaAPI.GetDropDownValue(self._mapNode.ddSelectAvgCharHeadFrame))
|
||||
local _nAvgCharHeadFrameX, _nAvgCharHeadFrameY = 0, 0
|
||||
local nAvgCharHeadFrameS, nAvgCharHeadFrameX, nAvgCharHeadFrameY = self.Offset:Get_AvgCharHeadFrameData(nPanelId, indexOfPose(sPose), nFrameIndex, _nAvgCharHeadFrameX, _nAvgCharHeadFrameY)
|
||||
self.trActorOffset.localPosition = Vector3(nAvgCharHeadFrameX, nAvgCharHeadFrameY, 0)
|
||||
self.trActorOffset.localScale = Vector3(nAvgCharHeadFrameS, math.abs(nAvgCharHeadFrameS), 1)
|
||||
end
|
||||
elseif self.bInUI == true then
|
||||
Actor2DManager.SetActor2D_PNG_ForActor2DEditor(self.nCurPanelId, trRawImg, sId, self:GetABRootPath() .. sFolder .. sId, s, 100 * x, 100 * y)
|
||||
else
|
||||
local trL2D = Actor2DManager.SetActor2D_ForActor2DEditor(self.nCurPanelId, rawImg, sId, bFull, self:GetABRootPath() .. sFolder, s, x, y, bL2D, l2dx, l2dy, l2ds, bIsNpc == true)
|
||||
if trL2D ~= nil then
|
||||
self.trActorOffset = trL2D
|
||||
end
|
||||
end
|
||||
NovaAPI.SetSliderValue(self._mapNode.sldScale, self.trActorOffset.localScale.y)
|
||||
NovaAPI.SetInputFieldText(self._mapNode.inputScale, tostring(self.trActorOffset.localScale.y))
|
||||
if NovaAPI.GetDDInteractable(self._mapNode.ddSelectEmoji) == true then
|
||||
local nValue = NovaAPI.GetDropDownValue(self._mapNode.ddSelectEmoji)
|
||||
local sEmojiPrefabName = self.tbEmojiPrefabPath[nValue + 1]
|
||||
local objEmojiPrefab = CS.UnityEditor.AssetDatabase.LoadAssetAtPath(Settings.AB_ROOT_PATH .. "UI/Avg/AnimEmoji/" .. sEmojiPrefabName .. ".prefab", typeof(Object))
|
||||
local goEmojiIns = instantiate(objEmojiPrefab, self.trEmojiOffset)
|
||||
local anim = goEmojiIns:GetComponent("Animator")
|
||||
anim:SetTrigger("tEditor")
|
||||
local _nX, _nY = 0, 0
|
||||
local _s, _x, _y = self.Offset:GetEmojiData(self.nCurPanelId, indexOfPose(sPose), self:GetCharEmojiIndex(sEmojiPrefabName), _nX, _nY)
|
||||
if self:IsAvgCharInTalkFrameBg(sPose, sId) == true then
|
||||
_y = _y + 540
|
||||
end
|
||||
NovaAPI.SetToggleIsOn(self._mapNode.togMirrorEmoji, _s < 0)
|
||||
self.trEmojiOffset.localPosition = Vector3(_x, _y, 0)
|
||||
self.trEmojiOffset.localScale = Vector3(_s, math.abs(_s), 1)
|
||||
if NovaAPI.GetToggleIsOn(self._mapNode.togEditEmoji) == true then
|
||||
NovaAPI.SetSliderValue(self._mapNode.sldScale, self.trEmojiOffset.localScale.y)
|
||||
NovaAPI.SetInputFieldText(self._mapNode.inputScale, tostring(self.trEmojiOffset.localScale.y))
|
||||
end
|
||||
end
|
||||
end
|
||||
function Actor2DEditorCtrl:OnBtnClick_Save()
|
||||
if self.Offset == nil or self.nReusePanelId > 0 then
|
||||
return
|
||||
end
|
||||
local sId = NovaAPI.GetCurDDOptionsText(self._mapNode.ddSelectActor)
|
||||
local sPose = "a"
|
||||
if NovaAPI.GetDDInteractable(self._mapNode.ddSelectPose) == true then
|
||||
sPose = NovaAPI.GetCurDDOptionsText(self._mapNode.ddSelectPose)
|
||||
end
|
||||
local v3Pos = self.trActorOffset.localPosition
|
||||
local v3Scale = self.trActorOffset.localScale
|
||||
if self._mapNode.ddSelectPngLive2D.gameObject.activeSelf == true and NovaAPI.GetDropDownValue(self._mapNode.ddSelectPngLive2D) == 1 then
|
||||
self.Offset:SetL2DData(v3Pos.x, v3Pos.y, v3Scale.x)
|
||||
elseif self.nCurPanelId == PanelId.AvgST and 0 < NovaAPI.GetDropDownValue(self._mapNode.ddSelectAvgCharHeadFrame) then
|
||||
local nFrameIndex = self:GetAvgCharHeadFrameIndex(NovaAPI.GetDropDownValue(self._mapNode.ddSelectAvgCharHeadFrame))
|
||||
self.Offset:Set_AvgCharHeadFrameData(self.nCurPanelId, indexOfPose(sPose), nFrameIndex, v3Pos.x, v3Pos.y, v3Scale.x)
|
||||
else
|
||||
local x, y, s = v3Pos.x, v3Pos.y, v3Scale.x
|
||||
if self:IsAvgCharInTalkFrameBg(sPose, sId) == true and self.nCurPanelId == PanelId.AvgST then
|
||||
y = y - 540
|
||||
end
|
||||
if self.bInUI == true and self.nCurPanelId ~= PanelId.AvgST then
|
||||
x = x / 100
|
||||
y = y / 100
|
||||
end
|
||||
self.Offset:SetOffsetData(self.nCurPanelId, indexOfPose(sPose), NovaAPI.GetDropDownValue(self._mapNode.ddSelectFullOrHalf) == 0, x, y, s)
|
||||
end
|
||||
if NovaAPI.GetDDInteractable(self._mapNode.ddSelectEmoji) == true then
|
||||
local v3EmojiPos = self.trEmojiOffset.localPosition
|
||||
local v3EmojiScale = self.trEmojiOffset.localScale
|
||||
local nValue = NovaAPI.GetDropDownValue(self._mapNode.ddSelectEmoji)
|
||||
local sEmojiPrefabName = self.tbEmojiPrefabPath[nValue + 1]
|
||||
local y = v3EmojiPos.y
|
||||
if self:IsAvgCharInTalkFrameBg(sPose, sId) == true and self.nCurPanelId == PanelId.AvgST then
|
||||
y = y - 540
|
||||
end
|
||||
self.Offset:SetEmojiData(self.nCurPanelId, indexOfPose(sPose), self:GetCharEmojiIndex(sEmojiPrefabName), v3EmojiPos.x, y, v3EmojiScale.x)
|
||||
end
|
||||
CS.UnityEditor.EditorUtility.SetDirty(self.Offset)
|
||||
CS.UnityEditor.AssetDatabase.SaveAssets()
|
||||
CS.UnityEditor.AssetDatabase.Refresh()
|
||||
end
|
||||
return Actor2DEditorCtrl
|
||||
@@ -0,0 +1,8 @@
|
||||
local Actor2DEditorPanel = class("Actor2DEditorPanel", BasePanel)
|
||||
Actor2DEditorPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Actor2DEditor/Actor2DEditor.prefab",
|
||||
sCtrlName = "Game.Actor2D.Editor.Actor2DEditorCtrl"
|
||||
}
|
||||
}
|
||||
return Actor2DEditorPanel
|
||||
@@ -0,0 +1,6 @@
|
||||
require("GameCore.GameCore")
|
||||
RUNNING_ACTOR2D_EDITOR = true
|
||||
local goLaunchUI = GameObject.Find("==== Builtin UI ====/LaunchUI")
|
||||
GameObject.Destroy(goLaunchUI)
|
||||
CS.WwiseAudioManager.Instance.MusicVolume = 0
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Actor2DEditor)
|
||||
@@ -0,0 +1,401 @@
|
||||
local BBVEditorCtrl = class("BBVEditorCtrl", BaseCtrl)
|
||||
local BubbleVoiceManager = require("Game.Actor2D.BubbleVoiceManager")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
BBVEditorCtrl._mapNodeConfig = {
|
||||
rawImage = {
|
||||
sNodeName = "----Actor2D----",
|
||||
sComponentName = "RawImage"
|
||||
},
|
||||
ipt_SrcContent = {sComponentName = "InputField"},
|
||||
dd_PlayerSex = {
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnDD_PlayerSex"
|
||||
},
|
||||
dd_Language_Vo = {
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnEvent_SwitchVoLan"
|
||||
},
|
||||
dd_Language_Txt = {
|
||||
sComponentName = "Dropdown",
|
||||
callback = "OnEvent_SwitchTxtLan"
|
||||
},
|
||||
btn_SaveSplitContent = {},
|
||||
btn_UseCn_Time_Anim = {
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtn_ReuseCnTimeAnim"
|
||||
},
|
||||
btn_UseJp_Time_Anim = {
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtn_ReuseJpTimeAnim"
|
||||
},
|
||||
btn_SaveByDefault = {
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtn_SaveNewDataByDefault"
|
||||
},
|
||||
dd_VoResName = {sComponentName = "Dropdown"},
|
||||
btn_Back = {sComponentName = "Button", callback = "OnBtn_Back"},
|
||||
tog_CnM = {sComponentName = "Toggle"},
|
||||
tog_CnF = {sComponentName = "Toggle"},
|
||||
tog_JpM = {sComponentName = "Toggle"},
|
||||
CnMText = {nCount = 4, sComponentName = "InputField"},
|
||||
CnMTextFallback = {nCount = 4, sComponentName = "Text"},
|
||||
CnMTime = {nCount = 4, sComponentName = "InputField"},
|
||||
CnMTimeFallback = {nCount = 4, sComponentName = "Text"},
|
||||
CnMAnim = {nCount = 4, sComponentName = "Dropdown"},
|
||||
CnFText = {nCount = 4, sComponentName = "InputField"},
|
||||
CnFTextFallback = {nCount = 4, sComponentName = "Text"},
|
||||
CnFTime = {nCount = 4, sComponentName = "InputField"},
|
||||
CnFTimeFallback = {nCount = 4, sComponentName = "Text"},
|
||||
CnFAnim = {nCount = 4, sComponentName = "Dropdown"},
|
||||
JpMText = {nCount = 4, sComponentName = "InputField"},
|
||||
JpMTextFallback = {nCount = 4, sComponentName = "Text"},
|
||||
JpMTime = {nCount = 4, sComponentName = "InputField"},
|
||||
JpMTimeFallback = {nCount = 4, sComponentName = "Text"},
|
||||
JpMAnim = {nCount = 4, sComponentName = "Dropdown"},
|
||||
JpFText = {nCount = 4, sComponentName = "InputField"},
|
||||
JpFTextFallback = {nCount = 4, sComponentName = "Text"},
|
||||
JpFTime = {nCount = 4, sComponentName = "InputField"},
|
||||
JpFTimeFallback = {nCount = 4, sComponentName = "Text"},
|
||||
JpFAnim = {nCount = 4, sComponentName = "Dropdown"},
|
||||
goBubbleRoot = {
|
||||
sNodeName = "----bubble----"
|
||||
},
|
||||
rtBubbleRoot = {
|
||||
sNodeName = "----bubble----",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
dd_BBLeftRight = {sComponentName = "Dropdown"},
|
||||
tmp_CurVosResLen = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
BBVEditorCtrl._mapEventConfig = {
|
||||
BBVE_SetTextTime = "onEvent_SetTextTime",
|
||||
BBVE_SaveTextTime = "onEvent_SaveTextTime",
|
||||
BBVE_SetCharL2D = "onEvent_SetCharL2D",
|
||||
BBVE_SaveOffset = "onEvent_SaveOffset",
|
||||
BBVE_Play = "onEvent_Play",
|
||||
BBVE_Stop = "onEvent_Stop",
|
||||
BBVE_Pause = "onEvent_Pause",
|
||||
BBVE_Resume = "onEvent_Resume",
|
||||
BBVE_CheckNewData = "onEvent_CheckNewData"
|
||||
}
|
||||
function BBVEditorCtrl:OnEnable()
|
||||
if Settings.sCurrentTxtLanguage == AllEnum.Language.CN then
|
||||
NovaAPI.SetToggleIsOn(self._mapNode.tog_CnF, true)
|
||||
NovaAPI.SetToggleInteractable(self._mapNode.tog_CnM, false)
|
||||
NovaAPI.SetToggleInteractable(self._mapNode.tog_JpM, false)
|
||||
for i = 1, 4 do
|
||||
self._mapNode.CnFAnim[i].gameObject:SetActive(true)
|
||||
self._mapNode.JpFAnim[i].gameObject:SetActive(false)
|
||||
end
|
||||
else
|
||||
if Settings.sCurrentTxtLanguage == AllEnum.Language.JP then
|
||||
NovaAPI.SetToggleInteractable(self._mapNode.tog_CnM, false)
|
||||
NovaAPI.SetToggleInteractable(self._mapNode.tog_CnF, false)
|
||||
else
|
||||
end
|
||||
end
|
||||
local ListString = CS.System.Collections.Generic.List(CS.System.String)
|
||||
local listLanguage = ListString()
|
||||
for i, v in ipairs(AllEnum.LanguageInfo) do
|
||||
listLanguage:Add(v[2])
|
||||
end
|
||||
NovaAPI.ClearDropDownOptions(self._mapNode.dd_Language_Vo)
|
||||
NovaAPI.DropDownAddOptions(self._mapNode.dd_Language_Vo, listLanguage)
|
||||
NovaAPI.SetDDValueWithoutNotify(self._mapNode.dd_Language_Vo, GetLanguageIndex(Settings.sCurrentVoLanguage) - 1)
|
||||
self.mapText = {
|
||||
male_cn = self._mapNode.CnMText,
|
||||
female_cn = self._mapNode.CnFText,
|
||||
male_jp = self._mapNode.JpMText,
|
||||
female_jp = self._mapNode.JpFText
|
||||
}
|
||||
self.mapTextFallback = {
|
||||
male_cn = self._mapNode.CnMTextFallback,
|
||||
female_cn = self._mapNode.CnFTextFallback,
|
||||
male_jp = self._mapNode.JpMTextFallback,
|
||||
female_jp = self._mapNode.JpFTextFallback
|
||||
}
|
||||
self.mapTime = {
|
||||
male_cn = self._mapNode.CnMTime,
|
||||
female_cn = self._mapNode.CnFTime,
|
||||
male_jp = self._mapNode.JpMTime,
|
||||
female_jp = self._mapNode.JpFTime
|
||||
}
|
||||
self.mapTimeFallback = {
|
||||
male_cn = self._mapNode.CnMTimeFallback,
|
||||
female_cn = self._mapNode.CnFTimeFallback,
|
||||
male_jp = self._mapNode.JpMTimeFallback,
|
||||
female_jp = self._mapNode.JpFTimeFallback
|
||||
}
|
||||
self.mapAnim = {
|
||||
male_cn = self._mapNode.CnMAnim,
|
||||
female_cn = self._mapNode.CnFAnim,
|
||||
male_jp = self._mapNode.JpMAnim,
|
||||
female_jp = self._mapNode.JpFAnim
|
||||
}
|
||||
self.tbCheckOrder = {
|
||||
"male_cn",
|
||||
"female_cn",
|
||||
"male_jp",
|
||||
"female_jp"
|
||||
}
|
||||
if Settings.sCurrentTxtLanguage == AllEnum.Language.CN then
|
||||
self.tbCheckOrder = {
|
||||
"male_jp",
|
||||
"female_jp",
|
||||
"male_cn",
|
||||
"female_cn"
|
||||
}
|
||||
elseif Settings.sCurrentTxtLanguage == AllEnum.Language.JP then
|
||||
self.tbCheckOrder = {"male_jp", "female_jp"}
|
||||
end
|
||||
self:InitL2DAnimDD()
|
||||
BubbleVoiceManager.Init(true)
|
||||
local bReuseFunc = Settings.sCurrentTxtLanguage ~= AllEnum.Language.CN and Settings.sCurrentTxtLanguage ~= AllEnum.Language.JP
|
||||
self._mapNode.btn_UseCn_Time_Anim.gameObject:SetActive(bReuseFunc)
|
||||
self._mapNode.btn_UseJp_Time_Anim.gameObject:SetActive(bReuseFunc)
|
||||
end
|
||||
function BBVEditorCtrl:OnDisable()
|
||||
Actor2DManager.DestroyL2D_InBBVEditor()
|
||||
end
|
||||
function BBVEditorCtrl:InitL2DAnimDD()
|
||||
self.tbAnimName = {
|
||||
"",
|
||||
"presents_a",
|
||||
"presents_b",
|
||||
"chat_a",
|
||||
"chat_b",
|
||||
"chat_c",
|
||||
"chat_d",
|
||||
"think_a",
|
||||
"shy_a",
|
||||
"special_a",
|
||||
"special_b"
|
||||
}
|
||||
local ListString = CS.System.Collections.Generic.List(CS.System.String)
|
||||
local listAnim = ListString()
|
||||
for i, v in ipairs(self.tbAnimName) do
|
||||
listAnim:Add(v)
|
||||
end
|
||||
for i = 1, 4 do
|
||||
NovaAPI.ClearDropDownOptions(self._mapNode.CnMAnim[i])
|
||||
NovaAPI.ClearDropDownOptions(self._mapNode.CnFAnim[i])
|
||||
NovaAPI.ClearDropDownOptions(self._mapNode.JpMAnim[i])
|
||||
NovaAPI.ClearDropDownOptions(self._mapNode.JpFAnim[i])
|
||||
end
|
||||
for i = 1, 4 do
|
||||
NovaAPI.DropDownAddOptions(self._mapNode.CnMAnim[i], listAnim)
|
||||
NovaAPI.DropDownAddOptions(self._mapNode.CnFAnim[i], listAnim)
|
||||
NovaAPI.DropDownAddOptions(self._mapNode.JpMAnim[i], listAnim)
|
||||
NovaAPI.DropDownAddOptions(self._mapNode.JpFAnim[i], listAnim)
|
||||
end
|
||||
end
|
||||
function BBVEditorCtrl:OnDD_PlayerSex()
|
||||
local bIsMale = NovaAPI.GetDropDownValue(self._mapNode.dd_PlayerSex) == 1
|
||||
PlayerData.Base:SetPlayerSex(bIsMale)
|
||||
end
|
||||
function BBVEditorCtrl:OnBtn_Back()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ExeEditor)
|
||||
end
|
||||
function BBVEditorCtrl:OnEvent_SwitchVoLan(dd)
|
||||
local nIndex = NovaAPI.GetDropDownValue(dd)
|
||||
local sVoLan = AllEnum.LanguageInfo[nIndex + 1][1]
|
||||
if sVoLan ~= AllEnum.Language.CN and sVoLan ~= AllEnum.Language.JP then
|
||||
sVoLan = Settings.sCurrentVoLanguage
|
||||
nIndex = GetLanguageIndex(sVoLan)
|
||||
NovaAPI.SetDDValueWithoutNotify(dd, nIndex - 1)
|
||||
return
|
||||
end
|
||||
local bDownloaded, nTotalSize, nNeedDownloadSize = NovaAPI.HasDownload_VoLanguage(sVoLan)
|
||||
if bDownloaded == false and 0 < nNeedDownloadSize then
|
||||
NovaAPI.Enable_VoLanguage(sVoLan)
|
||||
PanelManager.OnConfirmBackToLogIn()
|
||||
return
|
||||
end
|
||||
NovaAPI.SetCur_VoiceLanguage(sVoLan)
|
||||
Settings.sCurrentVoLanguage = sVoLan
|
||||
end
|
||||
function BBVEditorCtrl:OnEvent_SwitchTxtLan(dd)
|
||||
local nLanIdx = NovaAPI.GetDropDownValue(dd) + 1
|
||||
local sLan = GetLanguageByIndex(nLanIdx)
|
||||
NovaAPI.SetCur_TextLanguage(sLan)
|
||||
Settings.sCurrentTxtLanguage = sLan
|
||||
PanelManager.OnConfirmBackToLogIn()
|
||||
end
|
||||
function BBVEditorCtrl:_ReuseData(_sLan, _sKey)
|
||||
local data = BubbleVoiceManager.GetReuseData(_sLan)
|
||||
if data == nil then
|
||||
return
|
||||
end
|
||||
local tbFallbackTime = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
}
|
||||
local nCount = #self.tbCheckOrder
|
||||
for i = nCount, 1, -1 do
|
||||
local sKey = self.tbCheckOrder[i]
|
||||
local bTimeFB = false
|
||||
for ii = 1, 4 do
|
||||
local nTime = data.time[sKey][ii]
|
||||
bTimeFB = nTime <= 0
|
||||
if bTimeFB == false then
|
||||
tbFallbackTime[ii] = nTime
|
||||
end
|
||||
local _nTime = tbFallbackTime[ii]
|
||||
NovaAPI.SetInputFieldText(self.mapTime[sKey][ii], bTimeFB == true and "" or tostring(nTime))
|
||||
NovaAPI.SetText(self.mapTimeFallback[sKey][ii], bTimeFB == true and tostring(_nTime) or "")
|
||||
if sKey == "female_jp" then
|
||||
local nDDIndex = table.indexof(self.tbAnimName, data.anim[_sKey][ii]) - 1
|
||||
NovaAPI.SetDropDownValue(self.mapAnim[sKey][ii], nDDIndex)
|
||||
end
|
||||
end
|
||||
end
|
||||
self._mapNode.btn_SaveSplitContent:SetActive(true)
|
||||
end
|
||||
function BBVEditorCtrl:OnBtn_ReuseCnTimeAnim()
|
||||
self:_ReuseData(AllEnum.Language.CN, "female_cn")
|
||||
end
|
||||
function BBVEditorCtrl:OnBtn_ReuseJpTimeAnim()
|
||||
self:_ReuseData(AllEnum.Language.JP, "female_jp")
|
||||
end
|
||||
function BBVEditorCtrl:OnBtn_SaveNewDataByDefault()
|
||||
local sCurVoResName = self.sVoResName
|
||||
self.bSaveByDefault = true
|
||||
if type(self.tbVoResName) == "table" then
|
||||
for i, sVoResName in ipairs(self.tbVoResName) do
|
||||
if BubbleVoiceManager.IsNew(sVoResName) == true then
|
||||
NovaAPI.SetDropDownValue(self._mapNode.dd_VoResName, i - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
self.bSaveByDefault = nil
|
||||
NovaAPI.SetDropDownValue(self._mapNode.dd_VoResName, table.indexof(self.tbVoResName, sCurVoResName) - 1)
|
||||
end
|
||||
function BBVEditorCtrl:onEvent_SetTextTime(sVoResName)
|
||||
self.sVoResName = sVoResName
|
||||
self.mapAllData, self.bIsNewData = BubbleVoiceManager.GetBubbleData_All(sVoResName)
|
||||
local tbFallbackText = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
}
|
||||
local tbFallbackTime = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
}
|
||||
local nCount = #self.tbCheckOrder
|
||||
NovaAPI.SetTMPText(self._mapNode.tmp_CurVosResLen, tostring(BubbleVoiceManager.GetVoResLen(sVoResName)))
|
||||
if self.bIsNewData == true then
|
||||
local sKey = self.tbCheckOrder[nCount]
|
||||
self.mapAllData.text[sKey][1] = NovaAPI.GetInputFieldText(self._mapNode.ipt_SrcContent)
|
||||
self.mapAllData.time[sKey][1] = BubbleVoiceManager.GetVoResLen(sVoResName)
|
||||
end
|
||||
for i = nCount, 1, -1 do
|
||||
local sKey = self.tbCheckOrder[i]
|
||||
local bTextFB = false
|
||||
local bTimeFB = false
|
||||
for ii = 1, 4 do
|
||||
local sText = self.mapAllData.text[sKey][ii]
|
||||
local nTime = self.mapAllData.time[sKey][ii]
|
||||
sText = string.gsub(sText, "==RT==", "\n")
|
||||
if ii == 1 and i ~= nCount then
|
||||
bTextFB = sText == ""
|
||||
bTimeFB = nTime <= 0
|
||||
end
|
||||
if bTextFB == false then
|
||||
tbFallbackText[ii] = sText
|
||||
end
|
||||
if bTimeFB == false then
|
||||
tbFallbackTime[ii] = nTime
|
||||
end
|
||||
local _sText = tbFallbackText[ii]
|
||||
local _nTime = tbFallbackTime[ii]
|
||||
NovaAPI.SetInputFieldText(self.mapText[sKey][ii], bTextFB == true and "" or sText)
|
||||
NovaAPI.SetText(self.mapTextFallback[sKey][ii], bTextFB == true and _sText or "")
|
||||
NovaAPI.SetInputFieldText(self.mapTime[sKey][ii], bTimeFB == true and "" or tostring(nTime))
|
||||
NovaAPI.SetText(self.mapTimeFallback[sKey][ii], bTimeFB == true and tostring(_nTime) or "")
|
||||
if i == nCount then
|
||||
local nDDIndex = table.indexof(self.tbAnimName, self.mapAllData.anim[sKey][ii]) - 1
|
||||
NovaAPI.SetDropDownValue(self.mapAnim[sKey][ii], nDDIndex)
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.bSaveByDefault == true then
|
||||
self:onEvent_SaveTextTime()
|
||||
else
|
||||
self._mapNode.btn_SaveSplitContent:SetActive(self.bIsNewData == true)
|
||||
end
|
||||
end
|
||||
function BBVEditorCtrl:onEvent_SaveTextTime()
|
||||
if self.mapAllData ~= nil then
|
||||
local nCount = #self.tbCheckOrder
|
||||
for i = 1, nCount do
|
||||
local sKey = self.tbCheckOrder[i]
|
||||
local bTextFB = false
|
||||
local bTimeFB = false
|
||||
for ii = 1, 4 do
|
||||
local sText = NovaAPI.GetInputFieldText(self.mapText[sKey][ii])
|
||||
local sTime = NovaAPI.GetInputFieldText(self.mapTime[sKey][ii])
|
||||
sText = string.gsub(sText, "\r\n", "==RT==")
|
||||
sText = string.gsub(sText, "\r", "==RT==")
|
||||
sText = string.gsub(sText, "\n", "==RT==")
|
||||
sText = string.gsub(sText, "\\", "")
|
||||
sText = string.gsub(sText, "\"", "\"")
|
||||
if ii == 1 and i ~= nCount then
|
||||
bTextFB = sText == ""
|
||||
bTimeFB = sTime == ""
|
||||
end
|
||||
if sTime == "" then
|
||||
sTime = "0"
|
||||
end
|
||||
self.mapAllData.text[sKey][ii] = bTextFB == true and "" or sText
|
||||
self.mapAllData.time[sKey][ii] = bTimeFB == true and 0 or tonumber(sTime)
|
||||
if i == nCount then
|
||||
local nDDIndex = NovaAPI.GetDropDownValue(self.mapAnim[sKey][ii]) + 1
|
||||
self.mapAllData.anim[sKey][ii] = self.tbAnimName[nDDIndex]
|
||||
end
|
||||
end
|
||||
end
|
||||
BubbleVoiceManager.DoSaveData(self.mapAllData)
|
||||
if self.bSaveByDefault ~= true then
|
||||
self:onEvent_SetTextTime(self.sVoResName)
|
||||
end
|
||||
end
|
||||
end
|
||||
function BBVEditorCtrl:onEvent_SetCharL2D(bIsNpc, nCharSkinId, bIsCG)
|
||||
Actor2DManager.SetL2D_InBBVEditor(self._mapNode.rawImage, bIsNpc, nCharSkinId, bIsCG)
|
||||
local bIsLeft, x, y = BubbleVoiceManager.BBVEditor_GetBBPos(nCharSkinId, bIsCG)
|
||||
self._mapNode.rtBubbleRoot.anchoredPosition = Vector2(x, y)
|
||||
NovaAPI.SetDDValueWithoutNotify(self._mapNode.dd_BBLeftRight, bIsLeft == true and 0 or 1)
|
||||
end
|
||||
function BBVEditorCtrl:onEvent_SaveOffset(nCharSkinId, bIsCG, bIsLeft, x, y)
|
||||
BubbleVoiceManager.DoSaveOffset(nCharSkinId, bIsCG, bIsLeft, x / 100, y / 100)
|
||||
end
|
||||
function BBVEditorCtrl:onEvent_Play(sVoResName, nCharSkinId, bIsCG)
|
||||
BubbleVoiceManager.PlayBubbleAnim(self._mapNode.goBubbleRoot, sVoResName, nCharSkinId, bIsCG)
|
||||
end
|
||||
function BBVEditorCtrl:onEvent_Stop()
|
||||
BubbleVoiceManager.StopBubbleAnim()
|
||||
end
|
||||
function BBVEditorCtrl:onEvent_Pause()
|
||||
BubbleVoiceManager.PauseBubbleAnim()
|
||||
end
|
||||
function BBVEditorCtrl:onEvent_Resume()
|
||||
BubbleVoiceManager.ResumeBubbleAnim()
|
||||
end
|
||||
function BBVEditorCtrl:onEvent_CheckNewData(listVoResName, nCount)
|
||||
self.tbVoResName = {}
|
||||
nCount = nCount - 1
|
||||
for i = 0, nCount do
|
||||
local sVoResName = listVoResName[i]
|
||||
if type(sVoResName) == "string" then
|
||||
table.insert(self.tbVoResName, sVoResName)
|
||||
end
|
||||
end
|
||||
self._mapNode.btn_SaveByDefault.gameObject:SetActive(BubbleVoiceManager.HasNewDataToSave(self.tbVoResName) == true)
|
||||
end
|
||||
return BBVEditorCtrl
|
||||
@@ -0,0 +1,8 @@
|
||||
local BBVEditorPanel = class("BBVEditorPanel", BasePanel)
|
||||
BBVEditorPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "BubbleVoiceEditor/BubbleVoiceEditorPanel.prefab",
|
||||
sCtrlName = "Game.Actor2D.Editor_BBV.BBVEditorCtrl"
|
||||
}
|
||||
}
|
||||
return BBVEditorPanel
|
||||
@@ -0,0 +1,164 @@
|
||||
local ExeEditorCtrl = class("ExeEditorCtrl", BaseCtrl)
|
||||
ExeEditorCtrl._mapNodeConfig = {
|
||||
btn_AvgEditor = {
|
||||
sComponentName = "Button",
|
||||
callback = "onBtn_AvgEditor"
|
||||
},
|
||||
btn_BubbleVoiceEditor = {
|
||||
sComponentName = "Button",
|
||||
callback = "onBtn_BubbleVoiceEditor"
|
||||
},
|
||||
btn_TEST = {sComponentName = "Button", callback = "onBtn_TEST"}
|
||||
}
|
||||
ExeEditorCtrl._mapEventConfig = {}
|
||||
function ExeEditorCtrl:onBtn_AvgEditor()
|
||||
require("Game.UI.Avg.Editor.main")
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.AvgEditor)
|
||||
end
|
||||
function ExeEditorCtrl:onBtn_BubbleVoiceEditor()
|
||||
require("Game.Actor2D.Editor_BBV.main")
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BBVEditor)
|
||||
end
|
||||
function ExeEditorCtrl:onBtn_TEST()
|
||||
end
|
||||
function ExeEditorCtrl:CheckMissingAvgCharacterId()
|
||||
local rootPath = CS.UnityEngine.Application.dataPath .. "/../Lua/Game/UI/Avg/"
|
||||
local sourceDir = {
|
||||
rootPath .. "_cn/Config",
|
||||
rootPath .. "_en/Config",
|
||||
rootPath .. "_jp/Config",
|
||||
rootPath .. "_kr/Config",
|
||||
rootPath .. "_tw/Config"
|
||||
}
|
||||
local targetFile = rootPath .. "AvgCharacter/AvgCharacter.lua"
|
||||
local cmdGroup = self:ScanCmdGetParamTarget()
|
||||
local allFields = {}
|
||||
for k, v in ipairs(sourceDir) do
|
||||
print("开始扫描源目录: " .. v)
|
||||
local sourceFiles = self:ScanDirectoryForLuaFiles(v)
|
||||
for _, filePath in ipairs(sourceFiles) do
|
||||
local allParamTables = self:ExtractFieldsFromFile(filePath, cmdGroup)
|
||||
allFields[filePath] = allParamTables
|
||||
end
|
||||
end
|
||||
local missing = self:CheckFieldsInTarget(allFields, targetFile)
|
||||
self:ExportTxtFile(missing)
|
||||
end
|
||||
function ExeEditorCtrl:ScanCmdGetParamTarget()
|
||||
local filePath = "D:/NewNovaProject/Nova_Client/Lua/Game/UI/Avg/Editor/CmdInfo.lua"
|
||||
local paramTables = {}
|
||||
if CS.System.IO.File.Exists(filePath) then
|
||||
local lines = CS.System.IO.File.ReadAllLines(filePath)
|
||||
local funcName = ""
|
||||
for i = 0, lines.Length - 1 do
|
||||
local line = lines[i]
|
||||
if line:match("function") then
|
||||
funcName = line:match("_([^%(]+)%(")
|
||||
end
|
||||
if funcName ~= "" and line:match("SetAvgCharId") then
|
||||
local number = line:match("%[(%d+)%]")
|
||||
if number ~= nil then
|
||||
paramTables[funcName] = tonumber(number)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return paramTables
|
||||
end
|
||||
function ExeEditorCtrl:ScanDirectoryForLuaFiles(directory)
|
||||
local files = {}
|
||||
if CS.System.IO.Directory.Exists(directory) then
|
||||
local fileEntries = CS.System.IO.Directory.GetFiles(directory, "*.lua", CS.System.IO.SearchOption.AllDirectories)
|
||||
for i = 0, fileEntries.Length - 1 do
|
||||
table.insert(files, fileEntries[i])
|
||||
end
|
||||
else
|
||||
print("[错误] 目录不存在: " .. directory)
|
||||
end
|
||||
return files
|
||||
end
|
||||
function ExeEditorCtrl:ExtractFieldsFromFile(filePath, tbCmd)
|
||||
local paramTables = {}
|
||||
if CS.System.IO.File.Exists(filePath) then
|
||||
local lines = CS.System.IO.File.ReadAllLines(filePath)
|
||||
for i = 0, lines.Length - 1 do
|
||||
do
|
||||
local line = lines[i]
|
||||
local content = line:match("cmd=\"(.-)\"")
|
||||
if tbCmd[content] ~= nil then
|
||||
local paramTableStr = line:match("param%s*=%s*(%b{})")
|
||||
if paramTableStr then
|
||||
do
|
||||
local success, result = pcall(function()
|
||||
local env = {
|
||||
table = table
|
||||
}
|
||||
local func, err = load("return " .. paramTableStr, "tmp", "t", env)
|
||||
if func then
|
||||
return func()
|
||||
else
|
||||
print("[解析错误] 行 " .. i + 1 .. ": " .. err)
|
||||
return nil
|
||||
end
|
||||
end)
|
||||
if success and result then
|
||||
local num = tbCmd[content]
|
||||
local AvgCharacterId = result[num]
|
||||
table.insert(paramTables, {
|
||||
line = i + 1,
|
||||
value = AvgCharacterId
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return paramTables
|
||||
end
|
||||
function ExeEditorCtrl:CheckFieldsInTarget(fields, targetDir)
|
||||
local missing = {}
|
||||
local tbAllIds = {}
|
||||
if CS.System.IO.File.Exists(targetDir) then
|
||||
local lines = CS.System.IO.File.ReadAllLines(targetDir)
|
||||
for i = 0, lines.Length - 1 do
|
||||
local line = lines[i]
|
||||
local content = line:match("id = \"(.-)\"")
|
||||
if content ~= nil then
|
||||
table.insert(tbAllIds, content)
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, v in pairs(fields) do
|
||||
if 0 < #v then
|
||||
for _, param in ipairs(v) do
|
||||
if 0 >= table.indexof(tbAllIds, param.value) then
|
||||
if missing[k] == nil then
|
||||
missing[k] = {}
|
||||
end
|
||||
table.insert(missing[k], param)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return missing
|
||||
end
|
||||
function ExeEditorCtrl:ExportTxtFile(missing)
|
||||
local exportDir = CS.UnityEngine.Application.dataPath .. "/../AvgCharacterMissingId/"
|
||||
local filePath = exportDir .. "output.txt"
|
||||
if not CS.System.IO.Directory.Exists(exportDir) then
|
||||
CS.System.IO.Directory.CreateDirectory(exportDir)
|
||||
end
|
||||
local streamWriter = CS.System.IO.File.CreateText(filePath)
|
||||
for filePath, params in pairs(missing) do
|
||||
streamWriter:WriteLine(filePath)
|
||||
for _, param in pairs(params) do
|
||||
local line = string.format(" 第%s行, name:%s", param.line, param.value)
|
||||
streamWriter:WriteLine(line)
|
||||
end
|
||||
end
|
||||
streamWriter:Close()
|
||||
print("导出成功!路径: " .. filePath)
|
||||
end
|
||||
return ExeEditorCtrl
|
||||
@@ -0,0 +1,5 @@
|
||||
EXE_EDITOR = true
|
||||
require("GameCore.GameCore")
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ExeEditor)
|
||||
local goLaunchUI = GameObject.Find("==== Builtin UI ====/LaunchUI")
|
||||
GameObject.Destroy(goLaunchUI)
|
||||
@@ -0,0 +1,8 @@
|
||||
local ExeEditorPanel = class("ExeEditorPanel", BasePanel)
|
||||
ExeEditorPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "BubbleVoiceEditor/ExeEditorPanel.prefab",
|
||||
sCtrlName = "Game.Actor2D.Editor_BBV.ExeEditorCtrl"
|
||||
}
|
||||
}
|
||||
return ExeEditorPanel
|
||||
@@ -0,0 +1 @@
|
||||
RUNNING_BBV_EDITOR = true
|
||||
@@ -0,0 +1,58 @@
|
||||
local AchievementChecker = {}
|
||||
local MonsterRelevant = require("Game.Adventure.AchievementCheck.MonsterRelevant")
|
||||
local SkillsRelevant = require("Game.Adventure.AchievementCheck.SkillsRelevant")
|
||||
local PlayerRelevant = require("Game.Adventure.AchievementCheck.PlayerRelevant")
|
||||
AchievementChecker.BattleAchievementCheckFunction = {
|
||||
[GameEnum.questCompleteCondClient.KillMonsterWithoutHitBySkill] = SkillsRelevant.KillMonsterWithoutHitBySkill,
|
||||
[GameEnum.questCompleteCondClient.KillMonsterWithoutKillSpecifiedMonster] = MonsterRelevant.CheckKillMonsterWithoutKillSpecifiedMonster,
|
||||
[GameEnum.questCompleteCondClient.KillMonsterWithOneAttack] = MonsterRelevant.CheckKillMonsterWithOneAttack,
|
||||
[GameEnum.questCompleteCondClient.CritCount] = PlayerRelevant.CritCount,
|
||||
[GameEnum.questCompleteCondClient.CastSkillTypeCount] = PlayerRelevant.CastSkillTypeCount,
|
||||
[GameEnum.questCompleteCondClient.CastSkillCount] = PlayerRelevant.CastSkillCount,
|
||||
[GameEnum.questCompleteCondClient.ExtremDodgeCount] = PlayerRelevant.ExtremDodgeCount,
|
||||
[GameEnum.questCompleteCondClient.KillMonsterClass] = MonsterRelevant.KillMonsterClass,
|
||||
[GameEnum.questCompleteCondClient.TriggerTagElement] = PlayerRelevant.TriggerTagElement,
|
||||
[GameEnum.questCompleteCondClient.OneHitDamage] = PlayerRelevant.OneHitDamage,
|
||||
[GameEnum.questCompleteCondClient.ClearLevelWithHPBelow] = PlayerRelevant.ClearLevelWithHPBelow,
|
||||
[GameEnum.questCompleteCondClient.KillMonsterWithTag] = MonsterRelevant.KillMonsterWithTag,
|
||||
[GameEnum.questCompleteCondClient.KillMonsterWithSkin] = MonsterRelevant.KillMonsterWithSkin
|
||||
}
|
||||
function AchievementChecker:CheckBattleAchievement(tbAchievementId, tbRet, bBattleSuccess)
|
||||
local battleData = NovaAPI.GetAchievementData()
|
||||
if battleData == nil then
|
||||
printError("成就战斗数据null")
|
||||
return
|
||||
end
|
||||
for _, nAchievementId in ipairs(tbAchievementId) do
|
||||
local mapAchievementData = ConfigTable.GetData("Achievement", nAchievementId)
|
||||
if mapAchievementData == nil then
|
||||
printError("成就数据不存在:" .. nAchievementId)
|
||||
return
|
||||
end
|
||||
if mapAchievementData.CompleteCondClient > 999 then
|
||||
local bHasValue, nCount = battleData.specialBattleData:TryGetValue(mapAchievementData.CompleteCondClient)
|
||||
print("Check Special Battle Achievement:" .. nAchievementId .. " Type:" .. mapAchievementData.CompleteCondClient)
|
||||
if bHasValue and 0 < nCount then
|
||||
print("Add Special Battle Achievement:" .. nAchievementId .. " Type:" .. mapAchievementData.CompleteCondClient .. " Count:" .. nCount)
|
||||
table.insert(tbRet, {
|
||||
Data = {nCount, nAchievementId},
|
||||
Id = GameEnum.eventTypes.eClient
|
||||
})
|
||||
end
|
||||
else
|
||||
if self.BattleAchievementCheckFunction[mapAchievementData.CompleteCondClient] == nil then
|
||||
printError("成就检测方法未绑定:" .. mapAchievementData.CompleteCondClient)
|
||||
return
|
||||
end
|
||||
local nCount = self.BattleAchievementCheckFunction[mapAchievementData.CompleteCondClient](mapAchievementData, battleData, bBattleSuccess)
|
||||
if 0 < nCount then
|
||||
print(string.format("成就%d完成", nAchievementId))
|
||||
table.insert(tbRet, {
|
||||
Data = {nCount, nAchievementId},
|
||||
Id = GameEnum.eventTypes.eClient
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return AchievementChecker
|
||||
@@ -0,0 +1,95 @@
|
||||
local MonsterRelevant = {}
|
||||
function MonsterRelevant.CheckKillMonsterWithoutKillSpecifiedMonster(mapAchievementData, AchievementDataDic)
|
||||
for _, nMonsterId in ipairs(mapAchievementData.ClientCompleteParams1) do
|
||||
for nCharId, mapKillDic in pairs(AchievementDataDic.killDataDic) do
|
||||
if mapKillDic:ContainsKey(nMonsterId) then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, nMonsterId in ipairs(mapAchievementData.ClientCompleteParams2) do
|
||||
for nCharId, mapKillDic in pairs(AchievementDataDic.killDataDic) do
|
||||
if mapKillDic:ContainsKey(nMonsterId) then
|
||||
return 1
|
||||
end
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
function MonsterRelevant.CheckKillMonsterWithOneAttack(mapAchievementData, AchievementDataDic)
|
||||
local nTarget = mapAchievementData.ClientCompleteParams1[1]
|
||||
local nTargetChar = mapAchievementData.ClientCompleteParams2[1]
|
||||
for nCharId, nCount in pairs(AchievementDataDic.OnceSkillKillCountDic) do
|
||||
if (#nTargetChar == 0 or 0 < table.indexof(nTargetChar, nCharId)) and nCount > nTarget then
|
||||
return 1
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
function MonsterRelevant.KillMonsterClass(mapAchievementData, AchievementDataDic)
|
||||
local nCount = 0
|
||||
local tbTarget = mapAchievementData.ClientCompleteParams1
|
||||
local tbTargetChar = mapAchievementData.ClientCompleteParams2
|
||||
for nCharId, mapKillDic in pairs(AchievementDataDic.killDataDic) do
|
||||
if #tbTargetChar == 0 or 0 < table.indexof(tbTargetChar, nCharId) then
|
||||
for nMonsterId, nKillCount in pairs(mapKillDic) do
|
||||
local mapMonsterCfg = ConfigTable.GetData("Monster", nMonsterId)
|
||||
if mapMonsterCfg ~= nil and 0 < table.indexof(tbTarget, mapMonsterCfg.EpicLv) then
|
||||
nCount = nCount + nKillCount
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nCount
|
||||
end
|
||||
function MonsterRelevant.KillMonsterWithTag(mapAchievementData, AchievementDataDic)
|
||||
local nCount = 0
|
||||
local nTargetChar = mapAchievementData.ClientCompleteParams1
|
||||
local tbTarget = mapAchievementData.ClientCompleteParams3
|
||||
if tbTarget == nil then
|
||||
return 0
|
||||
end
|
||||
for nCharId, mapKillDic in pairs(AchievementDataDic.killDataDic) do
|
||||
if #nTargetChar == 0 or 0 < table.indexof(nTargetChar, nCharId) then
|
||||
for nMonsterId, nKillCount in pairs(mapKillDic) do
|
||||
local mapMonsterCfg = ConfigTable.GetData("Monster", nMonsterId)
|
||||
if mapMonsterCfg ~= nil then
|
||||
if 0 < table.indexof(mapMonsterCfg.Tag1, tbTarget) then
|
||||
nCount = nCount + nKillCount
|
||||
elseif 0 < table.indexof(mapMonsterCfg.Tag2, tbTarget) then
|
||||
nCount = nCount + nKillCount
|
||||
elseif 0 < table.indexof(mapMonsterCfg.Tag3, tbTarget) then
|
||||
nCount = nCount + nKillCount
|
||||
elseif 0 < table.indexof(mapMonsterCfg.Tag4, tbTarget) then
|
||||
nCount = nCount + nKillCount
|
||||
elseif 0 < table.indexof(mapMonsterCfg.Tag5, tbTarget) then
|
||||
nCount = nCount + nKillCount
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nCount
|
||||
end
|
||||
function MonsterRelevant.KillMonsterWithSkin(mapAchievementData, AchievementDataDic)
|
||||
local nCount = 0
|
||||
local tbTargetSkin = mapAchievementData.ClientCompleteParams1
|
||||
if tbTargetSkin == nil then
|
||||
return 0
|
||||
end
|
||||
for _, mapKillDic in pairs(AchievementDataDic.killDataDic) do
|
||||
if 0 < #tbTargetSkin then
|
||||
for nMonsterId, nKillCount in pairs(mapKillDic) do
|
||||
local mapMonsterCfg = ConfigTable.GetData("Monster", nMonsterId)
|
||||
if mapMonsterCfg ~= nil then
|
||||
local nFAId = mapMonsterCfg.FAId
|
||||
if 0 < table.indexof(tbTargetSkin, nFAId) then
|
||||
nCount = nCount + nKillCount
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nCount
|
||||
end
|
||||
return MonsterRelevant
|
||||
@@ -0,0 +1,70 @@
|
||||
local PlayerRelevant = {}
|
||||
function PlayerRelevant.CritCount(mapAchievementData, AchievementDataDic)
|
||||
local ret = 0
|
||||
for nCharId, nCritCount in ipairs(AchievementDataDic.CritCountData) do
|
||||
if #mapAchievementData.ClientCompleteParams1 == 0 or 0 < table.indexof(mapAchievementData.ClientCompleteParams1, nCharId) then
|
||||
ret = ret + nCritCount
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
function PlayerRelevant.CastSkillTypeCount(mapAchievementData, AchievementDataDic)
|
||||
local nCount = 0
|
||||
local tbTarget = mapAchievementData.ClientCompleteParams1
|
||||
for nSkillId, nCastCount in pairs(AchievementDataDic.CastSkillData) do
|
||||
local mapSkill = ConfigTable.GetData("Skill", nSkillId)
|
||||
if mapSkill ~= nil and 0 < table.indexof(tbTarget, mapSkill.Type) then
|
||||
nCount = nCount + nCastCount
|
||||
end
|
||||
end
|
||||
return nCount
|
||||
end
|
||||
function PlayerRelevant.CastSkillCount(mapAchievementData, AchievementDataDic)
|
||||
local nCount = 0
|
||||
local tbTarget = mapAchievementData.ClientCompleteParams1
|
||||
for nSkillId, nCastCount in pairs(AchievementDataDic.CastSkillData) do
|
||||
local mapSkill = ConfigTable.GetData("Skill", nSkillId)
|
||||
if mapSkill ~= nil and 0 < table.indexof(tbTarget, mapSkill.Id) then
|
||||
nCount = nCount + nCastCount
|
||||
end
|
||||
end
|
||||
return nCount
|
||||
end
|
||||
function PlayerRelevant.ExtremDodgeCount(mapAchievementData, AchievementDataDic)
|
||||
local ret = 0
|
||||
for nCharId, nPrefectDodgeCount in ipairs(AchievementDataDic.PrefectDodgeData) do
|
||||
if #mapAchievementData.ClientCompleteParams1 == 0 or 0 < table.indexof(mapAchievementData.ClientCompleteParams1, nCharId) then
|
||||
ret = ret + nPrefectDodgeCount
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
function PlayerRelevant.TriggerTagElement(mapAchievementData, AchievementDataDic)
|
||||
local nCount = 0
|
||||
local tbTarget = mapAchievementData.ClientCompleteParams1
|
||||
for nMark, nTriggerCount in pairs(AchievementDataDic.MarkTriggerData) do
|
||||
if 0 < table.indexof(tbTarget, nMark) then
|
||||
nCount = nCount + nTriggerCount
|
||||
end
|
||||
end
|
||||
return nCount
|
||||
end
|
||||
function PlayerRelevant.OneHitDamage(mapAchievementData, AchievementDataDic)
|
||||
local nTarget = mapAchievementData.ClientCompleteParams1[1]
|
||||
if nTarget <= AchievementDataDic.MaxDamageValue then
|
||||
return 1
|
||||
end
|
||||
return 0
|
||||
end
|
||||
function PlayerRelevant.ClearLevelWithHPBelow(mapAchievementData, AchievementDataDic, bSuccess)
|
||||
if not bSuccess then
|
||||
return 0
|
||||
end
|
||||
local nTarget = mapAchievementData.ClientCompleteParams1[1]
|
||||
local nCurPrec = AchievementDataDic.MainActorHpPrec * 100
|
||||
if nTarget >= nCurPrec then
|
||||
return 1
|
||||
end
|
||||
return 0
|
||||
end
|
||||
return PlayerRelevant
|
||||
@@ -0,0 +1,31 @@
|
||||
local SkillsRelevant = {}
|
||||
function SkillsRelevant.KillMonsterWithoutHitBySkill(mapAchievementData, AchievementDataDic)
|
||||
if mapAchievementData.ClientCompleteParams2 == nil then
|
||||
return 0
|
||||
end
|
||||
if mapAchievementData.ClientCompleteParams1 == nil then
|
||||
return 0
|
||||
end
|
||||
if AchievementDataDic.DamageDataDic == nil then
|
||||
return 0
|
||||
end
|
||||
if AchievementDataDic.killDataDic == nil then
|
||||
return 0
|
||||
end
|
||||
for _, nHitDamageId in ipairs(mapAchievementData.ClientCompleteParams2) do
|
||||
for nCharId, mapDamageDic in pairs(AchievementDataDic.DamageDataDic) do
|
||||
if mapDamageDic:ContainsKey(nHitDamageId) then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, nMonsterId in ipairs(mapAchievementData.ClientCompleteParams1) do
|
||||
for nCharId, mapKillDic in pairs(AchievementDataDic.killDataDic) do
|
||||
if mapKillDic:ContainsKey(nMonsterId) then
|
||||
return 1
|
||||
end
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
return SkillsRelevant
|
||||
@@ -0,0 +1,207 @@
|
||||
local ActivityLevelsInstanceLevel = class("ActivityLevelsInstanceLevel")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
BattlePause = "OnEvent_Pause",
|
||||
ActivityInstance_Result = "LevelResultChange",
|
||||
ActivityLevelSettle_Failed = "OnEvent_ActivityLevelSettleFailed"
|
||||
}
|
||||
function ActivityLevelsInstanceLevel:Init(parent, nActivityId, nLevelId, nBuildId)
|
||||
self.parent = parent
|
||||
self.nLevelId = nLevelId
|
||||
self.nActivityId = nActivityId
|
||||
self.isSettlement = false
|
||||
local GetBuildCallback = function(mapBuildData)
|
||||
self.mapBuildData = mapBuildData
|
||||
self.tbCharId = {}
|
||||
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, mapChar.nTid)
|
||||
end
|
||||
self.tbDiscId = {}
|
||||
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
end
|
||||
end
|
||||
self.mapActorInfo = {}
|
||||
for idx, nTid in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
|
||||
self.mapActorInfo[nTid] = stActorInfo
|
||||
end
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.EquipmentInstance
|
||||
CS.AdventureModuleHelper.EnterActivityLevelsInstance(nLevelId, self.tbCharId)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:OnEvent_LoadLevelRefresh()
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
EventManager.Hit("OpenActivityLevelsInstanceRoomInfo", self.nLevelId)
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:OnEvent_LevelResult(tbStar, bAbandon)
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:OnEvent_AbandonBattle()
|
||||
self:LevelResultChange(false, 0)
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:OnEvent_AdventureModuleEnter()
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.ActivityLevels)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ActivityLevelsBattlePanel, self.tbCharId)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:LevelResultChange(isWin, totalTime)
|
||||
EventManager.Hit("ActivityLevelsInstanceBattleEnd")
|
||||
self:SettleLevelsInstance(isWin, totalTime)
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:RefreshCharDamageData()
|
||||
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:SettleLevelsInstance(isWin, totalTime)
|
||||
if self.isSettlement then
|
||||
return
|
||||
end
|
||||
self.isSettlement = true
|
||||
local starCount = 0
|
||||
self:RefreshCharDamageData()
|
||||
if isWin then
|
||||
local mapCfg = ConfigTable.GetData("ActivityLevelsLevel", self.nLevelId)
|
||||
if totalTime <= mapCfg.ThreeStarCondition[1] then
|
||||
starCount = 3
|
||||
elseif totalTime <= mapCfg.TwoStarCondition[1] then
|
||||
starCount = 2
|
||||
else
|
||||
starCount = 1
|
||||
end
|
||||
end
|
||||
local callback = function(taFixed, tbFirstReward, nExp, mapChangeInfo)
|
||||
NovaAPI.InputEnable()
|
||||
EventManager.Hit("ActivityLevelsInstanceLevelEnd")
|
||||
self.passStar = starCount
|
||||
if isWin then
|
||||
self:PlaySuccessPerform(taFixed, tbFirstReward, nExp, starCount, mapChangeInfo)
|
||||
else
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ActivityLevelsInstanceResultPanel, false, 0, {}, {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
|
||||
end
|
||||
self:UnBindEvent()
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
NovaAPI.InputDisable()
|
||||
self.parent:SendActivityLevelSettleReq(self.nActivityId, starCount, callback)
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:OnEvent_ActivityLevelSettleFailed()
|
||||
NovaAPI.InputEnable()
|
||||
EventManager.Hit("ActivityLevelsInstanceLevelEnd")
|
||||
self.passStar = 0
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ActivityLevelsInstanceResultPanel, false, 0, {}, {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, nil, self.tbCharDamage)
|
||||
local nCurTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
local nEndTime = self.parent.nEndTime
|
||||
if nCurTime > nEndTime then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Activity_End_Notice"))
|
||||
end
|
||||
self:UnBindEvent()
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:PlaySuccessPerform(FixedRewardItems, FirstRewardItems, nExp, starCount, mapChangeInfo)
|
||||
local func_SettlementFinish = function(bSuccess)
|
||||
end
|
||||
local tbChar = self.tbCharId
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local nType = ConfigTable.GetData("ActivityLevelsFloor", ConfigTable.GetData("ActivityLevelsLevel", self.nLevelId).FloorId).Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ActivityLevelsInstanceResultPanel, true, starCount, FixedRewardItems or {}, FirstRewardItems or {}, {}, nExp or 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
|
||||
self.bSettle = false
|
||||
self.parent:LevelEnd()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:SetCharFixedAttribute()
|
||||
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
return stActorInfo
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function ActivityLevelsInstanceLevel:OnEvent_Pause()
|
||||
EventManager.Hit("OpenActivityLevelsInstancePause", self.nActivityId, self.nLevelId, self.tbCharId)
|
||||
end
|
||||
return ActivityLevelsInstanceLevel
|
||||
@@ -0,0 +1,78 @@
|
||||
function UTILS.AddEffect(nCharId, nEffectId, nLevel, nUseCount)
|
||||
if nUseCount == nil then
|
||||
nUseCount = 0
|
||||
end
|
||||
local mapEftCfgData = ConfigTable.GetData_Effect(nEffectId)
|
||||
if mapEftCfgData == nil then
|
||||
printError("Effect Id missing" .. nEffectId)
|
||||
return nil
|
||||
end
|
||||
local nEffectValueId = nEffectId
|
||||
if mapEftCfgData.levelTypeData == GameEnum.levelTypeData.Exclusive then
|
||||
nEffectValueId = nEffectValueId + nLevel * 10
|
||||
elseif mapEftCfgData.levelTypeData == GameEnum.levelTypeData.OutfitPromote then
|
||||
elseif mapEftCfgData.levelTypeData == GameEnum.levelTypeData.OutfifBreak then
|
||||
end
|
||||
local mapEftValueData = ConfigTable.GetData("EffectValue", nEffectValueId)
|
||||
if mapEftValueData == nil then
|
||||
printError("EffectValue Id missing" .. nEffectValueId)
|
||||
return nil
|
||||
end
|
||||
local nTakeEffectLimit = mapEftValueData.TakeEffectLimit
|
||||
local nEftRemainTimes = nTakeEffectLimit
|
||||
if nTakeEffectLimit ~= 0 then
|
||||
nEftRemainTimes = nTakeEffectLimit - nUseCount
|
||||
if nEftRemainTimes <= 0 then
|
||||
printLog("效果次数已用完:" .. nEffectId)
|
||||
return nil
|
||||
end
|
||||
end
|
||||
local nEffectUid = 0
|
||||
return nEffectUid
|
||||
end
|
||||
function UTILS.AddBuildEffect(mapCharEffect, mapOutfitEffect)
|
||||
local retCharEffect = {}
|
||||
local retOutfitEffect = {}
|
||||
for nCharId, mapEffect in pairs(mapCharEffect) do
|
||||
if mapEffect[AllEnum.EffectType.Affinity] ~= nil then
|
||||
for _, nEffectId in ipairs(mapEffect[AllEnum.EffectType.Affinity]) do
|
||||
if retCharEffect[AllEnum.EffectType.Affinity] == nil then
|
||||
retCharEffect[AllEnum.EffectType.Affinity] = {}
|
||||
end
|
||||
if retCharEffect[AllEnum.EffectType.Affinity][nEffectId] ~= nil then
|
||||
printError("重复的EffectID:" .. nEffectId)
|
||||
else
|
||||
local nEftUid = UTILS.AddEffect(nCharId, nEffectId, 0, 0)
|
||||
retCharEffect[AllEnum.EffectType.Affinity][nEffectId] = nEftUid
|
||||
end
|
||||
end
|
||||
end
|
||||
if mapEffect[AllEnum.EffectType.Talent] ~= nil then
|
||||
for _, nEffectId in ipairs(mapEffect[AllEnum.EffectType.Talent]) do
|
||||
if retCharEffect[AllEnum.EffectType.Talent] == nil then
|
||||
retCharEffect[AllEnum.EffectType.Talent] = {}
|
||||
end
|
||||
if retCharEffect[AllEnum.EffectType.Talent][nEffectId] ~= nil then
|
||||
printError("重复的EffectID:" .. nEffectId)
|
||||
else
|
||||
local nEftUid = UTILS.AddEffect(nCharId, nEffectId, 0, 0)
|
||||
retCharEffect[AllEnum.EffectType.Talent][nEffectId] = nEftUid
|
||||
end
|
||||
end
|
||||
end
|
||||
if mapOutfitEffect ~= nil then
|
||||
for nOutfitTid, tbOutfitEffectId in pairs(mapCharEffect) do
|
||||
if retOutfitEffect[nOutfitTid] == nil then
|
||||
retOutfitEffect[nOutfitTid] = {}
|
||||
end
|
||||
for _, nEffectId in ipairs(tbOutfitEffectId) do
|
||||
if retOutfitEffect[nOutfitTid][nEffectId] == nil then
|
||||
retOutfitEffect[nOutfitTid][nEffectId] = {}
|
||||
end
|
||||
local nEftUid = UTILS.AddEffect(nCharId, nEffectId, 0, 0)
|
||||
table.insert(retOutfitEffect[nOutfitTid][nEffectId], nEftUid)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,194 @@
|
||||
local DailyInstanceLevel = class("DailyInstanceLevel")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
DailyInstanceGameEnd = "OnEvent_LevelResult",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
BattlePause = "OnEvnet_Pause"
|
||||
}
|
||||
function DailyInstanceLevel:Init(parent, nLevelId, nBuildId)
|
||||
self.parent = parent
|
||||
self.nLevelId = nLevelId
|
||||
local GetBuildCallback = function(mapBuildData)
|
||||
self.mapBuildData = mapBuildData
|
||||
self.tbCharId = {}
|
||||
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, mapChar.nTid)
|
||||
end
|
||||
self.tbDiscId = {}
|
||||
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
end
|
||||
end
|
||||
self.mapActorInfo = {}
|
||||
for idx, nTid in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
|
||||
self.mapActorInfo[nTid] = stActorInfo
|
||||
end
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.DailyInstance
|
||||
CS.AdventureModuleHelper.EnterDailyInstanceMap(nLevelId, self.tbCharId)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
|
||||
end
|
||||
function DailyInstanceLevel:RefreshCharDamageData()
|
||||
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
|
||||
end
|
||||
function DailyInstanceLevel:OnEvent_LoadLevelRefresh()
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
EventManager.Hit("OpenDailyInstanceRoomInfo", ConfigTable.GetData("DailyInstance", self.nLevelId).FloorId, self.nLevelId)
|
||||
end
|
||||
function DailyInstanceLevel:OnEvent_LevelResult(tbStar, bAbandon)
|
||||
EventManager.Hit("DailyInstanceBattleEnd")
|
||||
if self.parent:GetSettlementState() then
|
||||
printError("日常副本结算流程重复进入,本次退出")
|
||||
return
|
||||
end
|
||||
self:RefreshCharDamageData()
|
||||
self.parent:SetSettlementState(true)
|
||||
local mapDILevelCfgData = ConfigTable.GetData("DailyInstance", self.nLevelId)
|
||||
local nStar = 0
|
||||
local nStarCount = 0
|
||||
nStar = tbStar[0] and nStar | 1 or nStar
|
||||
nStar = tbStar[1] and nStar | 2 or nStar
|
||||
nStar = tbStar[2] and nStar | 4 or nStar
|
||||
for i = 0, 2 do
|
||||
if tbStar[i] then
|
||||
nStarCount = nStarCount + 1
|
||||
end
|
||||
end
|
||||
local callback = function(tbSelectReward, tbFirstReward, nExp, mapChangeInfo)
|
||||
local waitCallback = function()
|
||||
NovaAPI.InputEnable()
|
||||
if 0 < nStar then
|
||||
self:PlaySuccessPerform(tbFirstReward, tbSelectReward, nExp, tbStar, mapChangeInfo)
|
||||
else
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DailyInstanceResultPanel, false, tbStar, {}, {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
end
|
||||
EventManager.Hit("DailyInstanceLevelEnd", mapDILevelCfgData.FloorId)
|
||||
if bAbandon then
|
||||
waitCallback()
|
||||
else
|
||||
TimerManager.Add(1, 2, self, waitCallback, true, true, true, nil)
|
||||
end
|
||||
end
|
||||
NovaAPI.InputDisable()
|
||||
self.parent:MsgSettleDailyInstance(self.nLevelId, self.mapBuildData.nBuildId, nStar, callback)
|
||||
end
|
||||
function DailyInstanceLevel:OnEvent_AbandonBattle()
|
||||
self:OnEvent_LevelResult({
|
||||
false,
|
||||
false,
|
||||
false
|
||||
}, true)
|
||||
end
|
||||
function DailyInstanceLevel:OnEvent_AdventureModuleEnter()
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.DailyInstance)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DailyInstanceBattlePanel, self.tbCharId)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function DailyInstanceLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function DailyInstanceLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function DailyInstanceLevel:PlaySuccessPerform(FirstRewardItems, tbSelectReward, nExp, tbStar, mapChangeInfo)
|
||||
local func_SettlementFinish = function(bSuccess)
|
||||
end
|
||||
local tbChar = self.tbCharId
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local nType = ConfigTable.GetData("DailyInstanceFloor", ConfigTable.GetData("DailyInstance", self.nLevelId).FloorId).Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DailyInstanceResultPanel, true, tbStar, tbSelectReward or {}, FirstRewardItems or {}, {}, nExp or 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
|
||||
self.bSettle = false
|
||||
self.parent:LevelEnd()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
end
|
||||
function DailyInstanceLevel:SetCharFixedAttribute()
|
||||
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function DailyInstanceLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
return stActorInfo
|
||||
end
|
||||
function DailyInstanceLevel:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function DailyInstanceLevel:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function DailyInstanceLevel:OnEvnet_Pause()
|
||||
EventManager.Hit("OpenDailyInstancePause", self.nLevelId, self.tbCharId)
|
||||
end
|
||||
return DailyInstanceLevel
|
||||
@@ -0,0 +1,194 @@
|
||||
local EquipmentInstanceLevel = class("EquipmentInstanceLevel")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
EquipmentInstanceGameEnd = "OnEvent_LevelResult",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
BattlePause = "OnEvnet_Pause"
|
||||
}
|
||||
function EquipmentInstanceLevel:Init(parent, nLevelId, nBuildId)
|
||||
self.parent = parent
|
||||
self.nLevelId = nLevelId
|
||||
local GetBuildCallback = function(mapBuildData)
|
||||
self.mapBuildData = mapBuildData
|
||||
self.tbCharId = {}
|
||||
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, mapChar.nTid)
|
||||
end
|
||||
self.tbDiscId = {}
|
||||
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
end
|
||||
end
|
||||
self.mapActorInfo = {}
|
||||
for idx, nTid in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
|
||||
self.mapActorInfo[nTid] = stActorInfo
|
||||
end
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.EquipmentInstance
|
||||
CS.AdventureModuleHelper.EnterEquipmentInstanceMap(nLevelId, self.tbCharId)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
|
||||
end
|
||||
function EquipmentInstanceLevel:RefreshCharDamageData()
|
||||
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
|
||||
end
|
||||
function EquipmentInstanceLevel:OnEvent_LoadLevelRefresh()
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
EventManager.Hit("OpenEquipmentInstanceRoomInfo", ConfigTable.GetData("CharGemInstance", self.nLevelId).FloorId, self.nLevelId)
|
||||
end
|
||||
function EquipmentInstanceLevel:OnEvent_LevelResult(tbStar, bAbandon)
|
||||
EventManager.Hit("EquipmentInstanceBattleEnd")
|
||||
if self.parent:GetSettlementState() then
|
||||
printError("装备副本结算流程重复进入,本次退出")
|
||||
return
|
||||
end
|
||||
self:RefreshCharDamageData()
|
||||
self.parent:SetSettlementState(true)
|
||||
local mapDILevelCfgData = ConfigTable.GetData("CharGemInstance", self.nLevelId)
|
||||
local nStar = 0
|
||||
local nStarCount = 0
|
||||
nStar = tbStar[0] and 1 or nStar
|
||||
nStar = tbStar[1] and 2 or nStar
|
||||
nStar = tbStar[2] and 3 or nStar
|
||||
for i = 0, 2 do
|
||||
if tbStar[i] then
|
||||
nStarCount = nStarCount + 1
|
||||
end
|
||||
end
|
||||
local callback = function(tbStarReward, tbFirstReward, tbSurpriseItems, nExp, mapChangeInfo)
|
||||
local waitCallback = function()
|
||||
NovaAPI.InputEnable()
|
||||
if 0 < nStar then
|
||||
self:PlaySuccessPerform(tbFirstReward, tbStarReward, tbSurpriseItems, nExp, tbStar, mapChangeInfo)
|
||||
else
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentInstanceResult, false, tbStar, {}, {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, {}, self.tbCharDamage or {})
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
end
|
||||
EventManager.Hit("EquipmentInstanceLevelEnd", mapDILevelCfgData.FloorId)
|
||||
if bAbandon then
|
||||
waitCallback()
|
||||
else
|
||||
TimerManager.Add(1, 2, self, waitCallback, true, true, true, nil)
|
||||
end
|
||||
end
|
||||
NovaAPI.InputDisable()
|
||||
self.parent:MsgSettleEquipmentInstance(self.nLevelId, self.mapBuildData.nBuildId, nStar, callback)
|
||||
end
|
||||
function EquipmentInstanceLevel:OnEvent_AbandonBattle()
|
||||
self:OnEvent_LevelResult({
|
||||
false,
|
||||
false,
|
||||
false
|
||||
}, true)
|
||||
end
|
||||
function EquipmentInstanceLevel:OnEvent_AdventureModuleEnter()
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.EquipmentInstance)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentInstanceBattlePanel, self.tbCharId)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function EquipmentInstanceLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function EquipmentInstanceLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function EquipmentInstanceLevel:PlaySuccessPerform(FirstRewardItems, tbStarReward, tbSurpriseItems, nExp, tbStar, mapChangeInfo)
|
||||
local func_SettlementFinish = function(bSuccess)
|
||||
end
|
||||
local tbChar = self.tbCharId
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local nType = ConfigTable.GetData("CharGemInstanceFloor", ConfigTable.GetData("CharGemInstance", self.nLevelId).FloorId).Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentInstanceResult, true, tbStar, tbStarReward or {}, FirstRewardItems or {}, {}, nExp or 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, tbSurpriseItems or {}, self.tbCharDamage or {})
|
||||
self.bSettle = false
|
||||
self.parent:LevelEnd()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
end
|
||||
function EquipmentInstanceLevel:SetCharFixedAttribute()
|
||||
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function EquipmentInstanceLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
return stActorInfo
|
||||
end
|
||||
function EquipmentInstanceLevel:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function EquipmentInstanceLevel:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function EquipmentInstanceLevel:OnEvnet_Pause()
|
||||
EventManager.Hit("OpenEquipmentInstancePause", self.nLevelId, self.tbCharId)
|
||||
end
|
||||
return EquipmentInstanceLevel
|
||||
@@ -0,0 +1,143 @@
|
||||
local InfinityTowerLevel = class("InfinityTowerLevel")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
InfinityTowerEnd = "OnEvent_InfinityTowerEnd",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
BattlePause = "OnEvnet_Pause",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
Infinity_Tower_RunTime = "OnEvent_InfinityTowerRunTime",
|
||||
ADVENTURE_LEVEL_UNLOAD_COMPLETE = "OnEvent_UnloadComplete"
|
||||
}
|
||||
function InfinityTowerLevel:Init(parent, floorId, nBuildId, againOrNextLv, isContinue)
|
||||
self.parent = parent
|
||||
self.floorId = floorId
|
||||
self.lvRunTime = 0
|
||||
local GetBuildCallback = function(mapBuildData)
|
||||
self.mapBuildData = mapBuildData
|
||||
self.tbCharId = {}
|
||||
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, mapChar.nTid)
|
||||
end
|
||||
self.tbDiscId = {}
|
||||
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
end
|
||||
end
|
||||
self.mapActorInfo = {}
|
||||
for idx, nTid in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
|
||||
self.mapActorInfo[nTid] = stActorInfo
|
||||
end
|
||||
self.parent:CacheBuildCharTid(self.tbCharId)
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.InfinityTower
|
||||
CS.AdventureModuleHelper.EnterInfinityTowerFloor(self.floorId, self.tbCharId, isContinue)
|
||||
if againOrNextLv == 0 then
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
else
|
||||
self:OnEvent_AdventureModuleEnter()
|
||||
end
|
||||
EventManager.Hit("Infinity_Refresh_Msg")
|
||||
end
|
||||
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
|
||||
end
|
||||
function InfinityTowerLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
return stActorInfo
|
||||
end
|
||||
function InfinityTowerLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function InfinityTowerLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function InfinityTowerLevel:OnEvent_InfinityTowerEnd(state)
|
||||
if state == 1 then
|
||||
self.parent:ITSettleReq(2, self.lvRunTime, self.tbCharId)
|
||||
elseif state == 2 then
|
||||
self.parent:ITSettleReq(1, self.lvRunTime, self.tbCharId)
|
||||
elseif state == 3 then
|
||||
self.parent:ITSettleReq(3, self.lvRunTime, self.tbCharId)
|
||||
end
|
||||
EventManager.Hit("Infinity_Hide_Time")
|
||||
EventManager.Hit("ResetBossHUD")
|
||||
end
|
||||
function InfinityTowerLevel:OnEvent_AdventureModuleEnter()
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.InfinityTower)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.InfinityTowerBattlePanel, self.tbCharId)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Hud)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function InfinityTowerLevel:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function InfinityTowerLevel:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function InfinityTowerLevel:OnEvent_LoadLevelRefresh()
|
||||
EventManager.Hit("MainBattleMenuBtnPauseActive", true)
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
local tabAddAffixBuff = PlayerData.InfinityTower:GetFloorAffixBuff(self.tbCharId, self.floorId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.InfinityTowerFloorEffects, tabAddAffixBuff)
|
||||
end
|
||||
function InfinityTowerLevel:OnEvent_UnloadComplete()
|
||||
self.parent:EnterInfinityTowerAgainNext()
|
||||
end
|
||||
function InfinityTowerLevel:OnEvnet_Pause()
|
||||
EventManager.Hit("show_Infinity_Pause", self.lvRunTime, self.tbCharId)
|
||||
end
|
||||
function InfinityTowerLevel:OnEvent_AbandonBattle()
|
||||
self:OnEvent_InfinityTowerEnd(3)
|
||||
end
|
||||
function InfinityTowerLevel:OnEvent_InfinityTowerRunTime(rTime)
|
||||
self.lvRunTime = rTime
|
||||
end
|
||||
return InfinityTowerLevel
|
||||
@@ -0,0 +1,688 @@
|
||||
local JointDrillLevelData = class("JointDrillLevelData")
|
||||
local FP = CS.TrueSync.FP
|
||||
local PB = require("pb")
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
BattlePause = "OnEvent_Pause",
|
||||
JointDrill_StartTiming = "OnEvent_BattleStart",
|
||||
JointDrill_MonsterSpawn = "OnEvent_MonsterSpawn",
|
||||
JointDrill_BattleLvsToggle = "OnEvent_BattleLvsToggle",
|
||||
ADVENTURE_LEVEL_UNLOAD_COMPLETE = "OnEvent_UnloadComplete",
|
||||
JointDrill_Gameplay_Time = "OnEvent_JointDrill_Gameplay_Time",
|
||||
JointDrill_DamageValue = "OnEvent_DamageValue",
|
||||
JointDrill_CharDamageValue = "OnEvent_CharDamageValue",
|
||||
GiveUpJointDrill = "OnEvent_GiveUpBattle",
|
||||
RestartJointDrill = "OnEvent_RestartJointDrill",
|
||||
RetreatJointDrill = "OnEvent_RetreatJointDrill",
|
||||
JointDrill_Result = "OnEvent_JointDrill_Result",
|
||||
InputEnable = "OnEvent_InputEnable",
|
||||
JointDrill_StopTime = "OnEvent_JointDrill_StopTime",
|
||||
JointDrillChallengeFinishError = "OnEvent_JointDrillChallengeFinishError",
|
||||
Upload_Dodge_Event = "OnEvent_UploadDodgeEvent"
|
||||
}
|
||||
function JointDrillLevelData:Init(parent, nLevelId, nBuildId, nCurLevel, bChangeLevel)
|
||||
self.parent = parent
|
||||
self.nLevelId = nLevelId
|
||||
self.nCurLevel = nCurLevel
|
||||
self.nBuildId = nBuildId
|
||||
self.bChangeLevel = bChangeLevel
|
||||
self.mapLevel = nil
|
||||
self.tbFloor = {}
|
||||
self.mapFloor = nil
|
||||
self.nGameTime = self.parent:GetGameTime()
|
||||
self.bInResult = false
|
||||
if not bChangeLevel or self.bRestart then
|
||||
self.nDamageValue = 0
|
||||
self.tbCharDamage = {}
|
||||
self.mapActorInfo = nil
|
||||
end
|
||||
self.mapTempData = {}
|
||||
if self.parent.record ~= nil and self.parent.record ~= "" then
|
||||
self.mapTempData = self.parent:DecodeTempDataJson()
|
||||
if not bChangeLevel or self.bRestart then
|
||||
self.mapInitTempData = clone(self.mapTempData)
|
||||
end
|
||||
end
|
||||
if self.mapInitTempData == nil then
|
||||
self.mapInitTempData = {}
|
||||
end
|
||||
local mapJointDrillLevelData = ConfigTable.GetData("JointDrillLevel", nLevelId)
|
||||
if mapJointDrillLevelData == nil then
|
||||
return
|
||||
end
|
||||
self.mapLevel = mapJointDrillLevelData
|
||||
local nFloorGroup = mapJointDrillLevelData.FloorId
|
||||
self.tbFloor = CacheTable.GetData("_JointDrillFloor", nFloorGroup)
|
||||
self.mapFloor = self.tbFloor[nCurLevel]
|
||||
local GetBuildCallback = function(mapBuildData)
|
||||
self.mapBuildData = mapBuildData
|
||||
self.parent:AddJointDrillTeam(self.mapBuildData, self.nGameTime, self.nDamageValue)
|
||||
self.tbCharId = {}
|
||||
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, mapChar.nTid)
|
||||
end
|
||||
self.tbDiscId = {}
|
||||
for _, nDiscId in pairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
end
|
||||
end
|
||||
if #self.tbCharDamage == 0 then
|
||||
for _, v in ipairs(self.tbCharId) do
|
||||
table.insert(self.tbCharDamage, {nCharId = v, nDamage = 0})
|
||||
end
|
||||
end
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.JointDrill
|
||||
local mapParams = {
|
||||
tostring(self.nCurLevel),
|
||||
tostring(self.bChangeLevel),
|
||||
tostring(self.nGameTime)
|
||||
}
|
||||
self.bRestart = false
|
||||
if not bChangeLevel then
|
||||
AdventureModuleHelper.EnterDynamic(self.nLevelId, self.tbCharId, GameEnum.dynamicLevelType.JointDrill, mapParams)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
else
|
||||
self:StartJointDrill()
|
||||
AdventureModuleHelper.EnterDynamic(self.nLevelId, self.tbCharId, GameEnum.dynamicLevelType.JointDrill, mapParams)
|
||||
end
|
||||
local sKey = LocalData.GetPlayerLocalData("JointDrillRecordKey") or ""
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDamageRecordId, sKey)
|
||||
end
|
||||
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
|
||||
end
|
||||
function JointDrillLevelData:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function JointDrillLevelData:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function JointDrillLevelData:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
return stActorInfo
|
||||
end
|
||||
function JointDrillLevelData:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function JointDrillLevelData:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function JointDrillLevelData:GetSyncGameTime(nTime)
|
||||
return math.floor(tonumber(string.format("%.3f", nTime)) * 1000)
|
||||
end
|
||||
function JointDrillLevelData:CacheTempData(bCharacter, bBoss, bChangeTeam, bChangeLevel, bLockBossHp)
|
||||
if not bCharacter and not bBoss then
|
||||
return
|
||||
end
|
||||
self.mapTempData = {}
|
||||
self.mapTempData.mapCharacterTempData = {}
|
||||
self.mapTempData.mapBossTempData = {}
|
||||
if bCharacter then
|
||||
local id = AdventureModuleHelper.GetCurrentActivePlayer()
|
||||
self.mapTempData.mapCharacterTempData.hpInfo = {}
|
||||
self.mapTempData.mapCharacterTempData.skillInfo = {}
|
||||
self.mapTempData.mapCharacterTempData.effectInfo = {}
|
||||
self.mapTempData.mapCharacterTempData.buffInfo = {}
|
||||
self.mapTempData.mapCharacterTempData.stateInfo = {}
|
||||
self.mapTempData.mapCharacterTempData.ammoInfo = {}
|
||||
self.mapTempData.mapCharacterTempData.sommonInfo = AdventureModuleHelper.GetSummonMonsterInfos()
|
||||
self.mapActorInfo = self:GetActorHp()
|
||||
self.mapTempData.mapCharacterTempData.hpInfo = self:GetActorHp()
|
||||
local playerids = AdventureModuleHelper.GetCurrentGroupPlayers()
|
||||
local Count = playerids.Count - 1
|
||||
for i = 0, Count do
|
||||
local charTid = AdventureModuleHelper.GetCharacterId(playerids[i])
|
||||
local clsSkillId = AdventureModuleHelper.GetPlayerSkillCd(playerids[i])
|
||||
local nStatus = AdventureModuleHelper.GetPlayerActorStatus(playerids[i])
|
||||
local nStatusTime = AdventureModuleHelper.GetPlayerActorSpecialStatusTime(playerids[i])
|
||||
local tbAmmo = AdventureModuleHelper.GetPlayerActorAmmoCount(playerids[i])
|
||||
local nAmmoType = AdventureModuleHelper.GetPlayerActorAmmoType(playerids[i])
|
||||
local jsonString = AdventureModuleHelper.GetPlayerActorLocalDataJson(playerids[i])
|
||||
print(string.format("Status:%d,Time:%d", nStatus, nStatusTime))
|
||||
if clsSkillId ~= nil then
|
||||
local tbSkillInfos = clsSkillId.skillInfos
|
||||
local nSkillCount = tbSkillInfos.Count - 1
|
||||
for j = 0, nSkillCount do
|
||||
local clsSkillInfo = tbSkillInfos[j]
|
||||
local mapSkill = ConfigTable.GetData_Skill(clsSkillInfo.skillId)
|
||||
if mapSkill == nil then
|
||||
return
|
||||
end
|
||||
if not mapSkill.IsCleanSkillCD then
|
||||
table.insert(self.mapTempData.mapCharacterTempData.skillInfo, {
|
||||
nCharId = charTid,
|
||||
nSkillId = clsSkillInfo.skillId,
|
||||
nCd = FP.ToInt(clsSkillInfo.currentUseInterval),
|
||||
nSectionAmount = clsSkillInfo.currentSectionAmount,
|
||||
nSectionResumeTime = FP.ToInt(clsSkillInfo.currentResumeTime),
|
||||
nUseTimeHint = FP.ToInt(clsSkillInfo.currentUseTimeHint),
|
||||
nEnergy = FP.ToInt(clsSkillInfo.currentEnergy)
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
self.mapTempData.mapCharacterTempData.effectInfo[charTid] = {
|
||||
mapEffect = {}
|
||||
}
|
||||
local tbClsEfts = AdventureModuleHelper.GetEffectList(playerids[i])
|
||||
if tbClsEfts ~= nil then
|
||||
local nEftCount = tbClsEfts.Count - 1
|
||||
for k = 0, nEftCount do
|
||||
local eftInfo = tbClsEfts[k]
|
||||
local mapEft = ConfigTable.GetData_Effect(eftInfo.effectConfig.Id)
|
||||
if mapEft == nil then
|
||||
return
|
||||
end
|
||||
local nCd = eftInfo.CD.RawValue
|
||||
if mapEft.Remove then
|
||||
self.mapTempData.mapCharacterTempData.effectInfo[charTid].mapEffect[eftInfo.effectConfig.Id] = {nCount = 0, nCd = nCd}
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.mapEffectTriggerCount ~= nil then
|
||||
for nEftId, nCount in pairs(self.mapEffectTriggerCount) do
|
||||
if self.mapTempData.mapCharacterTempData.effectInfo[charTid].mapEffect[nEftId] == nil then
|
||||
self.mapTempData.mapCharacterTempData.effectInfo[charTid].mapEffect[nEftId] = {nCount = nCount, nCd = 0}
|
||||
else
|
||||
self.mapTempData.mapCharacterTempData.effectInfo[charTid].mapEffect[nEftId].nCount = nCount
|
||||
end
|
||||
end
|
||||
end
|
||||
local tbBuffInfo = AdventureModuleHelper.GetEntityBuffList(playerids[i])
|
||||
self.mapTempData.mapCharacterTempData.buffInfo[charTid] = {}
|
||||
if tbBuffInfo ~= nil then
|
||||
local nBuffCount = tbBuffInfo.Count - 1
|
||||
for l = 0, nBuffCount do
|
||||
local eftInfo = tbBuffInfo[l]
|
||||
local mapBuff = ConfigTable.GetData_Buff(eftInfo.buffConfig.Id)
|
||||
if mapBuff == nil then
|
||||
return
|
||||
end
|
||||
if mapBuff.NotRemove then
|
||||
table.insert(self.mapTempData.mapCharacterTempData.buffInfo[charTid], {
|
||||
Id = eftInfo.buffConfig.Id,
|
||||
CD = eftInfo:GetBuffLeftTime().RawValue,
|
||||
nNum = eftInfo:GetBuffNum()
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
self.mapTempData.mapCharacterTempData.stateInfo[charTid] = {
|
||||
nState = nStatus,
|
||||
nStateTime = nStatusTime,
|
||||
jsonStr = jsonString
|
||||
}
|
||||
if tbAmmo ~= nil then
|
||||
self.mapTempData.mapCharacterTempData.ammoInfo[charTid] = {}
|
||||
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nCurAmmo = nAmmoType
|
||||
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmo1 = tbAmmo[0]
|
||||
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmo2 = tbAmmo[1]
|
||||
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmo3 = tbAmmo[2]
|
||||
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmoMax1 = tbAmmo[3]
|
||||
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmoMax2 = tbAmmo[4]
|
||||
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmoMax3 = tbAmmo[5]
|
||||
end
|
||||
if charTid == self.tbCharId[1] then
|
||||
self.mapTempData.mapCharacterTempData.shieldList = AdventureModuleHelper.GetEntityShieldList(playerids[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
if bBoss then
|
||||
local bSaveEnergyValue = false
|
||||
local bSaveResilience = false
|
||||
if bChangeLevel then
|
||||
bSaveEnergyValue = self.mapFloor.SaveEnergyValue
|
||||
bSaveResilience = self.mapFloor.SaveResilience
|
||||
elseif bChangeTeam then
|
||||
bSaveEnergyValue = self.mapFloor.TeamSaveEnergyValue
|
||||
bSaveResilience = self.mapFloor.TeamSaveResilience
|
||||
end
|
||||
EventManager.HitEntityEvent("RefreshBossEnergyValueHUD", self.nBossId, bSaveEnergyValue)
|
||||
self.mapTempData.mapBossTempData = AdventureModuleHelper.GetJointDrillBossData(self.nBossId, bChangeTeam, bSaveEnergyValue, bSaveResilience)
|
||||
if bLockBossHp then
|
||||
if 0 >= self.mapTempData.mapBossTempData.nHp then
|
||||
self.mapTempData.mapBossTempData.nHp = 1
|
||||
end
|
||||
if 0 >= self.mapTempData.mapBossTempData.nHpMax then
|
||||
self.mapTempData.mapBossTempData.nHpMax = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
local data, nDataLength = self.parent:EncodeTempDataJson(self.mapTempData)
|
||||
print("temp数据长度�?" .. #data)
|
||||
local msgInt = "proto.I32"
|
||||
local msgLength = {
|
||||
Value = #data
|
||||
}
|
||||
local dataLength = assert(PB.encode(msgInt, msgLength))
|
||||
local dataNew = dataLength .. data
|
||||
print("temp数据total长度�?" .. #dataNew)
|
||||
return data, nDataLength
|
||||
end
|
||||
function JointDrillLevelData:SetActorHP()
|
||||
local tbActorInfo = {}
|
||||
if self.mapActorInfo == nil then
|
||||
return
|
||||
end
|
||||
for nTid, nHp in pairs(self.mapActorInfo) do
|
||||
local stCharInfo = CS.Lua2CSharpInfo_ActorAttribute()
|
||||
stCharInfo.actorID = nTid
|
||||
stCharInfo.curHP = nHp
|
||||
table.insert(tbActorInfo, stCharInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorAttributes, tbActorInfo)
|
||||
end
|
||||
function JointDrillLevelData:ResetBuff()
|
||||
local ret = {}
|
||||
if self.mapTempData.mapCharacterTempData ~= nil and self.mapTempData.mapCharacterTempData.buffInfo ~= nil then
|
||||
for nCharId, mapBuff in pairs(self.mapTempData.mapCharacterTempData.buffInfo) do
|
||||
for _, mapBuffInfo in ipairs(mapBuff) do
|
||||
local stBuffInfo = CS.Lua2CSharpInfo_ResetBuffInfo()
|
||||
stBuffInfo.Id = mapBuffInfo.Id
|
||||
stBuffInfo.Cd = mapBuffInfo.CD
|
||||
stBuffInfo.buffNum = mapBuffInfo.nNum
|
||||
if ret[nCharId] == nil then
|
||||
ret[nCharId] = {}
|
||||
end
|
||||
table.insert(ret[nCharId], stBuffInfo)
|
||||
end
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ResetBuff, ret)
|
||||
end
|
||||
function JointDrillLevelData:ResetSkill()
|
||||
local ret = {}
|
||||
if self.mapTempData.mapCharacterTempData ~= nil and self.mapTempData.mapCharacterTempData.skillInfo ~= nil then
|
||||
for _, skillInfo in ipairs(self.mapTempData.mapCharacterTempData.skillInfo) do
|
||||
local stSkillInfo = CS.Lua2CSharpInfo_ResetSkillInfo()
|
||||
stSkillInfo.skillId = skillInfo.nSkillId
|
||||
stSkillInfo.currentSectionAmount = skillInfo.nSectionAmount
|
||||
stSkillInfo.cd = FP.FromFloat(skillInfo.nCd).RawValue
|
||||
stSkillInfo.currentResumeTime = FP.FromFloat(skillInfo.nSectionResumeTime).RawValue
|
||||
stSkillInfo.currentUseTimeHint = FP.FromFloat(skillInfo.nUseTimeHint).RawValue
|
||||
stSkillInfo.energy = FP.FromFloat(skillInfo.nEnergy).RawValue
|
||||
if ret[skillInfo.nCharId] == nil then
|
||||
ret[skillInfo.nCharId] = {}
|
||||
end
|
||||
table.insert(ret[skillInfo.nCharId], stSkillInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorSkillInfo, ret)
|
||||
end
|
||||
function JointDrillLevelData:ResetAmmo()
|
||||
if self.mapTempData.mapCharacterTempData ~= nil and self.mapTempData.mapCharacterTempData.ammoInfo ~= nil then
|
||||
local ret = {}
|
||||
for nCharId, mapAmmo in pairs(self.mapTempData.mapCharacterTempData.ammoInfo) do
|
||||
local stInfo = CS.Lua2CSharpInfo_ActorAmmoInfo()
|
||||
local tbAmmoCount = {
|
||||
mapAmmo.nAmmo1,
|
||||
mapAmmo.nAmmo2,
|
||||
mapAmmo.nAmmo3
|
||||
}
|
||||
stInfo.actorID = nCharId
|
||||
stInfo.ammoCount = tbAmmoCount
|
||||
stInfo.ammoType = mapAmmo.nCurAmmo
|
||||
table.insert(ret, stInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAmmoInfos, ret)
|
||||
end
|
||||
end
|
||||
function JointDrillLevelData:ResetSommon()
|
||||
if self.mapTempData.mapCharacterTempData ~= nil and self.mapTempData.mapCharacterTempData.sommonInfo ~= nil then
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetSummonMonsters, self.mapTempData.mapCharacterTempData.sommonInfo)
|
||||
end
|
||||
end
|
||||
function JointDrillLevelData:ResetCharacter()
|
||||
end
|
||||
function JointDrillLevelData:GetActorHp()
|
||||
local logStr = ""
|
||||
local tbActorEntity = AdventureModuleHelper.GetCurrentGroupPlayers()
|
||||
local mapCurCharInfo = {}
|
||||
local count = tbActorEntity.Count - 1
|
||||
for i = 0, count do
|
||||
local nCharId = AdventureModuleHelper.GetCharacterId(tbActorEntity[i])
|
||||
local hp = AdventureModuleHelper.GetEntityHp(tbActorEntity[i])
|
||||
mapCurCharInfo[nCharId] = hp
|
||||
logStr = logStr .. string.format("EntityID:%d\t角色Id�?%d\t角色血量:%d\n", tbActorEntity[i], nCharId, hp)
|
||||
end
|
||||
print(logStr)
|
||||
return mapCurCharInfo
|
||||
end
|
||||
function JointDrillLevelData:JointDrillSuccess(netMsg)
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(self.tbCharId) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
local nScoreOld = 0
|
||||
local mapSelfRank = self.parent:GetSelfRankData()
|
||||
if mapSelfRank ~= nil then
|
||||
nScoreOld = mapSelfRank.Score
|
||||
end
|
||||
local func_SettlementFinish = function()
|
||||
end
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local nType = self.mapFloor.Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
print("sceneName:" .. sName)
|
||||
AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
local nResultType = AllEnum.JointDrillResultType.Success
|
||||
local nScore = netMsg.FightScore + netMsg.HpScore + netMsg.DifficultyScore
|
||||
local mapScore = {
|
||||
FightScore = netMsg.FightScore,
|
||||
HpScore = netMsg.HpScore,
|
||||
DifficultyScore = netMsg.DifficultyScore,
|
||||
nTotalScore = self.parent.nTotalScore,
|
||||
nScore = nScore,
|
||||
nScoreOld = nScoreOld
|
||||
}
|
||||
local bSimulate = self.parent:GetBattleSimulate()
|
||||
local nBattleCount = self.parent:GetJointDrillBattleCount()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.JointDrillResult, nResultType, self.nCurLevel, 0, self.nLevelId, {}, mapScore, netMsg.Items or {}, netMsg.Change or {}, netMsg.Old, netMsg.New, bSimulate, nBattleCount, self.tbCharDamage)
|
||||
self.parent:ChallengeEnd()
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
AdventureModuleHelper.LevelStateChanged(true)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
end
|
||||
function JointDrillLevelData:CheckJointDrillGameOver()
|
||||
local nChallengeCount = self.parent:GetJointDrillBattleCount()
|
||||
local nAllChallengeCount = self.parent:GetMaxChallengeCount(self.nLevelId)
|
||||
if nChallengeCount >= nAllChallengeCount then
|
||||
local callback = function(netMsg)
|
||||
self:JointDrillFail(AllEnum.JointDrillResultType.ChallengeEnd, netMsg)
|
||||
end
|
||||
self.parent:JointDrillGameOver(callback)
|
||||
else
|
||||
local bBossFloor = self.mapFloor.FloorType == GameEnum.JointDrillFloorType.Boss
|
||||
local data, nDataLength = self:CacheTempData(false, bBossFloor, true, false, true)
|
||||
local mapBossInfo = self.mapTempData.mapBossTempData
|
||||
local callback = function(netMsg)
|
||||
self:JointDrillFail(AllEnum.JointDrillResultType.BattleEnd, netMsg)
|
||||
end
|
||||
self.parent:JointDrillGiveUp(self.nCurLevel, self.nGameTime, self.nDamageValue, mapBossInfo.nHp, data, self.mapBuildData, callback)
|
||||
end
|
||||
end
|
||||
function JointDrillLevelData:JointDrillFail(nResultType, netMsg)
|
||||
local bossInfo = {}
|
||||
local tempBossData = self.mapTempData.mapBossTempData
|
||||
if nResultType == AllEnum.JointDrillResultType.Retreat then
|
||||
tempBossData = self.mapInitTempData.mapBossTempData
|
||||
end
|
||||
if tempBossData ~= nil then
|
||||
bossInfo.nHp = tempBossData.nHp
|
||||
bossInfo.nHpMax = tempBossData.nHpMax
|
||||
end
|
||||
local bSimulate = self.parent:GetBattleSimulate()
|
||||
local nBattleCount = self.parent:GetJointDrillBattleCount()
|
||||
local mapScore = {}
|
||||
local mapReward = {}
|
||||
local mapChange = {}
|
||||
local nOld, nNew = 0, 0
|
||||
local nScoreOld = 0
|
||||
local mapSelfRank = self.parent:GetSelfRankData()
|
||||
if mapSelfRank ~= nil then
|
||||
nScoreOld = mapSelfRank.Score
|
||||
end
|
||||
if netMsg ~= nil then
|
||||
local nScore = netMsg.FightScore + netMsg.HpScore + netMsg.DifficultyScore
|
||||
mapScore = {
|
||||
FightScore = netMsg.FightScore,
|
||||
HpScore = netMsg.HpScore,
|
||||
DifficultyScore = netMsg.DifficultyScore,
|
||||
nTotalScore = self.parent.nTotalScore,
|
||||
nScore = nScore,
|
||||
nScoreOld = nScoreOld
|
||||
}
|
||||
nOld = netMsg.Old
|
||||
nNew = netMsg.New
|
||||
mapReward = netMsg.Items or {}
|
||||
mapChange = netMsg.Change or {}
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.JointDrillResult, nResultType, self.nCurLevel, self.nGameTime, self.nLevelId, bossInfo, mapScore, mapReward, mapChange, nOld, nNew, bSimulate, nBattleCount, self.tbCharDamage)
|
||||
self.parent:LevelEnd(nResultType)
|
||||
end
|
||||
function JointDrillLevelData:SyncGameTime(nTime)
|
||||
nTime = nTime or 0
|
||||
self.nGameTime = math.min(self:GetSyncGameTime(nTime), self.mapLevel.BattleTime * 1000)
|
||||
self.parent:SetGameTime(self.nGameTime)
|
||||
EventManager.Hit("RefreshJointDrillGameTime", self.nGameTime)
|
||||
end
|
||||
function JointDrillLevelData:ResetGameTimer()
|
||||
if self.gameTimer ~= nil then
|
||||
self.gameTimer:Cancel()
|
||||
self.gameTimer = nil
|
||||
end
|
||||
self.bTimerStart = false
|
||||
end
|
||||
function JointDrillLevelData:StartJointDrill()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.JointDrillBattlePanel, self.tbCharId)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
|
||||
safe_call_cs_func(AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_LoadLevelRefresh()
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
|
||||
safe_call_cs_func(AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
self:ResetBuff()
|
||||
self:SetActorHP()
|
||||
self:ResetSkill()
|
||||
self.parent:AddRecordFloorList()
|
||||
if not self.bChangeLevel and not self.bRestart then
|
||||
PlayerData.Build:SetBuildReportInfo(self.mapBuildData.nBuildId)
|
||||
end
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_AdventureModuleEnter()
|
||||
self:StartJointDrill()
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_BattleStart(nTime)
|
||||
self.bTimerStart = true
|
||||
self:SyncGameTime(nTime)
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_MonsterSpawn(nBossId)
|
||||
self.nBossId = nBossId
|
||||
local bBoss = self.mapFloor.FloorType == GameEnum.JointDrillFloorType.Boss
|
||||
if bBoss and self.mapTempData ~= nil and self.mapTempData.mapBossTempData ~= nil then
|
||||
AdventureModuleHelper.SetJointDrillBossData(nBossId, self.mapTempData.mapBossTempData)
|
||||
end
|
||||
if self.bChangeLevel then
|
||||
return
|
||||
end
|
||||
local data, nDataLength = self:CacheTempData(true, bBoss)
|
||||
local nHp, nHpMax = 0, 0
|
||||
if self.mapTempData ~= nil and self.mapTempData.mapBossTempData ~= nil then
|
||||
nHp = self.mapTempData.mapBossTempData.nHp
|
||||
nHpMax = self.mapTempData.mapBossTempData.nHpMax
|
||||
end
|
||||
self.parent:JointDrillSync(self.nCurLevel, self.nGameTime, self.nDamageValue, nHp, nHpMax, data)
|
||||
self.mapInitTempData = clone(self.mapTempData)
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_BattleLvsToggle(nBattleLv, nTotalTime, nDamageValue)
|
||||
if nBattleLv < self.nCurLevel then
|
||||
return
|
||||
end
|
||||
nTotalTime = math.min(self.mapLevel.BattleTime * 1000, self:GetSyncGameTime(nTotalTime))
|
||||
self.nCurLevel = nBattleLv + 1
|
||||
self.nDamageValue = self.nDamageValue + nDamageValue
|
||||
self.mapFloor = self.tbFloor[self.nCurLevel]
|
||||
local bBoss = self.mapFloor.FloorType == GameEnum.JointDrillFloorType.Boss
|
||||
self:CacheTempData(true, bBoss, false, true, true)
|
||||
self.parent:AddJointDrillTeam(self.mapBuildData, nTotalTime, self.nDamageValue)
|
||||
PanelManager.InputDisable()
|
||||
self.parent:StopRecord()
|
||||
local syncCallback = function()
|
||||
PanelManager.InputEnable()
|
||||
AdventureModuleHelper.LevelStateChanged(false)
|
||||
EventManager.Hit("ResetBossHUD")
|
||||
end
|
||||
local data, nDataLength = self.parent:EncodeTempDataJson(self.mapTempData)
|
||||
local nHp, nHpMax = 1, 1
|
||||
local tempBossData = self.mapTempData.mapBossTempData
|
||||
if tempBossData ~= nil then
|
||||
nHp = math.max(tempBossData.nHp, 1)
|
||||
nHpMax = math.max(tempBossData.nHpMax, 1)
|
||||
end
|
||||
self.parent:JointDrillSync(self.nCurLevel, nTotalTime, self.nDamageValue, nHp, nHpMax, data, syncCallback)
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_UnloadComplete()
|
||||
if self.bInResult == true then
|
||||
return
|
||||
end
|
||||
if self.bRestart then
|
||||
self.parent:RestartBattle()
|
||||
else
|
||||
self.parent:ChangeLevel(self.nCurLevel)
|
||||
end
|
||||
self:ResetCharacter()
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_JointDrill_Gameplay_Time(nTime)
|
||||
self:SyncGameTime(nTime)
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_Pause()
|
||||
EventManager.Hit("OpenJointDrillPause", self.nLevelId, self.tbCharId, self.nGameTime)
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_DamageValue(nDamageValue)
|
||||
self.nDamageValue = self.nDamageValue + nDamageValue
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_GiveUpBattle()
|
||||
self.parent:AddJointDrillTeam(self.mapBuildData, self.nGameTime, self.nDamageValue)
|
||||
self:CheckJointDrillGameOver()
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_RestartJointDrill()
|
||||
self.bRestart = true
|
||||
self.parent:SetGameTime(0)
|
||||
local sRecord = self.parent:EncodeTempDataJson(self.mapInitTempData)
|
||||
self.parent:ResetRecord(sRecord)
|
||||
self.parent:SetRecorderExcludeIds(true)
|
||||
AdventureModuleHelper.LevelStateChanged(false)
|
||||
EventManager.Hit("ResetBossHUD")
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_RetreatJointDrill()
|
||||
local callback = function()
|
||||
local sRecord = self.parent:EncodeTempDataJson(self.mapInitTempData)
|
||||
self.parent:ResetRecord(sRecord)
|
||||
self:JointDrillFail(AllEnum.JointDrillResultType.Retreat)
|
||||
end
|
||||
self.parent:JointDrillRetreat(self.mapBuildData, callback)
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_JointDrill_Result(nLevelState, nTotalTime, nDamageValue)
|
||||
if self.bInResult then
|
||||
return
|
||||
end
|
||||
nTotalTime = math.min(self.mapLevel.BattleTime * 1000, self:GetSyncGameTime(nTotalTime))
|
||||
self.bInResult = true
|
||||
self.nDamageValue = self.nDamageValue + nDamageValue
|
||||
if nLevelState == GameEnum.levelState.Failed then
|
||||
self.parent:AddJointDrillTeam(self.mapBuildData, self.nGameTime, self.nDamageValue)
|
||||
self:CheckJointDrillGameOver()
|
||||
elseif nLevelState == GameEnum.levelState.Success then
|
||||
local callback = function(netMsg)
|
||||
self:JointDrillSuccess(netMsg)
|
||||
end
|
||||
self.parent:JointDrillSettle(self.mapBuildData, self.nGameTime, self.nDamageValue, callback)
|
||||
end
|
||||
end
|
||||
function JointDrillLevelData:JointDrillTimeOut()
|
||||
if self.bInResult then
|
||||
return
|
||||
end
|
||||
self.bInResult = true
|
||||
NovaAPI.DispatchEventWithData("JointDrill_Level_TimeOut")
|
||||
local callback = function(netMsg)
|
||||
self:JointDrillFail(AllEnum.JointDrillResultType.ChallengeEnd, netMsg)
|
||||
end
|
||||
self.parent:AddJointDrillTeam(self.mapBuildData, self.nGameTime, self.nDamageValue)
|
||||
self.parent:JointDrillGameOver(callback)
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_CharDamageValue(charDamageValue)
|
||||
for nCharId, nValue in pairs(charDamageValue) do
|
||||
for _, v in ipairs(self.tbCharDamage) do
|
||||
if v.nCharId == nCharId then
|
||||
v.nDamage = v.nDamage + nValue
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_InputEnable(bEnable)
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_JointDrill_StopTime()
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_JointDrillChallengeFinishError()
|
||||
self:JointDrillFail(AllEnum.JointDrillResultType.ChallengeEnd)
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.JointDrillBuildList)
|
||||
self.parent:ChallengeEnd()
|
||||
end
|
||||
function JointDrillLevelData:OnEvent_UploadDodgeEvent(padMode)
|
||||
local tab = {}
|
||||
table.insert(tab, {
|
||||
"role_id",
|
||||
tostring(PlayerData.Base._nPlayerId)
|
||||
})
|
||||
table.insert(tab, {"pad_mode", padMode})
|
||||
table.insert(tab, {"level_type", "JointDrill"})
|
||||
table.insert(tab, {
|
||||
"build_id",
|
||||
tostring(self.nBuildId)
|
||||
})
|
||||
table.insert(tab, {
|
||||
"level_id",
|
||||
tostring(self.nLevelId)
|
||||
})
|
||||
table.insert(tab, {
|
||||
"up_time",
|
||||
tostring(CS.ClientManager.Instance.serverTimeStamp)
|
||||
})
|
||||
NovaAPI.UserEventUpload("use_dodge_key", tab)
|
||||
end
|
||||
return JointDrillLevelData
|
||||
@@ -0,0 +1,78 @@
|
||||
local MainlineAvgLevel = class("MainlineAvgLevel")
|
||||
local mapEventConfig = {
|
||||
LevelStateChanged = "OnEvent_SendMsgFinishBattle"
|
||||
}
|
||||
function MainlineAvgLevel:Init(parent, nMainlineId)
|
||||
self._nSelectId = nMainlineId
|
||||
self.parent = parent
|
||||
self.bSettle = false
|
||||
self:BindEvent()
|
||||
local mapMainline = ConfigTable.GetData_Mainline(nMainlineId)
|
||||
if mapMainline == nil then
|
||||
self.parent:LevelEnd()
|
||||
return
|
||||
end
|
||||
if mapMainline.AvgId == nil or mapMainline.AvgId == "" then
|
||||
self.parent:LevelEnd()
|
||||
return
|
||||
end
|
||||
self.parent = parent
|
||||
local mapData = {
|
||||
nType = AllEnum.StoryAvgType.PureAvg,
|
||||
sAvgId = mapMainline.AvgId,
|
||||
nNodeId = nMainlineId,
|
||||
callback = nil
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PureAvgStory, mapData)
|
||||
end
|
||||
function MainlineAvgLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function MainlineAvgLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function MainlineAvgLevel:OnEvent_SendMsgFinishBattle()
|
||||
if self.bSettle == true then
|
||||
print("已在结算流程中!")
|
||||
return
|
||||
end
|
||||
self.bSettle = true
|
||||
print("OnEvent_SendMsgFinishBattle")
|
||||
local nStar = 7
|
||||
local func_cbFinishSucc = function(_, mapMainData)
|
||||
self.parent:UpdateMainlineStar(self._nSelectId, nStar)
|
||||
EventManager.Hit(EventId.CloesCurPanel)
|
||||
local close = function()
|
||||
PlayerData.Base:OnBackToMainMenuModule()
|
||||
end
|
||||
if mapMainData.FirstRewardItems and #mapMainData.FirstRewardItems > 0 then
|
||||
UTILS.OpenReceiveByDisplayItem(mapMainData.FirstRewardItems, mapMainData.Change, close)
|
||||
else
|
||||
close()
|
||||
end
|
||||
self:UnBindEvent()
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
local mapSendMsg = {}
|
||||
mapSendMsg.Ok = true
|
||||
mapSendMsg.MinChests = {}
|
||||
mapSendMsg.MaxChests = {}
|
||||
HttpNetHandler.SendMsg(NetMsgId.Id.mainline_settle_req, mapSendMsg, nil, func_cbFinishSucc)
|
||||
end
|
||||
return MainlineAvgLevel
|
||||
@@ -0,0 +1,503 @@
|
||||
local MainlineBattleLevel = class("MainlineBattleLevel")
|
||||
local RapidJson = require("rapidjson")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local mapEventConfig = {
|
||||
LevelStateChanged = "OnEvent_SendMsgFinishBattle",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
InteractiveBoxGet = "OnEvent_OpenChest",
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
Mainline_Time_CountUp = "OnEvent_Time",
|
||||
BattlePause = "OnEvnet_Pause",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter"
|
||||
}
|
||||
function MainlineBattleLevel:Init(parent, nSelectId, nTeamIdx, tbChestS, tbChestL)
|
||||
self.bSettle = false
|
||||
self.parent = parent
|
||||
self.nMainLineTime = 0
|
||||
self:BindEvent()
|
||||
self._nSelectId = nSelectId
|
||||
self.curFloorIdx = 1
|
||||
self.nLargeTotalCount = 0
|
||||
self.nSmallTotalCount = 0
|
||||
self.curSmallCount = 0
|
||||
self.curLargeCount = 0
|
||||
self.bNewSmall = false
|
||||
self.bNewLarge = false
|
||||
self._tbBoxS = nil
|
||||
self._tbBoxL = nil
|
||||
self.mapCharacterTempData = {}
|
||||
self._tbOpendChestS = {}
|
||||
self._tbOpendChestL = {}
|
||||
local mapMainline = ConfigTable.GetData_Mainline(nSelectId)
|
||||
self:PrePorcessChestData(self._nSelectId)
|
||||
self.nSmallTotalCount = #self._tbBoxS
|
||||
self.nLargeTotalCount = #self._tbBoxL
|
||||
self.bTrialLevel = mapMainline.TrialCharacter ~= nil and 0 < #mapMainline.TrialCharacter
|
||||
if self.bTrialLevel then
|
||||
self.nCurTeamIndex = 1
|
||||
self.tbChar = {}
|
||||
self.tbTrialId = {}
|
||||
for _, nTrialId in pairs(mapMainline.TrialCharacter) do
|
||||
if 0 < nTrialId then
|
||||
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
|
||||
table.insert(self.tbChar, mapTrialChar.nId)
|
||||
table.insert(self.tbTrialId, nTrialId)
|
||||
end
|
||||
end
|
||||
else
|
||||
self.nCurTeamIndex = nTeamIdx
|
||||
self.tbChar = PlayerData.Team:GetTeamCharId(nTeamIdx)
|
||||
end
|
||||
self.tbOpenedChestId = {}
|
||||
for _, idx in ipairs(tbChestS) do
|
||||
table.insert(self.tbOpenedChestId, self._tbBoxS[idx])
|
||||
end
|
||||
for _, idx in ipairs(tbChestL) do
|
||||
table.insert(self.tbOpenedChestId, self._tbBoxL[idx])
|
||||
end
|
||||
if self.bTrialLevel then
|
||||
for _, nTrialId in ipairs(self.tbTrialId) do
|
||||
if 0 < nTrialId then
|
||||
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
|
||||
local stActorInfo = self.CalCharFixedEffectTrial(nTrialId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, mapTrialChar.nId, stActorInfo)
|
||||
end
|
||||
end
|
||||
else
|
||||
for idx, nCharId in ipairs(self.tbChar) do
|
||||
local stActorInfo = self.CalCharFixedEffect(nCharId, idx == 1)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.Mainline
|
||||
CS.AdventureModuleHelper.EnterMainlineMap(mapMainline.FloorId[1], self.tbChar, self.tbOpenedChestId)
|
||||
self.curSmallCount = #tbChestS
|
||||
self.curLargeCount = #tbChestL
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
function MainlineBattleLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function MainlineBattleLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function MainlineBattleLevel.CalCharFixedEffect(nCharId, bMainChar)
|
||||
local tbstInfo = {}
|
||||
local tbEffectId = {}
|
||||
PlayerData.Char:CalcAffinityEffect(nCharId, tbstInfo, tbEffectId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
local nHeartStoneLevel = PlayerData.Char:CalCharacterAttrBattle(nCharId, tbstInfo, stActorInfo, bMainChar)
|
||||
return tbstInfo, stActorInfo, nHeartStoneLevel
|
||||
end
|
||||
function MainlineBattleLevel.CalCharFixedEffectTrial(nTrialId)
|
||||
local tbstInfo = {}
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
local nHeartStoneLevel = PlayerData.Char:CalCharacterTrialAttrBattle(nTrialId, tbstInfo, stActorInfo)
|
||||
return stActorInfo, nHeartStoneLevel
|
||||
end
|
||||
function MainlineBattleLevel:PrePorcessChestData(nMainlineId)
|
||||
if ConfigTable.GetData_Mainline(nMainlineId) == nil then
|
||||
printError("no level data:" .. nMainlineId)
|
||||
end
|
||||
local tbChestS = decodeJson(ConfigTable.GetData_Mainline(nMainlineId).MinChestReward)
|
||||
local tbChestL = decodeJson(ConfigTable.GetData_Mainline(nMainlineId).MaxChestReward)
|
||||
self._tbBoxS = tbChestS
|
||||
self._tbBoxL = tbChestL
|
||||
end
|
||||
function MainlineBattleLevel:PlaySuccessPerform(GenerRewardItems, FirstRewardItems, ChestRewardItems, nExp, nStar, FadeTime, mapChangeInfo)
|
||||
local func_SettlementFinish = function(bSuccess)
|
||||
end
|
||||
local tbChar = self.tbChar
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local nFloorCount, nMapId
|
||||
if PlayerData.Mainline.bUseOldMainline then
|
||||
nFloorCount = #ConfigTable.GetData_Mainline(self._nSelectId).FloorId
|
||||
nMapId = ConfigTable.GetData_Mainline(self._nSelectId).FloorId[nFloorCount]
|
||||
else
|
||||
nFloorCount = #ConfigTable.GetData_Story(self._nSelectId).FloorId
|
||||
nMapId = ConfigTable.GetData_Story(self._nSelectId).FloorId[nFloorCount]
|
||||
end
|
||||
local nType = ConfigTable.GetData("MainlineFloor", nMapId).Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
local sLarge, sSmall = self:CalChestInfo()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, true, nStar or 3, GenerRewardItems or {}, FirstRewardItems or {}, ChestRewardItems or {}, nExp or 0, false, sLarge, sSmall, self._nSelectId, self.tbChar, mapChangeInfo)
|
||||
self.bSettle = false
|
||||
self:UnBindEvent()
|
||||
if PlayerData.Mainline.bUseOldMainline then
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true, FadeTime or 0.5)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
end
|
||||
function MainlineBattleLevel:OnEvent_OpenChest(nId)
|
||||
print("OpenBox:" .. nId)
|
||||
local mapChest = ConfigTable.GetData("Chest", nId)
|
||||
if mapChest == nil then
|
||||
printError("宝箱id不存在" .. nId)
|
||||
return
|
||||
end
|
||||
local nType = mapChest.Label
|
||||
if nType == 1 then
|
||||
local nIndex = table.indexof(self._tbBoxS, nId)
|
||||
if self._tbBoxS == nil then
|
||||
return
|
||||
end
|
||||
if nIndex < 1 then
|
||||
return
|
||||
end
|
||||
mapChest = ConfigTable.GetData("Chest", nId)
|
||||
table.insert(self._tbOpendChestS, nIndex)
|
||||
self.curSmallCount = self.curSmallCount + 1
|
||||
self.bNewSmall = true
|
||||
else
|
||||
local nIndex = table.indexof(self._tbBoxL, nId)
|
||||
if self._tbBoxL == nil then
|
||||
return
|
||||
end
|
||||
if nIndex < 1 then
|
||||
return
|
||||
end
|
||||
mapChest = ConfigTable.GetData("Chest", nId)
|
||||
table.insert(self._tbOpendChestL, nIndex)
|
||||
self.curLargeCount = self.curLargeCount + 1
|
||||
self.bNewLarge = true
|
||||
end
|
||||
local ShowTips = function(nTid, nCount)
|
||||
if nTid == 0 or nCount == 0 then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.ShowRoguelikeDrop, nTid, nCount)
|
||||
end
|
||||
ShowTips(mapChest.Item1, mapChest.Number1)
|
||||
ShowTips(mapChest.Item2, mapChest.Number2)
|
||||
ShowTips(mapChest.Item3, mapChest.Number3)
|
||||
ShowTips(mapChest.Item4, mapChest.Number4)
|
||||
end
|
||||
function MainlineBattleLevel:OnEvent_LoadLevelRefresh()
|
||||
self:ResetCharacter()
|
||||
end
|
||||
function MainlineBattleLevel:CacheTempData()
|
||||
local FP = CS.TrueSync.FP
|
||||
self.mapCharacterTempData = {}
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local id = AdventureModuleHelper.GetCurrentActivePlayer()
|
||||
self.mapCharacterTempData.curCharId = CS.AdventureModuleHelper.GetCharacterId(id)
|
||||
self.mapCharacterTempData.skillInfo = {}
|
||||
self.mapCharacterTempData.effectInfo = {}
|
||||
self.mapCharacterTempData.buffInfo = {}
|
||||
self.mapCharacterTempData.hpInfo = {}
|
||||
self.mapCharacterTempData.stateInfo = {}
|
||||
local playerids = AdventureModuleHelper.GetCurrentGroupPlayers()
|
||||
local Count = playerids.Count - 1
|
||||
for i = 0, Count do
|
||||
local charTid = AdventureModuleHelper.GetCharacterId(playerids[i])
|
||||
local clsSkillId = AdventureModuleHelper.GetPlayerSkillCd(playerids[i])
|
||||
local nStatus = AdventureModuleHelper.GetPlayerActorStatus(playerids[i])
|
||||
local nStatusTime = AdventureModuleHelper.GetPlayerActorSpecialStatusTime(playerids[i])
|
||||
self.mapCharacterTempData.hpInfo[charTid] = AdventureModuleHelper.GetEntityHp(playerids[i])
|
||||
if clsSkillId ~= nil then
|
||||
local tbSkillInfos = clsSkillId.skillInfos
|
||||
local nSkillCount = tbSkillInfos.Count - 1
|
||||
for j = 0, nSkillCount do
|
||||
local clsSkillInfo = tbSkillInfos[j]
|
||||
local mapSkill = ConfigTable.GetData_Skill(clsSkillInfo.skillId)
|
||||
if mapSkill.Type == GameEnum.skillType.ULTIMATE then
|
||||
table.insert(self.mapCharacterTempData.skillInfo, {
|
||||
nCharId = charTid,
|
||||
nSkillId = clsSkillInfo.skillId,
|
||||
nCd = clsSkillInfo.currentUseInterval.RawValue,
|
||||
nSectionAmount = clsSkillInfo.currentSectionAmount,
|
||||
nSectionResumeTime = clsSkillInfo.currentResumeTime.RawValue,
|
||||
nUseTimeHint = clsSkillInfo.currentUseTimeHint.RawValue,
|
||||
nEnergy = clsSkillInfo.currentEnergy.RawValue
|
||||
})
|
||||
end
|
||||
end
|
||||
self.mapCharacterTempData.effectInfo[charTid] = {
|
||||
mapEffect = {}
|
||||
}
|
||||
local tbClsEfts = AdventureModuleHelper.GetEffectList(playerids[i])
|
||||
if tbClsEfts ~= nil then
|
||||
local nEftCount = tbClsEfts.Count - 1
|
||||
for k = 0, nEftCount do
|
||||
local eftInfo = tbClsEfts[k]
|
||||
local mapEft = ConfigTable.GetData_Effect(eftInfo.effectConfig.Id)
|
||||
local nCd = eftInfo.CD.RawValue
|
||||
if mapEft.Remove and 0 < nCd then
|
||||
self.mapCharacterTempData.effectInfo[charTid].mapEffect[eftInfo.effectConfig.Id] = {nCount = 0, nCd = nCd}
|
||||
end
|
||||
end
|
||||
end
|
||||
local tbBuffInfo = AdventureModuleHelper.GetEntityBuffList(playerids[i])
|
||||
self.mapCharacterTempData.buffInfo[charTid] = {
|
||||
mapBuff = {}
|
||||
}
|
||||
if tbBuffInfo ~= nil then
|
||||
local nBuffCount = tbBuffInfo.Count - 1
|
||||
for l = 0, nBuffCount do
|
||||
local eftInfo = tbBuffInfo[l]
|
||||
local mapBuff = ConfigTable.GetData_Buff(eftInfo.buffConfig.Id)
|
||||
if mapBuff.NotRemove then
|
||||
table.insert(self.mapCharacterTempData.buffInfo[charTid].mapBuff, {
|
||||
Id = eftInfo.buffConfig.Id,
|
||||
CD = eftInfo:GetBuffLeftTime().RawValue,
|
||||
nNum = eftInfo:GetBuffNum()
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
self.mapCharacterTempData.stateInfo[charTid] = {nState = nStatus, nStateTime = nStatusTime}
|
||||
end
|
||||
end
|
||||
function MainlineBattleLevel:ResetCharacter()
|
||||
if self.mapCharacterTempData.hpInfo ~= nil then
|
||||
local tbActorInfo = {}
|
||||
for nTid, nHp in pairs(self.mapCharacterTempData.hpInfo) do
|
||||
local stCharInfo = CS.Lua2CSharpInfo_ActorAttribute()
|
||||
stCharInfo.actorID = nTid
|
||||
stCharInfo.curHP = nHp
|
||||
table.insert(tbActorInfo, stCharInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorAttributes, tbActorInfo)
|
||||
end
|
||||
if self.mapCharacterTempData.skillInfo ~= nil then
|
||||
local tbSkillInfos = {}
|
||||
for _, skillInfo in ipairs(self.mapCharacterTempData.skillInfo) do
|
||||
local stSkillInfo = CS.Lua2CSharpInfo_ResetSkillInfo()
|
||||
stSkillInfo.skillId = skillInfo.nSkillId
|
||||
stSkillInfo.currentSectionAmount = skillInfo.nSectionAmount
|
||||
stSkillInfo.cd = skillInfo.nCd
|
||||
stSkillInfo.currentResumeTime = skillInfo.nSectionResumeTime
|
||||
stSkillInfo.currentUseTimeHint = skillInfo.nUseTimeHint
|
||||
stSkillInfo.energy = skillInfo.nEnergy
|
||||
if tbSkillInfos[skillInfo.nCharId] == nil then
|
||||
tbSkillInfos[skillInfo.nCharId] = {}
|
||||
end
|
||||
table.insert(tbSkillInfos[skillInfo.nCharId], stSkillInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorSkillInfo, tbSkillInfos)
|
||||
end
|
||||
if self.mapCharacterTempData.buffInfo ~= nil then
|
||||
local tbBuffinfo = {}
|
||||
for nCharId, mapBuff in pairs(self.mapCharacterTempData.buffInfo) do
|
||||
if mapBuff.mapBuff ~= nil then
|
||||
for _, mapBuffInfo in pairs(mapBuff.mapBuff) do
|
||||
local stBuffInfo = CS.Lua2CSharpInfo_ResetBuffInfo()
|
||||
stBuffInfo.Id = mapBuffInfo.Id
|
||||
stBuffInfo.Cd = mapBuffInfo.CD
|
||||
stBuffInfo.buffNum = mapBuffInfo.nNum
|
||||
if tbBuffinfo[nCharId] == nil then
|
||||
tbBuffinfo[nCharId] = {}
|
||||
end
|
||||
table.insert(tbBuffinfo[nCharId], stBuffInfo)
|
||||
end
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ResetBuff, tbBuffinfo)
|
||||
end
|
||||
end
|
||||
function MainlineBattleLevel:OnEvent_SendMsgFinishBattle(LevelResult, _doorIdx, FadeTime)
|
||||
if self.bSettle == true then
|
||||
print("已在结算流程中!")
|
||||
return
|
||||
end
|
||||
self.bSettle = true
|
||||
print("OnEvent_SendMsgFinishBattle")
|
||||
local fadeT = 0
|
||||
if FadeTime ~= nil then
|
||||
fadeT = FadeTime
|
||||
end
|
||||
if LevelResult == AllEnum.LevelResult.Failed then
|
||||
self:OnEvent_AbandonBattle()
|
||||
return
|
||||
end
|
||||
local mapMainline
|
||||
if PlayerData.Mainline.bUseOldMainline then
|
||||
mapMainline = ConfigTable.GetData_Mainline(self._nSelectId)
|
||||
else
|
||||
mapMainline = ConfigTable.GetData_Story(self._nSelectId)
|
||||
end
|
||||
if self.curFloorIdx < #mapMainline.FloorId then
|
||||
self:ChangeFloor()
|
||||
return
|
||||
end
|
||||
local nStar = 1
|
||||
local nMainlineId = self._nSelectId
|
||||
if PlayerData.Mainline.bUseOldMainline then
|
||||
if #self._tbBoxS == self.curSmallCount then
|
||||
nStar = nStar | 2
|
||||
end
|
||||
if #self._tbBoxL == self.curLargeCount then
|
||||
nStar = nStar | 4
|
||||
end
|
||||
end
|
||||
local func_cbFinishSucc = function(_, mapMainData)
|
||||
local nLevelStar = 0
|
||||
if PlayerData.Mainline.bUseOldMainline then
|
||||
self.parent:UpdateMainlineStar(self._nSelectId, nStar)
|
||||
nLevelStar = self.parent:GetMianlineLevelStar(nMainlineId)
|
||||
end
|
||||
local function func_AvgEnd()
|
||||
EventManager.Remove("StoryDialog_DialogEnd", self, func_AvgEnd)
|
||||
local sLarge, sSmall = self:CalChestInfo()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, true, nLevelStar, mapMainData.GenerRewardItems or {}, mapMainData.FirstRewardItems or {}, mapMainData.ChestRewardItems or {}, mapMainData.Exp or 0, false, sLarge, sSmall, nMainlineId, self.tbChar, mapMainData.Change)
|
||||
self:UnBindEvent()
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
local sAvgId = PlayerData.Mainline:GetAfterBattleAvg()
|
||||
if sAvgId then
|
||||
EventManager.Add("StoryDialog_DialogEnd", self, func_AvgEnd)
|
||||
EventManager.Hit("StoryDialog_DialogStart", sAvgId)
|
||||
elseif PlayerData.Mainline.bUseOldMainline then
|
||||
self:PlaySuccessPerform(mapMainData.GenerRewardItems, mapMainData.FirstRewardItems, mapMainData.ChestRewardItems, mapMainData.Exp, nLevelStar, fadeT, mapMainData.Change)
|
||||
else
|
||||
self:PlaySuccessPerform()
|
||||
end
|
||||
end
|
||||
local Events = PlayerData.Achievement:GetBattleAchievement(GameEnum.levelType.Mainline, true)
|
||||
local mapSendMsg = {}
|
||||
mapSendMsg.Ok = true
|
||||
mapSendMsg.MinChests = self._tbOpendChestS
|
||||
mapSendMsg.MaxChests = self._tbOpendChestL
|
||||
if 0 < #Events then
|
||||
mapSendMsg.Events = {
|
||||
List = {}
|
||||
}
|
||||
mapSendMsg.Events.List = Events
|
||||
end
|
||||
print("====== 当前通关主线关卡ID:" .. self._nSelectId .. " ======")
|
||||
if PlayerData.Mainline.bUseOldMainline then
|
||||
HttpNetHandler.SendMsg(NetMsgId.Id.mainline_settle_req, mapSendMsg, nil, func_cbFinishSucc)
|
||||
else
|
||||
PlayerData.Avg:SendMsg_STORY_DONE(func_cbFinishSucc)
|
||||
end
|
||||
end
|
||||
function MainlineBattleLevel:OnEvent_AbandonBattle()
|
||||
if self._nSelectId > 0 then
|
||||
local nStar = PlayerData.Mainline:GetMianlineLevelStar(self._nSelectId)
|
||||
if 0 < nStar then
|
||||
if #self._tbBoxS == self.curSmallCount then
|
||||
nStar = 3
|
||||
end
|
||||
if #self._tbBoxL == self.curLargeCount then
|
||||
nStar = nStar | 4
|
||||
end
|
||||
end
|
||||
local func_cbExitSucc = function(_, mapMainData)
|
||||
local nMainlineId = self._nSelectId
|
||||
local sLarge, sSmall = self:CalChestInfo()
|
||||
self.parent:UpdateMainlineStar(self._nSelectId, nStar)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, false, 0, mapMainData.GenerRewardItems or {}, mapMainData.FirstRewardItems or {}, mapMainData.ChestRewardItems or {}, mapMainData.Exp or 0, false, sLarge, sSmall, nMainlineId, self.tbChar, mapMainData.Change)
|
||||
self:UnBindEvent()
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
local mapSendMsg = {}
|
||||
mapSendMsg.MinChests = self._tbOpendChestS
|
||||
mapSendMsg.MaxChests = self._tbOpendChestL
|
||||
HttpNetHandler.SendMsg(NetMsgId.Id.mainline_exit_req, mapSendMsg, nil, func_cbExitSucc)
|
||||
end
|
||||
end
|
||||
function MainlineBattleLevel:CalChestInfo()
|
||||
local sSmall, sLarge
|
||||
if self.bNewSmall then
|
||||
sSmall = string.format("<color=#4ee5d1>%d</color>/%d", self.curSmallCount, self.nSmallTotalCount)
|
||||
else
|
||||
sSmall = string.format("%d/%d", self.curSmallCount, self.nSmallTotalCount)
|
||||
end
|
||||
if self.bNewLarge then
|
||||
sLarge = string.format("<color=#4ee5d1>%d</color>/%d", self.curLargeCount, self.nLargeTotalCount)
|
||||
else
|
||||
sLarge = string.format("%d/%d", self.curLargeCount, self.nLargeTotalCount)
|
||||
end
|
||||
if self.nSmallTotalCount == 0 then
|
||||
sSmall = "无"
|
||||
end
|
||||
if self.nLargeTotalCount == 0 then
|
||||
sLarge = "无"
|
||||
end
|
||||
return sLarge, sSmall
|
||||
end
|
||||
function MainlineBattleLevel:ChangeFloor()
|
||||
self:CacheTempData()
|
||||
local mapMainline = ConfigTable.GetData_Mainline(self._nSelectId)
|
||||
self.curFloorIdx = self.curFloorIdx + 1
|
||||
local function levelUnloadCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
|
||||
if self.bTrialLevel then
|
||||
for _, nTrialId in ipairs(self.tbTrialId) do
|
||||
if 0 < nTrialId then
|
||||
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
|
||||
local stActorInfo, nHeartStoneLevel = self.CalCharFixedEffectTrial(nTrialId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, mapTrialChar.nId, stActorInfo)
|
||||
end
|
||||
end
|
||||
else
|
||||
for idx, nCharId in ipairs(self.tbChar) do
|
||||
local stActorInfo, nHeartStoneLevel = self.CalCharFixedEffect(nCharId, idx == 1)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
self:SetCharStatus()
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
|
||||
CS.AdventureModuleHelper.EnterMainlineMap(mapMainline.FloorId[self.curFloorIdx], self.tbChar, self.tbOpenedChestId)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(false)
|
||||
self.bSettle = false
|
||||
end
|
||||
function MainlineBattleLevel:SetCharStatus()
|
||||
local nStatus = 0
|
||||
local nStatusTime = 0
|
||||
local tbActorInfo = {}
|
||||
for _, nTid in pairs(self.tbChar) do
|
||||
local stCharInfo = CS.Lua2CSharpInfo_ActorStatus()
|
||||
if self.mapCharacterTempData.stateInfo ~= nil and self.mapCharacterTempData.stateInfo[nTid] ~= nil then
|
||||
nStatus = self.mapCharacterTempData.stateInfo[nTid].nState
|
||||
nStatusTime = self.mapCharacterTempData.stateInfo[nTid].nStateTime
|
||||
end
|
||||
stCharInfo.actorID = nTid
|
||||
stCharInfo.status = nStatus
|
||||
stCharInfo.specialStatusTime = nStatusTime
|
||||
table.insert(tbActorInfo, stCharInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorStatus, tbActorInfo)
|
||||
end
|
||||
function MainlineBattleLevel:OnEvent_Time(nTime)
|
||||
self.nMainLineTime = nTime
|
||||
end
|
||||
function MainlineBattleLevel:OnEvnet_Pause()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.MainBattlePause, self.nMainLineTime or 0)
|
||||
end
|
||||
function MainlineBattleLevel:OnEvent_AdventureModuleEnter()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Adventure, self.tbChar)
|
||||
end
|
||||
return MainlineBattleLevel
|
||||
@@ -0,0 +1,470 @@
|
||||
local MainlinePrologueLevel = class("MainlinePrologueLevel")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
local RapidJson = require("rapidjson")
|
||||
local mapFloor = {
|
||||
[1] = "Game.Adventure.MainlineLevel.PrologueFloor.DesertFloor",
|
||||
[2] = "Game.Adventure.MainlineLevel.PrologueFloor.BattleFloor"
|
||||
}
|
||||
local mapEventConfig = {
|
||||
LevelStateChanged = "OnEvent_LevelStateChanged",
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
ExitModule = "OnEvent_ExitModule",
|
||||
AfterEnterModule = "OnEvent_AfterEnterModule",
|
||||
PrologueBattleReload = "OnEvent_PrologueBattleReload",
|
||||
PrologueBattleArchive = "OnEvent_PrologueBattleArchive",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
EnterModule = "OnEvent_EnterModule"
|
||||
}
|
||||
local enterFloorForTest = 0
|
||||
local PrologueSceneId = 1200103
|
||||
local tbAfterDesertFloor = {1200104, 1200106}
|
||||
local tbTrialCharacter = {
|
||||
{
|
||||
1200201,
|
||||
1200203,
|
||||
1200202
|
||||
},
|
||||
{
|
||||
1200201,
|
||||
1200203,
|
||||
1200202
|
||||
}
|
||||
}
|
||||
local tbSelectPerks = {
|
||||
{
|
||||
500501,
|
||||
500801,
|
||||
500101
|
||||
}
|
||||
}
|
||||
local mapBoxReward = {
|
||||
[1] = {
|
||||
500501,
|
||||
500801,
|
||||
500101
|
||||
}
|
||||
}
|
||||
local tbTheme = {
|
||||
GameEnum.rglTheme.ChainLightning,
|
||||
GameEnum.rglTheme.WindBlade,
|
||||
GameEnum.rglTheme.FireRing
|
||||
}
|
||||
function MainlinePrologueLevel:Init(parent)
|
||||
self.curFloor = nil
|
||||
self.sAfterBattleAvg = "ST1001"
|
||||
local lastAccount = LocalData.GetLocalData("LoginUIData", "LastUserName_All")
|
||||
local sJson = LocalData.GetLocalData(lastAccount, "MainlinePrologueLevel")
|
||||
if sJson ~= nil then
|
||||
local tb = decodeJson(sJson)
|
||||
self.isThreePlayer = tb.isThreePlayer
|
||||
self.revivalPoint = Vector3(tb.revivalPoint[1], tb.revivalPoint[2], tb.revivalPoint[3])
|
||||
self.btnNames = tb.btnNames
|
||||
self.tbSelectPerks = tb.tbSelectPerks
|
||||
self.curFloorIdx = tb.curFloorIdx
|
||||
self.bDesertComplete = tb.bDesertComplete
|
||||
self.nCurAvgCmdIdx = tb.nCurAvgCmdIdx
|
||||
self.bBattleEnd = tb.bBattleEnd
|
||||
self.curCharId = tb.curCharId
|
||||
self.curNpcRewardIdx = tb.curNpcRewardIdx
|
||||
self.nBoxId = tb.nBoxId
|
||||
else
|
||||
self.isThreePlayer = false
|
||||
self.revivalPoint = Vector3.zero
|
||||
self.btnNames = nil
|
||||
self.tbSelectPerks = {}
|
||||
self.curFloorIdx = 1
|
||||
self.bDesertComplete = false
|
||||
self.nCurAvgCmdIdx = 0
|
||||
self.bBattleEnd = false
|
||||
self.curCharId = 0
|
||||
self.curNpcRewardIdx = 1
|
||||
self.nBoxId = 0
|
||||
end
|
||||
EventManager.Hit("MainlinePrologueLevelNextModule", self)
|
||||
self:BindEvent()
|
||||
self.parent = parent
|
||||
self.bSettle = false
|
||||
self.tbTrialId = {}
|
||||
self.tbChar = {}
|
||||
if not self.bDesertComplete then
|
||||
CS.AdventureModuleHelper.EnterProloguelMap(PrologueSceneId)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
elseif self.bBattleEnd then
|
||||
self:OnEvent_LevelStateChanged()
|
||||
else
|
||||
if #tbTrialCharacter[self.curFloorIdx] > 0 then
|
||||
PlayerData.Char:CreateTrialChar(tbTrialCharacter[self.curFloorIdx])
|
||||
for _, nTrialId in pairs(tbTrialCharacter[self.curFloorIdx]) do
|
||||
if 0 < nTrialId then
|
||||
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
|
||||
table.insert(self.tbChar, mapTrialChar.nId)
|
||||
table.insert(self.tbTrialId, nTrialId)
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, nTrialId in ipairs(self.tbTrialId) do
|
||||
if 0 < nTrialId then
|
||||
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
|
||||
local tbstInfo, stActorInfo, nHeartStoneLevel = self.CalCharFixedEffectTrial(nTrialId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, mapTrialChar.nId, stActorInfo)
|
||||
end
|
||||
end
|
||||
self:SetFloor(2)
|
||||
CS.AdventureModuleHelper.EnterProloguelBattleMap(tbAfterDesertFloor[self.curFloorIdx], self.tbChar, {}, self.isThreePlayer, self.revivalPoint, self.btnNames)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
end
|
||||
function MainlinePrologueLevel:SetLocalData()
|
||||
local mapLocalData = {
|
||||
isThreePlayer = self.isThreePlayer,
|
||||
revivalPoint = {
|
||||
self.revivalPoint.x,
|
||||
self.revivalPoint.y,
|
||||
self.revivalPoint.z
|
||||
},
|
||||
btnNames = self.btnNames,
|
||||
tbSelectPerks = self.tbSelectPerks,
|
||||
curFloorIdx = self.curFloorIdx,
|
||||
bDesertComplete = self.bDesertComplete,
|
||||
nCurAvgCmdIdx = self.nCurAvgCmdIdx,
|
||||
bBattleEnd = self.bBattleEnd,
|
||||
curCharId = self.curCharId,
|
||||
curNpcRewardIdx = self.curNpcRewardIdx,
|
||||
nBoxId = self.nBoxId
|
||||
}
|
||||
local sJson = RapidJson.encode(mapLocalData)
|
||||
local lastAccount = LocalData.GetLocalData("LoginUIData", "LastUserName_All")
|
||||
LocalData.SetLocalData(lastAccount, "MainlinePrologueLevel", sJson)
|
||||
end
|
||||
function MainlinePrologueLevel:SetFloor(nType)
|
||||
if self.curFloor ~= nil then
|
||||
self.curFloor:Exit()
|
||||
end
|
||||
self.curFloor = nil
|
||||
local luaPath = mapFloor[nType]
|
||||
if luaPath == nil then
|
||||
printError("no exist type:" .. nType)
|
||||
luaPath = mapFloor[1]
|
||||
end
|
||||
local luaFile = require(luaPath)
|
||||
local luaClass = luaFile.new(self)
|
||||
luaClass:Enter()
|
||||
self.curFloor = luaClass
|
||||
end
|
||||
function MainlinePrologueLevel:UnsetFloor()
|
||||
if self.curFloor ~= nil then
|
||||
self.curFloor:Exit()
|
||||
end
|
||||
self.curFloor = nil
|
||||
end
|
||||
function MainlinePrologueLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function MainlinePrologueLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function MainlinePrologueLevel.CalCharFixedEffectTrial(nTrialId)
|
||||
local tbstInfo = {}
|
||||
local tbEffectId = {}
|
||||
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
local nHeartStoneLevel = PlayerData.Char:CalCharacterTrialAttrBattle(nTrialId, tbstInfo, stActorInfo)
|
||||
return tbstInfo, stActorInfo, nHeartStoneLevel
|
||||
end
|
||||
function MainlinePrologueLevel:SetTheme()
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetRglTheme, tbTheme)
|
||||
end
|
||||
function MainlinePrologueLevel:SetThemePerk()
|
||||
local tbThemePerkInfo = {}
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
for _, nPerkId in ipairs(self.tbSelectPerks) do
|
||||
stPerkInfo.perkId = nPerkId
|
||||
stPerkInfo.nCount = 1
|
||||
table.insert(tbThemePerkInfo, stPerkInfo)
|
||||
end
|
||||
if 0 < #tbThemePerkInfo then
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangeThemePerkIds, tbThemePerkInfo)
|
||||
end
|
||||
end
|
||||
function MainlinePrologueLevel:GetRewardNpc(nNpcId, nNpcUid)
|
||||
local function SelectPerkCallBack(_, tbResult)
|
||||
EventManager.Remove(EventId.SelectPerk, self, SelectPerkCallBack)
|
||||
self.curNpcRewardIdx = self.curNpcRewardIdx + 1
|
||||
table.insert(self.tbSelectPerks, tbResult[1])
|
||||
local tbThemePerkInfo = {}
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = tbResult[1]
|
||||
stPerkInfo.nCount = 1
|
||||
table.insert(tbThemePerkInfo, stPerkInfo)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangeThemePerkIds, tbThemePerkInfo)
|
||||
local mapNpc = ConfigTable.GetData("NPC", nNpcId)
|
||||
if mapNpc.completeDestroy then
|
||||
safe_call_cs_func(CS.InteractiveManager.Instance.setInteractiveNpcState, CS.InteractiveManager.Instance, nNpcUid)
|
||||
end
|
||||
NovaAPI.DispatchEventWithData("PROLOGUELEVEL_SELECTPERK")
|
||||
end
|
||||
if tbSelectPerks[self.curNpcRewardIdx] == nil then
|
||||
printError(string.format("没有第%d个奖励", self.curNpcRewardIdx))
|
||||
return
|
||||
end
|
||||
local tbPerks = {}
|
||||
for _, nPerkId in ipairs(tbSelectPerks[self.curNpcRewardIdx]) do
|
||||
table.insert(tbPerks, {
|
||||
Id = nPerkId,
|
||||
Level = 1,
|
||||
nMaxLevel = 3
|
||||
})
|
||||
end
|
||||
local mapBag = {
|
||||
mapPerk = {},
|
||||
mapItem = {},
|
||||
mapSlotPerk = {
|
||||
[1] = {
|
||||
nPerkId = 0,
|
||||
nQty = 0,
|
||||
nMaxLevel = 0
|
||||
},
|
||||
[2] = {
|
||||
nPerkId = 0,
|
||||
nQty = 0,
|
||||
nMaxLevel = 0
|
||||
},
|
||||
[3] = {
|
||||
nPerkId = 0,
|
||||
nQty = 0,
|
||||
nMaxLevel = 0
|
||||
},
|
||||
[4] = {
|
||||
nPerkId = 0,
|
||||
nQty = 0,
|
||||
nMaxLevel = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
EventManager.Add(EventId.SelectPerk, self, SelectPerkCallBack)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.FRThemePerkSelect, {
|
||||
{Perks = tbPerks, Theme = 0}
|
||||
}, 0, mapBag, {}, true, true)
|
||||
end
|
||||
function MainlinePrologueLevel:GetRewardBox(nBoxId)
|
||||
local function SelectPerkCallBack(_, tbResult)
|
||||
EventManager.Remove(EventId.SelectPerk, self, SelectPerkCallBack)
|
||||
self.curNpcRewardIdx = self.curNpcRewardIdx + 1
|
||||
table.insert(self.tbSelectPerks, tbResult[1])
|
||||
local tbThemePerkInfo = {}
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = tbResult[1]
|
||||
stPerkInfo.nCount = 1
|
||||
table.insert(tbThemePerkInfo, stPerkInfo)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangeThemePerkIds, tbThemePerkInfo)
|
||||
local mapNpc = ConfigTable.GetData("NPC", nNpcId)
|
||||
if mapNpc.completeDestroy then
|
||||
safe_call_cs_func(CS.InteractiveManager.Instance.setInteractiveNpcState, CS.InteractiveManager.Instance, nNpcUid)
|
||||
end
|
||||
NovaAPI.DispatchEventWithData("PROLOGUELEVEL_SELECTPERK")
|
||||
end
|
||||
if mapBoxReward[self.nBoxId] == nil then
|
||||
printError(string.format("没有配置宝箱id为%d的奖励", self.nBoxId))
|
||||
return
|
||||
end
|
||||
local tbPerks = {}
|
||||
for _, nPerkId in ipairs(mapBoxReward[self.nBoxId]) do
|
||||
table.insert(tbPerks, {
|
||||
Id = nPerkId,
|
||||
Level = 1,
|
||||
nMaxLevel = 3
|
||||
})
|
||||
end
|
||||
local mapBag = {
|
||||
mapPerk = {},
|
||||
mapItem = {},
|
||||
mapSlotPerk = {
|
||||
[1] = {
|
||||
nPerkId = 0,
|
||||
nQty = 0,
|
||||
nMaxLevel = 0
|
||||
},
|
||||
[2] = {
|
||||
nPerkId = 0,
|
||||
nQty = 0,
|
||||
nMaxLevel = 0
|
||||
},
|
||||
[3] = {
|
||||
nPerkId = 0,
|
||||
nQty = 0,
|
||||
nMaxLevel = 0
|
||||
},
|
||||
[4] = {
|
||||
nPerkId = 0,
|
||||
nQty = 0,
|
||||
nMaxLevel = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
EventManager.Add(EventId.SelectPerk, self, SelectPerkCallBack)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.FRThemePerkSelect, {
|
||||
{Perks = tbPerks, Theme = 0}
|
||||
}, 0, mapBag, {}, true, true)
|
||||
end
|
||||
function MainlinePrologueLevel:OnEvent_LevelStateChanged()
|
||||
self.bDesertComplete = true
|
||||
if 0 < #tbAfterDesertFloor and #tbAfterDesertFloor > self.curFloorIdx and not self.bBattleEnd then
|
||||
self:ChangeFloor()
|
||||
return
|
||||
end
|
||||
local function func_AvgEnd()
|
||||
EventManager.Remove("StoryDialog_DialogEnd", self, func_AvgEnd)
|
||||
NovaAPI.EnterModule("MainMenuModuleScene", true)
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
local function UnloadCallback()
|
||||
CS.GameCameraStackManager.Instance:CloseMainCamera(0.1)
|
||||
CS.ClientManager.Instance:CloseLoadingView(nil)
|
||||
PlayerData.Char:DeleteTrialChar()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, UnloadCallback)
|
||||
local ModuleManager = require("GameCore.Module.ModuleManager")
|
||||
if ModuleManager.GetIsAdventure() then
|
||||
NovaAPI.InputDisable()
|
||||
end
|
||||
if self.sAfterBattleAvg ~= "" then
|
||||
self.bBattleEnd = true
|
||||
self:SetLocalData()
|
||||
EventManager.Add("StoryDialog_DialogEnd", self, func_AvgEnd)
|
||||
EventManager.Hit("StoryDialog_DialogStart", self.sAfterBattleAvg, nil, self.nCurAvgCmdIdx)
|
||||
else
|
||||
func_AvgEnd()
|
||||
end
|
||||
end
|
||||
self:UnsetFloor()
|
||||
local ModuleManager = require("GameCore.Module.ModuleManager")
|
||||
if ModuleManager.GetIsAdventure() then
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, UnloadCallback)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
NovaAPI.InputDisable()
|
||||
else
|
||||
UnloadCallback()
|
||||
end
|
||||
end
|
||||
function MainlinePrologueLevel:OnEvent_ExitModule(_, sEnterModuleName)
|
||||
end
|
||||
function MainlinePrologueLevel:OnEvent_AfterEnterModule(sEnterModuleName)
|
||||
if sEnterModuleName == "EmptyModuleScene" then
|
||||
local wait = function()
|
||||
self.bDesertComplete = true
|
||||
self:SetLocalData()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self.tbChar = {}
|
||||
self.tbTrialId = {}
|
||||
if #tbTrialCharacter[self.curFloorIdx] > 0 then
|
||||
PlayerData.Char:CreateTrialChar(tbTrialCharacter[self.curFloorIdx])
|
||||
for _, nTrialId in pairs(tbTrialCharacter[self.curFloorIdx]) do
|
||||
if 0 < nTrialId then
|
||||
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
|
||||
table.insert(self.tbChar, mapTrialChar.nId)
|
||||
table.insert(self.tbTrialId, nTrialId)
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, nTrialId in ipairs(self.tbTrialId) do
|
||||
if 0 < nTrialId then
|
||||
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
|
||||
local tbstInfo, stActorInfo, nHeartStoneLevel = self.CalCharFixedEffectTrial(nTrialId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, mapTrialChar.nId, stActorInfo)
|
||||
end
|
||||
end
|
||||
self:SetFloor(2)
|
||||
CS.AdventureModuleHelper.EnterProloguelBattleMap(tbAfterDesertFloor[self.curFloorIdx], self.tbChar, {}, self.isThreePlayer, self.revivalPoint, self.btnNames)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
EventManager.Hit(EventId.CloesCurPanel)
|
||||
end
|
||||
end
|
||||
function MainlinePrologueLevel:OnEvent_PrologueBattleReload()
|
||||
local function levelUnloadCallback()
|
||||
NovaAPI.EnterModule("EmptyModuleScene", true)
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
end
|
||||
function MainlinePrologueLevel:ChangeFloor()
|
||||
local function levelUnloadCallback()
|
||||
PlayerData.Char:DeleteTrialChar()
|
||||
self.curFloorIdx = self.curFloorIdx + 1
|
||||
NovaAPI.EnterModule("EmptyModuleScene", true)
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
|
||||
self.btnNames = {}
|
||||
self.revivalPoint = Vector3.zero
|
||||
self:SetLocalData()
|
||||
end
|
||||
local id = CS.AdventureModuleHelper.GetCurrentActivePlayer()
|
||||
self.curCharId = CS.AdventureModuleHelper.GetCharacterId(id)
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
|
||||
self:UnsetFloor()
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
end
|
||||
function MainlinePrologueLevel:OnEvent_LoadLevelRefresh()
|
||||
if self.curFloorIdx > 0 then
|
||||
for _, nTrialId in ipairs(self.tbTrialId) do
|
||||
if 0 < nTrialId then
|
||||
local tbstInfo, stActorInfo, nHeartStoneLevel = self.CalCharFixedEffectTrial(nTrialId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function MainlinePrologueLevel:OnEvent_PrologueBattleArchive(isThreePlayer, revivalPoint, btnNames, nCmdId, nBoxId)
|
||||
if nCmdId == -1 then
|
||||
local lastAccount = LocalData.GetLocalData("LoginUIData", "LastUserName_All")
|
||||
LocalData.SetLocalData(lastAccount, "MainlinePrologueLevel", "")
|
||||
end
|
||||
self.nBoxId = nBoxId
|
||||
if isThreePlayer == nil then
|
||||
end
|
||||
self.isThreePlayer = isThreePlayer
|
||||
self.revivalPoint = revivalPoint == nil and Vector3.zero or revivalPoint
|
||||
btnNames = btnNames == nil and {
|
||||
[0] = "",
|
||||
Count = 1
|
||||
} or btnNames
|
||||
self.nCurAvgCmdIdx = nCmdId
|
||||
local tbNames = {}
|
||||
local nCount = btnNames.Count - 1
|
||||
for i = 0, nCount do
|
||||
table.insert(tbNames, btnNames[i])
|
||||
end
|
||||
self.btnNames = tbNames
|
||||
self:SetLocalData()
|
||||
end
|
||||
function MainlinePrologueLevel:OnEvent_AdventureModuleEnter()
|
||||
if self.bDesertComplete then
|
||||
self:SetTheme()
|
||||
self:SetThemePerk()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Hud)
|
||||
end
|
||||
end
|
||||
function MainlinePrologueLevel:OnEvent_EnterModule()
|
||||
if not self.bDesertComplete then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Prologue, self.tbChar)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PrologueAdventurePanel, self.tbChar)
|
||||
end
|
||||
end
|
||||
return MainlinePrologueLevel
|
||||
@@ -0,0 +1,164 @@
|
||||
local PreviewLevel = class("PreviewLevel")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
BattlePause = "OnEvent_AbandonBattle",
|
||||
LevelStateChanged = "OnEvent_LevelResult",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter"
|
||||
}
|
||||
function PreviewLevel:Init(nLevelType, nLevelId, bView, nStarTowerFloorSetId, nPrefabID, nPrefabExtension, nPlayType, nSceneMir, parent)
|
||||
self.parent = parent
|
||||
self.tbCharId = PlayerData.Team:GetTeamCharId(1)
|
||||
self.nLevelType = nLevelType
|
||||
self.nLevelId = nLevelId
|
||||
self:BindEvent()
|
||||
CS.AdventureModuleHelper.EnterViewSceneLevel(nLevelType, nLevelId, self.tbCharId, bView, nStarTowerFloorSetId, nPrefabID, nPrefabExtension, nPlayType, nSceneMir)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
function PreviewLevel:OnEvent_LoadLevelRefresh()
|
||||
end
|
||||
function PreviewLevel:OnEvent_LevelResult(nState)
|
||||
self:PlaySuccessPerform({}, {}, 3)
|
||||
end
|
||||
function PreviewLevel:OnEvent_AbandonBattle()
|
||||
self:OnEvent_LevelResult(true, 0)
|
||||
end
|
||||
function PreviewLevel:OnEvent_AdventureModuleEnter()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Adventure, self.tbCharId)
|
||||
self:SetTheme()
|
||||
for _, value in ipairs(self.tbCharId) do
|
||||
self:SetTempActorAttribute(value)
|
||||
end
|
||||
end
|
||||
function PreviewLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function PreviewLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function PreviewLevel:PlaySuccessPerform()
|
||||
local func_OpenResult = function(bSuccess)
|
||||
end
|
||||
local tbChar = self.tbCharId
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local sName = ""
|
||||
if self.nLevelType == GameEnum.worldLevelType.Mainline then
|
||||
local nType = ConfigTable.GetData("MainlineFloor", self.nLevelId).Theme
|
||||
sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
elseif self.nLevelType == GameEnum.worldLevelType.RegionBoss then
|
||||
local nType = ConfigTable.GetData("RegionBossFloor", self.nLevelId).Theme
|
||||
sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
elseif self.nLevelType == GameEnum.worldLevelType.TravelerDuel then
|
||||
local nType = ConfigTable.GetData("TravelerDuelFloor", self.nLevelId).Theme
|
||||
sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
elseif self.nLevelType == GameEnum.worldLevelType.DailyInstance then
|
||||
local nType = ConfigTable.GetData("DailyInstanceFloor", self.nLevelId).Theme
|
||||
sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
else
|
||||
local nType = ConfigTable.GetData("StarTowerMap", self.nLevelId).Theme
|
||||
sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
end
|
||||
local jumpPerform = function()
|
||||
NovaAPI.DispatchEventWithData("SKIP_SETTLEMENT_PERFORM")
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BtnTips, jumpPerform)
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, true, 3, {}, {}, {}, 0, false, sLarge, sSmall, 13001, self.tbCharId)
|
||||
self.bSettle = false
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_OpenResult)
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
end
|
||||
function PreviewLevel:SetTempActorAttribute(nCharId)
|
||||
local mapChar = {nLevel = 1, nAdvance = 0}
|
||||
local nLevel = mapChar.nLevel
|
||||
local nAdvance = mapChar.nAdvance
|
||||
local nAttrId = UTILS.GetCharacterAttributeId(nCharId, nAdvance, nLevel)
|
||||
local mapCharAttr = ConfigTable.GetData_Attribute(tostring(nAttrId))
|
||||
if mapCharAttr == nil then
|
||||
printError("属性配置不存在:" .. nAttrId)
|
||||
return {}
|
||||
end
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
stActorInfo.Atk = mapCharAttr.Atk
|
||||
stActorInfo.Def = mapCharAttr.Def
|
||||
stActorInfo.MDef = mapCharAttr.Mdef
|
||||
stActorInfo.ShieldBonus = mapCharAttr.ShieldBonus
|
||||
stActorInfo.IncomingShieldBonus = mapCharAttr.IncomingShieldBonus
|
||||
stActorInfo.Evd = mapCharAttr.Evd
|
||||
stActorInfo.CritRate = mapCharAttr.CritRate
|
||||
stActorInfo.CritResistance = mapCharAttr.CritResistance
|
||||
stActorInfo.CritPower = mapCharAttr.CritPower
|
||||
stActorInfo.HitRate = mapCharAttr.HitRate
|
||||
stActorInfo.DefPierce = mapCharAttr.DefPierce
|
||||
stActorInfo.WEE = mapCharAttr.WEE
|
||||
stActorInfo.FEE = mapCharAttr.FEE
|
||||
stActorInfo.SEE = mapCharAttr.SEE
|
||||
stActorInfo.AEE = mapCharAttr.AEE
|
||||
stActorInfo.LEE = mapCharAttr.LEE
|
||||
stActorInfo.DEE = mapCharAttr.DEE
|
||||
stActorInfo.WEP = mapCharAttr.WEP
|
||||
stActorInfo.FEP = mapCharAttr.FEP
|
||||
stActorInfo.AEP = mapCharAttr.AEP
|
||||
stActorInfo.SEP = mapCharAttr.SEP
|
||||
stActorInfo.LEP = mapCharAttr.LEP
|
||||
stActorInfo.DEP = mapCharAttr.DEP
|
||||
stActorInfo.WER = mapCharAttr.WER
|
||||
stActorInfo.FER = mapCharAttr.FER
|
||||
stActorInfo.AER = mapCharAttr.AER
|
||||
stActorInfo.SER = mapCharAttr.SER
|
||||
stActorInfo.LER = mapCharAttr.LER
|
||||
stActorInfo.DER = mapCharAttr.DER
|
||||
stActorInfo.Hp = mapCharAttr.Hp
|
||||
stActorInfo.Suppress = mapCharAttr.Suppress
|
||||
stActorInfo.SkillLevel = {
|
||||
1,
|
||||
1,
|
||||
1
|
||||
}
|
||||
stActorInfo.skinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
stActorInfo.attrId = mapCharAttr.sAttrId
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
function PreviewLevel:SetCharFixedAttribute()
|
||||
for nCharId, mapInfo in pairs(self.mapActorInfo) do
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, mapInfo.stActorInfo)
|
||||
end
|
||||
end
|
||||
function PreviewLevel.CalCharFixedEffect(nCharId, bMainChar)
|
||||
local tbstInfo = {}
|
||||
local stActorInfo = {}
|
||||
local nHeartStoneLevel = 1
|
||||
return tbstInfo, stActorInfo, nHeartStoneLevel
|
||||
end
|
||||
function PreviewLevel:SetTheme()
|
||||
end
|
||||
return PreviewLevel
|
||||
@@ -0,0 +1,33 @@
|
||||
local BasePrologueFloor = class("BasePrologueFloor")
|
||||
function BasePrologueFloor:ctor(parentData)
|
||||
self.parent = parentData
|
||||
end
|
||||
function BasePrologueFloor:Enter()
|
||||
self:_BindEventCallback()
|
||||
end
|
||||
function BasePrologueFloor:_BindEventCallback()
|
||||
if type(self._mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(self._mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function BasePrologueFloor:_UnbindEventCallback()
|
||||
if type(self._mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(self._mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function BasePrologueFloor:Exit()
|
||||
self:_UnbindEventCallback()
|
||||
end
|
||||
return BasePrologueFloor
|
||||
@@ -0,0 +1,21 @@
|
||||
local BaseFloor = require("Game.Adventure.MainlineLevel.PrologueFloor.BasePrologueFloor")
|
||||
local BattleFloor = class("BattleFloor", BaseFloor)
|
||||
BattleFloor._mapEventConfig = {
|
||||
InteractiveNpc = "OnEvent_InteractiveNpc",
|
||||
InteractiveBoxGet = "OnEvent_InteractiveBoxGet"
|
||||
}
|
||||
function BattleFloor:OnEvent_InteractiveNpc(nNpcId, nNpcUid)
|
||||
local mapNpc = ConfigTable.GetData("NPC", nNpcId)
|
||||
if mapNpc == nil then
|
||||
print("NPC不存在" .. nNpcId)
|
||||
return
|
||||
end
|
||||
if mapNpc.type ~= GameEnum.npcType.PrologueReward then
|
||||
return
|
||||
end
|
||||
self.parent:GetRewardNpc(nNpcId, nNpcUid)
|
||||
end
|
||||
function BattleFloor:OnEvent_InteractiveBox(nBoxId, _, _, _)
|
||||
self.parent:GetRewardBox(nBoxId)
|
||||
end
|
||||
return BattleFloor
|
||||
@@ -0,0 +1,4 @@
|
||||
local BaseFloor = require("Game.Adventure.MainlineLevel.PrologueFloor.BasePrologueFloor")
|
||||
local DesertFloor = class("DesertFloor", BaseFloor)
|
||||
DesertFloor._mapEventConfig = {}
|
||||
return DesertFloor
|
||||
@@ -0,0 +1,305 @@
|
||||
local RegionBossBattleLevel = class("RegionBossBattleLevel")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
Region_Boss_Result = "LevelResultChange",
|
||||
BattlePause = "OnEvnet_Pause"
|
||||
}
|
||||
function RegionBossBattleLevel:Init(parent, nLevelId, nBuildId, isWeekBoss)
|
||||
self.parent = parent
|
||||
self.nLevelId = nLevelId
|
||||
self.nBuildId = nBuildId
|
||||
self.isSettlement = false
|
||||
local GetBuildCallback = function(mapBuildData)
|
||||
self.mapBuildData = mapBuildData
|
||||
self.tbCharId = {}
|
||||
if mapBuildData == nil then
|
||||
local sTip = ConfigTable.GetUIText("RegionBoss_Team_Delete")
|
||||
EventManager.Hit(EventId.OpenMessageBox, sTip)
|
||||
return
|
||||
end
|
||||
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, mapChar.nTid)
|
||||
end
|
||||
self.tbDiscId = {}
|
||||
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
end
|
||||
end
|
||||
self.mapActorInfo = {}
|
||||
for idx, nTid in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
|
||||
self.mapActorInfo[nTid] = stActorInfo
|
||||
end
|
||||
local nFloorId = 0
|
||||
if isWeekBoss == 1 then
|
||||
PlayerData.RogueBoss:SetIsWeeklyCopies(false)
|
||||
nFloorId = ConfigTable.GetData("RegionBossLevel", nLevelId).FloorId
|
||||
elseif isWeekBoss == 2 then
|
||||
PlayerData.RogueBoss:SetIsWeeklyCopies(true)
|
||||
nFloorId = ConfigTable.GetData("WeekBossLevel", nLevelId).FloorId
|
||||
end
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.Rogueboss
|
||||
CS.AdventureModuleHelper.EnterRogueBossMap(nFloorId, self.tbCharId, nLevelId, 0, isWeekBoss)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
|
||||
self.nResultTime = 0
|
||||
end
|
||||
function RegionBossBattleLevel:RefreshCharDamageData()
|
||||
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
|
||||
end
|
||||
function RegionBossBattleLevel:SettleRegionBoss(isWin)
|
||||
if self.isSettlement then
|
||||
return
|
||||
end
|
||||
self.isSettlement = true
|
||||
self:RefreshCharDamageData()
|
||||
local isWeeklyCopies = PlayerData.RogueBoss:GetIsWeeklyCopies()
|
||||
print("is week " .. tostring(isWeeklyCopies))
|
||||
if isWeeklyCopies then
|
||||
local callback = function(mapMsgData, nPassStar)
|
||||
local nExp = 0
|
||||
local CacheRewardTab = {}
|
||||
for i, v in ipairs(mapMsgData.FirstItems) do
|
||||
v.rewardType = AllEnum.RewardType.First
|
||||
table.insert(CacheRewardTab, v)
|
||||
end
|
||||
for i, v in ipairs(mapMsgData.AwardItems) do
|
||||
table.insert(CacheRewardTab, v)
|
||||
end
|
||||
if isWin then
|
||||
self:PlaySuccessPerform(ConfigTable.GetData("WeekBossLevel", self.nLevelId).FloorId, self.nBuildId, nExp, CacheRewardTab, mapMsgData.Change, true)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.RogueBossResult, 2, self.nResultTime, self.nBuildId, nExp, CacheRewardTab, mapMsgData.Change, self.tbCharDamage)
|
||||
end
|
||||
self:UnBindEvent()
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
self.parent:WeeklyCopiesLevelSettleReq(isWin, self.nResultTime, callback)
|
||||
else
|
||||
local callback = function(mapMsgData, nPassStar)
|
||||
self.passStar = nPassStar
|
||||
local nExp = mapMsgData.Exp
|
||||
local CacheRewardTab = {}
|
||||
for i, v in ipairs(mapMsgData.FirstItems) do
|
||||
v.rewardType = AllEnum.RewardType.First
|
||||
table.insert(CacheRewardTab, v)
|
||||
end
|
||||
for i, v in ipairs(mapMsgData.ThreeStarItems) do
|
||||
v.rewardType = AllEnum.RewardType.Three
|
||||
table.insert(CacheRewardTab, v)
|
||||
end
|
||||
for i, v in ipairs(mapMsgData.SurpriseItems) do
|
||||
v.rewardType = AllEnum.RewardType.Extra
|
||||
table.insert(CacheRewardTab, v)
|
||||
end
|
||||
for i, v in ipairs(mapMsgData.AwardItems) do
|
||||
table.insert(CacheRewardTab, v)
|
||||
end
|
||||
if isWin then
|
||||
self:PlaySuccessPerform(ConfigTable.GetData("RegionBossLevel", self.nLevelId).FloorId, self.nBuildId, nExp, CacheRewardTab, mapMsgData.Change, false)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BossInstanceResultPanel, false, 0, CacheRewardTab, nExp, self.nLevelId, self.tbCharId, mapMsgData.Change, self.tbCharDamage)
|
||||
end
|
||||
self:UnBindEvent()
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
self.parent:RegionBossLevelSettleReq(isWin, self.nResultTime, callback)
|
||||
end
|
||||
end
|
||||
function RegionBossBattleLevel:OnEvent_LoadLevelRefresh()
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
end
|
||||
function RegionBossBattleLevel:OnEvent_AbandonBattle()
|
||||
self:SettleRegionBoss(false)
|
||||
end
|
||||
function RegionBossBattleLevel:OnEvent_AdventureModuleEnter()
|
||||
local isWeeklyCopies = PlayerData.RogueBoss:GetIsWeeklyCopies()
|
||||
if isWeeklyCopies then
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.WeeklyCopies)
|
||||
else
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.RegionBoss)
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.RegionBossBattlePanel, self.tbCharId)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function RegionBossBattleLevel:OnEvent_OpenChest()
|
||||
local wait = function()
|
||||
self:SettleRegionBoss(true)
|
||||
end
|
||||
TimerManager.Add(1, 1, self, wait, true, true, true, nil)
|
||||
end
|
||||
function RegionBossBattleLevel:LevelResultChange(isWin, totaltime)
|
||||
self.nResultTime = totaltime
|
||||
self:SettleRegionBoss(isWin)
|
||||
end
|
||||
function RegionBossBattleLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function RegionBossBattleLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function RegionBossBattleLevel:PlaySuccessPerform(nMapId, buildId, nExp, tbReward, mapChangeInfo, isWeekBoss)
|
||||
local func_SettlementFinish = function(bSuccess)
|
||||
end
|
||||
local tbChar = self.tbCharId
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
if isWeekBoss then
|
||||
local nType = ConfigTable.GetData("WeekBossFloor", nMapId).Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
print("sceneName:" .. sName)
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
else
|
||||
local nType = ConfigTable.GetData("RegionBossFloor", nMapId).Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
print("sceneName:" .. sName)
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
end
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
if self.passStar == nil then
|
||||
self.passStar = 1
|
||||
end
|
||||
if isWeekBoss then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.RogueBossResult, 1, self.nResultTime, buildId, nExp, tbReward, mapChangeInfo, self.tbCharDamage)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BossInstanceResultPanel, true, self.passStar, tbReward, nExp, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
|
||||
end
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
end
|
||||
function RegionBossBattleLevel:SetTempActorAttribute(nCharId)
|
||||
local mapChar = {nLevel = 1, nAdvance = 0}
|
||||
local nLevel = mapChar.nLevel
|
||||
local nAdvance = mapChar.nAdvance
|
||||
local nAttrId = UTILS.GetCharacterAttributeId(nCharId, nAdvance, nLevel)
|
||||
local mapCharAttr = ConfigTable.GetData_Attribute(tostring(nAttrId))
|
||||
if mapCharAttr == nil then
|
||||
printError("属性配置不存在:" .. nAttrId)
|
||||
return {}
|
||||
end
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
stActorInfo.Atk = mapCharAttr.Atk
|
||||
stActorInfo.Def = mapCharAttr.Def
|
||||
stActorInfo.MDef = mapCharAttr.Mdef
|
||||
stActorInfo.ShieldBonus = mapCharAttr.ShieldBonus
|
||||
stActorInfo.IncomingShieldBonus = mapCharAttr.IncomingShieldBonus
|
||||
stActorInfo.Evd = mapCharAttr.Evd
|
||||
stActorInfo.CritRate = mapCharAttr.CritRate
|
||||
stActorInfo.CritResistance = mapCharAttr.CritResistance
|
||||
stActorInfo.CritPower = mapCharAttr.CritPower
|
||||
stActorInfo.HitRate = mapCharAttr.HitRate
|
||||
stActorInfo.DefPierce = mapCharAttr.DefPierce
|
||||
stActorInfo.WEE = mapCharAttr.WEE
|
||||
stActorInfo.FEE = mapCharAttr.FEE
|
||||
stActorInfo.SEE = mapCharAttr.SEE
|
||||
stActorInfo.AEE = mapCharAttr.AEE
|
||||
stActorInfo.LEE = mapCharAttr.LEE
|
||||
stActorInfo.DEE = mapCharAttr.DEE
|
||||
stActorInfo.WEP = mapCharAttr.WEP
|
||||
stActorInfo.FEP = mapCharAttr.FEP
|
||||
stActorInfo.AEP = mapCharAttr.AEP
|
||||
stActorInfo.SEP = mapCharAttr.SEP
|
||||
stActorInfo.LEP = mapCharAttr.LEP
|
||||
stActorInfo.DEP = mapCharAttr.DEP
|
||||
stActorInfo.WER = mapCharAttr.WER
|
||||
stActorInfo.FER = mapCharAttr.FER
|
||||
stActorInfo.AER = mapCharAttr.AER
|
||||
stActorInfo.SER = mapCharAttr.SER
|
||||
stActorInfo.LER = mapCharAttr.LER
|
||||
stActorInfo.DER = mapCharAttr.DER
|
||||
stActorInfo.Hp = mapCharAttr.Hp
|
||||
stActorInfo.Suppress = mapCharAttr.Suppress
|
||||
stActorInfo.SkillLevel = {
|
||||
1,
|
||||
1,
|
||||
1
|
||||
}
|
||||
stActorInfo.skinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
stActorInfo.attrId = mapCharAttr.sAttrId
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
function RegionBossBattleLevel:SetCharFixedAttribute()
|
||||
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function RegionBossBattleLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
return stActorInfo
|
||||
end
|
||||
function RegionBossBattleLevel:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function RegionBossBattleLevel:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function RegionBossBattleLevel:OnEvnet_Pause()
|
||||
EventManager.Hit("OpenRegionBossPause", self.nLevelId, self.tbCharId)
|
||||
end
|
||||
return RegionBossBattleLevel
|
||||
@@ -0,0 +1,29 @@
|
||||
local BossFloor = {}
|
||||
function BossFloor:Init()
|
||||
self.touchPortal = false
|
||||
end
|
||||
function BossFloor:OnRoguelikeEnter(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:SetActorEffects()
|
||||
PlayerRoguelikeData:ResetBoxCount()
|
||||
PlayerRoguelikeData:ResetPerkEffect()
|
||||
PlayerRoguelikeData:SetActorAttribute(false)
|
||||
end
|
||||
function BossFloor:OnTouchPortal(PlayerRoguelikeData)
|
||||
if self.touchPortal then
|
||||
return
|
||||
end
|
||||
self.touchPortal = true
|
||||
PlayerRoguelikeData:CacheCharAttr()
|
||||
PlayerRoguelikeData:SendSettleReq()
|
||||
end
|
||||
function BossFloor:SettleCallback(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:FloorEnd()
|
||||
end
|
||||
function BossFloor:OnBossDied(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:SyncKillBoss()
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.Lua2CSharp_RoguelikeOpenTeleporter)
|
||||
end
|
||||
function BossFloor:OnAbandon(PlayerRoguelikeData, bFailed)
|
||||
PlayerRoguelikeData:AbandonRoguelike(bFailed)
|
||||
end
|
||||
return BossFloor
|
||||
@@ -0,0 +1,21 @@
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local EditorFloor = {}
|
||||
function EditorFloor:Init()
|
||||
end
|
||||
function EditorFloor:OnRoguelikeEnter(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:SetActorEffects()
|
||||
PlayerRoguelikeData:SetActorAttribute()
|
||||
end
|
||||
function EditorFloor:OnTouchPortal(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:CacheCharAttr()
|
||||
PlayerRoguelikeData:FloorEndEditor()
|
||||
end
|
||||
function EditorFloor:SettleCallback(PlayerRoguelikeData)
|
||||
end
|
||||
function EditorFloor:OnBossDied(PlayerRoguelikeData)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.Lua2CSharp_RoguelikeOpenTeleporter)
|
||||
end
|
||||
function EditorFloor:OnAbandon(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:FloorEndEditor()
|
||||
end
|
||||
return EditorFloor
|
||||
@@ -0,0 +1,25 @@
|
||||
local FirstFloor = {}
|
||||
function FirstFloor:Init()
|
||||
self._bStart = true
|
||||
self.touchPortal = false
|
||||
end
|
||||
function FirstFloor:OnRoguelikeEnter(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:SetActorEffects()
|
||||
PlayerRoguelikeData:SetActorAttribute(true)
|
||||
PlayerRoguelikeData:ResetBoxCount()
|
||||
end
|
||||
function FirstFloor:OnTouchPortal(PlayerRoguelikeData)
|
||||
if self.touchPortal then
|
||||
return
|
||||
end
|
||||
self.touchPortal = true
|
||||
PlayerRoguelikeData:CacheCharAttr()
|
||||
PlayerRoguelikeData:SendSettleReq()
|
||||
end
|
||||
function FirstFloor:SettleCallback(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:FloorEnd()
|
||||
end
|
||||
function FirstFloor:OnAbandon(PlayerRoguelikeData, bFailed)
|
||||
PlayerRoguelikeData:AbandonRoguelike(bFailed)
|
||||
end
|
||||
return FirstFloor
|
||||
@@ -0,0 +1,25 @@
|
||||
local NormalFloor = {}
|
||||
function NormalFloor:Init()
|
||||
self.touchPortal = false
|
||||
end
|
||||
function NormalFloor:OnRoguelikeEnter(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:SetActorEffects()
|
||||
PlayerRoguelikeData:SetActorAttribute(false)
|
||||
PlayerRoguelikeData:ResetBoxCount()
|
||||
PlayerRoguelikeData:ResetPerkEffect()
|
||||
end
|
||||
function NormalFloor:OnTouchPortal(PlayerRoguelikeData)
|
||||
if self.touchPortal then
|
||||
return
|
||||
end
|
||||
self.touchPortal = true
|
||||
PlayerRoguelikeData:CacheCharAttr()
|
||||
PlayerRoguelikeData:SendSettleReq()
|
||||
end
|
||||
function NormalFloor:SettleCallback(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:FloorEnd()
|
||||
end
|
||||
function NormalFloor:OnAbandon(PlayerRoguelikeData, bFailed)
|
||||
PlayerRoguelikeData:AbandonRoguelike(bFailed)
|
||||
end
|
||||
return NormalFloor
|
||||
@@ -0,0 +1,26 @@
|
||||
local RenterBossDiedFloor = {}
|
||||
function RenterBossDiedFloor:Init()
|
||||
self._bBossTalent = true
|
||||
self.touchPortal = false
|
||||
end
|
||||
function RenterBossDiedFloor:OnRoguelikeEnter(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:SetActorEffects()
|
||||
PlayerRoguelikeData:SetActorAttribute(false)
|
||||
PlayerRoguelikeData:ResetBoxCount()
|
||||
PlayerRoguelikeData:ResetPerkEffect()
|
||||
end
|
||||
function RenterBossDiedFloor:OnTouchPortal(PlayerRoguelikeData)
|
||||
if self.touchPortal then
|
||||
return
|
||||
end
|
||||
self.touchPortal = true
|
||||
PlayerRoguelikeData:CacheCharAttr()
|
||||
PlayerRoguelikeData:SendSettleReq()
|
||||
end
|
||||
function RenterBossDiedFloor:SettleCallback(PlayerRoguelikeData)
|
||||
PlayerRoguelikeData:FloorEnd()
|
||||
end
|
||||
function RenterBossDiedFloor:OnAbandon(PlayerRoguelikeData, bFailed)
|
||||
PlayerRoguelikeData:AbandonRoguelike(bFailed)
|
||||
end
|
||||
return RenterBossDiedFloor
|
||||
@@ -0,0 +1,282 @@
|
||||
local ScoreBossLevel = class("ScoreBossLevel")
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
BattlePause = "OnEvent_Pause",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
ScoreBossLevelGameEnd = "OnEvent_LevelResult",
|
||||
BossRush_Spawn_Id = "OnEvent_BossRushSpawnId",
|
||||
ScoreBoss_Result_Time = "ScoreBossResultTime",
|
||||
LevelStateChanged = "ScoreBossResult",
|
||||
ScoreBoss_BehaviorScore = "OnEvent_ControlScore",
|
||||
ScoreBossSettleSuccess = "OnEvent_ScoreBossSettleSuccess",
|
||||
ScoreBossSettleGiveUp = "OnEvent_ScoreBossSettleGiveUp",
|
||||
Upload_Dodge_Event = "OnEvent_UploadDodgeEvent"
|
||||
}
|
||||
function ScoreBossLevel:Init(parent, nLevelId, nBuildId)
|
||||
self.isSettlement = false
|
||||
self.parent = parent
|
||||
self.LevelId = nLevelId
|
||||
self.tmpBuildId = nBuildId
|
||||
self.BossId = 0
|
||||
self.BossMaxHp = 0
|
||||
self.BossCurLvMinHp = -1
|
||||
self.BossCurLvTotalChangeHp = 0
|
||||
self.BattleLv = 1
|
||||
self.nTime = 0
|
||||
local leveData = ConfigTable.GetData("ScoreBossLevel", nLevelId)
|
||||
if leveData == nil then
|
||||
printError("ScoreBossLevel 表不存在 id ==== " .. nLevelId)
|
||||
return
|
||||
end
|
||||
local getControlData = ConfigTable.GetData("ScoreBossGetControl", leveData.NonDamageScoreGet)
|
||||
if getControlData == nil then
|
||||
printError("ScoreBossGetControl 表不存在 id ==== " .. leveData.NonDamageScoreGet)
|
||||
return
|
||||
end
|
||||
self.totalControlScore = 0
|
||||
self.OnceControlScore = getControlData.OnceScore
|
||||
self.MaxControlScore = getControlData.MaxLimit
|
||||
self.ScoreBossBehavior = getControlData.ScoreBossBehavior
|
||||
self.ScoreGetSwitchGroupId = leveData.ScoreGetSwitchGroup
|
||||
self.SwitchRate = 300
|
||||
local getSwitchData = ConfigTable.GetData("ScoreGetSwitch", self.ScoreGetSwitchGroupId * 1000 + 1)
|
||||
if getSwitchData ~= nil then
|
||||
self.SwitchRate = getSwitchData.SwitchRate
|
||||
end
|
||||
local GetBuildCallback = function(mapBuildData)
|
||||
self.mapBuildData = mapBuildData
|
||||
self.tbCharId = {}
|
||||
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, mapChar.nTid)
|
||||
end
|
||||
self.tbDiscId = {}
|
||||
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
end
|
||||
end
|
||||
self.mapActorInfo = {}
|
||||
for idx, nTid in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
|
||||
self.mapActorInfo[nTid] = stActorInfo
|
||||
end
|
||||
self.parent:CacheBuildCharTid(self.tbCharId)
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.ScoreBoss
|
||||
CS.AdventureModuleHelper.EnterScoreBossFloor(self.LevelId, self.tbCharId)
|
||||
local sKey = LocalData.GetPlayerLocalData("ScoreBossRecordKey")
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDamageRecordId, sKey)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
|
||||
end
|
||||
function ScoreBossLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
return stActorInfo
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_LoadLevelRefresh()
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
PlayerData.Build:SetBuildReportInfo(self.mapBuildData.nBuildId)
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_AdventureModuleEnter()
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.ScoreBoss)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ScoreBossBattlePanel, self.tbCharId)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function ScoreBossLevel:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ScoreBossLevel:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_Pause()
|
||||
EventManager.Hit("OpenScoreBossPause", self.LevelId, self.tbCharId)
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_AbandonBattle()
|
||||
self.parent:QuiteLevel()
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_LevelResult(tbStar, bAbandon)
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_BossRushSpawnId(bossId)
|
||||
self.BossId = bossId
|
||||
EventManager.AddEntityEvent("HpChanged", self.BossId, self, self.OnEvent_HpChanged)
|
||||
EventManager.AddEntityEvent("BossRushMonsterLevelChanged", self.BossId, self, self.OnEvent_BossRushMonsterLevelChanged)
|
||||
EventManager.AddEntityEvent("BossRushMonsterBattleAttrChanged", self.BossId, self, self.OnEvent_BossRushMonsterBattleAttrChanged)
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_HpChanged(hp, hpMax)
|
||||
if self.isSettlement then
|
||||
return
|
||||
end
|
||||
if self.isDontChangeHp then
|
||||
return
|
||||
end
|
||||
self.BossMaxHp = hpMax
|
||||
if self.BossCurLvMinHp == -1 then
|
||||
self.BossCurLvMinHp = hp
|
||||
self.parent:DamageToScore(hpMax - hp, self.SwitchRate, self.BattleLv)
|
||||
end
|
||||
if hp < self.BossCurLvMinHp then
|
||||
self.BossCurLvMinHp = hp
|
||||
self.parent:DamageToScore(hpMax - hp, self.SwitchRate, self.BattleLv)
|
||||
end
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_BossRushMonsterLevelChanged(oldLevel, battleLevel)
|
||||
if self.isSettlement then
|
||||
return
|
||||
end
|
||||
self.isDontChangeHp = true
|
||||
self.BossCurLvTotalChangeHp = self.BossCurLvTotalChangeHp + self.BossCurLvMinHp
|
||||
self.BossCurLvMinHp = -1
|
||||
self.BattleLv = battleLevel
|
||||
self.parent:DamageToScore(self.BossMaxHp, self.SwitchRate, self.BattleLv)
|
||||
self.BossCurLvTotalChangeHp = 0
|
||||
if battleLevel <= 100 then
|
||||
local getSwitchData = ConfigTable.GetData("ScoreGetSwitch", self.ScoreGetSwitchGroupId * 1000 + battleLevel)
|
||||
if getSwitchData ~= nil then
|
||||
self.SwitchRate = getSwitchData.SwitchRate
|
||||
end
|
||||
end
|
||||
self.parent:HPLevelChanged()
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_BossRushMonsterBattleAttrChanged()
|
||||
self.isDontChangeHp = false
|
||||
end
|
||||
function ScoreBossLevel:ScoreBossResultTime(nTime)
|
||||
self.nTime = nTime
|
||||
end
|
||||
function ScoreBossLevel:ScoreBossResult(levelState, totalTime)
|
||||
if self.isSettlement then
|
||||
return
|
||||
end
|
||||
self.isSettlement = true
|
||||
self.parent:SendScoreBossSettleReq(self.nTime)
|
||||
end
|
||||
function ScoreBossLevel:PlaySuccessPerform(entryLevelId, totalScore, totalStar)
|
||||
local tbChar = {}
|
||||
self:RefreshCharDamageData()
|
||||
for _, nCharId in ipairs(self.tbCharId) do
|
||||
table.insert(tbChar, nCharId)
|
||||
end
|
||||
local func_SettlementFinish = function(bSuccess)
|
||||
end
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local nLevelData = ConfigTable.GetData("ScoreBossLevel", self.LevelId)
|
||||
local nType = ConfigTable.GetData("ScoreBossFloor", nLevelData.FloorId).Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
print("sceneName:" .. sName)
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ScoreBossResult, entryLevelId, totalScore, totalStar, self.tbCharDamage)
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
end
|
||||
function ScoreBossLevel:RefreshCharDamageData()
|
||||
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_ControlScore(Id, nBehavior)
|
||||
if self.isSettlement then
|
||||
return
|
||||
end
|
||||
if self.BossId == Id and nBehavior == self.ScoreBossBehavior and self.totalControlScore < self.MaxControlScore then
|
||||
self.totalControlScore = self.totalControlScore + self.OnceControlScore
|
||||
self.parent:BehaviorToScore(self.totalControlScore)
|
||||
end
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_ScoreBossSettleSuccess(entryLevelId, totalScore, totalStar)
|
||||
self:PlaySuccessPerform(entryLevelId, totalScore, totalStar)
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_ScoreBossSettleGiveUp(totalScore, totalStar)
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
function ScoreBossLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ScoreBossLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
if self.BossId then
|
||||
EventManager.RemoveEntityEvent("HpChanged", self.BossId, self, self.OnEvent_HpChanged)
|
||||
EventManager.RemoveEntityEvent("BossRushMonsterLevelChanged", self.BossId, self, self.OnEvent_BossRushMonsterLevelChanged)
|
||||
EventManager.RemoveEntityEvent("BossRushMonsterBattleAttrChanged", self.BossId, self, self.OnEvent_BossRushMonsterBattleAttrChanged)
|
||||
self.BossId = nil
|
||||
end
|
||||
end
|
||||
function ScoreBossLevel:OnEvent_UploadDodgeEvent(padMode)
|
||||
local tab = {}
|
||||
table.insert(tab, {
|
||||
"role_id",
|
||||
tostring(PlayerData.Base._nPlayerId)
|
||||
})
|
||||
table.insert(tab, {"pad_mode", padMode})
|
||||
table.insert(tab, {"level_type", "ScoreBoss"})
|
||||
table.insert(tab, {
|
||||
"build_id",
|
||||
tostring(self.tmpBuildId)
|
||||
})
|
||||
table.insert(tab, {
|
||||
"level_id",
|
||||
tostring(self.LevelId)
|
||||
})
|
||||
table.insert(tab, {
|
||||
"up_time",
|
||||
tostring(CS.ClientManager.Instance.serverTimeStamp)
|
||||
})
|
||||
NovaAPI.UserEventUpload("use_dodge_key", tab)
|
||||
end
|
||||
return ScoreBossLevel
|
||||
@@ -0,0 +1,194 @@
|
||||
local SkillInstanceLevel = class("SkillInstanceLevel")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
SkillInstanceGameEnd = "OnEvent_LevelResult",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
BattlePause = "OnEvent_Pause"
|
||||
}
|
||||
function SkillInstanceLevel:Init(parent, nLevelId, nBuildId)
|
||||
self.parent = parent
|
||||
self.nLevelId = nLevelId
|
||||
local GetBuildCallback = function(mapBuildData)
|
||||
self.mapBuildData = mapBuildData
|
||||
self.tbCharId = {}
|
||||
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, mapChar.nTid)
|
||||
end
|
||||
self.tbDiscId = {}
|
||||
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
end
|
||||
end
|
||||
self.mapActorInfo = {}
|
||||
for idx, nTid in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
|
||||
self.mapActorInfo[nTid] = stActorInfo
|
||||
end
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.SkillInstance
|
||||
CS.AdventureModuleHelper.EnterSkillInstanceMap(nLevelId, self.tbCharId)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
|
||||
end
|
||||
function SkillInstanceLevel:RefreshCharDamageData()
|
||||
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
|
||||
end
|
||||
function SkillInstanceLevel:OnEvent_LoadLevelRefresh()
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
EventManager.Hit("OpenSkillInstanceRoomInfo", ConfigTable.GetData("SkillInstance", self.nLevelId).FloorId, self.nLevelId)
|
||||
end
|
||||
function SkillInstanceLevel:OnEvent_LevelResult(tbStar, bAbandon)
|
||||
EventManager.Hit("SkillInstanceBattleEnd")
|
||||
if self.parent:GetSettlementState() then
|
||||
printError("技能素材副本结算流程重复进入,本次退出")
|
||||
return
|
||||
end
|
||||
self:RefreshCharDamageData()
|
||||
self.parent:SetSettlementState(true)
|
||||
local mapDILevelCfgData = ConfigTable.GetData("SkillInstance", self.nLevelId)
|
||||
local nStar = 0
|
||||
local nStarCount = 0
|
||||
nStar = tbStar[0] and 1 or nStar
|
||||
nStar = tbStar[1] and 2 or nStar
|
||||
nStar = tbStar[2] and 3 or nStar
|
||||
for i = 0, 2 do
|
||||
if tbStar[i] then
|
||||
nStarCount = nStarCount + 1
|
||||
end
|
||||
end
|
||||
local callback = function(tbStarReward, tbFirstReward, tbThreeStarItems, tbSurpriseItems, nExp, mapChangeInfo)
|
||||
local waitCallback = function()
|
||||
NovaAPI.InputEnable()
|
||||
if 0 < nStar then
|
||||
self:PlaySuccessPerform(tbFirstReward, tbStarReward, tbThreeStarItems, tbSurpriseItems, nExp, tbStar, mapChangeInfo)
|
||||
else
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.SkillInstanceResult, false, tbStar, {}, {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, {}, self.tbCharDamage)
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
end
|
||||
EventManager.Hit("SkillInstanceLevelEnd", mapDILevelCfgData.FloorId)
|
||||
if bAbandon then
|
||||
waitCallback()
|
||||
else
|
||||
TimerManager.Add(1, 2, self, waitCallback, true, true, true, nil)
|
||||
end
|
||||
end
|
||||
NovaAPI.InputDisable()
|
||||
self.parent:MsgSettleSkillInstance(self.nLevelId, self.mapBuildData.nBuildId, nStar, callback)
|
||||
end
|
||||
function SkillInstanceLevel:OnEvent_AbandonBattle()
|
||||
self:OnEvent_LevelResult({
|
||||
false,
|
||||
false,
|
||||
false
|
||||
}, true)
|
||||
end
|
||||
function SkillInstanceLevel:OnEvent_AdventureModuleEnter()
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.SkillInstance)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.SkillInstanceBattlePanel, self.tbCharId)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function SkillInstanceLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function SkillInstanceLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function SkillInstanceLevel:PlaySuccessPerform(FirstRewardItems, tbStarReward, tbThreeStarItems, tbSurpriseItems, nExp, tbStar, mapChangeInfo)
|
||||
local func_SettlementFinish = function(bSuccess)
|
||||
end
|
||||
local tbChar = self.tbCharId
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local nType = ConfigTable.GetData("SkillInstanceFloor", ConfigTable.GetData("SkillInstance", self.nLevelId).FloorId).Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.SkillInstanceResult, true, tbStar, tbStarReward or {}, FirstRewardItems or {}, tbThreeStarItems or {}, nExp or 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, tbSurpriseItems or {}, self.tbCharDamage)
|
||||
self.bSettle = false
|
||||
self.parent:LevelEnd()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
end
|
||||
function SkillInstanceLevel:SetCharFixedAttribute()
|
||||
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function SkillInstanceLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
return stActorInfo
|
||||
end
|
||||
function SkillInstanceLevel:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function SkillInstanceLevel:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function SkillInstanceLevel:OnEvent_Pause()
|
||||
EventManager.Hit("OpenSkillInstancePause", self.nLevelId, self.tbCharId)
|
||||
end
|
||||
return SkillInstanceLevel
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,217 @@
|
||||
local BaseRoom = require("Game.Adventure.StarTower.StarTowerRoom.BaseRoom")
|
||||
local BattleRoom = class("BattleRoom", BaseRoom)
|
||||
BattleRoom._mapEventConfig = {
|
||||
CSHARP2LUA_BATTLE_DROP_COIN = "OnEvent_GetCoin",
|
||||
ADVENTURE_BATTLE_MONSTER_DIED = "OnEvent_MonsterDied",
|
||||
LevelStateChanged = "OnEvent_LevelStateChanged",
|
||||
LevelUseTotalTime = "OnEvent_TimeEnd",
|
||||
LevelPauseUseTotalTime = "OnEvent_TimeEnd",
|
||||
InteractiveNpc = "OnEvent_InteractiveNpc",
|
||||
Level_Settlement = "OnEvent_ActorFinishDie"
|
||||
}
|
||||
function BattleRoom:LevelStart()
|
||||
local mapBattleCase = self.mapCases[self.EnumCase.Battle]
|
||||
self.nCoinTemp = 0
|
||||
self.bBattleEnd = false
|
||||
if mapBattleCase == nil then
|
||||
self.bBattleEnd = true
|
||||
EventManager.Hit("ShowStarTowerRoomInfo", true, self.parent.nTeamLevel, self.parent.nTeamExp, clone(self.parent._mapNote), clone(self.parent._mapFateCard))
|
||||
local nCoin = self.parent._mapItem[AllEnum.CoinItemId.FixedRogCurrency]
|
||||
if nCoin == nil then
|
||||
nCoin = 0
|
||||
end
|
||||
local nBuildScore = self.parent:CalBuildScore()
|
||||
EventManager.Hit("ShowStarTowerCoin", true, nCoin, nBuildScore)
|
||||
self:AddTimer(1, 0.1, function()
|
||||
CS.WwiseAudioManager.Instance:SetState("combat", "explore")
|
||||
end, true, true, true)
|
||||
return
|
||||
end
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.StarTower)
|
||||
if mapBattleCase.Data.TimeLimit then
|
||||
local nLevel = self.parent.nCurLevel
|
||||
local nType = self.parent.nRoomType
|
||||
local nStage = self.parent:GetStage(nLevel)
|
||||
EventManager.Hit("OpenBossTime", nStage, nType)
|
||||
end
|
||||
EventManager.Hit("ShowStarTowerCoin", false)
|
||||
self.bFailed = false
|
||||
local nType = self.parent.nRoomType
|
||||
if nType == GameEnum.starTowerRoomType.BossRoom or nType == GameEnum.starTowerRoomType.FinalBossRoom then
|
||||
EventManager.Hit("StartClientRankTimer")
|
||||
end
|
||||
end
|
||||
function BattleRoom:OnLoadLevelRefresh()
|
||||
end
|
||||
function BattleRoom:OnEvent_LevelStateChanged(nState)
|
||||
if self.bFailed then
|
||||
printError("角色已死亡")
|
||||
return
|
||||
end
|
||||
if nState == GameEnum.levelState.Teleporter then
|
||||
if self.mapCases[self.EnumCase.OpenDoor] == nil then
|
||||
printError("无传送门case 无法进入下一层")
|
||||
return
|
||||
end
|
||||
local tbDoorCase = self.mapCases[self.EnumCase.OpenDoor]
|
||||
self.parent:EnterRoom(tbDoorCase[1], tbDoorCase[2])
|
||||
return
|
||||
end
|
||||
if self.mapCases[self.EnumCase.Battle] == nil then
|
||||
printError("无战斗事件需要处理")
|
||||
return
|
||||
end
|
||||
EventManager.Hit("CloseBossTime", nState == GameEnum.levelState.Success)
|
||||
local msg = {}
|
||||
local nEventId = self.mapCases[self.EnumCase.Battle].Id
|
||||
msg.Id = nEventId
|
||||
msg.BattleEndReq = {}
|
||||
local nType = self.parent.nRoomType
|
||||
if nType == GameEnum.starTowerRoomType.BossRoom or nType == GameEnum.starTowerRoomType.FinalBossRoom then
|
||||
EventManager.Hit("ResetClientRankTimer")
|
||||
end
|
||||
if nState == GameEnum.levelState.Success then
|
||||
self.bBattleEnd = true
|
||||
EventManager.Hit("ShowStarTowerRoomInfo", true, self.parent.nTeamLevel, self.parent.nTeamExp, clone(self.parent._mapNote), clone(self.parent._mapFateCard))
|
||||
local nCoin = self.parent._mapItem[AllEnum.CoinItemId.FixedRogCurrency]
|
||||
if nCoin == nil then
|
||||
nCoin = 0
|
||||
end
|
||||
local nBuildScore = self.parent:CalBuildScore()
|
||||
EventManager.Hit("ShowStarTowerCoin", true, nCoin, nBuildScore)
|
||||
local mapCharHpInfo = self.parent.GetActorHp()
|
||||
local nMainChar = self.parent.tbTeam[1]
|
||||
local nHp = -1
|
||||
if mapCharHpInfo[nMainChar] ~= nil then
|
||||
nHp = mapCharHpInfo[nMainChar]
|
||||
end
|
||||
local tbUsage = self.parent:GetFateCardUsage()
|
||||
local clientData, nDataLength = self.parent:CacheTempData()
|
||||
local tbDamage = self.parent:GetDamageRecord()
|
||||
local tbSamples = UTILS.GetBattleSamples()
|
||||
if self.parent.nTotalTime ~= nil then
|
||||
self.parent.nTotalTime = self.parent.nTotalTime + self.nTime
|
||||
end
|
||||
local tbEvent = {}
|
||||
tbEvent = PlayerData.Achievement:GetBattleAchievement(GameEnum.levelType.StarTower, true)
|
||||
msg.BattleEndReq.Victory = {
|
||||
HP = nHp,
|
||||
Time = self.nTime,
|
||||
ClientData = clientData,
|
||||
fateCardUsage = tbUsage,
|
||||
DateLen = nDataLength,
|
||||
Damages = tbDamage,
|
||||
Sample = tbSamples,
|
||||
Events = {List = tbEvent}
|
||||
}
|
||||
local tabUpLevel = {}
|
||||
table.insert(tabUpLevel, {
|
||||
"role_id",
|
||||
tostring(PlayerData.Base._nPlayerId)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"game_cost_time",
|
||||
tostring(self.nTime)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"real_cost_time",
|
||||
tostring(CS.ClientManager.Instance.serverTimeStampWithTimeZone - self._EntryTime)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"tower_id",
|
||||
tostring(self.parent.nTowerId)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"room_floor",
|
||||
tostring(self.parent.nCurLevel)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"room_type",
|
||||
tostring(self.parent.nRoomType)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"action",
|
||||
tostring(2)
|
||||
})
|
||||
NovaAPI.UserEventUpload("star_tower", tabUpLevel)
|
||||
elseif nState == GameEnum.levelState.Failed then
|
||||
self.bFailed = true
|
||||
return
|
||||
end
|
||||
local callback = function(msgData, tbChangeFateCard, mapChangeNote, mapItemChange, nLevelChange, nExpChange)
|
||||
self.nCoinTemp = 0
|
||||
self.mapCases[self.EnumCase.Battle].bFinish = true
|
||||
self.nWaitShowTime = 0
|
||||
self.showFinishCall = nil
|
||||
local setTime = function(nTime, callback)
|
||||
self.nWaitShowTime = nTime
|
||||
self.showFinishCall = callback
|
||||
end
|
||||
EventManager.Hit("ShowBattleReward", nLevelChange, nExpChange, tbChangeFateCard, mapChangeNote, mapItemChange, setTime)
|
||||
self.blockNpcBtn = true
|
||||
local waitCallback = function()
|
||||
if self.showFinishCall ~= nil then
|
||||
self.showFinishCall()
|
||||
self.showFinishCall = nil
|
||||
end
|
||||
self:HandleCases()
|
||||
end
|
||||
if 0 < self.nWaitShowTime then
|
||||
self:AddTimer(1, self.nWaitShowTime, waitCallback, true, true, true, nil)
|
||||
else
|
||||
waitCallback()
|
||||
end
|
||||
end
|
||||
self.parent:StarTowerInteract(msg, callback)
|
||||
end
|
||||
function BattleRoom:OnEvent_MonsterDied()
|
||||
end
|
||||
function BattleRoom:OnEvent_InteractiveNpc(nNpcId, nNpcUid)
|
||||
self:HandleNpc(nNpcId, nNpcUid)
|
||||
end
|
||||
function BattleRoom:OnEvent_GetCoin(num)
|
||||
end
|
||||
function BattleRoom:OnEvent_TimeEnd(nTime)
|
||||
self.nTime = nTime
|
||||
end
|
||||
function BattleRoom:OnEvent_ActorFinishDie()
|
||||
if self.bBattleEnd then
|
||||
EventManager.Hit("AbandonStarTower")
|
||||
else
|
||||
local msg = {}
|
||||
local nEventId = self.mapCases[self.EnumCase.Battle].Id
|
||||
msg.Id = nEventId
|
||||
msg.BattleEndReq = {}
|
||||
msg.BattleEndReq.Defeat = true
|
||||
local callback = function(msgData)
|
||||
self.nCoinTemp = 0
|
||||
self.mapCases[self.EnumCase.Battle].bFinish = true
|
||||
print("遗迹失败")
|
||||
self.parent:StarTowerFailed(msgData.Settle.Change, msgData.Settle.Build, msgData.Settle.TotalTime, msgData.Settle.Reward, msgData.Settle.TowerRewards, msgData.Settle.NpcInteraction)
|
||||
end
|
||||
local ConfirmCallback = function()
|
||||
self.parent:ReBattle()
|
||||
PanelManager.InputEnable()
|
||||
end
|
||||
local CancelCallback = function()
|
||||
self.parent:StarTowerInteract(msg, callback)
|
||||
PanelManager.InputEnable()
|
||||
end
|
||||
if self.parent.bPrologue == true then
|
||||
self.parent:StarTowerInteract(msg, callback)
|
||||
else
|
||||
do
|
||||
local data = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Startower_ReBattleHint"),
|
||||
sContentSub = "",
|
||||
callbackConfirm = ConfirmCallback,
|
||||
callbackCancel = CancelCallback
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, data)
|
||||
PanelManager.InputDisable()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return BattleRoom
|
||||
@@ -0,0 +1,35 @@
|
||||
local BaseRoom = require("Game.Adventure.StarTower.StarTowerRoom.BaseRoom")
|
||||
local EventRoom = class("EventRoom", BaseRoom)
|
||||
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
|
||||
EventRoom._mapEventConfig = {
|
||||
LevelStateChanged = "OnEvent_LevelStateChanged",
|
||||
InteractiveNpc = "OnEvent_InteractiveNpc"
|
||||
}
|
||||
function EventRoom:LevelStart()
|
||||
self:HandleCases()
|
||||
EventManager.Hit("ShowStarTowerRoomInfo", true, self.parent.nTeamLevel, self.parent.nTeamExp, clone(self.parent._mapNote), clone(self.parent._mapFateCard))
|
||||
local nCoin = self.parent._mapItem[AllEnum.CoinItemId.FixedRogCurrency]
|
||||
if nCoin == nil then
|
||||
nCoin = 0
|
||||
end
|
||||
local nBuildScore = self.parent:CalBuildScore()
|
||||
EventManager.Hit("ShowStarTowerCoin", true, nCoin, nBuildScore)
|
||||
EventManager.Hit("PlayStarTowerDiscBgm")
|
||||
end
|
||||
function EventRoom:OnEvent_InteractiveNpc(nNpcId, nNpcUid)
|
||||
self:HandleNpc(nNpcId, nNpcUid)
|
||||
end
|
||||
function EventRoom:OnLoadLevelRefresh()
|
||||
end
|
||||
function EventRoom:OnEvent_LevelStateChanged(nState)
|
||||
if nState == GameEnum.levelState.Teleporter then
|
||||
if self.mapCases[self.EnumCase.OpenDoor] == nil then
|
||||
printError("无传送门case 无法进入下一层")
|
||||
return
|
||||
end
|
||||
local tbDoorCase = self.mapCases[self.EnumCase.OpenDoor]
|
||||
self.parent:EnterRoom(tbDoorCase[1], tbDoorCase[2])
|
||||
return
|
||||
end
|
||||
end
|
||||
return EventRoom
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,404 @@
|
||||
local StoryLevel = class("StoryLevel")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local mapEventConfig = {
|
||||
LevelStateChanged = "OnEvent_SendMsgFinishBattle",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
Mainline_Time_CountUp = "OnEvent_Time",
|
||||
BattlePause = "OnEvnet_Pause",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter"
|
||||
}
|
||||
function StoryLevel:Init(parent, nLevelId, nBuildId)
|
||||
self.bSettle = false
|
||||
self.parent = parent
|
||||
self.nMainLineTime = 0
|
||||
self.nCacheFloorTime = 0
|
||||
self.nLevelId = nLevelId
|
||||
self.curFloorIdx = 1
|
||||
self.mapCharacterTempData = {}
|
||||
local mapStory = ConfigTable.GetData_Story(nLevelId)
|
||||
if mapStory == nil then
|
||||
printError("mapStory is nil,id = " .. nLevelId)
|
||||
return
|
||||
end
|
||||
self.bTrialLevel = mapStory.TrialBuild ~= nil and nBuildId == 0
|
||||
local GetBuildCallback = function(mapBuildData)
|
||||
self.mapBuildData = mapBuildData
|
||||
self.tbCharId, self.tbCharTrialId = {}, {}
|
||||
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, mapChar.nTid)
|
||||
self.tbCharTrialId[mapChar.nTid] = mapChar.nTrialId
|
||||
end
|
||||
self.tbDiscId = {}
|
||||
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
end
|
||||
end
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.Mainline
|
||||
CS.AdventureModuleHelper.EnterMainlineMap(mapStory.FloorId[1], self.tbCharId, {})
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
if self.bTrialLevel then
|
||||
local mapBuildData = PlayerData.Build:GetTrialBuild(mapStory.TrialBuild)
|
||||
GetBuildCallback(mapBuildData)
|
||||
else
|
||||
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
|
||||
end
|
||||
end
|
||||
function StoryLevel:RefreshCharDamageData()
|
||||
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
|
||||
end
|
||||
function StoryLevel:OnEvent_LoadLevelRefresh()
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = {}, {}, {}, {}
|
||||
if self.bTrialLevel then
|
||||
mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetTrialBuildAllEft()
|
||||
else
|
||||
mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
self:ResetCharacter()
|
||||
end
|
||||
function StoryLevel:OnEvent_SendMsgFinishBattle(LevelResult, FadeTime, sVideoName)
|
||||
if self.bSettle == true then
|
||||
print("已在结算流程中!")
|
||||
return
|
||||
end
|
||||
self.bSettle = true
|
||||
print("OnEvent_SendMsgFinishBattle")
|
||||
local fadeT = 0
|
||||
if FadeTime ~= nil then
|
||||
fadeT = FadeTime
|
||||
end
|
||||
if LevelResult == AllEnum.LevelResult.Failed then
|
||||
self:OnEvent_AbandonBattle()
|
||||
return
|
||||
end
|
||||
local mapStory = ConfigTable.GetData_Story(self.nLevelId)
|
||||
if self.curFloorIdx < #mapStory.FloorId then
|
||||
self:ChangeFloor()
|
||||
return
|
||||
end
|
||||
local func_cbFinishSucc = function(mapChangeInfo)
|
||||
self:PlaySuccessPerform(fadeT, mapChangeInfo, sVideoName)
|
||||
end
|
||||
print("====== 当前通关主线关卡ID:" .. self.nLevelId .. " ======")
|
||||
local events = {
|
||||
List = PlayerData.Achievement:GetBattleAchievement(GameEnum.levelType.Mainline, LevelResult ~= AllEnum.LevelResult.Failed)
|
||||
}
|
||||
PlayerData.Avg:SendMsg_STORY_DONE(func_cbFinishSucc, events)
|
||||
end
|
||||
function StoryLevel:OnEvent_AbandonBattle()
|
||||
self:RefreshCharDamageData()
|
||||
if self.nLevelId > 0 then
|
||||
local nMainlineId = self.nLevelId
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, false, 0, {}, {}, {}, 0, false, "", "", nMainlineId, self.tbCharId, {}, self.tbCharDamage)
|
||||
self:UnBindEvent()
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
end
|
||||
function StoryLevel:OnEvent_AdventureModuleEnter()
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.Mainline)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Adventure, self.tbCharId)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local nTrialOrCharId = self.bTrialLevel and self.tbCharTrialId[nCharId] or nCharId
|
||||
local stActorInfo = self:CalCharFixedEffect(nTrialOrCharId, idx == 1, self.tbDiscId, self.bTrialLevel)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function StoryLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function StoryLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function StoryLevel:PlaySuccessPerform(FadeTime, mapChangeInfo, sVideoName)
|
||||
local func_SettlementFinish = function(bSuccess)
|
||||
end
|
||||
local bHasReward = mapChangeInfo and mapChangeInfo.Props and #mapChangeInfo.Props > 0
|
||||
local FirstRewardItems = {}
|
||||
if bHasReward then
|
||||
local tbRewardDisplay = UTILS.DecodeChangeInfo(mapChangeInfo)
|
||||
for _, v in pairs(tbRewardDisplay) do
|
||||
for k, value in pairs(v) do
|
||||
table.insert(FirstRewardItems, {
|
||||
Tid = value.Tid,
|
||||
Qty = value.Qty,
|
||||
rewardType = AllEnum.RewardType.First
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
local tbChar = self.tbCharId
|
||||
self:RefreshCharDamageData()
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
local sLarge, sSmall = "", ""
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, true, 3, {}, FirstRewardItems or {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
|
||||
self.bSettle = false
|
||||
self.parent:LevelEnd()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
local function videoCallback()
|
||||
EventManager.Remove("VIDEO_END", self, videoCallback)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
local nFloorCount = #ConfigTable.GetData_Story(self.nLevelId).FloorId
|
||||
local nMapId = ConfigTable.GetData_Story(self.nLevelId).FloorId[nFloorCount]
|
||||
local nType = ConfigTable.GetData("MainlineFloor", nMapId).Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
end
|
||||
if sVideoName ~= nil and sVideoName ~= "" then
|
||||
EventManager.Add("VIDEO_END", self, videoCallback)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ProVideoGUI, sVideoName, true, 0.5, false, 0, true)
|
||||
else
|
||||
videoCallback()
|
||||
end
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true, FadeTime or 0.5)
|
||||
end
|
||||
function StoryLevel:CalCharFixedEffect(nTrialOrCharId, bMainChar, tbDiscId, bTrialLevel)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
if bTrialLevel then
|
||||
PlayerData.Char:CalCharacterTrialAttrBattle(nTrialOrCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
else
|
||||
PlayerData.Char:CalCharacterAttrBattle(nTrialOrCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
end
|
||||
return stActorInfo
|
||||
end
|
||||
function StoryLevel:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapAddLevel = {}
|
||||
if self.bTrialLevel then
|
||||
if self.tbCharTrialId[nCharId] then
|
||||
mapAddLevel = PlayerData.Talent:GetTrialEnhancedPotential(self.tbCharTrialId[nCharId])
|
||||
else
|
||||
printError("体验build内,有多余角色的潜能" .. nCharId)
|
||||
end
|
||||
else
|
||||
mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
|
||||
end
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function StoryLevel:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo
|
||||
if self.bTrialLevel then
|
||||
discInfo = PlayerData.Disc:CalcTrialInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
else
|
||||
discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
end
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function StoryLevel:OnEvent_Time(nTime)
|
||||
self.nMainLineTime = self.nCacheFloorTime + nTime
|
||||
end
|
||||
function StoryLevel:OnEvnet_Pause()
|
||||
local sAim = ConfigTable.GetData_Story(self.nLevelId).Aim
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.MainBattlePause, self.nMainLineTime or 0, self.mapBuildData.tbChar, sAim)
|
||||
end
|
||||
function StoryLevel:ChangeFloor()
|
||||
self:CacheTempData()
|
||||
local mapStory = ConfigTable.GetData_Story(self.nLevelId)
|
||||
self.curFloorIdx = self.curFloorIdx + 1
|
||||
self.nCacheFloorTime = self.nMainLineTime
|
||||
local function levelUnloadCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local nTrialOrCharId = self.bTrialLevel and self.tbCharTrialId[nCharId] or nCharId
|
||||
local stActorInfo = self:CalCharFixedEffect(nTrialOrCharId, idx == 1, self.tbDiscId, self.bTrialLevel)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
self:SetCharStatus()
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
|
||||
CS.AdventureModuleHelper.EnterMainlineMap(mapStory.FloorId[self.curFloorIdx], self.tbCharId, {})
|
||||
CS.AdventureModuleHelper.LevelStateChanged(false)
|
||||
self.bSettle = false
|
||||
end
|
||||
function StoryLevel:SetCharStatus()
|
||||
local nStatus = 0
|
||||
local nStatusTime = 0
|
||||
local tbActorInfo = {}
|
||||
for _, nTid in pairs(self.tbCharId) do
|
||||
local stCharInfo = CS.Lua2CSharpInfo_ActorStatus()
|
||||
if self.mapCharacterTempData.stateInfo ~= nil and self.mapCharacterTempData.stateInfo[nTid] ~= nil then
|
||||
nStatus = self.mapCharacterTempData.stateInfo[nTid].nState
|
||||
nStatusTime = self.mapCharacterTempData.stateInfo[nTid].nStateTime
|
||||
end
|
||||
stCharInfo.actorID = nTid
|
||||
stCharInfo.status = nStatus
|
||||
stCharInfo.specialStatusTime = nStatusTime
|
||||
table.insert(tbActorInfo, stCharInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorStatus, tbActorInfo)
|
||||
end
|
||||
function StoryLevel:ResetCharacter()
|
||||
if self.mapCharacterTempData.hpInfo ~= nil then
|
||||
local tbActorInfo = {}
|
||||
for nTid, nHp in pairs(self.mapCharacterTempData.hpInfo) do
|
||||
local stCharInfo = CS.Lua2CSharpInfo_ActorAttribute()
|
||||
stCharInfo.actorID = nTid
|
||||
stCharInfo.curHP = nHp
|
||||
table.insert(tbActorInfo, stCharInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorAttributes, tbActorInfo)
|
||||
end
|
||||
if self.mapCharacterTempData.skillInfo ~= nil then
|
||||
local tbSkillInfos = {}
|
||||
for _, skillInfo in ipairs(self.mapCharacterTempData.skillInfo) do
|
||||
local stSkillInfo = CS.Lua2CSharpInfo_ResetSkillInfo()
|
||||
stSkillInfo.skillId = skillInfo.nSkillId
|
||||
stSkillInfo.currentSectionAmount = skillInfo.nSectionAmount
|
||||
stSkillInfo.cd = skillInfo.nCd
|
||||
stSkillInfo.currentResumeTime = skillInfo.nSectionResumeTime
|
||||
stSkillInfo.currentUseTimeHint = skillInfo.nUseTimeHint
|
||||
stSkillInfo.energy = skillInfo.nEnergy
|
||||
if tbSkillInfos[skillInfo.nCharId] == nil then
|
||||
tbSkillInfos[skillInfo.nCharId] = {}
|
||||
end
|
||||
table.insert(tbSkillInfos[skillInfo.nCharId], stSkillInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorSkillInfo, tbSkillInfos)
|
||||
end
|
||||
if self.mapCharacterTempData.buffInfo ~= nil then
|
||||
local tbBuffinfo = {}
|
||||
for nCharId, mapBuff in pairs(self.mapCharacterTempData.buffInfo) do
|
||||
if mapBuff.mapBuff ~= nil then
|
||||
for _, mapBuffInfo in pairs(mapBuff.mapBuff) do
|
||||
local stBuffInfo = CS.Lua2CSharpInfo_ResetBuffInfo()
|
||||
stBuffInfo.Id = mapBuffInfo.Id
|
||||
stBuffInfo.Cd = mapBuffInfo.CD
|
||||
stBuffInfo.buffNum = mapBuffInfo.nNum
|
||||
if tbBuffinfo[nCharId] == nil then
|
||||
tbBuffinfo[nCharId] = {}
|
||||
end
|
||||
table.insert(tbBuffinfo[nCharId], stBuffInfo)
|
||||
end
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ResetBuff, tbBuffinfo)
|
||||
end
|
||||
end
|
||||
function StoryLevel:CacheTempData()
|
||||
local FP = CS.TrueSync.FP
|
||||
self.mapCharacterTempData = {}
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local id = AdventureModuleHelper.GetCurrentActivePlayer()
|
||||
self.mapCharacterTempData.curCharId = CS.AdventureModuleHelper.GetCharacterId(id)
|
||||
self.mapCharacterTempData.skillInfo = {}
|
||||
self.mapCharacterTempData.effectInfo = {}
|
||||
self.mapCharacterTempData.buffInfo = {}
|
||||
self.mapCharacterTempData.hpInfo = {}
|
||||
self.mapCharacterTempData.stateInfo = {}
|
||||
local playerids = AdventureModuleHelper.GetCurrentGroupPlayers()
|
||||
local Count = playerids.Count - 1
|
||||
for i = 0, Count do
|
||||
local charTid = AdventureModuleHelper.GetCharacterId(playerids[i])
|
||||
local clsSkillId = AdventureModuleHelper.GetPlayerSkillCd(playerids[i])
|
||||
local nStatus = AdventureModuleHelper.GetPlayerActorStatus(playerids[i])
|
||||
local nStatusTime = AdventureModuleHelper.GetPlayerActorSpecialStatusTime(playerids[i])
|
||||
self.mapCharacterTempData.hpInfo[charTid] = AdventureModuleHelper.GetEntityHp(playerids[i])
|
||||
if clsSkillId ~= nil then
|
||||
local tbSkillInfos = clsSkillId.skillInfos
|
||||
local nSkillCount = tbSkillInfos.Count - 1
|
||||
for j = 0, nSkillCount do
|
||||
local clsSkillInfo = tbSkillInfos[j]
|
||||
local mapSkill = ConfigTable.GetData_Skill(clsSkillInfo.skillId)
|
||||
if mapSkill.Type == GameEnum.skillType.ULTIMATE then
|
||||
table.insert(self.mapCharacterTempData.skillInfo, {
|
||||
nCharId = charTid,
|
||||
nSkillId = clsSkillInfo.skillId,
|
||||
nCd = clsSkillInfo.currentUseInterval.RawValue,
|
||||
nSectionAmount = clsSkillInfo.currentSectionAmount,
|
||||
nSectionResumeTime = clsSkillInfo.currentResumeTime.RawValue,
|
||||
nUseTimeHint = clsSkillInfo.currentUseTimeHint.RawValue,
|
||||
nEnergy = clsSkillInfo.currentEnergy.RawValue
|
||||
})
|
||||
end
|
||||
end
|
||||
self.mapCharacterTempData.effectInfo[charTid] = {
|
||||
mapEffect = {}
|
||||
}
|
||||
local tbClsEfts = AdventureModuleHelper.GetEffectList(playerids[i])
|
||||
if tbClsEfts ~= nil then
|
||||
local nEftCount = tbClsEfts.Count - 1
|
||||
for k = 0, nEftCount do
|
||||
local eftInfo = tbClsEfts[k]
|
||||
local mapEft = ConfigTable.GetData_Effect(eftInfo.effectConfig.Id)
|
||||
local nCd = eftInfo.CD.RawValue
|
||||
if mapEft.Remove and 0 < nCd then
|
||||
self.mapCharacterTempData.effectInfo[charTid].mapEffect[eftInfo.effectConfig.Id] = {nCount = 0, nCd = nCd}
|
||||
end
|
||||
end
|
||||
end
|
||||
local tbBuffInfo = AdventureModuleHelper.GetEntityBuffList(playerids[i])
|
||||
self.mapCharacterTempData.buffInfo[charTid] = {
|
||||
mapBuff = {}
|
||||
}
|
||||
if tbBuffInfo ~= nil then
|
||||
local nBuffCount = tbBuffInfo.Count - 1
|
||||
for l = 0, nBuffCount do
|
||||
local eftInfo = tbBuffInfo[l]
|
||||
local mapBuff = ConfigTable.GetData_Buff(eftInfo.buffConfig.Id)
|
||||
if mapBuff.NotRemove then
|
||||
table.insert(self.mapCharacterTempData.buffInfo[charTid].mapBuff, {
|
||||
Id = eftInfo.buffConfig.Id,
|
||||
CD = eftInfo:GetBuffLeftTime().RawValue,
|
||||
nNum = eftInfo:GetBuffNum()
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
self.mapCharacterTempData.stateInfo[charTid] = {nState = nStatus, nStateTime = nStatusTime}
|
||||
end
|
||||
end
|
||||
return StoryLevel
|
||||
@@ -0,0 +1,254 @@
|
||||
local TravelerDuelLevelData = class("TravelerDuelLevelData")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
TravelerDuel_Result = "OnEvent_LevelResult",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
BattlePause = "OnEvnet_Pause",
|
||||
Upload_Dodge_Event = "OnEvent_UploadDodgeEvent"
|
||||
}
|
||||
function TravelerDuelLevelData:Init(parent, nLevel, tbAffixes, nBuildId)
|
||||
self._EntryTime = CS.ClientManager.Instance.serverTimeStampWithTimeZone
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
local sKey = LocalData.GetPlayerLocalData("TravelerDuelRecordKey")
|
||||
if sKey ~= nil or sKey ~= "" then
|
||||
NovaAPI.DeleteRecFile(sKey)
|
||||
end
|
||||
self.bEnd = false
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
sKey = tostring(ClientManager.serverTimeStamp)
|
||||
LocalData.SetPlayerLocalData("TravelerDuelRecordKey", sKey)
|
||||
self.parent = parent
|
||||
self.nlevelId = nLevel
|
||||
self.tmpBuildId = nBuildId
|
||||
self.tbAffixes = tbAffixes
|
||||
local mapCfg = ConfigTable.GetData("TravelerDuelBossLevel", nLevel)
|
||||
if mapCfg then
|
||||
self.nTime = mapCfg.Timelimit
|
||||
end
|
||||
local GetDataCallback = function(mapBuildData)
|
||||
local mapLevel = ConfigTable.GetData("TravelerDuelBossLevel", nLevel)
|
||||
if mapLevel == nil then
|
||||
printError("TravelerDuelBossLevel missing:" .. nLevel)
|
||||
return
|
||||
end
|
||||
self.mapBuildData = mapBuildData
|
||||
self.tbCharId = {}
|
||||
for i, v in pairs(mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, v.nTid)
|
||||
end
|
||||
self.tbDiscId = {}
|
||||
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
end
|
||||
end
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.TravelerDuel
|
||||
CS.AdventureModuleHelper.EnterTravelerDuel(nLevel, mapLevel.FloorId, self.tbCharId, tbAffixes)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDamageRecordId, sKey)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
PlayerData.Build:GetBuildDetailData(GetDataCallback, nBuildId)
|
||||
end
|
||||
function TravelerDuelLevelData:RefreshCharDamageData()
|
||||
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
|
||||
end
|
||||
function TravelerDuelLevelData:OnEvent_LoadLevelRefresh()
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
end
|
||||
function TravelerDuelLevelData:OnEvent_LevelResult(bSuccess, nTime)
|
||||
if self.bEnd then
|
||||
return
|
||||
end
|
||||
self.bEnd = true
|
||||
self:RefreshCharDamageData()
|
||||
local msgCallback = function(mapMsgData)
|
||||
self._EndTime = CS.ClientManager.Instance.serverTimeStampWithTimeZone
|
||||
local tabUpLevel = {}
|
||||
local nResult = bSuccess and "1" or "2"
|
||||
table.insert(tabUpLevel, {
|
||||
"role_id",
|
||||
tostring(PlayerData.Base._nPlayerId)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"game_cost_time",
|
||||
tostring(nTime)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"real_cost_time",
|
||||
tostring(self._EndTime - self._EntryTime)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"build_id",
|
||||
tostring(self.mapBuildData.nBuildId)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"battle_id",
|
||||
tostring(self.nlevelId)
|
||||
})
|
||||
table.insert(tabUpLevel, {
|
||||
"battle_result",
|
||||
tostring(nResult)
|
||||
})
|
||||
NovaAPI.UserEventUpload("traveler_duel_battle", tabUpLevel)
|
||||
if bSuccess then
|
||||
self:PlaySuccessPerform(mapMsgData, 3, nTime)
|
||||
else
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TDBattleResultPanel, false, {
|
||||
false,
|
||||
false,
|
||||
false
|
||||
}, mapMsgData.AwardItems, mapMsgData.FirstItems, {}, 0, false, nTime, self.nlevelId, self.tbCharId, self.tbAffixes, mapMsgData.TimeScore, mapMsgData.BaseScore, mapMsgData.FinalScore, mapMsgData.FinalScore > mapMsgData.MaxScore, mapMsgData.Change, mapMsgData.SurpriseItems, mapMsgData.CustomItems, self.tbCharDamage)
|
||||
self.parent:LevelEnd()
|
||||
end
|
||||
end
|
||||
local nStar = 0
|
||||
if bSuccess then
|
||||
nStar = 3
|
||||
end
|
||||
local wait = function()
|
||||
self.parent:SendMsg_TravelerDuelSettle(nStar, self.nlevelId, nTime, msgCallback)
|
||||
end
|
||||
if bSuccess then
|
||||
TimerManager.Add(1, 2, self, wait, true, true, nil, nil)
|
||||
else
|
||||
wait()
|
||||
end
|
||||
end
|
||||
function TravelerDuelLevelData:OnEvent_AbandonBattle()
|
||||
self:OnEvent_LevelResult(false, 0)
|
||||
end
|
||||
function TravelerDuelLevelData:OnEvent_AdventureModuleEnter()
|
||||
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.TravelerDuel)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TDBattlePanel, self.tbCharId)
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function TravelerDuelLevelData:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function TravelerDuelLevelData:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function TravelerDuelLevelData:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function TravelerDuelLevelData:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function TravelerDuelLevelData:PlaySuccessPerform(mapMsgData, nStar, nTime)
|
||||
local func_OpenResult = function(bSuccess)
|
||||
end
|
||||
local tbChar = self.tbCharId
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local nFloorId = ConfigTable.GetData("TravelerDuelBossLevel", self.nlevelId).FloorId
|
||||
local nType = ConfigTable.GetData("TravelerDuelFloor", nFloorId).Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
local jumpPerform = function()
|
||||
NovaAPI.DispatchEventWithData("SKIP_SETTLEMENT_PERFORM")
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BtnTips, jumpPerform)
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_OpenResult)
|
||||
end
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TDBattleResultPanel, true, {
|
||||
true,
|
||||
true,
|
||||
true
|
||||
}, mapMsgData.AwardItems, mapMsgData.FirstItems, {}, 0, false, nTime, self.nlevelId, self.tbCharId, self.tbAffixes, mapMsgData.TimeScore, mapMsgData.BaseScore, mapMsgData.FinalScore, mapMsgData.FinalScore > mapMsgData.MaxScore, mapMsgData.Change, mapMsgData.SurpriseItems, mapMsgData.CustomItems, self.tbCharDamage)
|
||||
self.bSettle = false
|
||||
self.parent:LevelEnd()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
end
|
||||
function TravelerDuelLevelData:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
|
||||
return stActorInfo
|
||||
end
|
||||
function TravelerDuelLevelData:OnEvnet_Pause()
|
||||
EventManager.Hit("OpenTDPause", self.nlevelId, self.tbCharId)
|
||||
end
|
||||
function TravelerDuelLevelData:OnEvent_UploadDodgeEvent(padMode)
|
||||
local tab = {}
|
||||
table.insert(tab, {
|
||||
"role_id",
|
||||
tostring(PlayerData.Base._nPlayerId)
|
||||
})
|
||||
table.insert(tab, {"pad_mode", padMode})
|
||||
table.insert(tab, {
|
||||
"level_type",
|
||||
"TravelerDuel"
|
||||
})
|
||||
table.insert(tab, {
|
||||
"build_id",
|
||||
tostring(self.tmpBuildId)
|
||||
})
|
||||
table.insert(tab, {
|
||||
"level_id",
|
||||
tostring(self.nlevelId)
|
||||
})
|
||||
table.insert(tab, {
|
||||
"up_time",
|
||||
tostring(CS.ClientManager.Instance.serverTimeStamp)
|
||||
})
|
||||
NovaAPI.UserEventUpload("use_dodge_key", tab)
|
||||
end
|
||||
return TravelerDuelLevelData
|
||||
@@ -0,0 +1,243 @@
|
||||
local TrialLevel = class("TrialLevel")
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local mapEventConfig = {
|
||||
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
|
||||
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
|
||||
TrialGameEnd = "OnEvent_LevelResult",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
BattlePause = "OnEvent_Pause",
|
||||
TrialDepot = "OnEvent_Depot",
|
||||
TaskLevel_InitTask = "OnEvent_InitQuest",
|
||||
Trial_QuestComplete = "OnEvent_QuestComplete",
|
||||
Trial_Time = "OnEvent_Time"
|
||||
}
|
||||
function TrialLevel:Init(parent, nLevelId)
|
||||
self.parent = parent
|
||||
self.nLevelId = nLevelId
|
||||
self.mapChangeInfo = {}
|
||||
self.mapLevelCfg = ConfigTable.GetData("TrialFloor", nLevelId)
|
||||
if not self.mapLevelCfg then
|
||||
return
|
||||
end
|
||||
self.mapBuildData = PlayerData.Build:GetTrialBuild(self.mapLevelCfg.TrialBuild)
|
||||
self.tbCharId, self.tbCharTrialId, self.mapCharData, self.mapTalentAddLevel = {}, {}, {}, {}
|
||||
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
|
||||
table.insert(self.tbCharId, mapChar.nTid)
|
||||
self.tbCharTrialId[mapChar.nTid] = mapChar.nTrialId
|
||||
self.mapCharData[mapChar.nTid] = PlayerData.Char:GetTrialCharById(mapChar.nTrialId)
|
||||
self.mapTalentAddLevel[mapChar.nTid] = PlayerData.Talent:GetTrialEnhancedPotential(mapChar.nTrialId)
|
||||
end
|
||||
self.tbDiscId, self.mapDiscData = {}, {}
|
||||
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if 0 < nDiscId then
|
||||
table.insert(self.tbDiscId, nDiscId)
|
||||
local mapCfg = ConfigTable.GetData("TrialDisc", nDiscId)
|
||||
if mapCfg then
|
||||
self.mapDiscData[mapCfg.DiscId] = PlayerData.Disc:GetTrialDiscById(nDiscId)
|
||||
end
|
||||
end
|
||||
end
|
||||
self:ParseDepotData()
|
||||
self.mapActorInfo = {}
|
||||
for idx, nTid in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(self.tbCharTrialId[nTid], idx == 1, self.tbDiscId)
|
||||
self.mapActorInfo[nTid] = stActorInfo
|
||||
end
|
||||
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.Trial
|
||||
local params = NovaAPI.GetDynamicLevelParamsBootConfig()
|
||||
CS.AdventureModuleHelper.EnterDynamic(nLevelId, self.tbCharId, GameEnum.dynamicLevelType.Trial, params)
|
||||
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
|
||||
end
|
||||
function TrialLevel:ParseDepotData()
|
||||
self.tbDepotPotential = {}
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
if self.tbCharTrialId[nCharId] then
|
||||
if not self.tbDepotPotential[nCharId] then
|
||||
self.tbDepotPotential[nCharId] = {}
|
||||
end
|
||||
for _, v in ipairs(tbPerk) do
|
||||
self.tbDepotPotential[nCharId][v.nPotentialId] = v.nLevel
|
||||
end
|
||||
else
|
||||
printError("体验build内,有多余角色的潜能" .. nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function TrialLevel:OnEvent_LoadLevelRefresh()
|
||||
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetTrialBuildAllEft()
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
|
||||
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
|
||||
EventManager.Hit("OpenTrialInfo", self.nQuestId)
|
||||
end
|
||||
function TrialLevel:RefreshCharDamageData()
|
||||
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
|
||||
end
|
||||
function TrialLevel:OnEvent_LevelResult(nLevelTime)
|
||||
self:RefreshCharDamageData()
|
||||
local bReceived = PlayerData.Trial:CheckGroupReceived()
|
||||
local bAbandon = not bReceived
|
||||
EventManager.Hit("TrialBattleEnd")
|
||||
if self.parent:GetSettlementState() then
|
||||
printError("试玩关结算流程重复进入,本次退出")
|
||||
return
|
||||
end
|
||||
self.parent:SetSettlementState(true)
|
||||
if bAbandon then
|
||||
EventManager.Hit("TrialLevelEnd", self.nLevelId)
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TrialResult, false, nLevelTime or 0, self.tbCharId, self.parent.nActId, {}, self.tbCharDamage)
|
||||
self.parent:LevelEnd()
|
||||
return
|
||||
end
|
||||
EventManager.Hit("TrialLevelEnd", self.nLevelId)
|
||||
self:PlaySuccessPerform(nLevelTime)
|
||||
end
|
||||
function TrialLevel:OnEvent_AbandonBattle()
|
||||
self:OnEvent_LevelResult(self.nLevelTime)
|
||||
end
|
||||
function TrialLevel:OnEvent_AdventureModuleEnter()
|
||||
self:SetPersonalPerk()
|
||||
self:SetDiscInfo()
|
||||
for idx, nCharId in ipairs(self.tbCharId) do
|
||||
local stActorInfo = self:CalCharFixedEffect(self.tbCharTrialId[nCharId], idx == 1, self.tbDiscId)
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
local tbDisc = {}
|
||||
for _, v in ipairs(self.tbDiscId) do
|
||||
local mapCfg = ConfigTable.GetData("TrialDisc", v)
|
||||
if mapCfg then
|
||||
table.insert(tbDisc, mapCfg.DiscId)
|
||||
end
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TrialBattlePanel, self.tbCharId, tbDisc, self.mapCharData, self.mapDiscData, self.mapTalentAddLevel)
|
||||
end
|
||||
function TrialLevel:BindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Add(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function TrialLevel:UnBindEvent()
|
||||
if type(mapEventConfig) ~= "table" then
|
||||
return
|
||||
end
|
||||
for nEventId, sCallbackName in pairs(mapEventConfig) do
|
||||
local callback = self[sCallbackName]
|
||||
if type(callback) == "function" then
|
||||
EventManager.Remove(nEventId, self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function TrialLevel:PlaySuccessPerform(nLevelTime)
|
||||
local func_SettlementFinish = function(bSuccess)
|
||||
end
|
||||
local tbChar = self.tbCharId
|
||||
local function levelEndCallback()
|
||||
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local nType = self.mapLevelCfg.Theme
|
||||
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
|
||||
local tbSkin = {}
|
||||
for _, nCharId in ipairs(tbChar) do
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
table.insert(tbSkin, nSkinId)
|
||||
end
|
||||
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
|
||||
end
|
||||
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
|
||||
local function openBattleResultPanel()
|
||||
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TrialResult, true, nLevelTime or 0, self.tbCharId, self.parent.nActId, self.mapChangeInfo, self.tbCharDamage)
|
||||
self.bSettle = false
|
||||
self.parent:LevelEnd()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
|
||||
CS.AdventureModuleHelper.LevelStateChanged(true)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
|
||||
end
|
||||
function TrialLevel:SetCharFixedAttribute()
|
||||
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
|
||||
end
|
||||
end
|
||||
function TrialLevel:CalCharFixedEffect(nTrialId, bMainChar, tbDiscId)
|
||||
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
|
||||
PlayerData.Char:CalCharacterTrialAttrBattle(nTrialId, stActorInfo, bMainChar, tbDiscId, self.mapLevelCfg.TrialBuild)
|
||||
return stActorInfo
|
||||
end
|
||||
function TrialLevel:SetPersonalPerk()
|
||||
if self.mapBuildData ~= nil then
|
||||
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
|
||||
local mapTalentAddLevel = {}
|
||||
if self.tbCharTrialId[nCharId] then
|
||||
mapTalentAddLevel = PlayerData.Talent:GetTrialEnhancedPotential(self.tbCharTrialId[nCharId])
|
||||
else
|
||||
printError("体验build内,有多余角色的潜能" .. nCharId)
|
||||
end
|
||||
local tbPerkInfo = {}
|
||||
for _, mapPerkInfo in ipairs(tbPerk) do
|
||||
local nAddLv = mapTalentAddLevel[mapPerkInfo.nPotentialId] or 0
|
||||
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
|
||||
stPerkInfo.perkId = mapPerkInfo.nPotentialId
|
||||
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
|
||||
table.insert(tbPerkInfo, stPerkInfo)
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function TrialLevel:SetDiscInfo()
|
||||
local tbDiscInfo = {}
|
||||
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
|
||||
if k <= 3 then
|
||||
local discInfo = PlayerData.Disc:CalcTrialInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
|
||||
table.insert(tbDiscInfo, discInfo)
|
||||
end
|
||||
end
|
||||
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
|
||||
end
|
||||
function TrialLevel:OnEvent_InitQuest(nQuestId)
|
||||
self.nQuestId = nQuestId
|
||||
end
|
||||
function TrialLevel:OnEvent_QuestComplete()
|
||||
local bReceived = PlayerData.Trial:CheckGroupReceived()
|
||||
if not bReceived then
|
||||
PanelManager.InputDisable()
|
||||
local callback = function(mapChangeInfo)
|
||||
PanelManager.InputEnable()
|
||||
self.mapChangeInfo = mapChangeInfo or {}
|
||||
end
|
||||
self.parent:SendReceiveTrialRewardReq(callback)
|
||||
end
|
||||
self:ShowTeleportIndicator()
|
||||
end
|
||||
function TrialLevel:ShowTeleportIndicator()
|
||||
local tbTeleports = CS.AdventureModuleHelper.GetLevelTeleporters()
|
||||
if tbTeleports ~= nil then
|
||||
for i = 0, tbTeleports.Count - 1 do
|
||||
EventManager.Hit("SetIndicator", 2, tbTeleports[i], Vector3.zero, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
function TrialLevel:OnEvent_Time(nTime)
|
||||
self.nLevelTime = nTime
|
||||
end
|
||||
function TrialLevel:OnEvent_Pause()
|
||||
EventManager.Hit("OpenTrialPause", self.tbCharId, self.mapCharData, self.mapLevelCfg.TrialChar)
|
||||
end
|
||||
function TrialLevel:OnEvent_Depot()
|
||||
local tbDisc = {}
|
||||
for _, v in ipairs(self.tbDiscId) do
|
||||
local mapCfg = ConfigTable.GetData("TrialDisc", v)
|
||||
if mapCfg then
|
||||
table.insert(tbDisc, mapCfg.DiscId)
|
||||
end
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TrialDepot, self.tbCharId, tbDisc, self.mapCharData, self.mapDiscData, self.mapTalentAddLevel, self.tbDepotPotential, self.mapBuildData.tbNotes, true)
|
||||
end
|
||||
return TrialLevel
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
local ResourceLoader = CS.ResourceLoader
|
||||
local GameResourceLoader = {}
|
||||
GameResourceLoader.ResType = CS.GameResourceLoader.ResourceType
|
||||
GameResourceLoader.RootPath = "Assets/AssetBundles/"
|
||||
local tbCachedBundleGroup = {}
|
||||
GameResourceLoader.LoadAssets = CS.GameResourceLoader.LoadAssets
|
||||
GameResourceLoader.LoadAssetsAsync = CS.GameResourceLoader.LoadAssetsAsync
|
||||
GameResourceLoader.LoadSubAsset = CS.GameResourceLoader.LoadSubAsset
|
||||
GameResourceLoader.LoadSubAssetAsync = CS.GameResourceLoader.LoadSubAssetAsync
|
||||
GameResourceLoader.LoadSubAssets = CS.GameResourceLoader.LoadSubAssets
|
||||
GameResourceLoader.LoadSubAssetsAsync = CS.GameResourceLoader.LoadSubAssetsAsync
|
||||
GameResourceLoader.LoadAllSubAssets = CS.GameResourceLoader.LoadAllSubAssets
|
||||
GameResourceLoader.LoadAllSubAssetsAsync = CS.GameResourceLoader.LoadAllSubAssetsAsync
|
||||
GameResourceLoader.LoadAssetBundle = CS.GameResourceLoader.LoadAssetBundle
|
||||
GameResourceLoader.Unload = CS.GameResourceLoader.Unload
|
||||
function GameResourceLoader.LoadAsset(resourceType, path, type, bundleGroup, panelId)
|
||||
local res = CS.GameResourceLoader.LoadAsset(resourceType, path, type, GameResourceLoader.MakeBundleGroup(bundleGroup, panelId))
|
||||
if res ~= nil then
|
||||
return res
|
||||
else
|
||||
printError("load resource failed: " .. path)
|
||||
return nil
|
||||
end
|
||||
end
|
||||
function GameResourceLoader.LoadAssetAsync(resourceType, path, type, bundleGroup, panelId, callBack)
|
||||
CS.GameResourceLoader.LoadAssetAsync(resourceType, path, type, callBack, GameResourceLoader.MakeBundleGroup(bundleGroup, panelId))
|
||||
end
|
||||
function GameResourceLoader.UnloadAsset(nPanelId)
|
||||
if tbCachedBundleGroup[nPanelId] ~= nil then
|
||||
if PanelManager.CheckPanelOpen(nPanelId) == true then
|
||||
return
|
||||
end
|
||||
local _clonedBundleGroup = tbCachedBundleGroup[nPanelId].clonedBundleGroup
|
||||
GameResourceLoader.Unload(_clonedBundleGroup)
|
||||
_clonedBundleGroup = nil
|
||||
tbCachedBundleGroup[nPanelId] = nil
|
||||
end
|
||||
end
|
||||
function GameResourceLoader.ExistsAsset(path)
|
||||
return CS.GameResourceLoader.ExistsAsset(path)
|
||||
end
|
||||
function GameResourceLoader.MakeBundleGroup(sGroupName, nPanelId)
|
||||
local _clonedBundleGroup
|
||||
if sGroupName ~= nil and nPanelId ~= nil and 0 < nPanelId then
|
||||
if tbCachedBundleGroup[nPanelId] == nil then
|
||||
_clonedBundleGroup = CS.GameResourceLoader.CloneBundleGroup(sGroupName)
|
||||
tbCachedBundleGroup[nPanelId] = {clonedBundleGroup = _clonedBundleGroup}
|
||||
else
|
||||
_clonedBundleGroup = tbCachedBundleGroup[nPanelId].clonedBundleGroup
|
||||
end
|
||||
end
|
||||
return _clonedBundleGroup
|
||||
end
|
||||
return GameResourceLoader
|
||||
@@ -0,0 +1,344 @@
|
||||
local JumpUtil = {}
|
||||
function JumpUtil.JumpTo(jumpId, ...)
|
||||
if jumpId == nil then
|
||||
return
|
||||
end
|
||||
local unLock, mapJumpTo = JumpUtil.CheckJumpUnLock(jumpId, true)
|
||||
if not unLock then
|
||||
return
|
||||
end
|
||||
if mapJumpTo == nil then
|
||||
printError("未配置此跳转Id, JumpId: " .. jumpId)
|
||||
return
|
||||
end
|
||||
PanelManager.CloseAllDisposablePanel()
|
||||
local nType = mapJumpTo.Type
|
||||
EventManager.Hit(EventId.JumpToSuccess, nType)
|
||||
if nType == GameEnum.jumpType.Mainline then
|
||||
local nMainlineId = mapJumpTo.Param[1]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.MainlineEx, nMainlineId)
|
||||
elseif nType == GameEnum.jumpType.Rogue then
|
||||
printError("不再支持老遗迹跳转")
|
||||
elseif nType == GameEnum.jumpType.RogueGroup then
|
||||
printError("不再支持老遗迹跳转")
|
||||
elseif nType == GameEnum.jumpType.RoguePanel then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.RoguelikeLevel, 0, 0, true)
|
||||
elseif nType == GameEnum.jumpType.RegionBoss then
|
||||
local nRegionBossGroupId = mapJumpTo.Param[1]
|
||||
local nHard = mapJumpTo.Param[2]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.RogueBossLevel, nHard, nRegionBossGroupId, true)
|
||||
elseif nType == GameEnum.jumpType.RegionBossGroup then
|
||||
local nRegionBossGroupId = mapJumpTo.Param[1]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.RogueBossLevel, 0, nRegionBossGroupId, true)
|
||||
elseif nType == GameEnum.jumpType.RegionBossPanel then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.RogueBossLevel, 0, 0, true)
|
||||
elseif nType == GameEnum.jumpType.Map then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.LevelMenu)
|
||||
elseif nType == GameEnum.jumpType.Shop then
|
||||
local nTabIndex = mapJumpTo.Param[1]
|
||||
local func = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ShopPanel, nTabIndex)
|
||||
end
|
||||
EventManager.Hit(EventId.SetTransition, 5, func)
|
||||
elseif nType == GameEnum.jumpType.Mall then
|
||||
local nTabIndex1 = mapJumpTo.Param[1]
|
||||
local nTabIndex2 = mapJumpTo.Param[2]
|
||||
if PanelManager.CheckPanelOpen(PanelId.Mall) then
|
||||
EventManager.Hit("OpenMallTog", nTabIndex1)
|
||||
elseif PanelManager.CheckPanelOpen(PanelId.MallPopup) then
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.MallPopup)
|
||||
EventManager.Hit("OpenMallTog", nTabIndex1)
|
||||
else
|
||||
do
|
||||
local nState = ConfigTable.GetConfigNumber("IsShowComBtn")
|
||||
if nState == 1 then
|
||||
local func = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Mall, nTabIndex1, nTabIndex2)
|
||||
end
|
||||
EventManager.Hit(EventId.SetTransition, 5, func)
|
||||
else
|
||||
local sContent = ConfigTable.GetUIText("Function_NotAvailable")
|
||||
EventManager.Hit(EventId.OpenMessageBox, sContent)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif nType == GameEnum.jumpType.Gacha then
|
||||
local nPoolId = mapJumpTo.Param[1]
|
||||
local getInfoCallback = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.GachaSpin, nPoolId)
|
||||
end
|
||||
PlayerData.Gacha:GetGachaInfomation(getInfoCallback)
|
||||
elseif nType == GameEnum.jumpType.DailyInstanceLevel then
|
||||
local nHard = mapJumpTo.Param[1]
|
||||
local nDailyType = mapJumpTo.Param[2]
|
||||
if nDailyType == nil or nDailyType == 0 then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.LevelMenu, 3)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DailyInstanceLevelSelect, nHard, nDailyType, true)
|
||||
end
|
||||
elseif nType == GameEnum.jumpType.TravelerDuelLevel then
|
||||
local func = function()
|
||||
local nHard = mapJumpTo.Param[1]
|
||||
local nBossId = mapJumpTo.Param[2]
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TravelerDuelLevelSelect, nHard, nBossId, true)
|
||||
end
|
||||
PlayerData.TravelerDuel:GetTravelerDuelData(callback)
|
||||
end
|
||||
EventManager.Hit(EventId.SetTransition, 4, func)
|
||||
elseif nType == GameEnum.jumpType.Depot then
|
||||
local nItemMark = mapJumpTo.Param[1]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DepotPanel, nItemMark)
|
||||
elseif nType == GameEnum.jumpType.CharacterList then
|
||||
PlayerData.Char:TempClearCharInfoData()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharList)
|
||||
elseif nType == GameEnum.jumpType.Crafting then
|
||||
local nProductionId = mapJumpTo.Param[1]
|
||||
if PanelManager.CheckPanelOpen(PanelId.CraftingTip) then
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.1)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForSeconds(0.1))
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CraftingTip, nProductionId)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
EventManager.Hit("CloseCraftingTipPanel", callback)
|
||||
elseif PanelManager.CheckPanelOpen(PanelId.Crafting) then
|
||||
EventManager.Hit("JumpToProduction", nProductionId)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CraftingTip, nProductionId)
|
||||
end
|
||||
elseif nType == GameEnum.jumpType.StarTower then
|
||||
local bState = PlayerData.State:CheckStarTowerState()
|
||||
if bState then
|
||||
return
|
||||
end
|
||||
local nStarTowerId = mapJumpTo.Param[1]
|
||||
local mapStarTower = ConfigTable.GetData("StarTower", nStarTowerId)
|
||||
if mapStarTower == nil then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.StarTowerLevelSelect, mapStarTower.Difficulty, mapStarTower.GroupId, true)
|
||||
elseif nType == GameEnum.jumpType.StarTowerGroup then
|
||||
local bState = PlayerData.State:CheckStarTowerState()
|
||||
if bState then
|
||||
return
|
||||
end
|
||||
local nStarTowerGroupId = mapJumpTo.Param[1]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.StarTowerLevelSelect, 0, nStarTowerGroupId, true)
|
||||
elseif nType == GameEnum.jumpType.StarTowerPanel then
|
||||
local bState = PlayerData.State:CheckStarTowerState()
|
||||
if bState then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.LevelMenu, 2)
|
||||
elseif nType == GameEnum.jumpType.Disc then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DiscList)
|
||||
elseif nType == GameEnum.jumpType.EquipmentPanel then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentInstanceLevelSelect)
|
||||
elseif nType == GameEnum.jumpType.EquipmentGroup then
|
||||
local nGroup = mapJumpTo.Param[1]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentInstanceLevelSelect, 0, nGroup, true)
|
||||
elseif nType == GameEnum.jumpType.MainlineStory then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.StoryChapter)
|
||||
elseif nType == GameEnum.jumpType.InfinityTower then
|
||||
CS.WwiseAudioManager.Instance:PlaySound("ui_level_select")
|
||||
local func = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.InfinityTowerSelectTower)
|
||||
end
|
||||
EventManager.Hit(EventId.SetTransition, 8, func)
|
||||
elseif nType == GameEnum.jumpType.InfinityTowerGroup then
|
||||
local nStarTowerId = mapJumpTo.Param[1]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.InfinityTowerSelectTower, nStarTowerId)
|
||||
CS.WwiseAudioManager.Instance:PlaySound("ui_level_select")
|
||||
elseif nType == GameEnum.jumpType.Agent then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DispatchPanel)
|
||||
CS.WwiseAudioManager.Instance:PlaySound("ui_level_select")
|
||||
elseif nType == GameEnum.jumpType.Phone then
|
||||
local nTog = mapJumpTo.Param[1]
|
||||
local openCallback = function()
|
||||
PlayerData.Phone:OpenPhonePanel(nil, nTog)
|
||||
end
|
||||
PlayerData.Base:CheckFunctionBtn(GameEnum.OpenFuncType.Phone, openCallback)
|
||||
elseif nType == GameEnum.jumpType.Vampire then
|
||||
local stateCallback = function(bReEnter)
|
||||
if not bReEnter then
|
||||
local function success(bSuccess)
|
||||
EventManager.Remove("GetTalentDataVampire", JumpUtil, success)
|
||||
if bSuccess then
|
||||
local OpenTransCallback = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.VampireSurvivorLevelSelectPanel)
|
||||
end
|
||||
EventManager.Hit(EventId.SetTransition, 13, OpenTransCallback)
|
||||
else
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
end
|
||||
end
|
||||
EventManager.Add("GetTalentDataVampire", JumpUtil, success)
|
||||
local ret, _, _ = PlayerData.VampireSurvivor:GetTalentData()
|
||||
if ret ~= nil then
|
||||
success(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
local callbackCheck = function()
|
||||
PlayerData.State:CheckVampireState(stateCallback)
|
||||
end
|
||||
PlayerData.Base:CheckFunctionBtn(GameEnum.OpenFuncType.VampireSurvivor, callbackCheck, "ui_systerm_locked")
|
||||
elseif nType == GameEnum.jumpType.ComCYO then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Consumable, select(1, ...), select(2, ...), select(3, ...))
|
||||
elseif nType == GameEnum.jumpType.Quest then
|
||||
local nTog = mapJumpTo.Param[1]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Quest, nTog)
|
||||
elseif nType == GameEnum.jumpType.SkillInstancePanel then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.SkillInstanceLevelSelect)
|
||||
elseif nType == GameEnum.jumpType.SkillInstanceGroup then
|
||||
local nGroup = mapJumpTo.Param[1]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.SkillInstanceLevelSelect, 0, nGroup, true)
|
||||
elseif nType == GameEnum.jumpType.ScoreBoss then
|
||||
local openSC = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ScoreBossSelectPanel)
|
||||
end
|
||||
if not PlayerData.ScoreBoss:GetInitInfoState() then
|
||||
PlayerData.ScoreBoss:GetScoreBossInstanceData(openSC)
|
||||
else
|
||||
openSC()
|
||||
end
|
||||
elseif nType == GameEnum.jumpType.WeeklyCopies then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.WeeklyCopiesPanel, mapJumpTo.Param[1])
|
||||
elseif nType == GameEnum.jumpType.StorySet then
|
||||
PlayerData.StorySet:TryOpenStorySetPanel(function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.StorySet, true)
|
||||
end)
|
||||
elseif nType == GameEnum.jumpType.StarTowerGrowth then
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.StarTowerGrowth)
|
||||
end
|
||||
PlayerData.StarTower:SendTowerGrowthDetailReq(callback)
|
||||
elseif nType == GameEnum.jumpType.SwimActivityTask then
|
||||
local nActId = mapJumpTo.Param[1]
|
||||
if PlayerData.Activity:IsActivityInActivityGroup(nActId) then
|
||||
local actGroupId = ConfigTable.GetData("Activity", nActId).MidGroupId
|
||||
if actGroupId == 0 then
|
||||
return
|
||||
end
|
||||
local actGroupData = PlayerData.Activity:GetActivityGroupDataById(actGroupId)
|
||||
local taskActId = actGroupData:GetActivityDataByIndex(AllEnum.ActivityThemeFuncIndex.Task).ActivityId
|
||||
local taskActData = PlayerData.Activity:GetActivityDataById(taskActId)
|
||||
if taskActData ~= nil and taskActData:CheckActivityOpen() then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.SwimTask, taskActId)
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Activity_End_Notice"))
|
||||
end
|
||||
end
|
||||
end
|
||||
function JumpUtil.CheckJumpUnLock(jumpId, showTips)
|
||||
local mapJumpTo = ConfigTable.GetData("JumpTo", jumpId)
|
||||
if mapJumpTo == nil then
|
||||
printError("未配置此跳转Id, JumpId: " .. jumpId)
|
||||
return false
|
||||
end
|
||||
local nType = mapJumpTo.Type
|
||||
local bOpen = true
|
||||
local bFuncUnlock = true
|
||||
local sLockTip = ConfigTable.GetUIText("JumpTo_LevelUnlock")
|
||||
if nType == GameEnum.jumpType.Mainline then
|
||||
local nMainlineId = mapJumpTo.Param[1]
|
||||
bOpen = PlayerData.Mainline:IsMainlineLevelUnlock(nMainlineId)
|
||||
elseif nType == GameEnum.jumpType.Rogue then
|
||||
printError("不再支持老遗迹跳转")
|
||||
elseif nType == GameEnum.jumpType.RogueGroup then
|
||||
printError("不再支持老遗迹跳转")
|
||||
elseif nType == GameEnum.jumpType.RegionBossGroup then
|
||||
local nRegionBossGroupId = mapJumpTo.Param[1]
|
||||
bFuncUnlock = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.RegionBoss, true)
|
||||
bOpen = PlayerData.RogueBoss:CheckLevelOpen(nRegionBossGroupId, nil, showTips)
|
||||
showTips = false
|
||||
elseif nType == GameEnum.jumpType.RegionBossPanel then
|
||||
bFuncUnlock = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.RegionBoss, true)
|
||||
showTips = false
|
||||
elseif nType == GameEnum.jumpType.RegionBoss then
|
||||
local nRegionBossGroupId = mapJumpTo.Param[1]
|
||||
local nHard = mapJumpTo.Param[2]
|
||||
bFuncUnlock = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.RegionBoss, true)
|
||||
bOpen = PlayerData.RogueBoss:CheckLevelOpen(nRegionBossGroupId, nHard, showTips)
|
||||
showTips = false
|
||||
elseif nType == GameEnum.jumpType.DailyInstanceLevel then
|
||||
local nHard = mapJumpTo.Param[1]
|
||||
local nDailyType = mapJumpTo.Param[2]
|
||||
bFuncUnlock = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.DailyInstance, true)
|
||||
bOpen = PlayerData.DailyInstance:CheckLevelOpen(nDailyType, nHard, showTips)
|
||||
showTips = false
|
||||
elseif nType == GameEnum.jumpType.Crafting then
|
||||
local nProductionId = mapJumpTo.Param[1]
|
||||
bOpen = PlayerData.Crafting:CheckProductionUnlock(nProductionId)
|
||||
sLockTip = ConfigTable.GetUIText("Crafting_Lock_Tip")
|
||||
elseif nType == GameEnum.jumpType.StarTower then
|
||||
local nStarTowerId = mapJumpTo.Param[1]
|
||||
bOpen = PlayerData.StarTower:IsStarTowerUnlock(nStarTowerId)
|
||||
elseif nType == GameEnum.jumpType.StarTowerGroup then
|
||||
local nStarTowerGroupId = mapJumpTo.Param[1]
|
||||
bOpen = PlayerData.StarTower:IsStarTowerGroupUnlock(nStarTowerGroupId)
|
||||
elseif nType == GameEnum.jumpType.EquipmentPanel then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.CharGemInstance, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.CharGemInstance) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.EquipmentGroup then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.CharGemInstance, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.CharGemInstance) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.InfinityTower then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.InfinityTower, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.InfinityTower) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.InfinityTowerGroup then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.InfinityTower, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.InfinityTower) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.TravelerDuelLevel then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.TravelerDuel, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.TravelerDuel) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.Agent then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.Agent, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.Agent) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.Phone then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.Phone, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.Phone) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.Quest then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.Quest, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.Quest) or {}
|
||||
local nTog = mapJumpTo.Param[1]
|
||||
if nTog == AllEnum.QuestPanelTab.DailyQuest and bOpen then
|
||||
bOpen = bOpen and PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.DailyQuest, true)
|
||||
mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.DailyQuest) or {}
|
||||
end
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.SkillInstancePanel then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.SkillInstance, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.SkillInstance) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.SkillInstanceGroup then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.SkillInstance, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.SkillInstance) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.ScoreBoss then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.ScoreBoss, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.ScoreBoss) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
elseif nType == GameEnum.jumpType.WeeklyCopies then
|
||||
bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.WeeklyCopies, true)
|
||||
local mapLockCfgData = ConfigTable.GetData("OpenFunc", GameEnum.OpenFuncType.WeeklyCopies) or {}
|
||||
sLockTip = UTILS.ParseParamDesc(mapLockCfgData.Tips, mapLockCfgData)
|
||||
end
|
||||
bOpen = bFuncUnlock and bOpen
|
||||
if not bOpen and showTips then
|
||||
EventManager.Hit(EventId.OpenMessageBox, sLockTip or "")
|
||||
end
|
||||
return bOpen, mapJumpTo
|
||||
end
|
||||
return JumpUtil
|
||||
@@ -0,0 +1,96 @@
|
||||
local AchievementCtrl = class("AchievementCtrl", BaseCtrl)
|
||||
AchievementCtrl._mapNodeConfig = {
|
||||
animRoot = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
btnAchievement = {
|
||||
sComponentName = "UIButton",
|
||||
nCount = 5,
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
rtHomePage = {
|
||||
sCtrlName = "Game.UI.AchievementEx.AchievementHomepageCtrl"
|
||||
},
|
||||
rtDetail = {
|
||||
sCtrlName = "Game.UI.AchievementEx.AchievementDetailCtrl"
|
||||
}
|
||||
}
|
||||
AchievementCtrl._mapEventConfig = {
|
||||
[EventId.UIBackConfirm] = "OnEvent_Back",
|
||||
[EventId.UIHomeConfirm] = "OnEvent_BackHome"
|
||||
}
|
||||
AchievementCtrl._mapRedDotConfig = {}
|
||||
function AchievementCtrl:Awake()
|
||||
end
|
||||
function AchievementCtrl:FadeIn()
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
self._mapNode.animRoot:Play("AchievementPanel_in")
|
||||
end
|
||||
function AchievementCtrl:FadeOut()
|
||||
end
|
||||
function AchievementCtrl:OnEnable()
|
||||
self._mapNode.rtHomePage.gameObject:SetActive(false)
|
||||
self._mapNode.rtDetail.gameObject:SetActive(false)
|
||||
local callback = function()
|
||||
self._mapNode.rtHomePage:OnEvent_ReceiveReward()
|
||||
self._mapNode.rtDetail:UpdateData()
|
||||
if self._panel.nDetailIdx ~= nil and self._panel.nDetailIdx > 0 then
|
||||
self._mapNode.rtDetail.gameObject:SetActive(true)
|
||||
self._mapNode.rtDetail:OpenDetail(self._panel.nDetailIdx)
|
||||
self.bDetail = true
|
||||
else
|
||||
self._mapNode.rtHomePage.gameObject:SetActive(true)
|
||||
end
|
||||
PlayerData.Achievement:CheckReddot()
|
||||
end
|
||||
PlayerData.Achievement:SendAchievementInfoReq(callback)
|
||||
self.bDetail = false
|
||||
self:RegisterReddot()
|
||||
end
|
||||
function AchievementCtrl:OnDisable()
|
||||
end
|
||||
function AchievementCtrl:OnDestroy()
|
||||
end
|
||||
function AchievementCtrl:OnRelease()
|
||||
end
|
||||
function AchievementCtrl:OnBtnClick_Detail(btn, nIdx)
|
||||
self._mapNode.rtDetail:OpenDetail(nIdx)
|
||||
self._mapNode.rtHomePage.gameObject:SetActive(false)
|
||||
self._mapNode.rtDetail.gameObject:SetActive(true)
|
||||
self.bDetail = true
|
||||
self._panel.nDetailIdx = nIdx
|
||||
end
|
||||
function AchievementCtrl:RegisterReddot(...)
|
||||
for k, v in pairs(self._mapNode.btnAchievement) do
|
||||
local goReddot = v.transform:Find("AnimRoot/reddot").gameObject
|
||||
RedDotManager.RegisterNode(RedDotDefine.Achievement_Tab, k, goReddot)
|
||||
end
|
||||
end
|
||||
function AchievementCtrl:OnEvent_Back(nPanelId)
|
||||
if self._panel._nPanelId ~= nPanelId then
|
||||
return
|
||||
end
|
||||
if self.bDetail then
|
||||
self._mapNode.rtHomePage.gameObject:SetActive(true)
|
||||
self._mapNode.rtDetail.gameObject:SetActive(false)
|
||||
self.bDetail = false
|
||||
self._panel.nDetailIdx = 0
|
||||
self._mapNode.animRoot:Play("AchievementPanel_in")
|
||||
else
|
||||
self._panel.nDetailIdx = 0
|
||||
EventManager.Hit(EventId.CloesCurPanel)
|
||||
end
|
||||
end
|
||||
function AchievementCtrl:OnEvent_BackHome(nPanelId)
|
||||
if self._panel._nPanelId ~= nPanelId then
|
||||
return
|
||||
end
|
||||
self._panel.nDetailIdx = 0
|
||||
PanelManager.Home()
|
||||
end
|
||||
return AchievementCtrl
|
||||
@@ -0,0 +1,172 @@
|
||||
local AchievementDetailCtrl = class("AchievementDetailCtrl", BaseCtrl)
|
||||
AchievementDetailCtrl._mapNodeConfig = {
|
||||
TMPCupCount = {sComponentName = "TMP_Text", nCount = 3},
|
||||
txtBtnAllReceive = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_Btn_ReceiveAll"
|
||||
},
|
||||
imgFlagIcon = {sComponentName = "Image"},
|
||||
svAchievementList = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btnAllReceive = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_AllReceive"
|
||||
},
|
||||
btnTab = {
|
||||
sComponentName = "UIButton",
|
||||
nCount = 5,
|
||||
callback = "OnBtnClick_Tog"
|
||||
},
|
||||
imgTabBg = {
|
||||
sCtrlName = "Game.UI.AchievementEx.AchievementToggle"
|
||||
},
|
||||
imgIconF0 = {nCount = 5},
|
||||
AnimFlag = {sNodeName = "imgFlag", sComponentName = "Animator"}
|
||||
}
|
||||
AchievementDetailCtrl._mapEventConfig = {
|
||||
AchievementRefresh = "OnEvent_ReceiveReward"
|
||||
}
|
||||
AchievementDetailCtrl._mapRedDotConfig = {}
|
||||
function AchievementDetailCtrl:Awake()
|
||||
self.mapAllAchievement = {}
|
||||
self.mapAllAchievementCount = {}
|
||||
self.mapGrid = {}
|
||||
self.curIdx = 1
|
||||
end
|
||||
function AchievementDetailCtrl:FadeIn()
|
||||
end
|
||||
function AchievementDetailCtrl:FadeOut()
|
||||
end
|
||||
function AchievementDetailCtrl:OnEnable()
|
||||
self._mapNode.imgTabBg:SetText(ConfigTable.GetUIText("Achievement_Type_1"), ConfigTable.GetUIText("Achievement_Type_2"), ConfigTable.GetUIText("Achievement_Type_3"), ConfigTable.GetUIText("Achievement_Type_4"), ConfigTable.GetUIText("Achievement_Type_5"))
|
||||
self:RegisterReddot()
|
||||
end
|
||||
function AchievementDetailCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
if self.mapGrid[goGrid] == nil then
|
||||
local mapCtrl = self:BindCtrlByNode(goGrid, "Game.UI.AchievementEx.AchievementGridCtrl")
|
||||
self.mapGrid[goGrid] = mapCtrl
|
||||
end
|
||||
local nIdx = gridIndex
|
||||
if nIdx == nil then
|
||||
return
|
||||
end
|
||||
nIdx = nIdx + 1
|
||||
local mapAllAchievement = self.mapAllAchievement[self.curType][nIdx]
|
||||
self.mapGrid[goGrid]:OnGridRefresh(mapAllAchievement)
|
||||
end
|
||||
function AchievementDetailCtrl:OnDisable()
|
||||
for goGrid, mapCtrl in pairs(self.mapGrid) do
|
||||
self:UnbindCtrlByNode(mapCtrl)
|
||||
end
|
||||
self.mapGrid = {}
|
||||
end
|
||||
function AchievementDetailCtrl:OnDestroy()
|
||||
end
|
||||
function AchievementDetailCtrl:OnRelease()
|
||||
end
|
||||
function AchievementDetailCtrl:OpenDetail(nIdx)
|
||||
self.curType = nIdx
|
||||
for i = 1, 5 do
|
||||
self._mapNode.imgIconF0[i]:SetActive(nIdx == i)
|
||||
end
|
||||
self._mapNode.imgTabBg:SetState(nIdx)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
local sAnimName = "imgFlagIcon_in0" .. self.curType
|
||||
self._mapNode.AnimFlag:Play(sAnimName)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
self._mapNode.svAchievementList:Init(#self.mapAllAchievement[self.curType], self, self.OnGridRefresh)
|
||||
self:SetPngSprite(self._mapNode.imgFlagIcon, "UI/big_sprites/zs_achievement_icon_0" .. nIdx)
|
||||
NovaAPI.SetImageNativeSize(self._mapNode.imgFlagIcon)
|
||||
local bShowAllReceive = false
|
||||
for _, mapAchievement in ipairs(self.mapAllAchievement[self.curType]) do
|
||||
if mapAchievement.nStatus == 1 then
|
||||
bShowAllReceive = true
|
||||
end
|
||||
end
|
||||
self._mapNode.btnAllReceive.gameObject:SetActive(bShowAllReceive)
|
||||
local mapCount = PlayerData.Achievement:GetAchievementTypeCount(self.curType)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[1], mapCount.tbRarity[GameEnum.itemRarity.SSR])
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[2], mapCount.tbRarity[GameEnum.itemRarity.SR])
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[3], mapCount.tbRarity[GameEnum.itemRarity.R])
|
||||
end
|
||||
function AchievementDetailCtrl:UpdateData()
|
||||
for _, nValue in pairs(GameEnum.achievementType) do
|
||||
self.mapAllAchievement[nValue] = {}
|
||||
local mapAllAchievement = PlayerData.Achievement:GetAchievementTypeList(nValue)
|
||||
if mapAllAchievement ~= nil then
|
||||
for _, value in pairs(mapAllAchievement) do
|
||||
if not PlayerData.Achievement:JudgeHide(nValue, value) then
|
||||
table.insert(self.mapAllAchievement[nValue], value)
|
||||
end
|
||||
end
|
||||
local sortAchievement = function(a, b)
|
||||
if a.nStatus ~= b.nStatus then
|
||||
return a.nStatus < b.nStatus
|
||||
end
|
||||
return a.nId < b.nId
|
||||
end
|
||||
table.sort(self.mapAllAchievement[nValue], sortAchievement)
|
||||
end
|
||||
end
|
||||
end
|
||||
function AchievementDetailCtrl:RegisterReddot(...)
|
||||
for k, v in pairs(self._mapNode.btnTab) do
|
||||
local goReddot = v.transform:Find("reddot_Tab").gameObject
|
||||
RedDotManager.RegisterNode(RedDotDefine.Achievement_Tab, k, goReddot)
|
||||
end
|
||||
end
|
||||
function AchievementDetailCtrl:OnBtnClick_Tog(btn, nIdx)
|
||||
if nIdx == self.curType then
|
||||
return
|
||||
end
|
||||
self.curType = nIdx
|
||||
for i = 1, 5 do
|
||||
self._mapNode.imgIconF0[i]:SetActive(nIdx == i)
|
||||
end
|
||||
self._mapNode.imgTabBg:SetState(nIdx)
|
||||
self._mapNode.svAchievementList:SetAnim(0.06)
|
||||
self._mapNode.svAchievementList:Init(#self.mapAllAchievement[self.curType], self, self.OnGridRefresh)
|
||||
local mapCount = PlayerData.Achievement:GetAchievementTypeCount(self.curType)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[1], mapCount.tbRarity[GameEnum.itemRarity.SSR])
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[2], mapCount.tbRarity[GameEnum.itemRarity.SR])
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[3], mapCount.tbRarity[GameEnum.itemRarity.R])
|
||||
self:SetPngSprite(self._mapNode.imgFlagIcon, "UI/big_sprites/zs_achievement_icon_0" .. nIdx)
|
||||
NovaAPI.SetImageNativeSize(self._mapNode.imgFlagIcon)
|
||||
local bShowAllReceive = false
|
||||
for _, mapAchievement in ipairs(self.mapAllAchievement[self.curType]) do
|
||||
if mapAchievement.nStatus == 1 then
|
||||
bShowAllReceive = true
|
||||
end
|
||||
end
|
||||
self._panel.nDetailIdx = nIdx
|
||||
self._mapNode.btnAllReceive.gameObject:SetActive(bShowAllReceive)
|
||||
end
|
||||
function AchievementDetailCtrl:OnBtnClick_AllReceive(btn, nIdx)
|
||||
local tbId = {}
|
||||
for _, mapAchievement in ipairs(self.mapAllAchievement[self.curType]) do
|
||||
if mapAchievement.nStatus == 1 then
|
||||
table.insert(tbId, mapAchievement.nId)
|
||||
end
|
||||
end
|
||||
PlayerData.Achievement:SendAchievementRewardReq(tbId, self.curType, nil)
|
||||
end
|
||||
function AchievementDetailCtrl:OnEvent_ReceiveReward()
|
||||
self:UpdateData()
|
||||
self._mapNode.svAchievementList:Init(#self.mapAllAchievement[self.curType], self, self.OnGridRefresh)
|
||||
local mapCount = PlayerData.Achievement:GetAchievementTypeCount(self.curType)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[1], mapCount.tbRarity[GameEnum.itemRarity.SSR])
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[2], mapCount.tbRarity[GameEnum.itemRarity.SR])
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[3], mapCount.tbRarity[GameEnum.itemRarity.R])
|
||||
local bShowAllReceive = false
|
||||
for _, mapAchievement in ipairs(self.mapAllAchievement[self.curType]) do
|
||||
if mapAchievement.nStatus == 1 then
|
||||
bShowAllReceive = true
|
||||
end
|
||||
end
|
||||
self._mapNode.btnAllReceive.gameObject:SetActive(bShowAllReceive)
|
||||
end
|
||||
return AchievementDetailCtrl
|
||||
@@ -0,0 +1,113 @@
|
||||
local AchievementGridCtrl = class("AchievementGridCtrl", BaseCtrl)
|
||||
local JumpUtil = require("Game.Common.Utils.JumpUtil")
|
||||
local nBarLength = 512
|
||||
local nBarHeight = 512
|
||||
AchievementGridCtrl._mapNodeConfig = {
|
||||
imgCup = {sComponentName = "Image"},
|
||||
TMPTitle = {sComponentName = "TMP_Text"},
|
||||
TMPDesc = {sComponentName = "TMP_Text"},
|
||||
TMPProcess = {sComponentName = "TMP_Text"},
|
||||
TMPTimeTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Achievement_Tips_Completed"
|
||||
},
|
||||
txtBtnJump = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_JumpTo"
|
||||
},
|
||||
TMPTime = {sComponentName = "TMP_Text"},
|
||||
rtBarFill = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
btnItem = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Item"
|
||||
},
|
||||
btnReceive = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Receive"
|
||||
},
|
||||
btnJump = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Jumpto"
|
||||
},
|
||||
rtItem = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
|
||||
},
|
||||
imgCup0 = {nCount = 3},
|
||||
txtBtnReceive = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_Receive_Btn_Text"
|
||||
},
|
||||
TMPUncomplete = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_UnComplete_Text"
|
||||
}
|
||||
}
|
||||
AchievementGridCtrl._mapEventConfig = {}
|
||||
AchievementGridCtrl._mapRedDotConfig = {}
|
||||
function AchievementGridCtrl:Awake()
|
||||
end
|
||||
function AchievementGridCtrl:FadeIn()
|
||||
end
|
||||
function AchievementGridCtrl:FadeOut()
|
||||
end
|
||||
function AchievementGridCtrl:OnEnable()
|
||||
end
|
||||
function AchievementGridCtrl:OnDisable()
|
||||
end
|
||||
function AchievementGridCtrl:OnDestroy()
|
||||
end
|
||||
function AchievementGridCtrl:OnRelease()
|
||||
end
|
||||
function AchievementGridCtrl:OnGridRefresh(mapAchievement)
|
||||
self.mapAchievement = mapAchievement
|
||||
local mapAchievementCfgData = ConfigTable.GetData("Achievement", mapAchievement.nId)
|
||||
if mapAchievementCfgData == nil then
|
||||
self.gameObject:SetActive(false)
|
||||
return
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitle, mapAchievementCfgData.Title)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPDesc, mapAchievementCfgData.Desc)
|
||||
if mapAchievementCfgData.Tid1 ~= 0 then
|
||||
self._mapNode.rtItem.gameObject:SetActive(true)
|
||||
self._mapNode.rtItem:SetItem(mapAchievementCfgData.Tid1, nil, mapAchievementCfgData.Qty1, nil, mapAchievement.nStatus == 3)
|
||||
else
|
||||
self._mapNode.rtItem.gameObject:SetActive(false)
|
||||
end
|
||||
self._mapNode.btnReceive.gameObject:SetActive(mapAchievement.nStatus == 1)
|
||||
self._mapNode.btnJump.gameObject:SetActive(mapAchievement.nStatus == 2 and 0 < mapAchievementCfgData.JumpTo)
|
||||
self._mapNode.TMPTimeTitle.gameObject:SetActive(mapAchievement.nStatus == 3)
|
||||
self._mapNode.TMPUncomplete.gameObject:SetActive(mapAchievement.nStatus == 2 and mapAchievementCfgData.JumpTo == 0)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPProcess, string.format("%d/%d", mapAchievement.nCur, mapAchievement.nMax))
|
||||
if mapAchievement.nStatus == 3 then
|
||||
self._mapNode.rtBarFill.sizeDelta = Vector2(nBarLength, nBarHeight)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTime, mapAchievement.sTime)
|
||||
elseif 0 < mapAchievement.nMax then
|
||||
self._mapNode.rtBarFill.sizeDelta = Vector2(nBarLength * (mapAchievement.nCur / mapAchievement.nMax), nBarHeight)
|
||||
else
|
||||
self._mapNode.rtBarFill.sizeDelta = Vector2(0, nBarHeight)
|
||||
end
|
||||
self:SetPngSprite(self._mapNode.imgCup, "UI/big_sprites/zs_achievement_cup_0" .. mapAchievementCfgData.Rarity)
|
||||
for i = 1, 3 do
|
||||
self._mapNode.imgCup0[i]:SetActive(i == mapAchievementCfgData.Rarity and mapAchievement.nStatus == 3)
|
||||
end
|
||||
end
|
||||
function AchievementGridCtrl:OnBtnClick_Receive()
|
||||
local mapAchievementCfgData = ConfigTable.GetData("Achievement", self.mapAchievement.nId)
|
||||
PlayerData.Achievement:SendAchievementRewardReq({
|
||||
self.mapAchievement.nId
|
||||
}, mapAchievementCfgData.Type, nil)
|
||||
end
|
||||
function AchievementGridCtrl:OnBtnClick_Jumpto()
|
||||
local mapAchievementCfgData = ConfigTable.GetData("Achievement", self.mapAchievement.nId) or {}
|
||||
JumpUtil.JumpTo(mapAchievementCfgData.JumpTo)
|
||||
end
|
||||
function AchievementGridCtrl:OnBtnClick_Item(btn)
|
||||
local mapAchievementCfgData = ConfigTable.GetData("Achievement", self.mapAchievement.nId)
|
||||
if mapAchievementCfgData == nil then
|
||||
return
|
||||
end
|
||||
UTILS.ClickItemGridWithTips(mapAchievementCfgData.Tid1, btn.gameObject, true, true, true)
|
||||
end
|
||||
return AchievementGridCtrl
|
||||
@@ -0,0 +1,35 @@
|
||||
local AchievementHomepageCtrl = class("AchievementHomepageCtrl", BaseCtrl)
|
||||
AchievementHomepageCtrl._mapNodeConfig = {
|
||||
TMPAcheivementCount = {sComponentName = "TMP_Text"},
|
||||
TMPTitle = {sComponentName = "TMP_Text", nCount = 5},
|
||||
TMPCupCount = {sComponentName = "TMP_Text", nCount = 3}
|
||||
}
|
||||
AchievementHomepageCtrl._mapEventConfig = {
|
||||
AchievementRefresh = "OnEvent_ReceiveReward"
|
||||
}
|
||||
AchievementHomepageCtrl._mapRedDotConfig = {}
|
||||
function AchievementHomepageCtrl:Awake()
|
||||
end
|
||||
function AchievementHomepageCtrl:FadeIn()
|
||||
end
|
||||
function AchievementHomepageCtrl:FadeOut()
|
||||
end
|
||||
function AchievementHomepageCtrl:OnEnable()
|
||||
for i = 1, 5 do
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitle[i], ConfigTable.GetUIText("Achievement_Type_" .. i))
|
||||
end
|
||||
end
|
||||
function AchievementHomepageCtrl:OnDisable()
|
||||
end
|
||||
function AchievementHomepageCtrl:OnDestroy()
|
||||
end
|
||||
function AchievementHomepageCtrl:OnRelease()
|
||||
end
|
||||
function AchievementHomepageCtrl:OnEvent_ReceiveReward()
|
||||
self.mapCount = PlayerData.Achievement:GetAchievementAllTypeCount()
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPAcheivementCount, self.mapCount.nCompleted)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[1], self.mapCount.nSSR)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[2], self.mapCount.nSR)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCupCount[3], self.mapCount.nR)
|
||||
end
|
||||
return AchievementHomepageCtrl
|
||||
@@ -0,0 +1,20 @@
|
||||
local AchievementPanel = class("AchievementPanel", BasePanel)
|
||||
AchievementPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "AchievementEx/AchievementPanel.prefab",
|
||||
sCtrlName = "Game.UI.AchievementEx.AchievementCtrl"
|
||||
}
|
||||
}
|
||||
function AchievementPanel:Awake()
|
||||
end
|
||||
function AchievementPanel:OnEnable()
|
||||
end
|
||||
function AchievementPanel:OnAfterEnter()
|
||||
end
|
||||
function AchievementPanel:OnDisable()
|
||||
end
|
||||
function AchievementPanel:OnDestroy()
|
||||
end
|
||||
function AchievementPanel:OnRelease()
|
||||
end
|
||||
return AchievementPanel
|
||||
@@ -0,0 +1,40 @@
|
||||
local AchievementToggle = class("AchievementToggle", BaseCtrl)
|
||||
AchievementToggle._mapNodeConfig = {
|
||||
TMPTitle = {sComponentName = "TMP_Text", nCount = 5},
|
||||
TMPTitleOpen = {sComponentName = "TMP_Text", nCount = 5},
|
||||
imgTab = {nCount = 5}
|
||||
}
|
||||
AchievementToggle._mapEventConfig = {}
|
||||
AchievementToggle._mapRedDotConfig = {}
|
||||
function AchievementToggle:Awake()
|
||||
end
|
||||
function AchievementToggle:FadeIn()
|
||||
end
|
||||
function AchievementToggle:FadeOut()
|
||||
end
|
||||
function AchievementToggle:OnEnable()
|
||||
end
|
||||
function AchievementToggle:OnDisable()
|
||||
end
|
||||
function AchievementToggle:OnDestroy()
|
||||
end
|
||||
function AchievementToggle:OnRelease()
|
||||
end
|
||||
function AchievementToggle:SetText(sTitle1, sTitle2, sTitle3, sTitle4, sTitle5)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitle[1], sTitle1)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitle[2], sTitle2)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitle[3], sTitle3)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitle[4], sTitle4)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitle[5], sTitle5)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitleOpen[1], sTitle1)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitleOpen[2], sTitle2)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitleOpen[3], sTitle3)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitleOpen[4], sTitle4)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPTitleOpen[5], sTitle5)
|
||||
end
|
||||
function AchievementToggle:SetState(nIdx)
|
||||
for index, goTab in ipairs(self._mapNode.imgTab) do
|
||||
goTab:SetActive(nIdx == index)
|
||||
end
|
||||
end
|
||||
return AchievementToggle
|
||||
@@ -0,0 +1,81 @@
|
||||
local ActionBarCtrl = class("ActionBarCtrl", BaseCtrl)
|
||||
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
|
||||
ActionBarCtrl._mapNodeConfig = {
|
||||
rtContent = {sComponentName = "Transform"},
|
||||
goAction = {}
|
||||
}
|
||||
ActionBarCtrl._mapEventConfig = {
|
||||
GamepadUIChange = "OnEvent_GamepadUIChange"
|
||||
}
|
||||
function ActionBarCtrl:InitActionBar(tbConfig)
|
||||
if self.tbConfig and #tbConfig == #self.tbConfig then
|
||||
local bAllSame = true
|
||||
for i, v in ipairs(tbConfig) do
|
||||
if v.sAction ~= self.tbConfig[i].sAction then
|
||||
bAllSame = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if bAllSame then
|
||||
return
|
||||
end
|
||||
end
|
||||
self.tbActionObj = {}
|
||||
self.tbActionImg = {}
|
||||
self.tbConfig = tbConfig
|
||||
delChildren(self._mapNode.rtContent)
|
||||
for _, v in pairs(tbConfig) do
|
||||
local goAction = instantiate(self._mapNode.goAction, self._mapNode.rtContent)
|
||||
goAction:SetActive(true)
|
||||
local imgAction = goAction.transform:Find("imgAction"):GetComponent("Image")
|
||||
local imgAction2 = goAction.transform:Find("imgAction2"):GetComponent("Image")
|
||||
local txtAction = goAction.transform:Find("txtAction"):GetComponent("TMP_Text")
|
||||
NovaAPI.SetTMPText(txtAction, ConfigTable.GetUIText(v.sLang))
|
||||
self.tbActionObj[v.sAction] = goAction
|
||||
self.tbActionImg[v.sAction] = imgAction
|
||||
if v.sAction2 then
|
||||
imgAction2.gameObject:SetActive(true)
|
||||
self.tbActionObj[v.sAction2] = goAction
|
||||
self.tbActionImg[v.sAction2] = imgAction2
|
||||
end
|
||||
end
|
||||
self:RefreshActionImage()
|
||||
end
|
||||
function ActionBarCtrl:ClearActionBar()
|
||||
self.tbActionObj = {}
|
||||
self.tbActionImg = {}
|
||||
self.tbConfig = nil
|
||||
delChildren(self._mapNode.rtContent)
|
||||
end
|
||||
function ActionBarCtrl:RefreshActionImage()
|
||||
local nUIType = GamepadUIManager.GetCurUIType()
|
||||
if nUIType == AllEnum.GamepadUIType.Other then
|
||||
self.gameObject:SetActive(false)
|
||||
return
|
||||
end
|
||||
self.gameObject:SetActive(true)
|
||||
for sAction, imgAction in pairs(self.tbActionImg) do
|
||||
local sIcon
|
||||
if nUIType == AllEnum.GamepadUIType.PS then
|
||||
sIcon = ConfigTable.GetField("GamepadAction", sAction, "PlayStationIcon")
|
||||
elseif nUIType == AllEnum.GamepadUIType.Xbox then
|
||||
sIcon = ConfigTable.GetField("GamepadAction", sAction, "XboxIcon")
|
||||
elseif nUIType == AllEnum.GamepadUIType.Keyboard or nUIType == AllEnum.GamepadUIType.Mouse then
|
||||
sIcon = ConfigTable.GetField("GamepadAction", sAction, "KeyboardIcon")
|
||||
end
|
||||
if sIcon == nil or sIcon == "" then
|
||||
self.tbActionObj[sAction]:SetActive(false)
|
||||
else
|
||||
self.tbActionObj[sAction]:SetActive(true)
|
||||
self:SetPngSprite(imgAction, sIcon)
|
||||
NovaAPI.SetImageNativeSize(imgAction)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActionBarCtrl:OnEvent_GamepadUIChange(sName, nBeforeType, nAfterType)
|
||||
if not self.tbActionImg then
|
||||
return
|
||||
end
|
||||
self:RefreshActionImage()
|
||||
end
|
||||
return ActionBarCtrl
|
||||
@@ -0,0 +1,109 @@
|
||||
local ActivityTaskCtrl_01 = class("ActivityTaskCtrl_01", BaseCtrl)
|
||||
ActivityTaskCtrl_01._mapNodeConfig = {
|
||||
goTaskItem = {
|
||||
nCount = 7,
|
||||
sCtrlName = "Game.UI.Activity.ActivityTask.ActivityTaskItemCtrl_01"
|
||||
},
|
||||
btnItem = {
|
||||
nCount = 7,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Item"
|
||||
},
|
||||
btnTask = {
|
||||
nCount = 7,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Task"
|
||||
},
|
||||
txtActivityTime = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Energy_Item_Permanent_Time"
|
||||
}
|
||||
}
|
||||
ActivityTaskCtrl_01._mapEventConfig = {}
|
||||
function ActivityTaskCtrl_01:RefreshTaskList()
|
||||
self.tbTaskList = {}
|
||||
self.tbRewardList = {}
|
||||
self.nGroupId = 0
|
||||
local tbTaskGroup, tbTaskList = self.actData:GetAllTaskList()
|
||||
for nGroupId, tbTask in pairs(tbTaskGroup) do
|
||||
self.nGroupId = nGroupId
|
||||
for _, nId in ipairs(tbTask) do
|
||||
local mapQuest = tbTaskList[nId]
|
||||
if mapQuest ~= nil then
|
||||
local mapData = {
|
||||
nId = nId,
|
||||
nStatus = mapQuest.nStatus,
|
||||
nExpire = mapQuest.nExpire,
|
||||
nCur = mapQuest.nCur,
|
||||
nMax = mapQuest.nMax
|
||||
}
|
||||
table.insert(self.tbTaskList, mapData)
|
||||
end
|
||||
local mapCfg = ConfigTable.GetData("ActivityTask", nId)
|
||||
if mapCfg ~= nil and mapCfg.Tid1 ~= 0 then
|
||||
table.insert(self.tbRewardList, mapCfg.Tid1)
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(self.tbTaskList, function(a, b)
|
||||
return a.nId < b.nId
|
||||
end)
|
||||
for k, v in ipairs(self._mapNode.goTaskItem) do
|
||||
local mapQuestData = self.tbTaskList[k]
|
||||
v.gameObject:SetActive(mapQuestData ~= nil)
|
||||
if mapQuestData ~= nil then
|
||||
v:SetTaskItem(mapQuestData)
|
||||
if self._mapNode.btnItem[k] ~= nil then
|
||||
NovaAPI.SetRaycastTarget(self._mapNode.btnItem[k].gameObject, mapQuestData.nStatus ~= AllEnum.ActQuestStatus.Complete)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivityTaskCtrl_01:InitActData(actData)
|
||||
self.actData = actData
|
||||
self:RefreshTaskList()
|
||||
end
|
||||
function ActivityTaskCtrl_01:ClearActivity()
|
||||
end
|
||||
function ActivityTaskCtrl_01:Awake()
|
||||
end
|
||||
function ActivityTaskCtrl_01:OnEnable()
|
||||
end
|
||||
function ActivityTaskCtrl_01:OnDisable()
|
||||
end
|
||||
function ActivityTaskCtrl_01:OnDestroy()
|
||||
end
|
||||
function ActivityTaskCtrl_01:OnBtnClick_Detail()
|
||||
local mapActCfg = self.actData:GetLoginRewardControlCfg()
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = mapActCfg.DesText,
|
||||
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function ActivityTaskCtrl_01:OnBtnClick_Item(btn, nIndex)
|
||||
if self.tbRewardList[nIndex] ~= nil then
|
||||
UTILS.ClickItemGridWithTips(self.tbRewardList[nIndex], btn.gameObject.transform, true, true, false)
|
||||
end
|
||||
end
|
||||
function ActivityTaskCtrl_01:OnBtnClick_Task(btn, nIndex)
|
||||
if self.tbTaskList ~= nil and self.tbTaskList[nIndex] ~= nil then
|
||||
local mapQuest = self.tbTaskList[nIndex]
|
||||
if mapQuest.nStatus == AllEnum.ActQuestStatus.Complete then
|
||||
local mapGroupCfg = ConfigTable.GetData("ActivityTaskGroup", self.nGroupId)
|
||||
if self.actData ~= nil and mapGroupCfg ~= nil then
|
||||
local callback = function()
|
||||
self:RefreshTaskList()
|
||||
RedDotManager.SetValid(RedDotDefine.Activity_Tab, self.actData:GetActId(), false)
|
||||
end
|
||||
self.actData:SendMsg_ActivityTaskRewardReceiveReq(self.nGroupId, mapQuest.nId, mapGroupCfg.TaskTabType, callback)
|
||||
end
|
||||
elseif mapQuest.nStatus == AllEnum.ActQuestStatus.UnComplete then
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivityTaskCtrl_01:OnEvent_RefreshActivityTask()
|
||||
self:RefreshTaskList()
|
||||
end
|
||||
return ActivityTaskCtrl_01
|
||||
@@ -0,0 +1,45 @@
|
||||
local ActivityTaskItemCtrl_01 = class("ActivityTaskItemCtrl_01", BaseCtrl)
|
||||
ActivityTaskItemCtrl_01._mapNodeConfig = {
|
||||
imgCanReceiveBg = {},
|
||||
imgIcon = {sComponentName = "Image"},
|
||||
txtItemCount = {sComponentName = "TMP_Text"},
|
||||
txtDesc = {sComponentName = "TMP_Text"},
|
||||
txtItemName = {sComponentName = "TMP_Text"},
|
||||
goReceived = {},
|
||||
txtReceived = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "LoginReward_Received"
|
||||
},
|
||||
imgReceived = {},
|
||||
imgCanReceive = {},
|
||||
txtCanReceive = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "LoginReward_Can_Receive"
|
||||
}
|
||||
}
|
||||
ActivityTaskItemCtrl_01._mapEventConfig = {}
|
||||
ActivityTaskItemCtrl_01._mapRedDotConfig = {}
|
||||
function ActivityTaskItemCtrl_01:SetTaskItem(mapQuest)
|
||||
local mapCfg = ConfigTable.GetData("ActivityTask", mapQuest.nId)
|
||||
if mapCfg == nil then
|
||||
return
|
||||
end
|
||||
self.mapQuest = mapQuest
|
||||
local nTid = mapCfg.Tid1
|
||||
local nCount = mapCfg.Qty1
|
||||
if nTid ~= 0 then
|
||||
local itemCfg = ConfigTable.GetData_Item(nTid)
|
||||
if itemCfg ~= nil then
|
||||
self:SetPngSprite(self._mapNode.imgIcon, itemCfg.Icon)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtItemName, itemCfg.Title)
|
||||
end
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtItemCount, orderedFormat(ConfigTable.GetUIText("LoginReward_Reward_Count"), nCount))
|
||||
local sDesc = orderedFormat(mapCfg.Desc, mapCfg.AimNumShow)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDesc, sDesc)
|
||||
self._mapNode.imgCanReceiveBg.gameObject:SetActive(mapQuest.nStatus == AllEnum.ActQuestStatus.Complete)
|
||||
self._mapNode.imgCanReceive.gameObject:SetActive(mapQuest.nStatus == AllEnum.ActQuestStatus.Complete)
|
||||
self._mapNode.goReceived.gameObject:SetActive(mapQuest.nStatus == AllEnum.ActQuestStatus.Received)
|
||||
self._mapNode.imgReceived.gameObject:SetActive(mapQuest.nStatus == AllEnum.ActQuestStatus.Received)
|
||||
end
|
||||
return ActivityTaskItemCtrl_01
|
||||
@@ -0,0 +1,168 @@
|
||||
local InfinityTowerActCtrl = class("InfinityTowerActCtrl", BaseCtrl)
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local LocalSettingData = require("GameCore.Data.LocalSettingData")
|
||||
local rabbitRightId = 917302
|
||||
local rabbitLeftId = 917402
|
||||
InfinityTowerActCtrl._mapNodeConfig = {
|
||||
txtActTime = {sComponentName = "TMP_Text"},
|
||||
txtActDesc = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_TowerAllOpen_Des"
|
||||
},
|
||||
txtActTips = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_TowerAllOpen_Tip"
|
||||
},
|
||||
btn_Go = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Go"
|
||||
},
|
||||
txtBtn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_TowerAllOpen_Go"
|
||||
},
|
||||
imgActTimeBg = {},
|
||||
trRoot_L = {
|
||||
sNodeName = "----Actor2DLeft302----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
trRoot_R = {
|
||||
sNodeName = "----Actor2DRight402----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
Actor2DLeft = {
|
||||
sNodeName = "rawImg_L_302",
|
||||
sComponentName = "RawImage"
|
||||
},
|
||||
Actor2DPngL = {sNodeName = "png_L_302", sComponentName = "Transform"},
|
||||
Actor2DRight = {
|
||||
sNodeName = "rawImg_R_402",
|
||||
sComponentName = "RawImage"
|
||||
},
|
||||
Actor2DPngR = {sNodeName = "png_R_402", sComponentName = "Transform"}
|
||||
}
|
||||
InfinityTowerActCtrl._mapEventConfig = {}
|
||||
function InfinityTowerActCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self.nActId = actData:GetActId()
|
||||
self:StartActTimer()
|
||||
self.UseLive2D = LocalSettingData.mapData.UseLive2D
|
||||
self:LoadRabbit()
|
||||
end
|
||||
function InfinityTowerActCtrl:ClearActivity()
|
||||
end
|
||||
function InfinityTowerActCtrl:OnDisable()
|
||||
self:UnLoadRabbit()
|
||||
end
|
||||
function InfinityTowerActCtrl:GetTimeStr(nRemainTime)
|
||||
local sTimeStr = ""
|
||||
if nRemainTime <= 60 then
|
||||
local sec = math.floor(nRemainTime)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < nRemainTime and nRemainTime <= 3600 then
|
||||
local min = math.floor(nRemainTime / 60)
|
||||
local sec = math.floor(nRemainTime - min * 60)
|
||||
if sec == 0 then
|
||||
min = min - 1
|
||||
sec = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < nRemainTime and nRemainTime <= 86400 then
|
||||
local hour = math.floor(nRemainTime / 3600)
|
||||
local min = math.floor((nRemainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < nRemainTime then
|
||||
local day = math.floor(nRemainTime / 86400)
|
||||
local hour = math.floor((nRemainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
return sTimeStr
|
||||
end
|
||||
function InfinityTowerActCtrl:StartActTimer()
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
self.timer = nil
|
||||
end
|
||||
local nStartTime = self.actData:GetActOpenTime()
|
||||
local nEndTime = self.actData:GetActCloseTime()
|
||||
self.isTimeVisible = self._mapNode.imgActTimeBg.gameObject.activeSelf
|
||||
local refreshTime = function()
|
||||
local nCurTime = ClientManager.serverTimeStamp
|
||||
local sTime = ""
|
||||
local IsTimeVisible = true
|
||||
local nRemainTime = 0
|
||||
if nCurTime >= nStartTime and nCurTime < nEndTime then
|
||||
nRemainTime = math.max(nEndTime - nCurTime, 0)
|
||||
sTime = self:GetTimeStr(nRemainTime)
|
||||
else
|
||||
nRemainTime = math.max(nEndTime - nCurTime, 0)
|
||||
sTime = self:GetTimeStr(nRemainTime)
|
||||
end
|
||||
if nRemainTime <= 0 then
|
||||
IsTimeVisible = false
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
self.timer = nil
|
||||
end
|
||||
end
|
||||
if self.isTimeVisible ~= IsTimeVisible then
|
||||
self._mapNode.imgActTimeBg.gameObject:SetActive(IsTimeVisible)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActTime, sTime)
|
||||
end
|
||||
refreshTime()
|
||||
self.timer = self:AddTimer(0, 1, refreshTime, true, true, true)
|
||||
end
|
||||
function InfinityTowerActCtrl:OnBtnClick_Detail()
|
||||
if self.mapActCfg == nil then
|
||||
return
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = self.mapActCfg.DetailDesc,
|
||||
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function InfinityTowerActCtrl:OnBtnClick_Go()
|
||||
local nEndTime = self.actData:GetActCloseTime()
|
||||
local nCurTime = ClientManager.serverTimeStamp
|
||||
if nEndTime < nCurTime then
|
||||
return
|
||||
end
|
||||
local bPlayCond = self.actData:CheckActJumpCond(true)
|
||||
if not bPlayCond then
|
||||
return
|
||||
end
|
||||
local func = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.InfinityTowerSelectTower)
|
||||
end
|
||||
EventManager.Hit(EventId.SetTransition, 8, func)
|
||||
end
|
||||
function InfinityTowerActCtrl:LoadRabbit()
|
||||
self._mapNode.Actor2DLeft.transform.localScale = self.UseLive2D == true and Vector3.one or Vector3.zero
|
||||
self._mapNode.Actor2DRight.transform.localScale = self.UseLive2D == true and Vector3.one or Vector3.zero
|
||||
self._mapNode.Actor2DPngL.localScale = self.UseLive2D == true and Vector3.zero or Vector3.one
|
||||
self._mapNode.Actor2DPngR.localScale = self.UseLive2D == true and Vector3.zero or Vector3.one
|
||||
if self.UseLive2D == true then
|
||||
Actor2DManager.SetBoardNPC2D(PanelId.ActivityInfinity, self._mapNode.Actor2DLeft, rabbitLeftId, nil, nil, 1)
|
||||
Actor2DManager.SetBoardNPC2D(PanelId.ActivityInfinity, self._mapNode.Actor2DRight, rabbitRightId, nil, nil, 2)
|
||||
else
|
||||
Actor2DManager.SetBoardNPC2D_PNG(self._mapNode.Actor2DPngL, PanelId.ActivityInfinity, rabbitLeftId)
|
||||
Actor2DManager.SetBoardNPC2D_PNG(self._mapNode.Actor2DPngR, PanelId.ActivityInfinity, rabbitRightId)
|
||||
end
|
||||
end
|
||||
function InfinityTowerActCtrl:UnLoadRabbit()
|
||||
Actor2DManager.UnsetBoardNPC2D(1)
|
||||
Actor2DManager.UnsetBoardNPC2D(2)
|
||||
end
|
||||
return InfinityTowerActCtrl
|
||||
@@ -0,0 +1,85 @@
|
||||
NewTutorialsActCtrl = class("NewTutorialsActCtrl", BaseCtrl)
|
||||
NewTutorialsActCtrl._mapNodeConfig = {
|
||||
btn_GoGuideQusetPanel = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GoGuideQusetPanel"
|
||||
},
|
||||
txt_Title1 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "QuestPanel_Tab_1"
|
||||
},
|
||||
txt_Plan1 = {sNodeName = "txt_Plan1", sComponentName = "TMP_Text"},
|
||||
txt_Complete1 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_Complete"
|
||||
},
|
||||
txtBtnGo1 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_JumpTo"
|
||||
},
|
||||
btn_GoTutorialPanel = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GoTutorialPanel"
|
||||
},
|
||||
txt_Title2 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "QuestPanel_Tab_4"
|
||||
},
|
||||
txt_Plan2 = {sNodeName = "txt_Plan2", sComponentName = "TMP_Text"},
|
||||
txt_Complete2 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_Complete"
|
||||
},
|
||||
txtBtnGo2 = {
|
||||
sNodeName = "txtBtnGo2",
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Quest_JumpTo"
|
||||
}
|
||||
}
|
||||
NewTutorialsActCtrl._mapEventConfig = {}
|
||||
function NewTutorialsActCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self.nActId = actData:GetActId()
|
||||
self.AdConfig = ConfigTable.GetData("AdControl", self.nActId)
|
||||
self:Init()
|
||||
end
|
||||
function NewTutorialsActCtrl:Init()
|
||||
self:RefreshGuideQuset()
|
||||
self:RefreshTutorial()
|
||||
end
|
||||
function NewTutorialsActCtrl:RefreshGuideQuset()
|
||||
local nReceivedCount = 0
|
||||
local nTotalCount = PlayerData.Quest:GetMaxTourGroupOrderIndex()
|
||||
local nCurTourGroupOrder = PlayerData.Quest:GetCurTourGroupOrder()
|
||||
if PlayerData.Quest:CheckTourGroupReward(nTotalCount) then
|
||||
self._mapNode.btn_GoGuideQusetPanel.gameObject:SetActive(false)
|
||||
self._mapNode.txt_Complete1.gameObject:SetActive(true)
|
||||
nReceivedCount = nTotalCount
|
||||
else
|
||||
nReceivedCount = nCurTourGroupOrder - 1
|
||||
end
|
||||
local sPanel = orderedFormat(ConfigTable.GetUIText("NewTutorialsAct_Complete") or "", nReceivedCount, nTotalCount)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_Plan1, sPanel)
|
||||
end
|
||||
function NewTutorialsActCtrl:RefreshTutorial()
|
||||
local nTotalCount, nReceivedCount = PlayerData.TutorialData:GetProgress()
|
||||
local sPanel = orderedFormat(ConfigTable.GetUIText("NewTutorialsAct_Complete") or "", nReceivedCount, nTotalCount)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_Plan2, sPanel)
|
||||
if nTotalCount == nReceivedCount then
|
||||
self._mapNode.btn_GoTutorialPanel.gameObject:SetActive(false)
|
||||
self._mapNode.txt_Complete2.gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
function NewTutorialsActCtrl:OnBtnClick_GoGuideQusetPanel()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Quest, AllEnum.QuestPanelTab.GuideQuest)
|
||||
end
|
||||
function NewTutorialsActCtrl:OnBtnClick_GoTutorialPanel()
|
||||
local bPlayCond = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.TutorialLevel, true)
|
||||
if not bPlayCond then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Quest, AllEnum.QuestPanelTab.Tutorial)
|
||||
end
|
||||
function NewTutorialsActCtrl:ClearActivity()
|
||||
end
|
||||
return NewTutorialsActCtrl
|
||||
@@ -0,0 +1,119 @@
|
||||
local StoryCollectionActCtrl = class("StoryCollectionActCtrl", BaseCtrl)
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
local JumpUtil = require("Game.Common.Utils.JumpUtil")
|
||||
StoryCollectionActCtrl._mapNodeConfig = {
|
||||
txtActTime = {sComponentName = "TMP_Text"},
|
||||
btn_Go = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Go"
|
||||
},
|
||||
btn_Wait = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Wait"
|
||||
},
|
||||
txtBtn_GoRead = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "ActivityAdv_StoryRead_Go"
|
||||
},
|
||||
txtBtn_Wait = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "ActivityAdv_StoryRead_Wait"
|
||||
}
|
||||
}
|
||||
StoryCollectionActCtrl._mapEventConfig = {}
|
||||
function StoryCollectionActCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self.nActId = actData:GetActId()
|
||||
self.AdConfig = ConfigTable.GetData("AdControl", self.nActId)
|
||||
self:StartActTimer()
|
||||
end
|
||||
function StoryCollectionActCtrl:ClearActivity()
|
||||
end
|
||||
function StoryCollectionActCtrl:OnDisable()
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
end
|
||||
self.timer = nil
|
||||
end
|
||||
function StoryCollectionActCtrl:StartActTimer()
|
||||
local startTime = self.AdConfig.StartTime
|
||||
local nStartTime = CS.ClientManager.Instance:ISO8601StrToTimeStamp(startTime)
|
||||
local nEndTime = self.actData:GetActCloseTime()
|
||||
local refreshTime = function()
|
||||
local nCurTime = ClientManager.serverTimeStamp
|
||||
local nRemainTime = 0
|
||||
local isOpen = false
|
||||
local sTime = ""
|
||||
if nCurTime < nStartTime then
|
||||
isOpen = false
|
||||
nRemainTime = math.max(nStartTime - nCurTime, 0)
|
||||
sTime = self:GetTimeStr(nRemainTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActTime, ConfigTable.GetUIText("ActivityAdv_StoryCountDown") .. sTime)
|
||||
elseif nCurTime >= nStartTime then
|
||||
isOpen = true
|
||||
local sStartTime = os.date("%Y/%m/%d", nStartTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActTime, sStartTime .. ConfigTable.GetUIText("ActivityAdv_StoryUpdate"))
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
self.timer = nil
|
||||
end
|
||||
end
|
||||
self._mapNode.btn_Go.gameObject:SetActive(isOpen)
|
||||
self._mapNode.btn_Wait.gameObject:SetActive(not isOpen)
|
||||
end
|
||||
refreshTime()
|
||||
self.timer = self:AddTimer(0, 1, refreshTime, true, true, true)
|
||||
end
|
||||
function StoryCollectionActCtrl:GetTimeStr(nRemainTime)
|
||||
local sTimeStr = ""
|
||||
if nRemainTime <= 60 then
|
||||
local sec = math.floor(nRemainTime)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < nRemainTime and nRemainTime <= 3600 then
|
||||
local min = math.floor(nRemainTime / 60)
|
||||
local sec = math.floor(nRemainTime - min * 60)
|
||||
if sec == 0 then
|
||||
min = min - 1
|
||||
sec = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < nRemainTime and nRemainTime <= 86400 then
|
||||
local hour = math.floor(nRemainTime / 3600)
|
||||
local min = math.floor((nRemainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < nRemainTime then
|
||||
local day = math.floor(nRemainTime / 86400)
|
||||
local hour = math.floor((nRemainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
return sTimeStr
|
||||
end
|
||||
function StoryCollectionActCtrl:OnBtnClick_Go()
|
||||
local nEndTime = self.actData:GetActCloseTime()
|
||||
local nCurTime = ClientManager.serverTimeStamp
|
||||
if nEndTime < nCurTime then
|
||||
return
|
||||
end
|
||||
local bPlayCond = self.actData:CheckActJumpCond(true)
|
||||
if not bPlayCond then
|
||||
return
|
||||
end
|
||||
local jumpToId = self.AdConfig.JumpTo[1]
|
||||
JumpUtil.JumpTo(jumpToId)
|
||||
end
|
||||
function StoryCollectionActCtrl:OnBtnClick_Wait()
|
||||
local bPlayCond = self.actData:CheckActJumpCond(true)
|
||||
if not bPlayCond then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("ActivityAdv_StoryWait_Tip"))
|
||||
end
|
||||
return StoryCollectionActCtrl
|
||||
@@ -0,0 +1,438 @@
|
||||
local BdConvertBuildCtrl = class("BdConvertBuildCtrl", BaseCtrl)
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
local newDayTime = UTILS.GetDayRefreshTimeOffset()
|
||||
BdConvertBuildCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
BuildListContent = {},
|
||||
BuildListContent_Empty = {},
|
||||
txt_empty = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_BuildEmpty"
|
||||
},
|
||||
BuildList = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btn_sort_time = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_SortTime"
|
||||
},
|
||||
btn_sort_score = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_SortScore"
|
||||
},
|
||||
img_icon = {
|
||||
sNodeName = "img_icon_detail",
|
||||
sComponentName = "Image"
|
||||
},
|
||||
txt_title = {sComponentName = "TMP_Text"},
|
||||
txt_reward = {sComponentName = "TMP_Text"},
|
||||
sv = {},
|
||||
svItem = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
txt_SubmitTips = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_BuildTips"
|
||||
},
|
||||
txt_srot_timeTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "RoguelikeBuild_Manage_SortTime"
|
||||
},
|
||||
txt_srot_ScoreTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "RoguelikeBuild_Manage_SortScore"
|
||||
},
|
||||
txt_Allselect = {sComponentName = "TMP_Text"},
|
||||
btn_submit = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Submit"
|
||||
},
|
||||
txt_submit = {
|
||||
nCount = 2,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_Submit"
|
||||
},
|
||||
btn_submit_none = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Submit"
|
||||
},
|
||||
BdConvertFinishPanel = {
|
||||
sCtrlName = "Game.UI.Activity.BdConvert._500001.BdConvertFinishCtrl"
|
||||
},
|
||||
bg_anim = {sNodeName = "----BG----", sComponentName = "Animator"},
|
||||
anim = {
|
||||
sNodeName = "SafeAreaRoot",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
txt_detailTips = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_DesTips"
|
||||
}
|
||||
}
|
||||
BdConvertBuildCtrl._mapEventConfig = {
|
||||
BdConvert_ShowReward = "OnEvent_ShowReward",
|
||||
BdConvert_FinishPanelClose = "OnEvent_CloseReward",
|
||||
[EventId.UIBackConfirm] = "OnEvent_BackHome",
|
||||
[EventId.UIHomeConfirm] = "OnEvent_Home"
|
||||
}
|
||||
BdConvertBuildCtrl._mapRedDotConfig = {}
|
||||
local SortType = {Time = 1, Score = 2}
|
||||
local SortOrder = {Descending = true, Ascending = false}
|
||||
local BtnTextColor = {
|
||||
[true] = Color(0.3288888888888889, 0.43555555555555553, 0.5422222222222223, 1),
|
||||
[false] = Color(0.7288888888888889, 0.8, 0.8711111111111111, 1)
|
||||
}
|
||||
function BdConvertBuildCtrl:Awake()
|
||||
self._mapNode.BdConvertFinishPanel.gameObject:SetActive(false)
|
||||
local param = self:GetPanelParam()
|
||||
if type(param) == "table" then
|
||||
self.nActId = param[1]
|
||||
self.nOptionId = param[2]
|
||||
end
|
||||
self.actData = PlayerData.Activity:GetActivityDataById(self.nActId)
|
||||
self.nSortype = SortType.Score
|
||||
self.nSortOrder = SortOrder.Ascending
|
||||
self.tbSelected = {}
|
||||
end
|
||||
function BdConvertBuildCtrl:OnEnable()
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.6)
|
||||
self.tbItemIns = {}
|
||||
self.mapListItemCtrl = {}
|
||||
self:InitSort()
|
||||
self:InitData()
|
||||
end
|
||||
function BdConvertBuildCtrl:OnDisable()
|
||||
if self.tbItemIns ~= nil then
|
||||
for _, ctrl in pairs(self.tbItemIns) do
|
||||
self:UnbindCtrlByNode(ctrl)
|
||||
end
|
||||
end
|
||||
if self.mapListItemCtrl ~= nil then
|
||||
for _, ctrl in pairs(self.mapListItemCtrl) do
|
||||
self:UnbindCtrlByNode(ctrl)
|
||||
end
|
||||
end
|
||||
end
|
||||
function BdConvertBuildCtrl:OnDestroy()
|
||||
end
|
||||
function BdConvertBuildCtrl:InitData()
|
||||
self._tbAllBuild = self.actData:GetAllBuildByOpId(self.nOptionId)
|
||||
self.bdCfg = self.actData:GetBdConvertConfig()
|
||||
self.contentCfg = ConfigTable.GetData("BdConvertContent", self.nOptionId)
|
||||
self.data = self.actData:GetBdDataBy(self.nOptionId)
|
||||
if self.data == nil then
|
||||
return
|
||||
end
|
||||
if self.contentCfg.Icon ~= "" then
|
||||
self:SetPngSprite(self._mapNode.img_icon, self.contentCfg.Icon)
|
||||
end
|
||||
self.tbItem = {}
|
||||
local tbReward = decodeJson(self.contentCfg.BasicReward)
|
||||
local tbTemp = {}
|
||||
for key, value in pairs(tbReward) do
|
||||
tbTemp[tonumber(key)] = tonumber(value)
|
||||
end
|
||||
for _, rewardId in ipairs(self.contentCfg.BasicRewardPreview) do
|
||||
table.insert(self.tbItem, {
|
||||
itemId = rewardId,
|
||||
itemCount = tbTemp[rewardId]
|
||||
})
|
||||
end
|
||||
self._mapNode.svItem:Init(#self.tbItem, self, self.OnRewardItemGridRefresh, self.OnGridBtnClick)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_title, self.contentCfg.Des)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_reward, ConfigTable.GetUIText("BdConvert_RewardTitle") .. " " .. self.data.nCurSub .. "/" .. self.data.nMaxSub)
|
||||
local tbTarget = {}
|
||||
for i = 1, 5 do
|
||||
local target = self._mapNode.sv.transform:Find("Viewport/Content/target" .. i)
|
||||
target.gameObject:SetActive(false)
|
||||
table.insert(tbTarget, target)
|
||||
end
|
||||
for index, optionId in ipairs(self.contentCfg.ConvertConditionList) do
|
||||
local txt_target = tbTarget[index]:Find("txt_target"):GetComponent("TMP_Text")
|
||||
local targetCfg = ConfigTable.GetData("BdConvertCondition", optionId)
|
||||
if targetCfg ~= nil then
|
||||
NovaAPI.SetTMPText(txt_target, targetCfg.RequestDes)
|
||||
tbTarget[index].gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.sv.transform:Find("Viewport/Content"):GetComponent("RectTransform"))
|
||||
self:RefreshList()
|
||||
end
|
||||
function BdConvertBuildCtrl:OnTargetGridRefresh(goGrid, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local txt_target = goGrid.transform:Find("txt_target"):GetComponent("TMP_Text")
|
||||
local targetId = self.contentCfg.ConvertConditionList[nDataIndex]
|
||||
local targetCfg = ConfigTable.GetData("BdConvertCondition", targetId)
|
||||
if targetCfg == nil then
|
||||
return
|
||||
end
|
||||
NovaAPI.SetTMPText(txt_target, targetCfg.RequestDes)
|
||||
end
|
||||
function BdConvertBuildCtrl:OnRewardItemGridRefresh(goGrid, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local itemId = self.tbItem[nDataIndex].itemId
|
||||
local goItem = goGrid.transform:Find("btnGrid/AnimRoot/tcItem").gameObject
|
||||
local instanceId = goItem:GetInstanceID()
|
||||
if self.tbItemIns[instanceId] == nil then
|
||||
self.tbItemIns[instanceId] = self:BindCtrlByNode(goItem, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
end
|
||||
local bGet = self.data.nCurSub == self.data.nMaxSub
|
||||
self.tbItemIns[instanceId]:SetItem(itemId, nil, self.tbItem[nDataIndex].itemCount, nil, bGet)
|
||||
end
|
||||
function BdConvertBuildCtrl:OnGridBtnClick(goGrid, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local itemId = self.tbItem[nDataIndex].itemId
|
||||
UTILS.ClickItemGridWithTips(itemId, goGrid.transform:Find("btnGrid"), true, false, false)
|
||||
end
|
||||
function BdConvertBuildCtrl:InitSort()
|
||||
NovaAPI.SetTMPColor(self._mapNode.txt_srot_timeTitle, BtnTextColor[self.nSortype == SortType.Time])
|
||||
NovaAPI.SetTMPColor(self._mapNode.txt_srot_ScoreTitle, BtnTextColor[self.nSortype == SortType.Score])
|
||||
self._mapNode.btn_sort_score.transform:Find("AnimRoot/btn_AsceIcon"):GetComponent("Button").interactable = self.nSortype == SortType.Score and self.nSortOrder == SortOrder.Ascending
|
||||
self._mapNode.btn_sort_score.transform:Find("AnimRoot/btn_DescIcon"):GetComponent("Button").interactable = self.nSortype == SortType.Score and self.nSortOrder == SortOrder.Descending
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_AsceIcon"):GetComponent("Button").interactable = self.nSortype == SortType.Time and self.nSortOrder == SortOrder.Ascending
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_DescIcon"):GetComponent("Button").interactable = self.nSortype == SortType.Time and self.nSortOrder == SortOrder.Descending
|
||||
end
|
||||
function BdConvertBuildCtrl:OnBtnClick_AAA()
|
||||
end
|
||||
function BdConvertBuildCtrl:OnEvent_AAA()
|
||||
end
|
||||
function BdConvertBuildCtrl:RefreshList()
|
||||
self._tbAllBuild = self.actData:GetAllBuildByOpId(self.nOptionId)
|
||||
if #self._tbAllBuild == 0 then
|
||||
self._mapNode.BuildListContent:SetActive(false)
|
||||
self._mapNode.BuildListContent_Empty:SetActive(true)
|
||||
self._mapNode.btn_submit_none.gameObject:SetActive(true)
|
||||
self._mapNode.btn_submit.gameObject:SetActive(false)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_Empty, ConfigTable.GetUIText("RoguelikeBuild_Manage_EmptyList"))
|
||||
self:RerfeshSelected()
|
||||
return
|
||||
else
|
||||
self._mapNode.BuildListContent:SetActive(true)
|
||||
self._mapNode.btn_submit_none.gameObject:SetActive(false)
|
||||
self._mapNode.btn_submit.gameObject:SetActive(true)
|
||||
end
|
||||
self:SortBuildData()
|
||||
self._mapNode.BuildList:Init(#self._tbAllBuild, self, self.RefreshBuildGrid, self.OnBtnCal)
|
||||
self:RerfeshSelected()
|
||||
end
|
||||
function BdConvertBuildCtrl:RefreshBuildGrid(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self._tbAllBuild[nIndex]
|
||||
if self.mapListItemCtrl[goGrid] == nil then
|
||||
self.mapListItemCtrl[goGrid] = self:BindCtrlByNode(goGrid, "Game.UI.Activity.BdConvert._500001.BdConvertBuildItemCtrl")
|
||||
self.mapListItemCtrl[goGrid]:Init(self)
|
||||
end
|
||||
self.mapListItemCtrl[goGrid]:RefreshGrid(mapData)
|
||||
local index = table.indexof(self.tbSelected, mapData)
|
||||
if 0 < index then
|
||||
self:RerfeshSelected()
|
||||
end
|
||||
end
|
||||
function BdConvertBuildCtrl:RerfeshSelected()
|
||||
EventManager.Hit("BdConvert_BuildCancleSelect")
|
||||
for index, data in ipairs(self.tbSelected) do
|
||||
EventManager.Hit("BdConvert_BuildRefreshIndex", data, index)
|
||||
end
|
||||
local str = string.format("<color=#0abec5>%s</color>/%s", #self.tbSelected, self.data.nMaxSub - self.data.nCurSub)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_Allselect, ConfigTable.GetUIText("BdConvert_Selected") .. " " .. str)
|
||||
end
|
||||
function BdConvertBuildCtrl:ClearSelectedData()
|
||||
self.tbSelected = {}
|
||||
self:RerfeshSelected()
|
||||
end
|
||||
function BdConvertBuildCtrl:SortBuildData()
|
||||
if self.nSortype == SortType.Time then
|
||||
local sortByTime = function(a, b)
|
||||
if self.nSortOrder == SortOrder.Descending then
|
||||
return a.nBuildId > b.nBuildId
|
||||
else
|
||||
return a.nBuildId < b.nBuildId
|
||||
end
|
||||
end
|
||||
table.sort(self._tbAllBuild, sortByTime)
|
||||
else
|
||||
local sortByScore = function(a, b)
|
||||
if self.nSortOrder == SortOrder.Descending then
|
||||
if a.nScore ~= b.nScore then
|
||||
return a.nScore > b.nScore
|
||||
else
|
||||
return a.nBuildId > b.nBuildId
|
||||
end
|
||||
elseif a.nScore ~= b.nScore then
|
||||
return a.nScore < b.nScore
|
||||
else
|
||||
return a.nBuildId > b.nBuildId
|
||||
end
|
||||
end
|
||||
table.sort(self._tbAllBuild, sortByScore)
|
||||
end
|
||||
end
|
||||
function BdConvertBuildCtrl:OnBtnClick_SortTime(btn)
|
||||
if self.nSortype == SortType.Time then
|
||||
self.nSortOrder = not self.nSortOrder
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_AsceIcon"):GetComponent("Button").interactable = self.nSortOrder == SortOrder.Ascending
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_DescIcon"):GetComponent("Button").interactable = self.nSortOrder == SortOrder.Descending
|
||||
else
|
||||
self.nSortype = SortType.Time
|
||||
self.nSortOrder = SortOrder.Descending
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_AsceIcon"):GetComponent("Button").interactable = false
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_DescIcon"):GetComponent("Button").interactable = true
|
||||
self._mapNode.btn_sort_score.transform:Find("AnimRoot/btn_AsceIcon"):GetComponent("Button").interactable = false
|
||||
self._mapNode.btn_sort_score.transform:Find("AnimRoot/btn_DescIcon"):GetComponent("Button").interactable = false
|
||||
NovaAPI.SetTMPColor(self._mapNode.txt_srot_timeTitle, BtnTextColor[self.nSortype == SortType.Time])
|
||||
NovaAPI.SetTMPColor(self._mapNode.txt_srot_ScoreTitle, BtnTextColor[self.nSortype == SortType.Score])
|
||||
end
|
||||
self:RefreshList()
|
||||
end
|
||||
function BdConvertBuildCtrl:OnBtnClick_SortScore(btn)
|
||||
if self.nSortype == SortType.Score then
|
||||
self.nSortOrder = not self.nSortOrder
|
||||
self._mapNode.btn_sort_score.transform:Find("AnimRoot/btn_AsceIcon"):GetComponent("Button").interactable = self.nSortOrder == SortOrder.Ascending
|
||||
self._mapNode.btn_sort_score.transform:Find("AnimRoot/btn_DescIcon"):GetComponent("Button").interactable = self.nSortOrder == SortOrder.Descending
|
||||
else
|
||||
self.nSortype = SortType.Score
|
||||
self.nSortOrder = SortOrder.Descending
|
||||
self._mapNode.btn_sort_score.transform:Find("AnimRoot/btn_AsceIcon"):GetComponent("Button").interactable = false
|
||||
self._mapNode.btn_sort_score.transform:Find("AnimRoot/btn_DescIcon"):GetComponent("Button").interactable = true
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_AsceIcon"):GetComponent("Button").interactable = false
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_DescIcon"):GetComponent("Button").interactable = false
|
||||
NovaAPI.SetTMPColor(self._mapNode.txt_srot_timeTitle, BtnTextColor[self.nSortype == SortType.Time])
|
||||
NovaAPI.SetTMPColor(self._mapNode.txt_srot_ScoreTitle, BtnTextColor[self.nSortype == SortType.Score])
|
||||
end
|
||||
self:RefreshList()
|
||||
end
|
||||
function BdConvertBuildCtrl:OnBtnClickGrid(nIdx, itemCtrl)
|
||||
local mapBuild = self._tbAllBuild[nIdx]
|
||||
if mapBuild.bLock then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("BdConvert_LockTips"))
|
||||
return
|
||||
end
|
||||
local index = table.indexof(self.tbSelected, itemCtrl._mapData)
|
||||
if index ~= nil and 0 < index then
|
||||
table.remove(self.tbSelected, index)
|
||||
self:RerfeshSelected()
|
||||
return
|
||||
end
|
||||
if #self.tbSelected >= self.data.nMaxSub - self.data.nCurSub then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("BdConvert_SelectedMaxTips"))
|
||||
return
|
||||
end
|
||||
table.insert(self.tbSelected, mapBuild)
|
||||
self:RerfeshSelected()
|
||||
end
|
||||
function BdConvertBuildCtrl:OpenBuildDes(nIdx, itemCtrl)
|
||||
local mapBuild = self._tbAllBuild[nIdx]
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BdConvertBuildDetail, mapBuild, self.actData)
|
||||
end
|
||||
function BdConvertBuildCtrl:OnBuildGridLock(nIdx, itemCtrl)
|
||||
local mapBuild = self._tbAllBuild[nIdx]
|
||||
local callback = function()
|
||||
itemCtrl:SetLockState(mapBuild.bLock)
|
||||
self:RerfeshSelected()
|
||||
end
|
||||
self.actData:ChangeBuildLock(mapBuild.nBuildId, not mapBuild.bLock, callback)
|
||||
end
|
||||
function BdConvertBuildCtrl:OnBtnClick_Submit()
|
||||
if #self.tbSelected == 0 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("BdConvert_SubmitNoneTips"))
|
||||
return
|
||||
end
|
||||
local bHasHighLevelBuild = false
|
||||
for _, mapBuild in ipairs(self.tbSelected) do
|
||||
if mapBuild.mapRank.Level >= self.contentCfg.DoubleCheckMinLevel then
|
||||
bHasHighLevelBuild = true
|
||||
break
|
||||
end
|
||||
end
|
||||
local tbBuildId = {}
|
||||
for _, buildData in ipairs(self.tbSelected) do
|
||||
table.insert(tbBuildId, buildData.nBuildId)
|
||||
end
|
||||
if bHasHighLevelBuild then
|
||||
local TipsTime = LocalData.GetPlayerLocalData("BdConvert_BuildTips_Time")
|
||||
local _tipDay = 0
|
||||
if TipsTime ~= nil then
|
||||
_tipDay = tonumber(TipsTime)
|
||||
end
|
||||
local curTimeStamp = CS.ClientManager.Instance.serverTimeStampWithTimeZone
|
||||
local fixedTimeStamp = curTimeStamp + newDayTime * 3600
|
||||
local nYear = tonumber(os.date("!%Y", fixedTimeStamp))
|
||||
local nMonth = tonumber(os.date("!%m", fixedTimeStamp))
|
||||
local nDay = tonumber(os.date("!%d", fixedTimeStamp))
|
||||
local nowD = nYear * 366 + nMonth * 31 + nDay
|
||||
if nowD == _tipDay then
|
||||
self.actData:RequestSubmitBuild(self.nOptionId, tbBuildId)
|
||||
self:ClearSelectedData()
|
||||
else
|
||||
local isSelectAgain = false
|
||||
local confirmCallback = function()
|
||||
if isSelectAgain then
|
||||
local _curTimeStamp = CS.ClientManager.Instance.serverTimeStampWithTimeZone
|
||||
local _fixedTimeStamp = _curTimeStamp + newDayTime * 3600
|
||||
local _nYear = tonumber(os.date("!%Y", _fixedTimeStamp))
|
||||
local _nMonth = tonumber(os.date("!%m", _fixedTimeStamp))
|
||||
local _nDay = tonumber(os.date("!%d", _fixedTimeStamp))
|
||||
local _nowD = _nYear * 366 + _nMonth * 31 + _nDay
|
||||
LocalData.SetPlayerLocalData("BdConvert_BuildTips_Time", tostring(_nowD))
|
||||
end
|
||||
self:ClearSelectedData()
|
||||
self.actData:RequestSubmitBuild(self.nOptionId, tbBuildId)
|
||||
end
|
||||
local againCallback = function(isSelect)
|
||||
isSelectAgain = isSelect
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("BdConvert_CheckTips"),
|
||||
callbackConfirmAfterClose = confirmCallback,
|
||||
callbackAgain = againCallback
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
else
|
||||
self.actData:RequestSubmitBuild(self.nOptionId, tbBuildId)
|
||||
self:ClearSelectedData()
|
||||
end
|
||||
end
|
||||
function BdConvertBuildCtrl:OnEvent_ShowReward(tbItem, icon)
|
||||
if tbItem == nil or #tbItem == 0 then
|
||||
return
|
||||
end
|
||||
local tbItemData = {}
|
||||
for _, itemData in ipairs(tbItem) do
|
||||
table.insert(tbItemData, {
|
||||
id = itemData.Tid,
|
||||
count = itemData.Qty
|
||||
})
|
||||
end
|
||||
local callback = function()
|
||||
self:InitData()
|
||||
if self.data.nCurSub == self.data.nMaxSub then
|
||||
self:OnEvent_BackHome(PanelId.BdConvertBuildPanel)
|
||||
end
|
||||
end
|
||||
self._mapNode.BdConvertFinishPanel.gameObject:SetActive(true)
|
||||
self._mapNode.BdConvertFinishPanel:ShowReward(tbItemData, icon, callback)
|
||||
end
|
||||
function BdConvertBuildCtrl:OnEvent_CloseReward()
|
||||
self._mapNode.BdConvertFinishPanel.gameObject:SetActive(false)
|
||||
end
|
||||
function BdConvertBuildCtrl:OnEvent_BackHome(nPanelId)
|
||||
if nPanelId == PanelId.BdConvertBuildPanel then
|
||||
self._mapNode.anim:Play("BdConvertBuildPanel_out")
|
||||
self._mapNode.bg_anim:Play("BdConvertBuildPanel_Bg_out")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
|
||||
self:AddTimer(1, 0.2, function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.BdConvertBuildPanel)
|
||||
end, true, true, true)
|
||||
end
|
||||
end
|
||||
function BdConvertBuildCtrl:OnEvent_Home(nPanelId)
|
||||
if nPanelId == PanelId.BdConvertBuildPanel then
|
||||
PanelManager.Home()
|
||||
end
|
||||
end
|
||||
return BdConvertBuildCtrl
|
||||
@@ -0,0 +1,98 @@
|
||||
local BdConvertBuildDetailCtrl = class("BdConvertBuildDetailCtrl", BaseCtrl)
|
||||
BdConvertBuildDetailCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
TMPBuildSaveTime = {sComponentName = "TMP_Text"},
|
||||
btnRename = {},
|
||||
btn_Preference = {},
|
||||
txtBuildLock = {sComponentName = "TMP_Text"},
|
||||
btn_Lock = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Lock"
|
||||
},
|
||||
btn_LockIcon = {sComponentName = "Button"},
|
||||
btnDelete = {},
|
||||
ani_root = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
BuildDetail = {
|
||||
sCtrlName = "Game.UI.StarTower.Build.StarTowerBuildDetailItemCtrl"
|
||||
},
|
||||
ContentList = {
|
||||
sCtrlName = "Game.UI.StarTower.Build.StarTowerBuildContentCtrl"
|
||||
}
|
||||
}
|
||||
BdConvertBuildDetailCtrl._mapEventConfig = {}
|
||||
function BdConvertBuildDetailCtrl:InitPanel()
|
||||
self._mapNode.btnRename:SetActive(false)
|
||||
self._mapNode.btn_Preference:SetActive(false)
|
||||
self._mapNode.btnDelete:SetActive(false)
|
||||
if not self.mapBuild.bDetail then
|
||||
print("build数据错误 无详细数据")
|
||||
return
|
||||
end
|
||||
self._mapNode.BuildDetail:Refresh(self.mapBuild)
|
||||
self._mapNode.ContentList:Refresh(self.mapBuild)
|
||||
self._mapNode.btn_LockIcon.interactable = self.mapBuild.bLock
|
||||
NovaAPI.SetTMPText(self._mapNode.txtBuildLock, self.mapBuild.bLock and ConfigTable.GetUIText("RoguelikeBuild_Save_Lock") or ConfigTable.GetUIText("RoguelikeBuild_Save_Unlock"))
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtBuildLock, self.mapBuild.bLock and Color(0.14901960784313725, 0.25882352941176473, 0.47058823529411764) or Color(0.5803921568627451, 0.6666666666666666, 0.7529411764705882))
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPBuildSaveTime, string.format("<color=#5e89b4>保存时间:</color>%s", os.date("%Y/%m/%d %H:%M", math.floor(self.mapBuild.nBuildId / 1.0E9))))
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:OpenConfirmHint()
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:Awake()
|
||||
self.tbCoinRate = ConfigTable.GetConfigArray("StarTowerBuildTransformParas")
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.mapBuild = tbParam[1]
|
||||
self.actData = tbParam[2]
|
||||
end
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:OnEnable()
|
||||
self:InitPanel()
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:OnDisable()
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:OnDestroy()
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:OnRelease()
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:OnBtnClick_Preference(btn)
|
||||
local tbPreferenceCheckIn = {}
|
||||
local tbPreferenceCheckOut = {}
|
||||
local callback = function()
|
||||
self._mapNode.btn_PreferenceIcon.interactable = self.mapBuild.bPreference
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtLike, self.mapBuild.bPreference and Color(0.14901960784313725, 0.25882352941176473, 0.47058823529411764) or Color(0.5803921568627451, 0.6666666666666666, 0.7529411764705882))
|
||||
end
|
||||
if self.mapBuild.bPreference then
|
||||
table.insert(tbPreferenceCheckOut, self.mapBuild.nBuildId)
|
||||
else
|
||||
table.insert(tbPreferenceCheckIn, self.mapBuild.nBuildId)
|
||||
end
|
||||
PlayerData.Build:SetBuildPreference(tbPreferenceCheckIn, tbPreferenceCheckOut, callback)
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:OnBtnClick_Lock(btn)
|
||||
local callback = function()
|
||||
self._mapNode.btn_LockIcon.interactable = self.mapBuild.bLock
|
||||
NovaAPI.SetTMPText(self._mapNode.txtBuildLock, self.mapBuild.bLock and ConfigTable.GetUIText("RoguelikeBuild_Save_Lock") or ConfigTable.GetUIText("RoguelikeBuild_Save_Unlock"))
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtBuildLock, self.mapBuild.bLock and Color(0.14901960784313725, 0.25882352941176473, 0.47058823529411764) or Color(0.5803921568627451, 0.6666666666666666, 0.7529411764705882))
|
||||
end
|
||||
self.actData:ChangeBuildLock(self.mapBuild.nBuildId, not self.mapBuild.bLock, callback)
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:OnBtnClick_DeleteBuild(btn)
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:OnBtnClick_Rename(btn)
|
||||
end
|
||||
function BdConvertBuildDetailCtrl:OnBtnClick_CharInfo(btn, nIndex)
|
||||
local nCharTid = self.mapBuild.tbChar[nIndex].nTid
|
||||
local tbChar = {
|
||||
self.mapBuild.tbChar[1].nTid,
|
||||
self.mapBuild.tbChar[2].nTid,
|
||||
self.mapBuild.tbChar[3].nTid
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharBgPanel, PanelId.CharInfo, nCharTid, tbChar)
|
||||
end
|
||||
return BdConvertBuildDetailCtrl
|
||||
@@ -0,0 +1,19 @@
|
||||
local BdConvertBuildDetailPanel = class("BdConvertBuildDetailPanel", BasePanel)
|
||||
BdConvertBuildDetailPanel._sUIResRootPath = "UI_Activity/"
|
||||
BdConvertBuildDetailPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "_500001/BdConvertBuildDetailPanel.prefab",
|
||||
sCtrlName = "Game.UI.Activity.BdConvert._500001.BdConvertBuildDetailCtrl"
|
||||
}
|
||||
}
|
||||
function BdConvertBuildDetailPanel:Awake()
|
||||
end
|
||||
function BdConvertBuildDetailPanel:OnEnable()
|
||||
end
|
||||
function BdConvertBuildDetailPanel:OnDisable()
|
||||
end
|
||||
function BdConvertBuildDetailPanel:OnDestroy()
|
||||
end
|
||||
function BdConvertBuildDetailPanel:OnRelease()
|
||||
end
|
||||
return BdConvertBuildDetailPanel
|
||||
@@ -0,0 +1,165 @@
|
||||
local BdConvertBuildItemCtrl = class("BdConvertBuildItemCtrl", BaseCtrl)
|
||||
local PanelState = {
|
||||
Normal = 1,
|
||||
Delete = 2,
|
||||
Preference = 3
|
||||
}
|
||||
BdConvertBuildItemCtrl._mapNodeConfig = {
|
||||
img_SelectPreference = {},
|
||||
btn_LockIcon = {sComponentName = "Button"},
|
||||
btn_grid = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Grid"
|
||||
},
|
||||
btn_Lock = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Lock"
|
||||
},
|
||||
imgRareFrame = {sComponentName = "Image"},
|
||||
imgRareScore = {sComponentName = "Image"},
|
||||
txtBuildName = {sComponentName = "TMP_Text"},
|
||||
imgLike = {},
|
||||
txtLeaderCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Build_Leader"
|
||||
},
|
||||
txtSubCn = {
|
||||
nCount = 2,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Build_Sub"
|
||||
},
|
||||
imgCharIcon = {nCount = 3, sComponentName = "Image"},
|
||||
imgCharFrame = {nCount = 3, sComponentName = "Image"},
|
||||
txtPotentialCount = {nCount = 3, sComponentName = "TMP_Text"},
|
||||
imgCharElement = {nCount = 3, sComponentName = "Image"},
|
||||
txtChar = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Build_Char_Title"
|
||||
},
|
||||
txtDisc = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Build_MainDisc_Title"
|
||||
},
|
||||
goDiscItem = {
|
||||
nCount = 3,
|
||||
sCtrlName = "Game.UI.StarTower.Build.BuildSimpleDiscItem"
|
||||
},
|
||||
objUnavailable = {},
|
||||
objUnavailableIcon = {sComponentName = "Image"},
|
||||
imgRareScoreMask = {sComponentName = "Image"},
|
||||
texUnavailable = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "InfinityTower_Build_NotAvailable"
|
||||
},
|
||||
imgUnavailable = {},
|
||||
imgBuildUsed = {},
|
||||
txtBuildUsed = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "JointDrill_Build_Used"
|
||||
},
|
||||
imgCharUsed = {},
|
||||
txtCharUsed = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "JointDrill_Build_Char_Used"
|
||||
},
|
||||
selectedIndex = {},
|
||||
txt_select_index = {sComponentName = "TMP_Text"},
|
||||
txt_select = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_Selected"
|
||||
}
|
||||
}
|
||||
BdConvertBuildItemCtrl._mapEventConfig = {
|
||||
BdConvert_BuildRefreshIndex = "RefreshIndex",
|
||||
BdConvert_BuildCancleSelect = "CancleSelected"
|
||||
}
|
||||
function BdConvertBuildItemCtrl:RefreshGrid(mapData)
|
||||
self._mapData = mapData
|
||||
self:RefreshInfo()
|
||||
self:RefreshChar()
|
||||
self:RefreshDisc()
|
||||
self:CancleSelected()
|
||||
end
|
||||
function BdConvertBuildItemCtrl:RefreshInfo()
|
||||
local sScore = "Icon/BuildRank/BuildRank_" .. self._mapData.mapRank.Id
|
||||
local sFrame = AllEnum.FrameType_New.BuildRankDB .. AllEnum.FrameColor_New[self._mapData.mapRank.Rarity]
|
||||
self:SetPngSprite(self._mapNode.imgRareScore, sScore)
|
||||
self:SetAtlasSprite(self._mapNode.imgRareFrame, "12_rare", sFrame)
|
||||
if self._mapData.sName == "" or self._mapData.sName == nil then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtBuildName, ConfigTable.GetUIText("RoguelikeBuild_EmptyBuildName"))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtBuildName, self._mapData.sName)
|
||||
end
|
||||
self._mapNode.imgLike:SetActive(self._mapData.bPreference)
|
||||
self._mapNode.btn_LockIcon.interactable = self._mapData.bLock
|
||||
end
|
||||
function BdConvertBuildItemCtrl:RefreshChar()
|
||||
for i = 1, 3 do
|
||||
local nCharTid = self._mapData.tbChar[i].nTid
|
||||
local nCharSkinId = PlayerData.Char:GetCharSkinId(nCharTid)
|
||||
local mapCharSkin = ConfigTable.GetData_CharacterSkin(nCharSkinId)
|
||||
local mapCharCfg = ConfigTable.GetData_Character(nCharTid)
|
||||
local sFrame = AllEnum.FrameType_New.BoardFrame .. AllEnum.BoardFrameColor[mapCharCfg.Grade]
|
||||
self:SetPngSprite(self._mapNode.imgCharIcon[i], mapCharSkin.Icon .. AllEnum.CharHeadIconSurfix.XXL)
|
||||
self:SetAtlasSprite(self._mapNode.imgCharFrame[i], "12_rare", sFrame)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPotentialCount[i], self._mapData.tbChar[i].nPotentialCount)
|
||||
self:SetAtlasSprite(self._mapNode.imgCharElement[i], "12_rare", AllEnum.Char_Element[mapCharCfg.EET].icon)
|
||||
end
|
||||
end
|
||||
function BdConvertBuildItemCtrl:RefreshDisc()
|
||||
local tbDisc = self._mapData.tbDisc
|
||||
local nIndex = 1
|
||||
for _, nId in ipairs(tbDisc) do
|
||||
if nil ~= self._mapNode.goDiscItem[nIndex] and nIndex <= 3 then
|
||||
self._mapNode.goDiscItem[nIndex]:Init(nId)
|
||||
end
|
||||
nIndex = nIndex + 1
|
||||
end
|
||||
end
|
||||
function BdConvertBuildItemCtrl:RefreshIndex(mapData, nIndex)
|
||||
if mapData ~= self._mapData then
|
||||
return
|
||||
end
|
||||
self:Selected(nIndex)
|
||||
end
|
||||
function BdConvertBuildItemCtrl:Init(parentCtrl)
|
||||
self._parentCtrl = parentCtrl
|
||||
end
|
||||
function BdConvertBuildItemCtrl:SetLockState(bLock)
|
||||
self._mapNode.btn_LockIcon.interactable = bLock
|
||||
end
|
||||
function BdConvertBuildItemCtrl:CancleSelected()
|
||||
self._mapNode.img_SelectPreference:SetActive(false)
|
||||
self._mapNode.selectedIndex:SetActive(false)
|
||||
end
|
||||
function BdConvertBuildItemCtrl:Selected(nIndex)
|
||||
self._mapNode.img_SelectPreference:SetActive(true)
|
||||
self._mapNode.selectedIndex:SetActive(true)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_select_index, nIndex)
|
||||
end
|
||||
function BdConvertBuildItemCtrl:Awake()
|
||||
end
|
||||
function BdConvertBuildItemCtrl:OnEnable()
|
||||
end
|
||||
function BdConvertBuildItemCtrl:OnDisable()
|
||||
end
|
||||
function BdConvertBuildItemCtrl:OnDestroy()
|
||||
end
|
||||
function BdConvertBuildItemCtrl:OnRelease()
|
||||
end
|
||||
function BdConvertBuildItemCtrl:OnBtnClick_Grid(btn)
|
||||
if btn.Operate_Type == 0 then
|
||||
local nIndex = tonumber(self.gameObject.name) + 1
|
||||
self._parentCtrl:OnBtnClickGrid(nIndex, self)
|
||||
elseif btn.Operate_Type == 2 then
|
||||
local nIndex = tonumber(self.gameObject.name) + 1
|
||||
self._parentCtrl:OpenBuildDes(nIndex, self)
|
||||
end
|
||||
end
|
||||
function BdConvertBuildItemCtrl:OnBtnClick_Lock(btn)
|
||||
local nIndex = tonumber(self.gameObject.name) + 1
|
||||
self._parentCtrl:OnBuildGridLock(nIndex, self)
|
||||
end
|
||||
function BdConvertBuildItemCtrl:OnBtnClick_Preference(btn)
|
||||
end
|
||||
return BdConvertBuildItemCtrl
|
||||
@@ -0,0 +1,24 @@
|
||||
local BdConvertBuildPanel = class("BdConvertBuildPanel", BasePanel)
|
||||
BdConvertBuildPanel._bIsMainPanel = true
|
||||
BdConvertBuildPanel._bAddToBackHistory = true
|
||||
BdConvertBuildPanel._sSortingLayerName = AllEnum.SortingLayerName.UI
|
||||
BdConvertBuildPanel._sUIResRootPath = "UI_Activity/"
|
||||
BdConvertBuildPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "_500001/BdConvertBuildPanel.prefab",
|
||||
sCtrlName = "Game.UI.Activity.BdConvert._500001.BdConvertBuildCtrl"
|
||||
}
|
||||
}
|
||||
function BdConvertBuildPanel:Awake()
|
||||
end
|
||||
function BdConvertBuildPanel:OnEnable()
|
||||
end
|
||||
function BdConvertBuildPanel:OnAfterEnter()
|
||||
end
|
||||
function BdConvertBuildPanel:OnDisable()
|
||||
end
|
||||
function BdConvertBuildPanel:OnDestroy()
|
||||
end
|
||||
function BdConvertBuildPanel:OnRelease()
|
||||
end
|
||||
return BdConvertBuildPanel
|
||||
@@ -0,0 +1,167 @@
|
||||
local BdConvertCellCtrl = class("BdConvertCellCtrl", BaseCtrl)
|
||||
local minHeight = 85.26
|
||||
BdConvertCellCtrl._mapNodeConfig = {
|
||||
bg = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
img_unOpen = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txt_unOpenTips = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_UnopenTips"
|
||||
},
|
||||
txt_unOpen = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_Unopen"
|
||||
},
|
||||
txt_finishTips = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_Finish"
|
||||
},
|
||||
icon = {sComponentName = "Image"},
|
||||
txt_title = {sComponentName = "TMP_Text"},
|
||||
bg_reward = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txt_reward = {sComponentName = "TMP_Text"},
|
||||
svItem = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
icon_com = {},
|
||||
img_finish = {},
|
||||
btnGrid = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_JumpTo"
|
||||
},
|
||||
btnGrid_None = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_JumpTo"
|
||||
},
|
||||
txt_btn = {
|
||||
nCount = 2,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_ToBuild"
|
||||
},
|
||||
txt_tip = {sComponentName = "TMP_Text"},
|
||||
icon_star = {},
|
||||
Content = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
target = {nCount = 3}
|
||||
}
|
||||
function BdConvertCellCtrl:Awake()
|
||||
self.tbItemIns = {}
|
||||
end
|
||||
function BdConvertCellCtrl:OnDisable()
|
||||
if self.tbItemIns ~= nil then
|
||||
for _, ctrl in pairs(self.tbItemIns) do
|
||||
self:UnbindCtrlByNode(ctrl)
|
||||
end
|
||||
end
|
||||
self.tbItemIns = {}
|
||||
end
|
||||
function BdConvertCellCtrl:SetData(actId, optionId)
|
||||
self.nActId = actId
|
||||
self.nOptionId = optionId
|
||||
self.actData = PlayerData.Activity:GetActivityDataById(self.nActId)
|
||||
self.contentData = self.actData:GetBdDataBy(self.nOptionId)
|
||||
local contentCfg = ConfigTable.GetData("BdConvertContent", self.nOptionId)
|
||||
if contentCfg == nil then
|
||||
return
|
||||
end
|
||||
local data = self.actData:GetBdDataBy(optionId)
|
||||
if data == nil then
|
||||
return
|
||||
end
|
||||
self._mapNode.img_unOpen.gameObject:SetActive(data.bIsOpen == false)
|
||||
if contentCfg.Icon ~= "" then
|
||||
self:SetPngSprite(self._mapNode.icon, contentCfg.Icon)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_title, contentCfg.Des)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_reward, ConfigTable.GetUIText("BdConvert_RewardTitle") .. " " .. data.nCurSub .. "/" .. data.nMaxSub)
|
||||
self.tbItem = {}
|
||||
local tbReward = decodeJson(contentCfg.BasicReward)
|
||||
local tbTemp = {}
|
||||
for key, value in pairs(tbReward) do
|
||||
tbTemp[tonumber(key)] = tonumber(value)
|
||||
end
|
||||
for _, rewardId in ipairs(contentCfg.BasicRewardPreview) do
|
||||
table.insert(self.tbItem, {
|
||||
itemId = rewardId,
|
||||
itemCount = tbTemp[rewardId]
|
||||
})
|
||||
end
|
||||
self._mapNode.svItem:Init(#self.tbItem, self, self.OnRewardItemGridRefresh, self.OnGridBtnClick)
|
||||
self._mapNode.icon_com:SetActive(data.nCurSub == data.nMaxSub)
|
||||
self._mapNode.img_finish:SetActive(data.nCurSub == data.nMaxSub)
|
||||
self._mapNode.icon_star:SetActive(data.nCurSub ~= data.nMaxSub)
|
||||
self._mapNode.txt_unOpen.gameObject:SetActive(data.bIsOpen == false)
|
||||
for i = 1, 3 do
|
||||
self._mapNode.target[i].gameObject:SetActive(false)
|
||||
end
|
||||
for index, optionId in ipairs(contentCfg.ConvertConditionList) do
|
||||
if index <= 3 then
|
||||
local txt_target = self._mapNode.target[index].transform:Find("txt_target"):GetComponent("TMP_Text")
|
||||
local targetCfg = ConfigTable.GetData("BdConvertCondition", optionId)
|
||||
if targetCfg ~= nil then
|
||||
NovaAPI.SetTMPText(txt_target, targetCfg.RequestDes)
|
||||
self._mapNode.target[index].gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
local nCount = 0
|
||||
local tbAllbuild = self.actData:GetAllBuildByOpId(self.nOptionId)
|
||||
if tbAllbuild ~= nil then
|
||||
nCount = #tbAllbuild
|
||||
end
|
||||
self._mapNode.btnGrid_None.gameObject:SetActive(nCount == 0)
|
||||
self._mapNode.btnGrid.gameObject:SetActive(nCount ~= 0)
|
||||
if nCount == 0 then
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_tip, ConfigTable.GetUIText("BdConvert_BuildCountTips1"))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_tip, orderedFormat(ConfigTable.GetUIText("BdConvert_BuildCountTips2"), nCount))
|
||||
end
|
||||
local bGet = self.contentData.nCurSub == self.contentData.nMaxSub
|
||||
if bGet then
|
||||
self._mapNode.btnGrid_None.gameObject:SetActive(false)
|
||||
self._mapNode.btnGrid.gameObject:SetActive(false)
|
||||
self._mapNode.txt_tip.gameObject:SetActive(false)
|
||||
self._mapNode.txt_finishTips.gameObject:SetActive(true)
|
||||
else
|
||||
self._mapNode.txt_finishTips.gameObject:SetActive(false)
|
||||
end
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.bg_reward)
|
||||
CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.Content)
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
local curHeight = self._mapNode.Content.sizeDelta.y
|
||||
local rectTransform = self.gameObject:GetComponent("RectTransform")
|
||||
rectTransform.sizeDelta = Vector2(rectTransform.sizeDelta.x, rectTransform.sizeDelta.y + curHeight - minHeight)
|
||||
self._mapNode.bg.sizeDelta = Vector2(self._mapNode.bg.sizeDelta.x, self._mapNode.bg.sizeDelta.y + curHeight - minHeight)
|
||||
CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform)
|
||||
CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.bg)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
function BdConvertCellCtrl:OnRewardItemGridRefresh(goGrid, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local itemId = self.tbItem[nDataIndex].itemId
|
||||
local goItem = goGrid.transform:Find("btnGrid/AnimRoot/tcItem").gameObject
|
||||
local instanceId = goItem:GetInstanceID()
|
||||
if self.tbItemIns[instanceId] == nil then
|
||||
self.tbItemIns[instanceId] = self:BindCtrlByNode(goItem, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
end
|
||||
local bGet = self.contentData.nCurSub == self.contentData.nMaxSub
|
||||
self.tbItemIns[instanceId]:SetItem(itemId, nil, self.tbItem[nDataIndex].itemCount, nil, bGet)
|
||||
end
|
||||
function BdConvertCellCtrl:OnGridBtnClick(goGrid, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local itemId = self.tbItem[nDataIndex].itemId
|
||||
UTILS.ClickItemGridWithTips(itemId, goGrid.transform:Find("btnGrid").transform, true, true, false)
|
||||
end
|
||||
function BdConvertCellCtrl:OnBtnClick_JumpTo()
|
||||
EventManager.Hit("BdConvert_JumpToBuildPanel", self.nOptionId)
|
||||
end
|
||||
return BdConvertCellCtrl
|
||||
@@ -0,0 +1,223 @@
|
||||
local BdConvertCtrl = class("BdConvertCtrl", BaseCtrl)
|
||||
local LocalSettingData = require("GameCore.Data.LocalSettingData")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local barMinX = -378
|
||||
local barMaxX = 0
|
||||
BdConvertCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
txt_quest = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_QuestTitle"
|
||||
},
|
||||
redDotQuest = {},
|
||||
btn_quest = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Quest"
|
||||
},
|
||||
txt_mainProcess = {sComponentName = "TMP_Text"},
|
||||
imgMainBarFill = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
Actor2D = {
|
||||
sNodeName = "----Actor2D----"
|
||||
},
|
||||
btn_starTower = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GoStarTower"
|
||||
},
|
||||
anim = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
bg_anim = {sNodeName = "----BG----", sComponentName = "Animator"},
|
||||
imgBgLevelSelect = {
|
||||
sNodeName = "----Actor2D----",
|
||||
sComponentName = "RawImage"
|
||||
},
|
||||
trActor2D_PNG = {
|
||||
sNodeName = "----Actor2D_PNG----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
cell = {},
|
||||
ListContent = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
ListCanvasGroup = {
|
||||
sNodeName = "ListContent",
|
||||
sComponentName = "CanvasGroup"
|
||||
},
|
||||
txt_starTower = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_GoToStarTower"
|
||||
}
|
||||
}
|
||||
BdConvertCtrl._mapEventConfig = {
|
||||
BdConvertQuestUpdate = "InitQuest",
|
||||
BdConvert_JumpToBuildPanel = "OnEvent_JumpTo",
|
||||
[EventId.UIBackConfirm] = "OnEvent_BackHome",
|
||||
[EventId.UIHomeConfirm] = "OnEvent_Home"
|
||||
}
|
||||
BdConvertCtrl._mapRedDotConfig = {
|
||||
[RedDotDefine.Activity_BdConvert_AllQuest] = {
|
||||
sNodeName = "redDotQuest"
|
||||
}
|
||||
}
|
||||
function BdConvertCtrl:Awake()
|
||||
local param = self:GetPanelParam()
|
||||
if type(param) == "table" then
|
||||
self.nActId = param[1]
|
||||
end
|
||||
self.actData = PlayerData.Activity:GetActivityDataById(self.nActId)
|
||||
self.bInAnim_In = false
|
||||
end
|
||||
function BdConvertCtrl:OnEnable()
|
||||
if self._panel.bPlayedAnim_In then
|
||||
EventManager.Hit(EventId.BlockInput, true)
|
||||
self._mapNode.anim:Play("BdConVertPanel_in_02")
|
||||
self._mapNode.bg_anim:Play("BdConvertPanel_Bg_out_02")
|
||||
self.bInAnim_In = true
|
||||
self:AddTimer(1, 0.7, function()
|
||||
self.bInAnim_In = false
|
||||
EventManager.Hit(EventId.BlockInput, false)
|
||||
end, true, true, true)
|
||||
else
|
||||
EventManager.Hit(EventId.BlockInput, true)
|
||||
self._mapNode.anim:Play("BdConVertPanel_in_01")
|
||||
self._mapNode.bg_anim:Play("BdConvertPanel_Bg_in_01")
|
||||
self.bInAnim_In = true
|
||||
self:AddTimer(1, 0.67, function()
|
||||
self.bInAnim_In = false
|
||||
EventManager.Hit(EventId.BlockInput, false)
|
||||
end, true, true, true)
|
||||
end
|
||||
self._panel.bPlayedAnim_In = true
|
||||
local bUseL2D = LocalSettingData.mapData.UseLive2D
|
||||
self._mapNode.imgBgLevelSelect.transform.localScale = bUseL2D == true and Vector3.one or Vector3.zero
|
||||
self._mapNode.trActor2D_PNG.localScale = bUseL2D == true and Vector3.zero or Vector3.one
|
||||
if bUseL2D == true then
|
||||
Actor2DManager.SetBoardNPC2D(self:GetPanelId(), self._mapNode.imgBgLevelSelect, 9102)
|
||||
else
|
||||
Actor2DManager.SetBoardNPC2D_PNG(self._mapNode.trActor2D_PNG, self:GetPanelId(), 9102)
|
||||
end
|
||||
local bResult = self.actData:CheckBuildsData()
|
||||
if bResult then
|
||||
self:UpdateOptionList()
|
||||
else
|
||||
EventManager.Hit(EventId.BlockInput, true)
|
||||
self.actData:RequestAllBuildData(function()
|
||||
if not self.bInAnim_In then
|
||||
EventManager.Hit(EventId.BlockInput, false)
|
||||
end
|
||||
self:UpdateOptionList()
|
||||
end)
|
||||
end
|
||||
self:InitQuest()
|
||||
end
|
||||
function BdConvertCtrl:OnDisable()
|
||||
Actor2DManager.UnsetBoardNPC2D()
|
||||
if self.GridIns ~= nil then
|
||||
for _, ctrl in pairs(self.GridIns) do
|
||||
self:UnbindCtrlByNode(ctrl)
|
||||
end
|
||||
end
|
||||
self.GridIns = {}
|
||||
if self.tbListCtrl ~= nil then
|
||||
for _, ctrl in pairs(self.tbListCtrl) do
|
||||
self:UnbindCtrlByNode(ctrl)
|
||||
end
|
||||
end
|
||||
self.tbListCtrl = {}
|
||||
end
|
||||
function BdConvertCtrl:UpdateOptionList()
|
||||
self.bdConfig = self.actData:GetBdConvertConfig()
|
||||
self.optionList = self.bdConfig.OptionList
|
||||
local sort = function(a, b)
|
||||
local contentA_Data = self.actData:GetBdDataBy(a)
|
||||
local contentB_Data = self.actData:GetBdDataBy(b)
|
||||
local bFinish_A = contentA_Data.nCurSub == contentA_Data.nMaxSub
|
||||
local bFinish_B = contentB_Data.nCurSub == contentB_Data.nMaxSub
|
||||
if bFinish_A and not bFinish_B then
|
||||
return false
|
||||
elseif not bFinish_A and bFinish_B then
|
||||
return true
|
||||
end
|
||||
return a < b
|
||||
end
|
||||
table.sort(self.optionList, sort)
|
||||
self.tbGridSize = {}
|
||||
for _, optionId in ipairs(self.optionList) do
|
||||
local contentCfg = ConfigTable.GetData("BdConvertContent", optionId)
|
||||
if contentCfg ~= nil then
|
||||
local height = 0
|
||||
if #contentCfg.ConvertConditionList >= 3 then
|
||||
height = 360
|
||||
else
|
||||
height = 310
|
||||
end
|
||||
table.insert(self.tbGridSize, height)
|
||||
end
|
||||
end
|
||||
delChildren(self._mapNode.ListContent.gameObject)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.ListCanvasGroup, 0)
|
||||
if self.tbListCtrl ~= nil then
|
||||
for _, ctrl in pairs(self.tbListCtrl) do
|
||||
self:UnbindCtrlByNode(ctrl)
|
||||
end
|
||||
end
|
||||
self.tbListCtrl = {}
|
||||
self.GridIns = {}
|
||||
for _, opId in ipairs(self.optionList) do
|
||||
local go = instantiate(self._mapNode.cell, self._mapNode.ListContent)
|
||||
local ctrl = self:BindCtrlByNode(go, "Game.UI.Activity.BdConvert._500001.BdConvertCellCtrl")
|
||||
ctrl:SetData(self.nActId, opId)
|
||||
table.insert(self.tbListCtrl, ctrl)
|
||||
go:SetActive(true)
|
||||
end
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.ListCanvasGroup, 1)
|
||||
CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.ListContent)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
function BdConvertCtrl:InitQuest()
|
||||
local allCount = self.actData:GetAllQuestCount()
|
||||
local receivedCount = self.actData:GetAllReceivedCount()
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_mainProcess, receivedCount .. "/" .. allCount)
|
||||
self._mapNode.imgMainBarFill.anchoredPosition = Vector2(barMinX + (barMaxX - barMinX) * (receivedCount / allCount), self._mapNode.imgMainBarFill.anchoredPosition.y)
|
||||
end
|
||||
function BdConvertCtrl:OnBtnClick_Quest()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BdConvertQuestPanel, self.nActId)
|
||||
end
|
||||
function BdConvertCtrl:OnBtnClick_GoStarTower()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.LevelMenu, 2)
|
||||
end
|
||||
function BdConvertCtrl:OnEvent_JumpTo(nOptionId)
|
||||
self._mapNode.bg_anim:Play("BdConvertPanel_Bg_in_02")
|
||||
self._mapNode.anim:Play("BdConVertPanel_out_01")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.17)
|
||||
self:AddTimer(1, 0.17, function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BdConvertBuildPanel, self.nActId, nOptionId)
|
||||
end, true, true, true)
|
||||
end
|
||||
function BdConvertCtrl:OnEvent_BackHome(nPanelId)
|
||||
if nPanelId == PanelId.BdConvertPanel then
|
||||
self._mapNode.anim:Play("BdConVertPanel_out_02")
|
||||
self._mapNode.bg_anim:Play("BdConvertPanel_Bg_out_01")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.23)
|
||||
self:AddTimer(1, 0.23, function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.BdConvertPanel)
|
||||
end, true, true, true)
|
||||
end
|
||||
end
|
||||
function BdConvertCtrl:OnEvent_Home(nPanelId)
|
||||
if nPanelId == PanelId.BdConvertPanel then
|
||||
PanelManager.Home()
|
||||
end
|
||||
end
|
||||
return BdConvertCtrl
|
||||
@@ -0,0 +1,144 @@
|
||||
local BdConvertFinishCtrl = class("BdConvertFinishCtrl", BaseCtrl)
|
||||
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
|
||||
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
|
||||
BdConvertFinishCtrl._mapNodeConfig = {
|
||||
goBlur = {
|
||||
sNodeName = "t_fullscreen_blur_black"
|
||||
},
|
||||
btn_close = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
HideRoot = {
|
||||
sNodeName = "----SafeAreaRoot----"
|
||||
},
|
||||
aniRoot = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
btnSkip = {
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Skip"
|
||||
},
|
||||
btnGrid = {},
|
||||
img_icon = {sComponentName = "Image"},
|
||||
txt_tips = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_RewardTips"
|
||||
},
|
||||
goItemList1 = {
|
||||
sComponentName = "RectTransform"
|
||||
}
|
||||
}
|
||||
BdConvertFinishCtrl._mapEventConfig = {}
|
||||
BdConvertFinishCtrl._mapRedDotConfig = {}
|
||||
function BdConvertFinishCtrl:RefreshNormal()
|
||||
for _, v in ipairs(self.tbReward) do
|
||||
local nItemId = v.id
|
||||
local goItem = instantiate(self._mapNode.btnGrid, self._mapNode.goItemList1)
|
||||
local ctrlObj = self:BindCtrlByNode(goItem, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
local mapCfg = ConfigTable.GetData_Item(nItemId)
|
||||
if mapCfg then
|
||||
if mapCfg.Type == GameEnum.itemType.Char or mapCfg.Type == GameEnum.itemType.CharacterSkin then
|
||||
ctrlObj:SetChar(nItemId, v.count, nil, v.rewardType)
|
||||
else
|
||||
ctrlObj:SetItem(nItemId, mapCfg.Rarity, v.count, nil, nil, v.rewardType and v.rewardType == AllEnum.RewardType.First, v.rewardType and v.rewardType == AllEnum.RewardType.Three, true, false, false, v.rewardType and v.rewardType == AllEnum.RewardType.Extra)
|
||||
end
|
||||
end
|
||||
local btnGrid = goItem:GetComponent("UIButton")
|
||||
btnGrid.onClick:RemoveAllListeners()
|
||||
local cbSelect = function()
|
||||
self:OnSelectItem(nItemId, btnGrid, v.nHasCount)
|
||||
EventManager.Hit("Stop_InfinityTowerAutoNextLv")
|
||||
end
|
||||
btnGrid.onClick:AddListener(cbSelect)
|
||||
goItem.gameObject:SetActive(true)
|
||||
NovaAPI.SetCanvasGroupAlpha(goItem:GetComponent("CanvasGroup"), 0)
|
||||
end
|
||||
self:PlayNormalAni()
|
||||
end
|
||||
function BdConvertFinishCtrl:OnSelectItem(itemId, btn, nHasCount)
|
||||
UTILS.ClickItemGridWithTips(itemId, btn.transform, false, true, false, nHasCount)
|
||||
end
|
||||
function BdConvertFinishCtrl:PlayNormalAni()
|
||||
self.sequence = DOTween.Sequence()
|
||||
self.sequence:AppendInterval(0.18)
|
||||
for i = 1, self.nRewardCount do
|
||||
self.sequence:AppendCallback(function()
|
||||
local goGrid = self._mapNode.goItemList1:GetChild(i - 1)
|
||||
if goGrid then
|
||||
NovaAPI.SetCanvasGroupAlpha(goGrid:GetComponent("CanvasGroup"), 1)
|
||||
local ani = goGrid.transform:Find("AnimRoot/aniGrid"):GetComponent("Animator")
|
||||
ani:Play("receiveprops_icon_t_in")
|
||||
end
|
||||
end)
|
||||
self.sequence:AppendInterval(0.14)
|
||||
end
|
||||
self.sequence.onComplete = dotween_callback_handler(self, function()
|
||||
self:CloseSkip()
|
||||
end)
|
||||
self.sequence:SetUpdate(true)
|
||||
end
|
||||
function BdConvertFinishCtrl:ShowReward(tbReward, sIconPath, callback)
|
||||
self.tbReward = tbReward
|
||||
self.nRewardCount = #tbReward
|
||||
self.callback = callback
|
||||
local sort = function(a, b)
|
||||
local cfgA = ConfigTable.GetData_Item(a.id)
|
||||
local cfgB = ConfigTable.GetData_Item(b.id)
|
||||
local rarityA = cfgA.Rarity
|
||||
local rarityB = cfgB.Rarity
|
||||
local typeA = cfgA.Type
|
||||
local typeB = cfgB.Type
|
||||
if a.rewardType ~= nil ~= (b.rewardType ~= nil) then
|
||||
return a.rewardType ~= nil and b.rewardType == nil
|
||||
elseif a.rewardType and b.rewardType and a.rewardType ~= b.rewardType then
|
||||
return a.rewardType < b.rewardType
|
||||
elseif rarityA ~= rarityB then
|
||||
return rarityA < rarityB
|
||||
elseif typeA ~= typeB then
|
||||
return typeA < typeB
|
||||
elseif a.count ~= b.count then
|
||||
return a.count > b.count
|
||||
else
|
||||
return a.id < b.id
|
||||
end
|
||||
end
|
||||
table.sort(self.tbReward, sort)
|
||||
self:RefreshNormal()
|
||||
self:SetPngSprite(self._mapNode.img_icon:GetComponent("Image"), sIconPath)
|
||||
self._mapNode.goBlur:SetActive(true)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self._mapNode.HideRoot:SetActive(true)
|
||||
self._mapNode.aniRoot:Play("receiveprops_t_in")
|
||||
WwiseAudioMgr:PlaySound("ui_roguelike_gacha_reward")
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.5)
|
||||
end
|
||||
function BdConvertFinishCtrl:CloseSkip()
|
||||
self._mapNode.btnSkip.gameObject:SetActive(false)
|
||||
self._mapNode.btn_close.interactable = true
|
||||
end
|
||||
function BdConvertFinishCtrl:OnBtnClick_Close()
|
||||
delChildren(self._mapNode.goItemList1)
|
||||
EventManager.Hit("BdConvert_FinishPanelClose")
|
||||
if self.callback ~= nil then
|
||||
self.callback()
|
||||
end
|
||||
end
|
||||
function BdConvertFinishCtrl:OnBtnClick_Skip(btn)
|
||||
if self.sequence then
|
||||
self.sequence:Kill()
|
||||
self.sequence = nil
|
||||
end
|
||||
for i = 1, self.nRewardCount do
|
||||
local goGrid = self._mapNode.goItemList1:GetChild(i - 1)
|
||||
if goGrid then
|
||||
NovaAPI.SetCanvasGroupAlpha(goGrid:GetComponent("CanvasGroup"), 1)
|
||||
end
|
||||
end
|
||||
self:CloseSkip()
|
||||
end
|
||||
return BdConvertFinishCtrl
|
||||
@@ -0,0 +1,23 @@
|
||||
local BdConvertPanel = class("BdConvertPanel", BasePanel)
|
||||
BdConvertPanel._bIsMainPanel = true
|
||||
BdConvertPanel._sSortingLayerName = AllEnum.SortingLayerName.UI
|
||||
BdConvertPanel._sUIResRootPath = "UI_Activity/"
|
||||
BdConvertPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "_500001/BdConvertPanel.prefab",
|
||||
sCtrlName = "Game.UI.Activity.BdConvert._500001.BdConvertCtrl"
|
||||
}
|
||||
}
|
||||
function BdConvertPanel:Awake()
|
||||
end
|
||||
function BdConvertPanel:OnEnable()
|
||||
end
|
||||
function BdConvertPanel:OnAfterEnter()
|
||||
end
|
||||
function BdConvertPanel:OnDisable()
|
||||
end
|
||||
function BdConvertPanel:OnDestroy()
|
||||
end
|
||||
function BdConvertPanel:OnRelease()
|
||||
end
|
||||
return BdConvertPanel
|
||||
@@ -0,0 +1,143 @@
|
||||
local BdConvertQuestCtrl = class("BdConvertQuestCtrl", BaseCtrl)
|
||||
local barMinX = -750
|
||||
local barMaxX = 0
|
||||
BdConvertQuestCtrl._mapNodeConfig = {
|
||||
goBlur = {
|
||||
sNodeName = "t_fullscreen_blur_blue"
|
||||
},
|
||||
animator = {sNodeName = "quest", sComponentName = "Animator"},
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_QuestTitle"
|
||||
},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
btnFullClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
txt_socreTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_Score"
|
||||
},
|
||||
txt_score = {sComponentName = "TMP_Text"},
|
||||
sv = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btn_GetAllReward = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GetAllReward"
|
||||
},
|
||||
btn_GetAllReward_None = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GetAllReward"
|
||||
},
|
||||
txt_GetAll = {
|
||||
nCount = 2,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_GetQuestReward"
|
||||
}
|
||||
}
|
||||
BdConvertQuestCtrl._mapEventConfig = {}
|
||||
BdConvertQuestCtrl._mapRedDotConfig = {}
|
||||
function BdConvertQuestCtrl:Awake()
|
||||
local param = self:GetPanelParam()
|
||||
if type(param) == "table" then
|
||||
self.nActId = param[1]
|
||||
end
|
||||
self:InitData()
|
||||
end
|
||||
function BdConvertQuestCtrl:OnEnable()
|
||||
self._mapNode.goBlur:SetActive(true)
|
||||
self._mapNode.animator:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function BdConvertQuestCtrl:OnDestory()
|
||||
if self.tbItemCtrl ~= nil then
|
||||
for _, ctrl in pairs(self.tbItemCtrl) do
|
||||
self:UnbindCtrlByNode(ctrl)
|
||||
end
|
||||
end
|
||||
end
|
||||
function BdConvertQuestCtrl:InitData()
|
||||
self.tbItemCtrl = {}
|
||||
self.actData = PlayerData.Activity:GetActivityDataById(self.nActId)
|
||||
self.bdConfig = self.actData:GetBdConvertConfig()
|
||||
self:InitQuest()
|
||||
self:UpdateScore()
|
||||
local bHasComQuest = self.actData:CheckHasComQuest()
|
||||
self._mapNode.btn_GetAllReward.gameObject:SetActive(bHasComQuest)
|
||||
self._mapNode.btn_GetAllReward_None.gameObject:SetActive(not bHasComQuest)
|
||||
end
|
||||
function BdConvertQuestCtrl:InitQuest()
|
||||
self.questIdList = self.actData:GetQuestIdList()
|
||||
self._mapNode.sv:Init(#self.questIdList, self, self.OnGridRefresh)
|
||||
end
|
||||
function BdConvertQuestCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local instanceId = goGrid:GetInstanceID()
|
||||
local nId = self.questIdList[nIndex]
|
||||
local questData = self.actData:GetQuestDataById(nId)
|
||||
local img_Received = goGrid.transform:Find("GameObject/AnimRoot/Root/img_Received")
|
||||
local btn_item = goGrid.transform:Find("GameObject/AnimRoot/Root/btn_item"):GetComponent("UIButton")
|
||||
local item = goGrid.transform:Find("GameObject/AnimRoot/Root/btn_item/AnimRoot/item")
|
||||
if self.tbItemCtrl[instanceId] == nil then
|
||||
self.tbItemCtrl[instanceId] = self:BindCtrlByNode(item, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
end
|
||||
local txtTarget = goGrid.transform:Find("GameObject/AnimRoot/Root/txt_target"):GetComponent("TMP_Text")
|
||||
local txt_com1 = goGrid.transform:Find("GameObject/AnimRoot/txt_com1"):GetComponent("TMP_Text")
|
||||
local txt_com2 = goGrid.transform:Find("GameObject/AnimRoot/txt_com2"):GetComponent("TMP_Text")
|
||||
local bar = goGrid.transform:Find("GameObject/AnimRoot/Root/imgBarBg/rtBarFill/imgMainBarFill"):GetComponent("RectTransform")
|
||||
local img_state1 = goGrid.transform:Find("GameObject/AnimRoot/Root/img_state1").gameObject
|
||||
local img_state2 = goGrid.transform:Find("GameObject/AnimRoot/Root/img_state2").gameObject
|
||||
local img_state3 = goGrid.transform:Find("GameObject/AnimRoot/Root/img_state3").gameObject
|
||||
img_state1:SetActive(questData.nState == AllEnum.ActQuestStatus.Complete)
|
||||
img_state2:SetActive(questData.nState == AllEnum.ActQuestStatus.Received)
|
||||
img_state3:SetActive(questData.nState == AllEnum.ActQuestStatus.UnComplete)
|
||||
img_Received.gameObject:SetActive(questData.nState == AllEnum.ActQuestStatus.Received)
|
||||
btn_item.onClick:RemoveAllListeners()
|
||||
local questConfig = ConfigTable.GetData("BdConvertRewardGroup", questData.nId)
|
||||
local tbReward = decodeJson(questConfig.Rewards)
|
||||
local itemId = 0
|
||||
local itemCount = 0
|
||||
for k, v in pairs(tbReward) do
|
||||
itemId = tonumber(k)
|
||||
itemCount = tonumber(v)
|
||||
end
|
||||
btn_item.onClick:AddListener(function()
|
||||
UTILS.ClickItemGridWithTips(itemId, btn_item.transform, true, false, false)
|
||||
end)
|
||||
self.tbItemCtrl[instanceId]:SetItem(itemId, nil, itemCount, false, questData.nState == AllEnum.ActQuestStatus.Received, false, false)
|
||||
NovaAPI.SetTMPText(txtTarget, questConfig.Des)
|
||||
if questData.nState == AllEnum.ActQuestStatus.UnComplete then
|
||||
NovaAPI.SetTMPText(txt_com1, tostring(questData.nCur) .. "/" .. tostring(questData.nMax))
|
||||
NovaAPI.SetTMPText(txt_com2, tostring(questData.nCur) .. "/" .. tostring(questData.nMax))
|
||||
else
|
||||
NovaAPI.SetTMPText(txt_com1, ConfigTable.GetUIText("BdConvert_QuestFinish"))
|
||||
NovaAPI.SetTMPText(txt_com2, ConfigTable.GetUIText("BdConvert_QuestFinish"))
|
||||
end
|
||||
txt_com1.gameObject:SetActive(questData.nState ~= AllEnum.ActQuestStatus.Received)
|
||||
txt_com2.gameObject:SetActive(questData.nState == AllEnum.ActQuestStatus.Received)
|
||||
bar.anchoredPosition = Vector2(barMinX + (barMaxX - barMinX) * (questData.nCur / questData.nMax), bar.anchoredPosition.y)
|
||||
end
|
||||
function BdConvertQuestCtrl:UpdateScore()
|
||||
local nCurScore = self.actData:GetScore()
|
||||
local nMaxScore = self.bdConfig.ScoreItemLimit
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_score, string.format("<color=#D19C62>%s</color>/%s", nCurScore, nMaxScore))
|
||||
end
|
||||
function BdConvertQuestCtrl:OnBtnClick_Close()
|
||||
self._mapNode.animator:Play("t_window_04_t_out")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
self:AddTimer(1, 0.3, function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.BdConvertQuestPanel)
|
||||
end, true, true, true, nil)
|
||||
end
|
||||
function BdConvertQuestCtrl:OnBtnClick_GetAllReward()
|
||||
local callback = function()
|
||||
self:InitData()
|
||||
end
|
||||
self.actData:RequestReceiveQuest(callback)
|
||||
end
|
||||
return BdConvertQuestCtrl
|
||||
@@ -0,0 +1,23 @@
|
||||
local BdConvertQuestPanel = class("BdConvertQuestPanel", BasePanel)
|
||||
BdConvertQuestPanel._bIsMainPanel = false
|
||||
BdConvertQuestPanel._sSortingLayerName = AllEnum.SortingLayerName.UI
|
||||
BdConvertQuestPanel._sUIResRootPath = "UI_Activity/"
|
||||
BdConvertQuestPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "_500001/BdConvertQuestPanel.prefab",
|
||||
sCtrlName = "Game.UI.Activity.BdConvert._500001.BdConvertQuestCtrl"
|
||||
}
|
||||
}
|
||||
function BdConvertQuestPanel:Awake()
|
||||
end
|
||||
function BdConvertQuestPanel:OnEnable()
|
||||
end
|
||||
function BdConvertQuestPanel:OnAfterEnter()
|
||||
end
|
||||
function BdConvertQuestPanel:OnDisable()
|
||||
end
|
||||
function BdConvertQuestPanel:OnDestroy()
|
||||
end
|
||||
function BdConvertQuestPanel:OnRelease()
|
||||
end
|
||||
return BdConvertQuestPanel
|
||||
@@ -0,0 +1,182 @@
|
||||
local BdConvertActCtrl = class("BdConvertActCtrl", BaseCtrl)
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local LocalSettingData = require("GameCore.Data.LocalSettingData")
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local barMinX = -378
|
||||
local barMaxX = 0
|
||||
BdConvertActCtrl._mapNodeConfig = {
|
||||
txt_time = {sComponentName = "TMP_Text"},
|
||||
txt_des = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_DesTitle"
|
||||
},
|
||||
btn_des = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
txt_quest = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_QuestTitle"
|
||||
},
|
||||
redDotQuest = {},
|
||||
btn_quest = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Quest"
|
||||
},
|
||||
txt_mainProcess = {sComponentName = "TMP_Text"},
|
||||
imgMainBarFill = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txt_go = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_EnterActivity"
|
||||
},
|
||||
btn_go = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Go"
|
||||
},
|
||||
txtRewardTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "BdConvert_RewardPre"
|
||||
},
|
||||
svItem = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
imgBgLevelSelect = {
|
||||
sNodeName = "----Actor2D----",
|
||||
sComponentName = "RawImage"
|
||||
},
|
||||
trActor2D_PNG = {
|
||||
sNodeName = "----Actor2D_PNG----",
|
||||
sComponentName = "Transform"
|
||||
}
|
||||
}
|
||||
BdConvertActCtrl._mapEventConfig = {BdConvertQuestUpdate = "InitQuest"}
|
||||
BdConvertActCtrl._mapRedDotConfig = {
|
||||
[RedDotDefine.Activity_BdConvert_AllQuest] = {
|
||||
sNodeName = "redDotQuest"
|
||||
}
|
||||
}
|
||||
function BdConvertActCtrl:RefreshRemainTime()
|
||||
if self.actData.actCfg.EndType == GameEnum.activityEndType.NoLimit then
|
||||
self._mapNode.txt_time.transform.parent.gameObject:SetActive(false)
|
||||
else
|
||||
local endTime = self.actData:GetActEndTime()
|
||||
local curTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
if remainTime < 0 then
|
||||
TimerManager.Remove(self.remainTimer)
|
||||
self.remainTimer = nil
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1"),
|
||||
callbackConfirm = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
|
||||
end
|
||||
})
|
||||
end
|
||||
local sTimeStr = self:GetTimeText(remainTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_time, orderedFormat(ConfigTable.GetUIText("PerActivity_Remain_Time") or "", sTimeStr))
|
||||
end
|
||||
end
|
||||
function BdConvertActCtrl:GetTimeText(remainTime)
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < remainTime and remainTime <= 3600 then
|
||||
local min = math.floor(remainTime / 60)
|
||||
local sec = math.floor(remainTime - min * 60)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < remainTime and remainTime <= 86400 then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
local min = math.floor((remainTime - hour * 3600) / 60)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
local hour = math.floor((remainTime - day * 86400) / 3600)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
return sTimeStr
|
||||
end
|
||||
function BdConvertActCtrl:InitItem()
|
||||
local rewardData = ConfigTable.GetData("BdConvertControl", self.nActId)
|
||||
if rewardData == nil then
|
||||
return
|
||||
end
|
||||
self.tbReward = rewardData.RewardsShow
|
||||
self.tbItemIns = {}
|
||||
self._mapNode.svItem:Init(#self.tbReward, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
end
|
||||
function BdConvertActCtrl:OnGridRefresh(go, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local itemId = self.tbReward[nDataIndex]
|
||||
local goItem = go.transform:Find("btnGrid/AnimRoot/tcItem").gameObject
|
||||
local instanceId = goItem:GetInstanceID()
|
||||
if self.tbItemIns[instanceId] == nil then
|
||||
self.tbItemIns[instanceId] = self:BindCtrlByNode(goItem, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
end
|
||||
self.tbItemIns[instanceId]:SetItem(itemId)
|
||||
end
|
||||
function BdConvertActCtrl:OnGridBtnClick(go, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local itemId = self.tbReward[nDataIndex]
|
||||
UTILS.ClickItemGridWithTips(itemId, go.transform:Find("btnGrid"), true, false, false)
|
||||
end
|
||||
function BdConvertActCtrl:InitQuest()
|
||||
local allCount = self.actData:GetAllQuestCount()
|
||||
local receivedCount = self.actData:GetAllReceivedCount()
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_mainProcess, receivedCount .. "/" .. allCount)
|
||||
self._mapNode.imgMainBarFill.anchoredPosition = Vector2(barMinX + (barMaxX - barMinX) * (receivedCount / allCount), self._mapNode.imgMainBarFill.anchoredPosition.y)
|
||||
end
|
||||
function BdConvertActCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self.nActId = actData:GetActId()
|
||||
self:RefreshRemainTime()
|
||||
if nil == self.remainTimer then
|
||||
self.remainTimer = self:AddTimer(0, 1, "RefreshRemainTime", true, true, false)
|
||||
end
|
||||
self:InitItem()
|
||||
self:InitQuest()
|
||||
local bUseL2D = LocalSettingData.mapData.UseLive2D
|
||||
self._mapNode.imgBgLevelSelect.transform.localScale = bUseL2D == true and Vector3.one or Vector3.zero
|
||||
self._mapNode.trActor2D_PNG.localScale = bUseL2D == true and Vector3.zero or Vector3.one
|
||||
if bUseL2D == true then
|
||||
Actor2DManager.SetBoardNPC2D(PanelId.BdConvertActPanel, self._mapNode.imgBgLevelSelect, 9102)
|
||||
else
|
||||
Actor2DManager.SetBoardNPC2D_PNG(self._mapNode.trActor2D_PNG, PanelId.BdConvertActPanel, 9102)
|
||||
end
|
||||
end
|
||||
function BdConvertActCtrl:ClearActivity()
|
||||
Actor2DManager.UnsetBoardNPC2D()
|
||||
if self.tbItemIns ~= nil then
|
||||
for _, ctrl in pairs(self.tbItemIns) do
|
||||
self:UnbindCtrlByNode(ctrl)
|
||||
end
|
||||
end
|
||||
self.tbItemIns = {}
|
||||
end
|
||||
function BdConvertActCtrl:OnBtnClick_Detail()
|
||||
local config = ConfigTable.GetData("BdConvertControl", self.nActId)
|
||||
if config == nil then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = config.DesText,
|
||||
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
|
||||
})
|
||||
end
|
||||
function BdConvertActCtrl:OnBtnClick_Quest()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BdConvertQuestPanel, self.nActId)
|
||||
end
|
||||
function BdConvertActCtrl:OnBtnClick_Go()
|
||||
local bPlayCond = self.actData:CheckActJumpCond(true)
|
||||
if not bPlayCond then
|
||||
return
|
||||
end
|
||||
self.actData:RequestAllBuildData(function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.BdConvertPanel, self.nActId)
|
||||
end)
|
||||
end
|
||||
return BdConvertActCtrl
|
||||
@@ -0,0 +1,140 @@
|
||||
local CookieActCtrl = class("CookieActCtrl", BaseCtrl)
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
CookieActCtrl._mapNodeConfig = {
|
||||
btnEnter = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Enter"
|
||||
},
|
||||
txtBtnEnter = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Settings_Btn_Go"
|
||||
},
|
||||
btnActDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ActDetail"
|
||||
},
|
||||
txtBtnActDetail = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Btn_Detail"
|
||||
},
|
||||
txtLabelPreview = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Daily_Quest_Reward_Tip_Title"
|
||||
},
|
||||
txtRemainTime = {sComponentName = "TMP_Text"},
|
||||
txtActTime = {sComponentName = "TMP_Text"},
|
||||
svItem = {
|
||||
sComponentName = "LoopScrollView"
|
||||
}
|
||||
}
|
||||
function CookieActCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self:RefreshTimeout()
|
||||
self.mapActCtrl = ConfigTable.GetData("CookieControl", self.actData:GetActId())
|
||||
if self.mapActCtrl ~= nil then
|
||||
local rewardData = self.mapActCtrl.RewardsShow
|
||||
local tbReward = decodeJson(rewardData)
|
||||
self.tbPreviewItem = tbReward
|
||||
end
|
||||
self._mapNode.svItem:Init(#self.tbPreviewItem, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
local nStartTime = self.actData:GetActOpenTime() or 0
|
||||
local nEndTime = self.actData:GetActEndTime() or 0
|
||||
local sStartTime = os.date("%m.%d", nStartTime)
|
||||
local sEndTime = os.date("%m.%d", nEndTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActTime, sStartTime .. " - " .. sEndTime)
|
||||
end
|
||||
function CookieActCtrl:OnGridRefresh(go, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local itemData = self.tbPreviewItem[nDataIndex]
|
||||
if itemData == nil then
|
||||
return
|
||||
end
|
||||
local goItem = go.transform:Find("btnGrid/AnimRoot/tcItem").gameObject
|
||||
if goItem == nil then
|
||||
return
|
||||
end
|
||||
local itemCtrl = self:BindCtrlByNode(goItem, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
if itemCtrl ~= nil then
|
||||
itemCtrl:SetItem(itemData)
|
||||
end
|
||||
end
|
||||
function CookieActCtrl:OnGridBtnClick(go, nIndex)
|
||||
local nDataIndex = nIndex + 1
|
||||
local itemData = self.tbPreviewItem[nDataIndex]
|
||||
if itemData == nil then
|
||||
return
|
||||
end
|
||||
UTILS.ClickItemGridWithTips(itemData[1], go.transform, true, false, false)
|
||||
end
|
||||
function CookieActCtrl:UnInit()
|
||||
end
|
||||
function CookieActCtrl:RefreshTimeout()
|
||||
local endTime = self.actData:GetActEndTime()
|
||||
local curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
if remainTime < 0 then
|
||||
TimerManager.Remove(self.remainTimer)
|
||||
self.remainTimer = nil
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1"),
|
||||
callbackConfirm = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
|
||||
end
|
||||
})
|
||||
return
|
||||
end
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
sTimeStr = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < remainTime and remainTime <= 3600 then
|
||||
local min = math.floor(remainTime / 60)
|
||||
local sec = math.floor(remainTime - min * 60)
|
||||
if sec == 0 then
|
||||
min = min - 1
|
||||
sec = 60
|
||||
end
|
||||
sTimeStr = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < remainTime and remainTime <= 86400 then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
local min = math.floor((remainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
sTimeStr = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
local hour = math.floor((remainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtRemainTime, sTimeStr)
|
||||
end
|
||||
function CookieActCtrl:OnBtnClick_Enter(...)
|
||||
local nRandom = math.random(28, 29)
|
||||
local nActId = self.actData:GetActId()
|
||||
local func = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CookieGamePanel, nActId)
|
||||
end
|
||||
EventManager.Hit(EventId.SetTransition, nRandom, func)
|
||||
end
|
||||
function CookieActCtrl:OnBtnClick_ActDetail(...)
|
||||
if self.mapActCtrl == nil then
|
||||
return
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = self.mapActCtrl.DetailDesc,
|
||||
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function CookieActCtrl:ClearActivity()
|
||||
end
|
||||
return CookieActCtrl
|
||||
@@ -0,0 +1,46 @@
|
||||
local JointDrillActCtrl_01 = class("JointDrillActCtrl_01", BaseCtrl)
|
||||
JointDrillActCtrl_01._mapNodeConfig = {
|
||||
goCommon = {
|
||||
sNodeName = "---Common---"
|
||||
}
|
||||
}
|
||||
JointDrillActCtrl_01._mapEventConfig = {
|
||||
PlayJointDrillActAnim = "OnEvent_PlayAnim"
|
||||
}
|
||||
function JointDrillActCtrl_01:UnbindCtrl()
|
||||
if self.activityCtrl ~= nil then
|
||||
self:UnbindCtrlByNode(self.activityCtrl)
|
||||
self.activityCtrl = nil
|
||||
end
|
||||
end
|
||||
function JointDrillActCtrl_01:InitActData(actData)
|
||||
if self.activityCtrl == nil then
|
||||
self.activityCtrl = self:BindCtrlByNode(self._mapNode.goCommon, "Game.UI.Activity.JointDrill.JointDrillActCtrl")
|
||||
end
|
||||
self.actData = actData
|
||||
self.nActId = actData:GetActId()
|
||||
self.activityCtrl:InitActData(actData)
|
||||
end
|
||||
function JointDrillActCtrl_01:ClearActivity()
|
||||
self:UnbindCtrl()
|
||||
end
|
||||
function JointDrillActCtrl_01:OnEvent_PlayAnim(sAnim, callback)
|
||||
if self.animRoot ~= nil then
|
||||
local nAnimTime = NovaAPI.GetAnimClipLength(self.animRoot, {sAnim})
|
||||
self.animRoot:Play(sAnim, 0, 0)
|
||||
self:AddTimer(1, nAnimTime, function()
|
||||
if callback ~= nil then
|
||||
callback()
|
||||
end
|
||||
end, true, true, true)
|
||||
elseif callback ~= nil then
|
||||
callback()
|
||||
end
|
||||
end
|
||||
function JointDrillActCtrl_01:OnEnable()
|
||||
self.animRoot = self.gameObject:GetComponent("Animator")
|
||||
end
|
||||
function JointDrillActCtrl_01:OnDisable()
|
||||
self:UnbindCtrl()
|
||||
end
|
||||
return JointDrillActCtrl_01
|
||||
@@ -0,0 +1,149 @@
|
||||
local JointDrillActCtrl = class("JointDrillActCtrl", BaseCtrl)
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
JointDrillActCtrl._mapNodeConfig = {
|
||||
btnDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
txtDetail = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Btn_Detail"
|
||||
},
|
||||
btnWaitStart = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnEvent_WaitStart"
|
||||
},
|
||||
txtBtnWaitStart = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "JointDrill_Act_Wait_Start"
|
||||
},
|
||||
imgBtnMask = {},
|
||||
btnStart = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Start"
|
||||
},
|
||||
txtBtnStart = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "JointDrill_Act_Goto"
|
||||
},
|
||||
txtActDesc = {sComponentName = "TMP_Text"},
|
||||
txtActTime = {sComponentName = "TMP_Text"},
|
||||
txtFuncLock = {sComponentName = "TMP_Text"},
|
||||
txtBeta = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "JointDrill_Beta_Tip"
|
||||
}
|
||||
}
|
||||
JointDrillActCtrl._mapEventConfig = {}
|
||||
function JointDrillActCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self.mapActCfg = self.actData:GetJointDrillActCfg()
|
||||
if self.mapActCfg == nil then
|
||||
return
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActDesc, self.mapActCfg.DescText)
|
||||
self:StartActTimer()
|
||||
local bPlayCond, sTips = self.actData:CheckActJumpCond()
|
||||
self._mapNode.txtFuncLock.gameObject:SetActive(not bPlayCond)
|
||||
if not bPlayCond then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtFuncLock, sTips)
|
||||
end
|
||||
end
|
||||
function JointDrillActCtrl:GetTimeStr(nRemainTime)
|
||||
local sTimeStr = ""
|
||||
if nRemainTime <= 60 then
|
||||
local sec = math.floor(nRemainTime)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < nRemainTime and nRemainTime <= 3600 then
|
||||
local min = math.floor(nRemainTime / 60)
|
||||
local sec = math.floor(nRemainTime - min * 60)
|
||||
if sec == 0 then
|
||||
min = min - 1
|
||||
sec = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < nRemainTime and nRemainTime <= 86400 then
|
||||
local hour = math.floor(nRemainTime / 3600)
|
||||
local min = math.floor((nRemainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < nRemainTime then
|
||||
local day = math.floor(nRemainTime / 86400)
|
||||
local hour = math.floor((nRemainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
return sTimeStr
|
||||
end
|
||||
function JointDrillActCtrl:StartActTimer()
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
self.timer = nil
|
||||
end
|
||||
local nOpenTime = self.actData:GetActOpenTime()
|
||||
local nCloseTime = self.actData:GetActCloseTime()
|
||||
local nStartTime = nOpenTime + self.mapActCfg.DrillStartTime
|
||||
local nEndTime = nStartTime + self.mapActCfg.DrillDurationTime
|
||||
local nStatus = 0
|
||||
local refreshTime = function()
|
||||
local nCurTime = ClientManager.serverTimeStamp
|
||||
local sTime = ""
|
||||
local nRemainTime = 0
|
||||
if nCurTime < nStartTime then
|
||||
nStatus = AllEnum.JointDrillActStatus.WaitStart
|
||||
nRemainTime = math.max(nStartTime - nCurTime, 0)
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("JointDrill_Act_Wait_Start_Time"), self:GetTimeStr(nRemainTime))
|
||||
elseif nCurTime >= nStartTime and nCurTime < nEndTime then
|
||||
nStatus = AllEnum.JointDrillActStatus.Start
|
||||
nRemainTime = math.max(nEndTime - nCurTime, 0)
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("JointDrill_Act_Start_Time"), self:GetTimeStr(nRemainTime))
|
||||
else
|
||||
nStatus = AllEnum.JointDrillActStatus.WaitClose
|
||||
nRemainTime = math.max(nCloseTime - nCurTime, 0)
|
||||
sTime = orderedFormat(ConfigTable.GetUIText("JointDrill_Act_Wait_Close_Time"), self:GetTimeStr(nRemainTime))
|
||||
end
|
||||
if nRemainTime <= 0 and self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
self.timer = nil
|
||||
end
|
||||
self._mapNode.btnStart.gameObject:SetActive(nStatus ~= AllEnum.JointDrillActStatus.WaitStart)
|
||||
self._mapNode.btnWaitStart.gameObject:SetActive(nStatus == AllEnum.JointDrillActStatus.WaitStart)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActTime, sTime)
|
||||
end
|
||||
refreshTime()
|
||||
self.timer = self:AddTimer(0, 1, refreshTime, true, true, true)
|
||||
end
|
||||
function JointDrillActCtrl:OnEvent_WaitStart()
|
||||
local bPlayCond = self.actData:CheckActJumpCond(true)
|
||||
if not bPlayCond then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("JointDrill_Act_Wait_Start_Tip"))
|
||||
end
|
||||
function JointDrillActCtrl:OnBtnClick_Start()
|
||||
local bPlayCond = self.actData:CheckActJumpCond(true)
|
||||
if not bPlayCond then
|
||||
return
|
||||
end
|
||||
EventManager.Hit("PlayJointDrillActAnim", "JointDrill_Act_01_out", function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.JointDrillLevelSelect, self.actData.nActId)
|
||||
end)
|
||||
end
|
||||
function JointDrillActCtrl:OnBtnClick_Detail()
|
||||
if self.mapActCfg == nil then
|
||||
return
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = self.mapActCfg.DetailDesc,
|
||||
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
return JointDrillActCtrl
|
||||
@@ -0,0 +1,28 @@
|
||||
local LoginRewardCtrl_01 = class("LoginRewardCtrl_01", BaseCtrl)
|
||||
LoginRewardCtrl_01._mapNodeConfig = {
|
||||
goCommon = {
|
||||
sNodeName = "---Common---"
|
||||
}
|
||||
}
|
||||
LoginRewardCtrl_01._mapEventConfig = {}
|
||||
function LoginRewardCtrl_01:UnbindCtrl()
|
||||
if self.activityCtrl ~= nil then
|
||||
self:UnbindCtrlByNode(self.activityCtrl)
|
||||
self.activityCtrl = nil
|
||||
end
|
||||
end
|
||||
function LoginRewardCtrl_01:InitActData(actData)
|
||||
if self.activityCtrl == nil then
|
||||
self.activityCtrl = self:BindCtrlByNode(self._mapNode.goCommon, "Game.UI.Activity.LoginReward.LoginRewardCtrl")
|
||||
end
|
||||
self.actData = actData
|
||||
self.nActId = actData:GetActId()
|
||||
self.activityCtrl:InitActData(actData)
|
||||
end
|
||||
function LoginRewardCtrl_01:ClearActivity()
|
||||
self:UnbindCtrl()
|
||||
end
|
||||
function LoginRewardCtrl_01:OnDisable()
|
||||
self:UnbindCtrl()
|
||||
end
|
||||
return LoginRewardCtrl_01
|
||||
@@ -0,0 +1,134 @@
|
||||
local LoginRewardPopUpCtrl_01 = class("LoginRewardPopUpCtrl_01", BaseCtrl)
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
LoginRewardPopUpCtrl_01._mapNodeConfig = {
|
||||
imgActivity = {sComponentName = "Image"},
|
||||
goRewardList = {},
|
||||
goRewardItem = {
|
||||
nCount = 7,
|
||||
sCtrlName = "Game.UI.Activity.LoginReward.LoginRewardItemCtrl"
|
||||
},
|
||||
goActTime = {},
|
||||
txtActivityTime = {sComponentName = "TMP_Text"},
|
||||
btnActivity = {
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Activity"
|
||||
},
|
||||
txtTips = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "LoginReward_PopUp_Tip"
|
||||
}
|
||||
}
|
||||
LoginRewardPopUpCtrl_01._mapEventConfig = {}
|
||||
LoginRewardPopUpCtrl_01._mapRedDotConfig = {}
|
||||
function LoginRewardPopUpCtrl_01:RefreshRemainTime()
|
||||
local endTime = self.actData:GetActEndTime()
|
||||
local curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < remainTime and remainTime <= 3600 then
|
||||
local min = math.floor(remainTime / 60)
|
||||
local sec = math.floor(remainTime - min * 60)
|
||||
if sec == 0 then
|
||||
min = min - 1
|
||||
sec = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < remainTime and remainTime <= 86400 then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
local min = math.floor((remainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
local hour = math.floor((remainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActivityTime, sTimeStr)
|
||||
end
|
||||
function LoginRewardPopUpCtrl_01:RefreshActData()
|
||||
self.nActId = self._panel.nActId
|
||||
self.actData = self._panel.actData
|
||||
self.remainTimer = nil
|
||||
self:RefreshRewardList()
|
||||
local actCfg = self.actData:GetActCfgData()
|
||||
if actCfg.EndType == GameEnum.activityEndType.NoLimit then
|
||||
self._mapNode.goActTime.gameObject:SetActive(false)
|
||||
else
|
||||
self._mapNode.goActTime.gameObject:SetActive(true)
|
||||
self:RefreshRemainTime()
|
||||
end
|
||||
end
|
||||
function LoginRewardPopUpCtrl_01:RefreshRewardList()
|
||||
local tbRewardList = self.actData:GetActLoginRewardList()
|
||||
if nil ~= tbRewardList then
|
||||
local nMaxDay = #self._mapNode.goRewardItem
|
||||
for k, v in ipairs(self._mapNode.goRewardItem) do
|
||||
v.gameObject:SetActive(tbRewardList[k] ~= nil)
|
||||
if tbRewardList[k] ~= nil then
|
||||
v:SetRewardItem(k, tbRewardList[k], k == nMaxDay)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function LoginRewardPopUpCtrl_01:PlayOutAnim()
|
||||
local nAnimLength = 0
|
||||
if self.animRoot ~= nil then
|
||||
nAnimLength = NovaAPI.GetAnimClipLength(self.animRoot, {
|
||||
"LoginReward_01_out"
|
||||
})
|
||||
self.animRoot:Play("LoginReward_01_out")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAnimLength)
|
||||
end
|
||||
return nAnimLength
|
||||
end
|
||||
function LoginRewardPopUpCtrl_01:Awake()
|
||||
self.animRoot = self.gameObject:GetComponent("Animator")
|
||||
end
|
||||
function LoginRewardPopUpCtrl_01:OnEnable()
|
||||
if self.animRoot ~= nil then
|
||||
local nAnimLength = NovaAPI.GetAnimClipLength(self.animRoot, {
|
||||
"LoginReward_01_in"
|
||||
})
|
||||
self.animRoot:Play("LoginReward_01_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAnimLength)
|
||||
end
|
||||
end
|
||||
function LoginRewardPopUpCtrl_01:OnDisable()
|
||||
end
|
||||
function LoginRewardPopUpCtrl_01:OnDestroy()
|
||||
end
|
||||
function LoginRewardPopUpCtrl_01:OnBtnClick_Activity()
|
||||
local bOpen = self.actData:CheckActivityOpen()
|
||||
if not bOpen then
|
||||
local callback = function()
|
||||
EventManager.Hit("RefreshLoginRewardPanel")
|
||||
end
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = ConfigTable.GetUIText("Activity_PopUp_Time_Out"),
|
||||
callbackConfirm = callback
|
||||
})
|
||||
return
|
||||
end
|
||||
local canReceive = self.actData:CheckCanReceive()
|
||||
if not canReceive then
|
||||
EventManager.Hit("RefreshLoginRewardPanel")
|
||||
return
|
||||
end
|
||||
local callback = function()
|
||||
EventManager.Hit("RefreshLoginRewardPanel")
|
||||
end
|
||||
PlayerData.Activity:SendReceiveLoginRewardMsg(self.nActId, callback)
|
||||
end
|
||||
return LoginRewardPopUpCtrl_01
|
||||
@@ -0,0 +1,146 @@
|
||||
local LoginRewardCtrl = class("LoginRewardCtrl", BaseCtrl)
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
LoginRewardCtrl._mapNodeConfig = {
|
||||
btnDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
txtDetail = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Btn_Detail"
|
||||
},
|
||||
goActTime = {},
|
||||
txtActivityTime = {sComponentName = "TMP_Text"},
|
||||
goRewardItem = {
|
||||
nCount = 7,
|
||||
sCtrlName = "Game.UI.Activity.LoginReward.LoginRewardItemCtrl"
|
||||
},
|
||||
btnItem = {
|
||||
nCount = 7,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Item"
|
||||
}
|
||||
}
|
||||
LoginRewardCtrl._mapEventConfig = {}
|
||||
function LoginRewardCtrl:RefreshRemainTime()
|
||||
local endTime = self.actData:GetActEndTime()
|
||||
local curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
if remainTime < 0 then
|
||||
TimerManager.Remove(self.remainTimer)
|
||||
self.remainTimer = nil
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1"),
|
||||
callbackConfirm = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
|
||||
end
|
||||
})
|
||||
return
|
||||
end
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < remainTime and remainTime <= 3600 then
|
||||
local min = math.floor(remainTime / 60)
|
||||
local sec = math.floor(remainTime - min * 60)
|
||||
if sec == 0 then
|
||||
min = min - 1
|
||||
sec = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < remainTime and remainTime <= 86400 then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
local min = math.floor((remainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
local hour = math.floor((remainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActivityTime, sTimeStr)
|
||||
end
|
||||
function LoginRewardCtrl:RefreshRewardList()
|
||||
self.tbRewardList = {}
|
||||
local tbRewardList = self.actData:GetActLoginRewardList()
|
||||
if nil ~= tbRewardList then
|
||||
local nMaxDay = #self._mapNode.goRewardItem
|
||||
local nReceiveDay = self.actData:GetCanReceive()
|
||||
local nActual = self.actData:GetReceived()
|
||||
for k, v in ipairs(self._mapNode.goRewardItem) do
|
||||
self.tbRewardList[k] = {}
|
||||
local mapReward = tbRewardList[k]
|
||||
v.gameObject:SetActive(mapReward ~= nil)
|
||||
if mapReward ~= nil then
|
||||
v:SetRewardItem(k, mapReward, k == nMaxDay, nReceiveDay == nActual and k == nActual + 1)
|
||||
for i = 1, 3 do
|
||||
local nTid = mapReward["RewardId" .. i]
|
||||
local nCount = mapReward["Qty" .. i]
|
||||
if nTid ~= 0 then
|
||||
table.insert(self.tbRewardList[k], {nTid = nTid, nCount = nCount})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function LoginRewardCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self:RefreshRewardList()
|
||||
local actCfg = self.actData:GetActCfgData()
|
||||
if actCfg.EndType == GameEnum.activityEndType.NoLimit then
|
||||
self._mapNode.goActTime.gameObject:SetActive(false)
|
||||
else
|
||||
self._mapNode.goActTime.gameObject:SetActive(true)
|
||||
self:RefreshRemainTime()
|
||||
if nil == self.remainTimer then
|
||||
self.remainTimer = self:AddTimer(0, 1, "RefreshRemainTime", true, true, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
function LoginRewardCtrl:Awake()
|
||||
end
|
||||
function LoginRewardCtrl:OnEnable()
|
||||
end
|
||||
function LoginRewardCtrl:OnDisable()
|
||||
end
|
||||
function LoginRewardCtrl:OnDestroy()
|
||||
end
|
||||
function LoginRewardCtrl:OnBtnClick_Detail()
|
||||
local mapActCfg = self.actData:GetLoginRewardControlCfg()
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = mapActCfg.DesText,
|
||||
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function LoginRewardCtrl:OnBtnClick_Item(btn, nIndex)
|
||||
if self.tbRewardList[nIndex] ~= nil then
|
||||
if #self.tbRewardList[nIndex] == 1 then
|
||||
local nTid = self.tbRewardList[nIndex][1].nTid
|
||||
UTILS.ClickItemGridWithTips(nTid, btn.gameObject.transform, true, true, false)
|
||||
else
|
||||
local tbReward = {}
|
||||
for _, v in ipairs(self.tbRewardList[nIndex]) do
|
||||
local rewardData = {
|
||||
[1] = v.nTid,
|
||||
[5] = v.nCount
|
||||
}
|
||||
table.insert(tbReward, rewardData)
|
||||
end
|
||||
EventManager.Hit("ShowActRewardList", tbReward)
|
||||
end
|
||||
end
|
||||
end
|
||||
return LoginRewardCtrl
|
||||
@@ -0,0 +1,52 @@
|
||||
local LoginRewardItemCtrl = class("LoginRewardItemCtrl", BaseCtrl)
|
||||
LoginRewardItemCtrl._mapNodeConfig = {
|
||||
imgCanReceiveBg = {},
|
||||
imgBg = {},
|
||||
imgPlusBg = {},
|
||||
imgIcon = {sComponentName = "Image"},
|
||||
txtItemCount = {sComponentName = "TMP_Text"},
|
||||
imgDay = {nCount = 2, sComponentName = "Image"},
|
||||
txtItemName = {sComponentName = "TMP_Text"},
|
||||
goReceived = {},
|
||||
txtReceived = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "LoginReward_Received"
|
||||
},
|
||||
imgCanReceive = {},
|
||||
txtCanReceive = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "LoginReward_Can_Receive"
|
||||
},
|
||||
imgNextReceive = {},
|
||||
txtNextReceive = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "LoginReward_Next_Receive"
|
||||
},
|
||||
goParticle = {sNodeName = "UIParticle"}
|
||||
}
|
||||
LoginRewardItemCtrl._mapEventConfig = {}
|
||||
LoginRewardItemCtrl._mapRedDotConfig = {}
|
||||
function LoginRewardItemCtrl:SetRewardItem(nDay, mapReward, bFinalDay, bNextDay)
|
||||
for _, v in ipairs(self._mapNode.imgDay) do
|
||||
self:SetAtlasSprite(v, "05_number", "zs_activity_02_num_" .. nDay)
|
||||
end
|
||||
self:SetPngSprite(self._mapNode.imgIcon, mapReward.RewardIcon or "")
|
||||
NovaAPI.SetTMPText(self._mapNode.txtItemCount, orderedFormat(ConfigTable.GetUIText("LoginReward_Reward_Count"), mapReward.RewardCount))
|
||||
NovaAPI.SetTMPText(self._mapNode.txtItemName, mapReward.RewardDesc)
|
||||
self._mapNode.imgCanReceive.gameObject:SetActive(mapReward.Status == 1)
|
||||
self._mapNode.imgCanReceiveBg.gameObject:SetActive(mapReward.Status == 1)
|
||||
self._mapNode.goReceived.gameObject:SetActive(mapReward.Status == 2)
|
||||
self._mapNode.imgNextReceive.gameObject:SetActive(bNextDay)
|
||||
self._mapNode.imgPlusBg.gameObject:SetActive(mapReward.DisRare)
|
||||
self._mapNode.goParticle.gameObject:SetActive(mapReward.DisRare and mapReward.Status ~= 2)
|
||||
self._mapNode.imgBg.gameObject:SetActive(not mapReward.DisRare)
|
||||
self.tbRewardList = {}
|
||||
for i = 1, 3 do
|
||||
local nTid = mapReward["RewardId" .. i]
|
||||
local nCount = mapReward["Qty" .. i]
|
||||
if nTid ~= 0 then
|
||||
table.insert(self.tbRewardList, {nTid = nTid, nCount = nCount})
|
||||
end
|
||||
end
|
||||
end
|
||||
return LoginRewardItemCtrl
|
||||
@@ -0,0 +1,85 @@
|
||||
local LoginRewardPopUpCtrl = class("LoginRewardPopUpCtrl", BaseCtrl)
|
||||
local GameResourceLoader = require("Game.Common.Resource.GameResourceLoader")
|
||||
local ResTypeAny = GameResourceLoader.ResType.Any
|
||||
LoginRewardPopUpCtrl._mapNodeConfig = {
|
||||
imgBlurredBg = {},
|
||||
imgBlurMask = {},
|
||||
rtContent = {
|
||||
sNodeName = "---Content---",
|
||||
sComponentName = "RectTransform"
|
||||
}
|
||||
}
|
||||
LoginRewardPopUpCtrl._mapEventConfig = {
|
||||
RefreshLoginRewardPanel = "OnEvent_RefreshLoginRewardPanel"
|
||||
}
|
||||
LoginRewardPopUpCtrl._mapRedDotConfig = {}
|
||||
local sPrefabFolder = "UI_Activity/%s.prefab"
|
||||
function LoginRewardPopUpCtrl:ShowLoginReward()
|
||||
if self.tbActivityList == nil or #self.tbActivityList == 0 then
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.LoginRewardPopUp)
|
||||
if nil ~= self.callback then
|
||||
self.callback()
|
||||
end
|
||||
return
|
||||
end
|
||||
local actData = table.remove(self.tbActivityList, 1)
|
||||
self._panel.nActId = actData:GetActId()
|
||||
self._panel.actData = PlayerData.Activity:GetActivityDataById(self._panel.nActId)
|
||||
if nil ~= self._panel.actData then
|
||||
self:RefreshActContent()
|
||||
end
|
||||
end
|
||||
function LoginRewardPopUpCtrl:RefreshActContent()
|
||||
self:ResetActContent()
|
||||
local mapActCfg = ConfigTable.GetData("LoginRewardControl", self._panel.nActId)
|
||||
if mapActCfg ~= nil then
|
||||
local sPrefabPath = string.format(sPrefabFolder, mapActCfg.PopUpUIAssets)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local sCtrlPath = string.format("Game.UI.Activity.LoginReward.%s.LoginRewardPopUpCtrl_01", "_" .. self._panel.nActId)
|
||||
self.curPopUpCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.curPopUpCtrl:RefreshActData()
|
||||
end
|
||||
end
|
||||
function LoginRewardPopUpCtrl:ResetActContent()
|
||||
if nil ~= self.curPopUpCtrl then
|
||||
destroy(self.curPopUpCtrl.gameObject)
|
||||
self:UnbindCtrlByNode(self.curPopUpCtrl)
|
||||
end
|
||||
self.curPopUpCtrl = nil
|
||||
end
|
||||
function LoginRewardPopUpCtrl:Awake()
|
||||
self:ResetActContent()
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.tbActivityList = tbParam[1]
|
||||
self.callback = tbParam[2]
|
||||
end
|
||||
end
|
||||
function LoginRewardPopUpCtrl:OnEnable()
|
||||
self._mapNode.rtContent.gameObject:SetActive(false)
|
||||
self._mapNode.imgBlurMask.gameObject:SetActive(false)
|
||||
self._mapNode.imgBlurredBg.gameObject:SetActive(true)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self._mapNode.imgBlurMask.gameObject:SetActive(true)
|
||||
self._mapNode.rtContent.gameObject:SetActive(true)
|
||||
self:ShowLoginReward()
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
function LoginRewardPopUpCtrl:OnDisable()
|
||||
end
|
||||
function LoginRewardPopUpCtrl:OnDestroy()
|
||||
end
|
||||
function LoginRewardPopUpCtrl:OnEvent_RefreshLoginRewardPanel()
|
||||
if self.curPopUpCtrl == nil then
|
||||
self:ShowLoginReward()
|
||||
else
|
||||
self._panel.actData = PlayerData.Activity:GetActivityDataById(self._panel.nActId)
|
||||
self.curPopUpCtrl:RefreshActData()
|
||||
local nAnimTime = self.curPopUpCtrl:PlayOutAnim()
|
||||
self:AddTimer(1, nAnimTime, "ShowLoginReward", true, true, true)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAnimTime)
|
||||
end
|
||||
end
|
||||
return LoginRewardPopUpCtrl
|
||||
@@ -0,0 +1,23 @@
|
||||
local LoginRewardPopUpPanel = class("LoginRewardPopUpPanel", BasePanel)
|
||||
LoginRewardPopUpPanel._bIsMainPanel = false
|
||||
LoginRewardPopUpPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "LoginRewardPopUp/LoginRewardPopUpPanel.prefab",
|
||||
sCtrlName = "Game.UI.Activity.LoginReward.LoginRewardPopUpCtrl"
|
||||
}
|
||||
}
|
||||
function LoginRewardPopUpPanel:Awake()
|
||||
self.nActId = nil
|
||||
self.actData = nil
|
||||
end
|
||||
function LoginRewardPopUpPanel:OnEnable()
|
||||
end
|
||||
function LoginRewardPopUpPanel:OnAfterEnter()
|
||||
end
|
||||
function LoginRewardPopUpPanel:OnDisable()
|
||||
end
|
||||
function LoginRewardPopUpPanel:OnDestroy()
|
||||
end
|
||||
function LoginRewardPopUpPanel:OnRelease()
|
||||
end
|
||||
return LoginRewardPopUpPanel
|
||||
@@ -0,0 +1,138 @@
|
||||
local ActivityMiningCtrl = class("ActivityMiningCtrl", BaseCtrl)
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local ClientManager = CS.ClientManager.Instance
|
||||
local axeItemId = 0
|
||||
ActivityMiningCtrl._mapNodeConfig = {
|
||||
btnGo = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Go"
|
||||
}
|
||||
}
|
||||
function ActivityMiningCtrl:OnDestory(...)
|
||||
self:UnInit()
|
||||
end
|
||||
function ActivityMiningCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self:ShowAddAxeCount()
|
||||
self:RefreshTimeout()
|
||||
end
|
||||
function ActivityMiningCtrl:UnInit(...)
|
||||
RedDotManager.UnRegisterNode(RedDotDefine.Activity_Mining_Quest_Group, nil, self._mapNode.reddot_Task)
|
||||
end
|
||||
function ActivityMiningCtrl:RefreshTimeout()
|
||||
local endTime = self.actData:GetActEndTime()
|
||||
local curTime = ClientManager.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
if remainTime < 0 then
|
||||
TimerManager.Remove(self.remainTimer)
|
||||
self.remainTimer = nil
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1"),
|
||||
callbackConfirm = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
|
||||
end
|
||||
})
|
||||
return
|
||||
end
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
sTimeStr = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < remainTime and remainTime <= 3600 then
|
||||
local min = math.floor(remainTime / 60)
|
||||
local sec = math.floor(remainTime - min * 60)
|
||||
if sec == 0 then
|
||||
min = min - 1
|
||||
sec = 60
|
||||
end
|
||||
sTimeStr = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < remainTime and remainTime <= 86400 then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
local min = math.floor((remainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
sTimeStr = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
local hour = math.floor((remainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
sTimeStr = string.format(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTimeout, sTimeStr)
|
||||
end
|
||||
function ActivityMiningCtrl:ShowAddAxeCount()
|
||||
local nActId = self.actData:GetActId()
|
||||
local data = PlayerData.Activity:GetActivityDataById(nActId)
|
||||
local nAddAxeCount = data:GetAddAxeCount()
|
||||
if 0 < nAddAxeCount then
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Item,
|
||||
tbItem = {
|
||||
[1] = {nTid = axeItemId, nCount = nAddAxeCount}
|
||||
}
|
||||
})
|
||||
data:ResetAddAxeCount()
|
||||
end
|
||||
end
|
||||
function ActivityMiningCtrl:OnBtnClick_Go(...)
|
||||
local nActId = self.actData:GetActId()
|
||||
local tbStoryConfig = self.actData:GetStoryConfigIdList()
|
||||
local nCurLevel = self.actData:GetLevel()
|
||||
local sNeedPlayAvgyId = 0
|
||||
local nStoryId = 0
|
||||
local tbAllData = self.actData:GetGroupStoryData()
|
||||
for _, v in pairs(tbStoryConfig) do
|
||||
if nCurLevel >= v.config.UnlockLayer then
|
||||
local temp = v.config.Id
|
||||
if not tbAllData[temp].bIsRead then
|
||||
sNeedPlayAvgyId = v.config.AvgId
|
||||
nStoryId = v.config.Id
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
local bAvgReadState = true
|
||||
if tbAllData[nStoryId] ~= nil then
|
||||
bAvgReadState = false
|
||||
end
|
||||
if sNeedPlayAvgyId ~= 0 and not bAvgReadState then
|
||||
local callback = function(...)
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.PureAvgStory)
|
||||
self.actData:RequestFinishAvg(nStoryId)
|
||||
end
|
||||
local mapData = {
|
||||
nType = AllEnum.StoryAvgType.Plot,
|
||||
sAvgId = sNeedPlayAvgyId,
|
||||
nNodeId = nil,
|
||||
callback = callback
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PureAvgStory, mapData)
|
||||
end
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.MiningGame, nActId)
|
||||
end
|
||||
self.actData:RequestLevelData(0, callback)
|
||||
end
|
||||
function ActivityMiningCtrl:OnBtnClick_Story(...)
|
||||
local nActId = self.actData:GetActId()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.MiningGameStory, nActId)
|
||||
end
|
||||
function ActivityMiningCtrl:OnBtnClick_Task(...)
|
||||
local nActId = self.actData:GetActId()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.MiningGameQuest, nActId)
|
||||
end
|
||||
function ActivityMiningCtrl:OnBtnClick_Shop(...)
|
||||
local nActId = self.actData:GetActId()
|
||||
local tbConfig = ConfigTable.GetData("MiningControl", nActId)
|
||||
local nShopId = tbConfig.ShopId
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ShopPanel, nShopId)
|
||||
end
|
||||
function ActivityMiningCtrl:ClearActivity()
|
||||
end
|
||||
return ActivityMiningCtrl
|
||||
@@ -0,0 +1,172 @@
|
||||
local PeriodicQuestCtrl_01 = class("PeriodicQuestCtrl_01", BaseCtrl)
|
||||
PeriodicQuestCtrl_01._mapNodeConfig = {
|
||||
goCommon = {
|
||||
sNodeName = "---Common---"
|
||||
},
|
||||
goQuestProcess = {},
|
||||
txtProcess = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_Process"
|
||||
},
|
||||
txtQuestProcess = {sComponentName = "TMP_Text"},
|
||||
btnReceiveFinal = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Receive"
|
||||
},
|
||||
txtBtnReceiveFinal = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_Receive"
|
||||
},
|
||||
imgCompleteFinal = {},
|
||||
txtComplete = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_Received"
|
||||
},
|
||||
btnUnComplete = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_UnComplete"
|
||||
},
|
||||
txtBtnUnComplete = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_Receive"
|
||||
},
|
||||
btnRewardPreview = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_RewardPreview"
|
||||
},
|
||||
txtRewardName = {sComponentName = "TMP_Text"},
|
||||
btnCharDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_CharPreview"
|
||||
}
|
||||
}
|
||||
PeriodicQuestCtrl_01._mapEventConfig = {
|
||||
RefreshPeriodicAct = "OnEvent_RefreshPeriodicAct"
|
||||
}
|
||||
function PeriodicQuestCtrl_01:RefreshActInfo()
|
||||
if self.activityCtrl ~= nil then
|
||||
self.activityCtrl:RefreshQuestList()
|
||||
end
|
||||
self:RefreshQuestProgress()
|
||||
self:RefreshQuestReward()
|
||||
local perQuestActCfg = self.actData:GetPerQuestCfg()
|
||||
self.nShowType = perQuestActCfg.PreviewType
|
||||
self.nRewardId = 0
|
||||
if self.nShowType == GameEnum.itemType.Char then
|
||||
self.nRewardId = perQuestActCfg.FinalReward1
|
||||
if 0 ~= self.nRewardId then
|
||||
self._mapNode.btnCharDetail.gameObject:SetActive(true)
|
||||
local charConfig = ConfigTable.GetData_Character(self.nRewardId)
|
||||
if charConfig ~= nil then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtRewardName, charConfig.Name)
|
||||
end
|
||||
end
|
||||
elseif self.nShowType == GameEnum.itemType.Disc then
|
||||
self.nRewardId = perQuestActCfg.FinalReward1
|
||||
if 0 ~= self.nRewardId then
|
||||
self._mapNode.btnCharDetail.gameObject:SetActive(true)
|
||||
local itemCfg = ConfigTable.GetData_Item(self.nRewardId)
|
||||
if itemCfg ~= nil then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtRewardName, itemCfg.Title)
|
||||
end
|
||||
end
|
||||
elseif self.nShowType == GameEnum.itemType.Item then
|
||||
self.nRewardId = perQuestActCfg.FinalReward1
|
||||
if 0 ~= self.nRewardId then
|
||||
self._mapNode.btnCharDetail.gameObject:SetActive(true)
|
||||
local itemCfg = ConfigTable.GetData_Item(self.nRewardId)
|
||||
if itemCfg ~= nil then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtRewardName, itemCfg.Title)
|
||||
end
|
||||
end
|
||||
else
|
||||
self._mapNode.btnCharDetail.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
function PeriodicQuestCtrl_01:UnbindCtrl()
|
||||
if self.activityCtrl ~= nil then
|
||||
self:UnbindCtrlByNode(self.activityCtrl)
|
||||
self.activityCtrl = nil
|
||||
end
|
||||
end
|
||||
function PeriodicQuestCtrl_01:RefreshQuestProgress()
|
||||
local curProgress, allProgress, canReceive = self.actData:GetQuestProgress()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtQuestProcess, string.format("%s/%s", curProgress, allProgress))
|
||||
self.bAllReceive = curProgress == allProgress
|
||||
end
|
||||
function PeriodicQuestCtrl_01:RefreshQuestReward()
|
||||
self._mapNode.btnReceiveFinal.gameObject:SetActive(not self.actData:CheckFinalReward() and self.bAllReceive)
|
||||
self._mapNode.btnUnComplete.gameObject:SetActive(not self.bAllReceive)
|
||||
self._mapNode.imgCompleteFinal.gameObject:SetActive(self.actData:CheckFinalReward())
|
||||
local perQuestActCfg = self.actData:GetPerQuestCfg()
|
||||
end
|
||||
function PeriodicQuestCtrl_01:InitActData(actData, bResetGroup)
|
||||
if self.activityCtrl == nil then
|
||||
self.activityCtrl = self:BindCtrlByNode(self._mapNode.goCommon, "Game.UI.Activity.PeriodicQuest.PeriodicQuestCtrl")
|
||||
end
|
||||
self.actData = actData
|
||||
self.nActId = actData:GetActId()
|
||||
self.activityCtrl:InitActData(actData, bResetGroup)
|
||||
self:RefreshActInfo()
|
||||
end
|
||||
function PeriodicQuestCtrl_01:ClearActivity()
|
||||
self:UnbindCtrl()
|
||||
end
|
||||
function PeriodicQuestCtrl_01:Awake()
|
||||
end
|
||||
function PeriodicQuestCtrl_01:FadeIn()
|
||||
end
|
||||
function PeriodicQuestCtrl_01:FadeOut()
|
||||
end
|
||||
function PeriodicQuestCtrl_01:OnEnable()
|
||||
end
|
||||
function PeriodicQuestCtrl_01:OnDisable()
|
||||
self:UnbindCtrl()
|
||||
end
|
||||
function PeriodicQuestCtrl_01:OnDestroy()
|
||||
end
|
||||
function PeriodicQuestCtrl_01:OnRelease()
|
||||
end
|
||||
function PeriodicQuestCtrl_01:OnBtnClick_Receive()
|
||||
local callback = function()
|
||||
self:RefreshQuestReward()
|
||||
PlayerData.Base:TryOpenWorldClassUpgrade()
|
||||
end
|
||||
PlayerData.Activity:SendReceiveFinalReward(self.nActId, callback)
|
||||
end
|
||||
function PeriodicQuestCtrl_01:OnBtnClick_UnComplete()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("PerActivity_UnComplete"))
|
||||
end
|
||||
function PeriodicQuestCtrl_01:OnBtnClick_RewardPreview()
|
||||
local perQuestActCfg = self.actData:GetPerQuestCfg()
|
||||
local nShowType = perQuestActCfg.PreviewType
|
||||
if nShowType == GameEnum.itemType.Char then
|
||||
local nCharId = perQuestActCfg.FinalReward1
|
||||
if 0 ~= nCharId then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.GachaPreview, nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
function PeriodicQuestCtrl_01:OnEvent_RefreshPeriodicAct(nActId)
|
||||
if nActId == self.nActId then
|
||||
self.bQuestAnim = false
|
||||
self:RefreshActInfo()
|
||||
end
|
||||
end
|
||||
function PeriodicQuestCtrl_01:OnBtnClick_CharPreview()
|
||||
if self.nRewardId == nil then
|
||||
return
|
||||
end
|
||||
if self.nShowType == GameEnum.itemType.Char then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharBgTrialPanel, PanelId.CharInfoTrial, self.nRewardId)
|
||||
elseif self.nShowType == GameEnum.itemType.Item then
|
||||
local itemCfg = ConfigTable.GetData_Item(self.nRewardId)
|
||||
if itemCfg ~= nil then
|
||||
local sType = itemCfg.Stype
|
||||
if sType == GameEnum.itemStype.OutfitCYO then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DiscPreview, self.nRewardId, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return PeriodicQuestCtrl_01
|
||||
@@ -0,0 +1,259 @@
|
||||
local PeriodicQuestCtrl = class("PeriodicQuestCtrl", BaseCtrl)
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
PeriodicQuestCtrl._mapNodeConfig = {
|
||||
loopSv = {
|
||||
sNodeName = "srGuideQuest",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
rtDays = {},
|
||||
PerActGroupItem = {
|
||||
nCount = 7,
|
||||
sCtrlName = "Game.UI.Activity.PeriodicQuest.PeriodicQuestGroupCtrl"
|
||||
},
|
||||
btnGroup = {
|
||||
sNodeName = "PerActGroupItem",
|
||||
nCount = 7,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Group"
|
||||
},
|
||||
btnGroupLock = {
|
||||
sNodeName = "btnGroupLock",
|
||||
nCount = 7,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GroupLock"
|
||||
},
|
||||
btnDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
txtBtnDetail = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Btn_Detail"
|
||||
},
|
||||
btnQuickRec = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_QuickRec"
|
||||
},
|
||||
txtBtnQuickRec = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_Btn_Quick_Receive"
|
||||
},
|
||||
goActTime = {},
|
||||
txtActivityTime = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
PeriodicQuestCtrl._mapEventConfig = {}
|
||||
function PeriodicQuestCtrl:RefreshRemainTime()
|
||||
local endTime = self.actData:GetActEndTime()
|
||||
local curTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
if remainTime < 0 then
|
||||
TimerManager.Remove(self.remainTimer)
|
||||
self.remainTimer = nil
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1"),
|
||||
callbackConfirm = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
|
||||
end
|
||||
})
|
||||
return
|
||||
end
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < remainTime and remainTime <= 3600 then
|
||||
local min = math.floor(remainTime / 60)
|
||||
local sec = math.floor(remainTime - min * 60)
|
||||
if sec == 0 then
|
||||
min = min - 1
|
||||
sec = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < remainTime and remainTime <= 86400 then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
local min = math.floor((remainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
local hour = math.floor((remainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActivityTime, orderedFormat(ConfigTable.GetUIText("PerActivity_Remain_Time") or "", sTimeStr))
|
||||
end
|
||||
function PeriodicQuestCtrl:RefreshQuestList()
|
||||
self.tbAllQuestList = self.actData:GetQuestListByGroup()
|
||||
if nil == self.tbAllQuestList[self._panel.nSelectGroup] then
|
||||
printLog(string.format("任务列表为空!!!actId = %s, group = %s", self.nActId, self._panel.nSelectGroup))
|
||||
return
|
||||
end
|
||||
self.tbQuestList = self.tbAllQuestList[self._panel.nSelectGroup]
|
||||
table.sort(self.tbQuestList, function(a, b)
|
||||
if a.nStatus == b.nStatus then
|
||||
return a.Id < b.Id
|
||||
end
|
||||
return a.nStatus < b.nStatus
|
||||
end)
|
||||
for k, v in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(v)
|
||||
self.tbGridCtrl[k] = nil
|
||||
end
|
||||
if nil ~= self.tbQuestList then
|
||||
self.nPageCount = 0
|
||||
self._mapNode.loopSv:SetAnim(0.06)
|
||||
self._mapNode.loopSv:Init(#self.tbQuestList, self, self.OnGridRefresh, nil, false, self.GetGridPageCount)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
|
||||
end
|
||||
local _, _, canReceive = self.actData:GetQuestProgress()
|
||||
self._mapNode.btnQuickRec.gameObject:SetActive(0 < canReceive)
|
||||
for k, v in ipairs(self._mapNode.PerActGroupItem) do
|
||||
local nAllQuest, nReceivedQuest = self.actData:GetDayQuestStatus(k)
|
||||
v:RefreshStatus(nAllQuest <= nReceivedQuest and 0 < nReceivedQuest)
|
||||
end
|
||||
end
|
||||
function PeriodicQuestCtrl:GetGridPageCount(pageCount)
|
||||
self.nPageCount = pageCount > #self.tbQuestList and #self.tbQuestList or pageCount
|
||||
end
|
||||
function PeriodicQuestCtrl:InitGroupList()
|
||||
local nCurDay = self.actData:GetCurOpenDay()
|
||||
self.nMaxOpenGroup = 0
|
||||
local tbNextOpenGroupList = {}
|
||||
if nil ~= CacheTable.GetData("_PeriodicQuestGroup", self.nActId) then
|
||||
local tbGroup = CacheTable.GetData("_PeriodicQuestGroup", self.nActId)[nCurDay]
|
||||
if nil ~= tbGroup then
|
||||
for _, v in ipairs(tbGroup) do
|
||||
if v > self.nMaxOpenGroup then
|
||||
self.nMaxOpenGroup = v
|
||||
end
|
||||
end
|
||||
end
|
||||
if nil ~= CacheTable.GetData("_PeriodicQuestGroup", self.nActId)[nCurDay + 1] then
|
||||
for _, v in ipairs(CacheTable.GetData("_PeriodicQuestGroup", self.nActId)[nCurDay + 1]) do
|
||||
tbNextOpenGroupList[v] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
local nSelectGroup = self.actData:GetCanReceiveRewardGroup()
|
||||
if 0 == nSelectGroup then
|
||||
nSelectGroup = self.nMaxOpenGroup
|
||||
end
|
||||
for k, v in ipairs(self._mapNode.PerActGroupItem) do
|
||||
v:Init(self.nActId, k, self.nMaxOpenGroup)
|
||||
if nil ~= tbNextOpenGroupList[k] then
|
||||
local nHour = self.actData:GetNextDayOpenTime()
|
||||
if nHour < 1 then
|
||||
v:SetTime(orderedFormat(ConfigTable.GetUIText("PerActivity_Quest_Open_Time_2") or "", 1))
|
||||
else
|
||||
v:SetTime(orderedFormat(ConfigTable.GetUIText("PerActivity_Quest_Open_Time_1") or "", nHour))
|
||||
end
|
||||
end
|
||||
end
|
||||
if nil == self._panel.nSelectGroup then
|
||||
self._panel.nSelectGroup = nSelectGroup
|
||||
end
|
||||
self._mapNode.PerActGroupItem[self._panel.nSelectGroup]:SetSelect(true)
|
||||
end
|
||||
function PeriodicQuestCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local nInstanceId = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceId] then
|
||||
self.tbGridCtrl[nInstanceId] = self:BindCtrlByNode(goGrid, "Game.UI.Activity.PeriodicQuest.PeriodicQuestItemCtrl")
|
||||
end
|
||||
self.tbGridCtrl[nInstanceId]:SetData(self.nActId, self.tbQuestList[nIndex])
|
||||
end
|
||||
function PeriodicQuestCtrl:InitActData(actData, bResetGroup)
|
||||
self.actData = actData
|
||||
if bResetGroup then
|
||||
self._panel.nSelectGroup = nil
|
||||
end
|
||||
self.nActId = actData:GetActId()
|
||||
self.bQuestAnim = false
|
||||
self:InitGroupList()
|
||||
local tbAllQuestList = self.actData:GetQuestListByGroup()
|
||||
if nil == tbAllQuestList[self._panel.nSelectGroup] then
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Tips,
|
||||
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1")
|
||||
})
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
|
||||
return
|
||||
end
|
||||
local actCfg = self.actData:GetActCfgData()
|
||||
if actCfg.EndType == GameEnum.activityEndType.NoLimit then
|
||||
self._mapNode.goActTime.gameObject:SetActive(false)
|
||||
else
|
||||
self._mapNode.goActTime.gameObject:SetActive(true)
|
||||
self:RefreshRemainTime()
|
||||
if nil == self.remainTimer then
|
||||
self.remainTimer = self:AddTimer(0, 1, "RefreshRemainTime", true, true, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
function PeriodicQuestCtrl:Awake()
|
||||
self.tbGridCtrl = {}
|
||||
self.tbSequences = {}
|
||||
end
|
||||
function PeriodicQuestCtrl:FadeIn()
|
||||
end
|
||||
function PeriodicQuestCtrl:FadeOut()
|
||||
end
|
||||
function PeriodicQuestCtrl:OnEnable()
|
||||
end
|
||||
function PeriodicQuestCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function PeriodicQuestCtrl:OnDestroy()
|
||||
end
|
||||
function PeriodicQuestCtrl:OnRelease()
|
||||
end
|
||||
function PeriodicQuestCtrl:OnBtnClick_Group(_, nIndex)
|
||||
if self._panel.nSelectGroup == nIndex then
|
||||
return
|
||||
end
|
||||
if nIndex > self.nMaxOpenGroup then
|
||||
return
|
||||
end
|
||||
if nil == self.tbAllQuestList[nIndex] or nil == next(self.tbAllQuestList[nIndex]) then
|
||||
printError(string.format("当前任务组下没有任务!!! 活动id = %d, 任务组 = %s", self.nActId, nIndex))
|
||||
return
|
||||
end
|
||||
self._mapNode.PerActGroupItem[self._panel.nSelectGroup]:SetSelect(false)
|
||||
if nil ~= self._mapNode.PerActGroupItem[nIndex] then
|
||||
self._mapNode.PerActGroupItem[nIndex]:SetSelect(true)
|
||||
end
|
||||
self._panel.nSelectGroup = nIndex
|
||||
self.bQuestAnim = true
|
||||
self:RefreshQuestList()
|
||||
end
|
||||
function PeriodicQuestCtrl:OnBtnClick_GroupLock()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("PerActivity_Not_Open"))
|
||||
end
|
||||
function PeriodicQuestCtrl:OnBtnClick_Detail()
|
||||
local perQuestActCfg = self.actData:GetPerQuestCfg()
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = perQuestActCfg.DesText,
|
||||
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function PeriodicQuestCtrl:OnBtnClick_QuickRec()
|
||||
local callback = function()
|
||||
EventManager.Hit("RefreshPeriodicAct", self.nActId)
|
||||
PlayerData.Base:TryOpenWorldClassUpgrade()
|
||||
end
|
||||
PlayerData.Activity:SendReceivePerQuest(self.nActId, 0, callback)
|
||||
end
|
||||
return PeriodicQuestCtrl
|
||||
@@ -0,0 +1,54 @@
|
||||
local PeriodicQuestCtrl_02 = class("PeriodicQuestCtrl_02", BaseCtrl)
|
||||
PeriodicQuestCtrl_02._mapNodeConfig = {
|
||||
goCommon = {
|
||||
sNodeName = "---Common---"
|
||||
}
|
||||
}
|
||||
PeriodicQuestCtrl_02._mapEventConfig = {
|
||||
RefreshPeriodicAct = "OnEvent_RefreshPeriodicAct"
|
||||
}
|
||||
function PeriodicQuestCtrl_02:RefreshActInfo()
|
||||
if self.activityCtrl ~= nil then
|
||||
self.activityCtrl:RefreshQuestList()
|
||||
end
|
||||
end
|
||||
function PeriodicQuestCtrl_02:UnbindCtrl()
|
||||
if self.activityCtrl ~= nil then
|
||||
self:UnbindCtrlByNode(self.activityCtrl)
|
||||
self.activityCtrl = nil
|
||||
end
|
||||
end
|
||||
function PeriodicQuestCtrl_02:InitActData(actData, bResetGroup)
|
||||
if self.activityCtrl == nil then
|
||||
self.activityCtrl = self:BindCtrlByNode(self._mapNode.goCommon, "Game.UI.Activity.PeriodicQuest.PeriodicQuestCtrl")
|
||||
end
|
||||
self.actData = actData
|
||||
self.nActId = actData:GetActId()
|
||||
self.activityCtrl:InitActData(actData, bResetGroup)
|
||||
self:RefreshActInfo()
|
||||
end
|
||||
function PeriodicQuestCtrl_02:ClearActivity()
|
||||
self:UnbindCtrl()
|
||||
end
|
||||
function PeriodicQuestCtrl_02:Awake()
|
||||
end
|
||||
function PeriodicQuestCtrl_02:FadeIn()
|
||||
end
|
||||
function PeriodicQuestCtrl_02:FadeOut()
|
||||
end
|
||||
function PeriodicQuestCtrl_02:OnEnable()
|
||||
end
|
||||
function PeriodicQuestCtrl_02:OnDisable()
|
||||
self:UnbindCtrl()
|
||||
end
|
||||
function PeriodicQuestCtrl_02:OnDestroy()
|
||||
end
|
||||
function PeriodicQuestCtrl_02:OnRelease()
|
||||
end
|
||||
function PeriodicQuestCtrl_02:OnEvent_RefreshPeriodicAct(nActId)
|
||||
if nActId == self.nActId then
|
||||
self.bQuestAnim = false
|
||||
self:RefreshActInfo()
|
||||
end
|
||||
end
|
||||
return PeriodicQuestCtrl_02
|
||||
@@ -0,0 +1,56 @@
|
||||
local PeriodicQuestGroupCtrl = class("PeriodicQuestGroupCtrl", BaseCtrl)
|
||||
PeriodicQuestGroupCtrl._mapNodeConfig = {
|
||||
goNormal = {},
|
||||
goSelect = {},
|
||||
goLock = {},
|
||||
txt_Group = {sComponentName = "TMP_Text", nCount = 3},
|
||||
goTime = {},
|
||||
txtOpenTime = {sComponentName = "TMP_Text"},
|
||||
redDotGroup = {},
|
||||
imgComplete = {}
|
||||
}
|
||||
PeriodicQuestGroupCtrl._mapEventConfig = {}
|
||||
function PeriodicQuestGroupCtrl:Init(nActId, nGroup, nCurGroup)
|
||||
self.nActId = nActId
|
||||
self.nGroup = nGroup
|
||||
for _, v in ipairs(self._mapNode.txt_Group) do
|
||||
NovaAPI.SetTMPText(v, self.nGroup)
|
||||
end
|
||||
self._mapNode.goNormal.gameObject:SetActive(true)
|
||||
self._mapNode.goSelect.gameObject:SetActive(false)
|
||||
self._mapNode.goLock.gameObject:SetActive(false)
|
||||
self._mapNode.goTime.gameObject:SetActive(false)
|
||||
self._mapNode.redDotGroup.gameObject:SetActive(false)
|
||||
self.bUnlock = nGroup <= nCurGroup
|
||||
self:SetSelect(false)
|
||||
self._mapNode.goNormal.gameObject:SetActive(nGroup <= nCurGroup)
|
||||
self._mapNode.goLock.gameObject:SetActive(nCurGroup < nGroup)
|
||||
self:RegisterRedDot()
|
||||
end
|
||||
function PeriodicQuestGroupCtrl:RegisterRedDot()
|
||||
RedDotManager.RegisterNode(RedDotDefine.Activity_Periodic_Quest_Group, {
|
||||
self.nActId,
|
||||
self.nGroup
|
||||
}, self._mapNode.redDotGroup)
|
||||
end
|
||||
function PeriodicQuestGroupCtrl:SetTime(sTime)
|
||||
self._mapNode.goTime.gameObject:SetActive(true)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtOpenTime, sTime)
|
||||
end
|
||||
function PeriodicQuestGroupCtrl:SetSelect(bSelect)
|
||||
self.bSelect = bSelect
|
||||
self._mapNode.goNormal.gameObject:SetActive(not self.bSelect)
|
||||
self._mapNode.goSelect.gameObject:SetActive(self.bSelect)
|
||||
end
|
||||
function PeriodicQuestGroupCtrl:RefreshStatus(bAllReceived)
|
||||
self._mapNode.imgComplete.gameObject:SetActive(bAllReceived and self.bUnlock)
|
||||
end
|
||||
function PeriodicQuestGroupCtrl:Awake()
|
||||
end
|
||||
function PeriodicQuestGroupCtrl:OnDisable()
|
||||
end
|
||||
function PeriodicQuestGroupCtrl:OnDestroy()
|
||||
end
|
||||
function PeriodicQuestGroupCtrl:OnRelease()
|
||||
end
|
||||
return PeriodicQuestGroupCtrl
|
||||
@@ -0,0 +1,105 @@
|
||||
local PeriodicQuestItemCtrl = class("PeriodicQuestItemCtrl", BaseCtrl)
|
||||
local JumpUtil = require("Game.Common.Utils.JumpUtil")
|
||||
local LayoutRebuilder = CS.UnityEngine.UI.LayoutRebuilder
|
||||
PeriodicQuestItemCtrl._mapNodeConfig = {
|
||||
rtTitle = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txtTitle = {sNodeName = "TMPTitle", sComponentName = "TMP_Text"},
|
||||
rtBarFill = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txtProcess = {sNodeName = "TMPProcess", sComponentName = "TMP_Text"},
|
||||
btnReward = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Reward"
|
||||
},
|
||||
rtReward = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
|
||||
},
|
||||
btnReceive = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Receive"
|
||||
},
|
||||
txtBtnReceive = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_Receive"
|
||||
},
|
||||
btnJump = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Jump"
|
||||
},
|
||||
txtBtnJump = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_Jump"
|
||||
},
|
||||
txtUnComplete = {
|
||||
sNodeName = "TMPUncomplete",
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "PerActivity_Quest_UnComplete"
|
||||
},
|
||||
imgComplete = {},
|
||||
imgCompleteMask = {},
|
||||
imgPoint = {}
|
||||
}
|
||||
PeriodicQuestItemCtrl._mapEventConfig = {}
|
||||
local totalLength = 520
|
||||
local totalHeight = 37
|
||||
function PeriodicQuestItemCtrl:SetData(nActId, mapData)
|
||||
self.nActId = nActId
|
||||
self.nQuestId = mapData.Id
|
||||
local nStatus = mapData.nStatus
|
||||
local questCfg = ConfigTable.GetData("PeriodicQuest", self.nQuestId)
|
||||
if nil ~= questCfg then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTitle, questCfg.Title)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProcess, string.format("%s/%s", mapData.nCurProcess, mapData.nTotalProcess))
|
||||
self.nJumpTo = questCfg.JumpTo
|
||||
self.rewardId = questCfg.Reward
|
||||
self._mapNode.rtReward:SetItem(questCfg.Reward, nil, questCfg.RewardQty, nil, nil, nil, nil, true)
|
||||
self._mapNode.txtUnComplete.gameObject:SetActive(nStatus == AllEnum.ActQuestStatus.UnComplete and questCfg.JumpTo == 0)
|
||||
self._mapNode.btnJump.gameObject:SetActive(nStatus == AllEnum.ActQuestStatus.UnComplete and questCfg.JumpTo ~= 0)
|
||||
self._mapNode.btnReceive.gameObject:SetActive(nStatus == AllEnum.ActQuestStatus.Complete)
|
||||
self._mapNode.imgComplete.gameObject:SetActive(nStatus == AllEnum.ActQuestStatus.Received)
|
||||
self._mapNode.imgCompleteMask.gameObject:SetActive(nStatus == AllEnum.ActQuestStatus.Received)
|
||||
self._mapNode.imgPoint.gameObject:SetActive(nStatus ~= AllEnum.ActQuestStatus.Received)
|
||||
if nStatus == AllEnum.ActQuestStatus.Received then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProcess, ConfigTable.GetUIText("PerActivity_Quest_Complete"))
|
||||
self._mapNode.rtBarFill.sizeDelta = Vector2(totalLength, totalHeight)
|
||||
else
|
||||
self._mapNode.rtBarFill.sizeDelta = Vector2(mapData.nCurProcess / mapData.nTotalProcess * totalLength, totalHeight)
|
||||
end
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtTitle)
|
||||
end
|
||||
end
|
||||
function PeriodicQuestItemCtrl:Awake()
|
||||
end
|
||||
function PeriodicQuestItemCtrl:FadeIn()
|
||||
end
|
||||
function PeriodicQuestItemCtrl:FadeOut()
|
||||
end
|
||||
function PeriodicQuestItemCtrl:OnEnable()
|
||||
end
|
||||
function PeriodicQuestItemCtrl:OnDisable()
|
||||
end
|
||||
function PeriodicQuestItemCtrl:OnDestroy()
|
||||
end
|
||||
function PeriodicQuestItemCtrl:OnRelease()
|
||||
end
|
||||
function PeriodicQuestItemCtrl:OnBtnClick_Reward(btn)
|
||||
if nil ~= self.rewardId then
|
||||
UTILS.ClickItemGridWithTips(self.rewardId, btn.transform, true, true, true)
|
||||
end
|
||||
end
|
||||
function PeriodicQuestItemCtrl:OnBtnClick_Receive()
|
||||
local callback = function()
|
||||
EventManager.Hit("RefreshPeriodicAct", self.nActId)
|
||||
PlayerData.Base:TryOpenWorldClassUpgrade()
|
||||
end
|
||||
PlayerData.Activity:SendReceivePerQuest(self.nActId, self.nQuestId, callback)
|
||||
end
|
||||
function PeriodicQuestItemCtrl:OnBtnClick_Jump()
|
||||
if nil ~= self.nJumpTo and 0 ~= self.nJumpTo then
|
||||
JumpUtil.JumpTo(self.nJumpTo)
|
||||
end
|
||||
end
|
||||
return PeriodicQuestItemCtrl
|
||||
@@ -0,0 +1,178 @@
|
||||
local ActivityTowerDefenseCtrl = class("ActivityTowerDefenseCtrl", BaseCtrl)
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local barMinX = -365
|
||||
local barMaxX = 0
|
||||
local panelType = {
|
||||
Default = 1,
|
||||
QuestPanel = 2,
|
||||
StoryPanel = 3,
|
||||
DesPanel = 4
|
||||
}
|
||||
ActivityTowerDefenseCtrl._mapNodeConfig = {
|
||||
item = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl",
|
||||
nCount = 4
|
||||
},
|
||||
ItemBtn = {nCount = 4, sComponentName = "UIButton"},
|
||||
txt_time = {sComponentName = "TMP_Text"},
|
||||
txt_des = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "TowerDef_ActivityDes"
|
||||
},
|
||||
btn_des = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
txt_quest = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "TowerDef_QuestTitle"
|
||||
},
|
||||
redDotQuest = {},
|
||||
btn_quest = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Quest"
|
||||
},
|
||||
txt_mainProcess = {sComponentName = "TMP_Text"},
|
||||
imgMainBarFill = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txt_go = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "TowerDef_EnterActivity"
|
||||
},
|
||||
btn_go = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Go"
|
||||
},
|
||||
go_nextLevel = {},
|
||||
txt_nextLevelTime = {sComponentName = "TMP_Text"},
|
||||
txtRewardTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "TowerDef_RewardPre"
|
||||
}
|
||||
}
|
||||
ActivityTowerDefenseCtrl._mapEventConfig = {
|
||||
TowerDefenseQuestUpdate = "InitQuest",
|
||||
TowerDefenseCloseQuestPanel = "OnEvent_CloseQuestPanel"
|
||||
}
|
||||
ActivityTowerDefenseCtrl._mapRedDotConfig = {
|
||||
[RedDotDefine.Activity_TowerDefense_AllQuest] = {
|
||||
sNodeName = "redDotQuest"
|
||||
}
|
||||
}
|
||||
function ActivityTowerDefenseCtrl:Awake()
|
||||
end
|
||||
function ActivityTowerDefenseCtrl:RefreshRemainTime()
|
||||
if self.actData.actCfg.EndType == GameEnum.activityEndType.NoLimit then
|
||||
self._mapNode.txt_time.transform.parent.gameObject:SetActive(false)
|
||||
else
|
||||
local endTime = self.actData:GetActEndTime()
|
||||
local curTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
if remainTime < 0 then
|
||||
TimerManager.Remove(self.remainTimer)
|
||||
self.remainTimer = nil
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1"),
|
||||
callbackConfirm = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
|
||||
end
|
||||
})
|
||||
end
|
||||
local sTimeStr = self:GetTimeText(remainTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_time, orderedFormat(ConfigTable.GetUIText("PerActivity_Remain_Time") or "", sTimeStr))
|
||||
end
|
||||
local nextLevelTime = self.actData:GetNextLevelUnlockTime()
|
||||
if nextLevelTime == 0 then
|
||||
self._mapNode.go_nextLevel:SetActive(false)
|
||||
else
|
||||
self._mapNode.go_nextLevel:SetActive(true)
|
||||
local curTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
local nextLevelRemainTime = nextLevelTime - curTime
|
||||
local sNextLevelTime = self:GetTimeText(nextLevelRemainTime)
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_nextLevelTime, orderedFormat(ConfigTable.GetUIText("TowerDef_LevelPreTime") or "", sNextLevelTime))
|
||||
end
|
||||
end
|
||||
function ActivityTowerDefenseCtrl:GetTimeText(remainTime)
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < remainTime and remainTime <= 3600 then
|
||||
local min = math.floor(remainTime / 60)
|
||||
local sec = math.floor(remainTime - min * 60)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < remainTime and remainTime <= 86400 then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
local min = math.floor((remainTime - hour * 3600) / 60)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
local hour = math.floor((remainTime - day * 86400) / 3600)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
return sTimeStr
|
||||
end
|
||||
function ActivityTowerDefenseCtrl:InitItem()
|
||||
for _, item in pairs(self._mapNode.item) do
|
||||
item.gameObject:SetActive(false)
|
||||
end
|
||||
local rewardData = ConfigTable.GetData("TowerDefenseControl", self.nActId)
|
||||
if rewardData == nil then
|
||||
return
|
||||
end
|
||||
local rewardData = rewardData.RewardsShow
|
||||
local tbReward = decodeJson(rewardData)
|
||||
for i = 1, math.min(4, #tbReward) do
|
||||
self._mapNode.item[i]:SetItem(tbReward[i])
|
||||
self._mapNode.item[i].gameObject:SetActive(true)
|
||||
self._mapNode.ItemBtn[i].onClick:RemoveAllListeners()
|
||||
self._mapNode.ItemBtn[i].onClick:AddListener(function()
|
||||
local nRewardId = tbReward[i]
|
||||
if nRewardId ~= nil then
|
||||
UTILS.ClickItemGridWithTips(nRewardId, self._mapNode.ItemBtn[i].transform, true, false, false)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
function ActivityTowerDefenseCtrl:InitQuest()
|
||||
local allCount = self.actData:GetAllQuestCount()
|
||||
local receivedCount = self.actData:GetAllReceivedCount()
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_mainProcess, receivedCount .. "/" .. allCount)
|
||||
self._mapNode.imgMainBarFill.anchoredPosition = Vector2(barMinX + (barMaxX - barMinX) * (receivedCount / allCount), self._mapNode.imgMainBarFill.anchoredPosition.y)
|
||||
end
|
||||
function ActivityTowerDefenseCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self.nActId = actData:GetActId()
|
||||
self:RefreshRemainTime()
|
||||
if nil == self.remainTimer then
|
||||
self.remainTimer = self:AddTimer(0, 1, "RefreshRemainTime", true, true, false)
|
||||
end
|
||||
self:InitItem()
|
||||
self:InitQuest()
|
||||
end
|
||||
function ActivityTowerDefenseCtrl:ClearActivity()
|
||||
end
|
||||
function ActivityTowerDefenseCtrl:OnBtnClick_Detail()
|
||||
local config = ConfigTable.GetData("TowerDefenseControl", self.nActId)
|
||||
if config == nil then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = config.DesText,
|
||||
sTitle = ConfigTable.GetUIText("Activity_Btn_Detail")
|
||||
})
|
||||
end
|
||||
function ActivityTowerDefenseCtrl:OnBtnClick_Quest()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TowerDefenseQuest, self.nActId)
|
||||
end
|
||||
function ActivityTowerDefenseCtrl:OnBtnClick_Go()
|
||||
local bPlayCond = self.actData:CheckActJumpCond(true)
|
||||
if not bPlayCond then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TowerDefenseSelectPanel, self.nActId)
|
||||
end
|
||||
return ActivityTowerDefenseCtrl
|
||||
@@ -0,0 +1,314 @@
|
||||
local TrialCtrl = class("TrialCtrl", BaseCtrl)
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
TrialCtrl._mapNodeConfig = {
|
||||
rawImgActor2D = {
|
||||
sNodeName = "----Actor2D----",
|
||||
sComponentName = "RawImage"
|
||||
},
|
||||
goActTime = {},
|
||||
txtActivityTime = {sComponentName = "TMP_Text"},
|
||||
btnTrialInfo = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_TrialInfo"
|
||||
},
|
||||
txtBtnTrialInfo = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Trial_Btn_TrialDetial"
|
||||
},
|
||||
txtReward = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Trial_RewardInfo"
|
||||
},
|
||||
btnItem = {
|
||||
nCount = 3,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ItemTips"
|
||||
},
|
||||
item = {
|
||||
nCount = 3,
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
|
||||
},
|
||||
sv = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
rtChar = {},
|
||||
btnChar = {
|
||||
nCount = 4,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Char"
|
||||
},
|
||||
imgSelectBg = {nCount = 4},
|
||||
goSelect = {nCount = 4},
|
||||
imgHead = {nCount = 4, sComponentName = "Image"},
|
||||
goCharRoot = {},
|
||||
btnTrial = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Trial"
|
||||
},
|
||||
btnGacha = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Gacha"
|
||||
},
|
||||
txtBtnGacha = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Trial_Btn_GotoGacha"
|
||||
},
|
||||
txtBtnTrial = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Trial_Btn_GotoTrial"
|
||||
},
|
||||
goStar = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateStarCtrl"
|
||||
},
|
||||
txtName = {sComponentName = "TMP_Text"},
|
||||
btnCharInfo = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_CharInfo"
|
||||
},
|
||||
imgElementIcon = {sComponentName = "Image"},
|
||||
txtElement = {sComponentName = "TMP_Text"},
|
||||
txtCharClass = {sComponentName = "TMP_Text"},
|
||||
imgAttackType = {sComponentName = "Image"}
|
||||
}
|
||||
TrialCtrl._mapEventConfig = {}
|
||||
function TrialCtrl:RefreshRemainTime()
|
||||
local endTime = self.actData:GetActEndTime()
|
||||
local curTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
if remainTime < 0 then
|
||||
TimerManager.Remove(self.remainTimer)
|
||||
self.remainTimer = nil
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1"),
|
||||
callbackConfirm = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
|
||||
end
|
||||
})
|
||||
return
|
||||
end
|
||||
local sTimeStr = ""
|
||||
if remainTime <= 60 then
|
||||
local sec = math.floor(remainTime)
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
|
||||
elseif 60 < remainTime and remainTime <= 3600 then
|
||||
local min = math.floor(remainTime / 60)
|
||||
local sec = math.floor(remainTime - min * 60)
|
||||
if sec == 0 then
|
||||
min = min - 1
|
||||
sec = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
|
||||
elseif 3600 < remainTime and remainTime <= 86400 then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
local min = math.floor((remainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
|
||||
elseif 86400 < remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
local hour = math.floor((remainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtActivityTime, sTimeStr)
|
||||
end
|
||||
function TrialCtrl:Refresh()
|
||||
self:RefreshCharList()
|
||||
self:RefreshCharInfo()
|
||||
self:RefreshReward()
|
||||
end
|
||||
function TrialCtrl:RefreshCharInfo()
|
||||
local nCharId = self.tbCharId[self.nSelectIndex]
|
||||
local mapCfg = ConfigTable.GetData_Character(nCharId)
|
||||
local mapItem = ConfigTable.GetData_Item(nCharId)
|
||||
if not mapCfg or not mapItem then
|
||||
return
|
||||
end
|
||||
local nMaxStar = 6 - mapItem.Rarity
|
||||
self._mapNode.goStar:SetStar(0, nMaxStar)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtName, mapCfg.Name)
|
||||
local nEET = mapCfg.EET
|
||||
self:SetAtlasSprite(self._mapNode.imgElementIcon, "12_rare", AllEnum.ElementIconType.Icon .. nEET)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtElement, ConfigTable.GetUIText("T_Element_Attr_" .. nEET))
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCharClass, ConfigTable.GetUIText("Char_JobClass_" .. mapCfg.Class))
|
||||
if mapCfg.CharacterAttackType == GameEnum.characterAttackType.MELEE then
|
||||
self:SetAtlasSprite(self._mapNode.imgAttackType, "10_ico", "zs_list_near")
|
||||
elseif mapCfg.CharacterAttackType == GameEnum.characterAttackType.RANGED then
|
||||
self:SetAtlasSprite(self._mapNode.imgAttackType, "10_ico", "zs_list_far")
|
||||
end
|
||||
local nCharSkinId = ConfigTable.GetData_Character(nCharId).AdvanceSkinId
|
||||
Actor2DManager.SetActor2D(PanelId.TrialActivity, self._mapNode.rawImgActor2D, nCharId, nCharSkinId)
|
||||
end
|
||||
function TrialCtrl:RefreshReward()
|
||||
self.tbReward = {}
|
||||
local nGroupId = self.tbGroup[self.nSelectIndex]
|
||||
local mapCfg = ConfigTable.GetData("TrialGroup", nGroupId)
|
||||
if not mapCfg then
|
||||
return
|
||||
end
|
||||
local bReceived = self.actData:CheckGroupReceived(nGroupId)
|
||||
for i = 1, 3 do
|
||||
local nId = mapCfg["RewardId" .. i]
|
||||
if 0 < nId then
|
||||
self._mapNode.btnItem[i].gameObject:SetActive(true)
|
||||
self._mapNode.item[i]:SetItem(nId, nil, mapCfg["Qty" .. i], nil, bReceived)
|
||||
table.insert(self.tbReward, nId)
|
||||
else
|
||||
self._mapNode.btnItem[i].gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
function TrialCtrl:RefreshCharList()
|
||||
local nCount = #self.tbCharId
|
||||
if nCount == 1 then
|
||||
self._mapNode.goCharRoot:SetActive(false)
|
||||
return
|
||||
end
|
||||
self._mapNode.goCharRoot:SetActive(true)
|
||||
self._mapNode.rtChar:SetActive(nCount <= 4)
|
||||
self._mapNode.sv.gameObject:SetActive(4 < nCount)
|
||||
if nCount <= 4 then
|
||||
for i = 1, 4 do
|
||||
self._mapNode.btnChar[i].gameObject:SetActive(i <= nCount)
|
||||
if i <= nCount then
|
||||
local nCharId = self.tbCharId[i]
|
||||
local nCharSkinId = ConfigTable.GetData_Character(nCharId).AdvanceSkinId
|
||||
local sIcon = ConfigTable.GetData_CharacterSkin(nCharSkinId).Icon
|
||||
self:SetPngSprite(self._mapNode.imgHead[i], sIcon .. AllEnum.CharHeadIconSurfix.L)
|
||||
self._mapNode.goSelect[i]:SetActive(self.nSelectIndex == i)
|
||||
self._mapNode.imgSelectBg[i]:SetActive(self.nSelectIndex == i)
|
||||
end
|
||||
end
|
||||
else
|
||||
self._mapNode.sv:Init(nCount, self, self.OnGridRefresh, self.OnGridClick)
|
||||
end
|
||||
end
|
||||
function TrialCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local nCharId = self.tbCharId[nIndex]
|
||||
local nCharSkinId = ConfigTable.GetData_Character(nCharId).AdvanceSkinId
|
||||
local sIcon = ConfigTable.GetData_CharacterSkin(nCharSkinId).Icon
|
||||
local imgHead = goGrid.transform:Find("btnChar/AnimRoot/imgHead"):GetComponent("Image")
|
||||
local goSelect = goGrid.transform:Find("btnChar/AnimRoot/goSelect").gameObject
|
||||
local imgSelectBg = goGrid.transform:Find("btnChar/AnimRoot/imgSelectBg").gameObject
|
||||
self:SetPngSprite(imgHead, sIcon .. AllEnum.CharHeadIconSurfix.L)
|
||||
goSelect:SetActive(self.nSelectIndex == nIndex)
|
||||
imgSelectBg:SetActive(self.nSelectIndex == nIndex)
|
||||
end
|
||||
function TrialCtrl:OnGridClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
if self.nSelectIndex == nIndex then
|
||||
return
|
||||
end
|
||||
goGrid.transform:Find("btnChar/AnimRoot/imgSelectBg").gameObject:SetActive(true)
|
||||
goGrid.transform:Find("btnChar/AnimRoot/goSelect").gameObject:SetActive(true)
|
||||
local sPathSelectBg = "Viewport/Content/" .. tostring(self.nSelectIndex - 1) .. "/btnChar/AnimRoot/imgSelectBg"
|
||||
local sPathSelect = "Viewport/Content/" .. tostring(self.nSelectIndex - 1) .. "/btnChar/AnimRoot/goSelect"
|
||||
local goSelectBg = self._mapNode.sv.transform:Find(sPathSelectBg)
|
||||
local goSelect = self._mapNode.sv.transform:Find(sPathSelect)
|
||||
if goSelectBg then
|
||||
goSelectBg.gameObject:SetActive(false)
|
||||
end
|
||||
if goSelect then
|
||||
goSelect.gameObject:SetActive(false)
|
||||
end
|
||||
self.nSelectIndex = nIndex
|
||||
self._mapNode.sv:SetScrollGridPos(gridIndex, 0.1, 1)
|
||||
self:RefreshCharInfo()
|
||||
self:RefreshReward()
|
||||
end
|
||||
function TrialCtrl:InitActData(actData)
|
||||
self.actData = actData
|
||||
self.nActId = actData:GetActId()
|
||||
PlayerData.Trial:SetTrialAct(self.nActId)
|
||||
self.nSelectIndex = 1
|
||||
local actCfg = self.actData:GetActCfgData()
|
||||
if actCfg.EndType == GameEnum.activityEndType.NoLimit then
|
||||
self._mapNode.goActTime.gameObject:SetActive(false)
|
||||
else
|
||||
self._mapNode.goActTime.gameObject:SetActive(true)
|
||||
self:RefreshRemainTime()
|
||||
if nil == self.remainTimer then
|
||||
self.remainTimer = self:AddTimer(0, 1, "RefreshRemainTime", true, true, false)
|
||||
end
|
||||
end
|
||||
local mapCfg = ConfigTable.GetData("TrialControl", self.nActId)
|
||||
if not mapCfg then
|
||||
return
|
||||
end
|
||||
self.tbGacha = mapCfg.Gachas
|
||||
self.tbGroup = mapCfg.GroupIds
|
||||
self.tbCharId = {}
|
||||
for _, v in ipairs(self.tbGroup) do
|
||||
local mapGroup = ConfigTable.GetData("TrialGroup", v)
|
||||
if mapGroup then
|
||||
local mapTrial = ConfigTable.GetData("TrialCharacter", mapGroup.TrialChar)
|
||||
if mapTrial then
|
||||
table.insert(self.tbCharId, mapTrial.CharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
self:Refresh()
|
||||
end
|
||||
function TrialCtrl:ClearActivity()
|
||||
Actor2DManager.UnsetActor2D()
|
||||
end
|
||||
function TrialCtrl:Awake()
|
||||
end
|
||||
function TrialCtrl:OnEnable()
|
||||
end
|
||||
function TrialCtrl:OnDisable()
|
||||
Actor2DManager.UnsetActor2D()
|
||||
end
|
||||
function TrialCtrl:OnDestroy()
|
||||
end
|
||||
function TrialCtrl:OnBtnClick_Trial()
|
||||
PlayerData.Trial:SetSelectTrialGroup(self.tbGroup[self.nSelectIndex])
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.TrialLevelSelect)
|
||||
end
|
||||
function TrialCtrl:OnBtnClick_Gacha()
|
||||
local getInfoCallback = function()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.GachaSpin, self.tbGacha[self.nSelectIndex])
|
||||
end
|
||||
PlayerData.Gacha:GetGachaInfomation(getInfoCallback)
|
||||
end
|
||||
function TrialCtrl:OnBtnClick_CharInfo()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharBgTrialPanel, PanelId.CharInfoTrial, self.tbCharId[self.nSelectIndex])
|
||||
end
|
||||
function TrialCtrl:OnBtnClick_Char(btn, nIndex)
|
||||
if self.nSelectIndex == nIndex then
|
||||
return
|
||||
end
|
||||
self._mapNode.goSelect[self.nSelectIndex]:SetActive(false)
|
||||
self._mapNode.imgSelectBg[self.nSelectIndex]:SetActive(false)
|
||||
self._mapNode.goSelect[nIndex]:SetActive(true)
|
||||
self._mapNode.imgSelectBg[nIndex]:SetActive(true)
|
||||
self.nSelectIndex = nIndex
|
||||
self:RefreshCharInfo()
|
||||
self:RefreshReward()
|
||||
end
|
||||
function TrialCtrl:OnBtnClick_TrialInfo()
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Desc,
|
||||
sContent = ConfigTable.GetUIText("Trial_DetailInfo")
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function TrialCtrl:OnBtnClick_ItemTips(btn, nIndex)
|
||||
if self.tbReward[nIndex] then
|
||||
local mapData = {
|
||||
nTid = self.tbReward[nIndex],
|
||||
bShowDepot = true,
|
||||
bShowJumpto = false
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ItemTips, btn.transform, mapData)
|
||||
end
|
||||
end
|
||||
return TrialCtrl
|
||||
@@ -0,0 +1,429 @@
|
||||
local ActivityListCtrl = class("ActivityListCtrl", BaseCtrl)
|
||||
local GameResourceLoader = require("Game.Common.Resource.GameResourceLoader")
|
||||
local ResTypeAny = GameResourceLoader.ResType.Any
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
ActivityListCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
loopSv = {
|
||||
sNodeName = "sv",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
trSv = {sNodeName = "sv", sComponentName = "Transform"},
|
||||
rtContent = {
|
||||
sNodeName = "---Content---",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
animRoot = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
goRewardList = {
|
||||
sCtrlName = "Game.UI.MainlineEx.RewardListCtrl"
|
||||
}
|
||||
}
|
||||
ActivityListCtrl._mapEventConfig = {
|
||||
ShowActRewardList = "OnEvent_ShowActRewardList"
|
||||
}
|
||||
local sEntranceFolder_old = "UI_Activity/%s/%s.prefab"
|
||||
local sEntranceFolder = "UI_Activity/%s.prefab"
|
||||
local sActTypePath = {
|
||||
[GameEnum.activityType.PeriodicQuest] = "PeriodicQuest",
|
||||
[GameEnum.activityType.LoginReward] = "LoginReward",
|
||||
[GameEnum.activityType.Mining] = "Mining",
|
||||
[GameEnum.activityType.Trial] = "Trial",
|
||||
[GameEnum.activityType.Cookie] = "Cookie",
|
||||
[GameEnum.activityType.TowerDefense] = "TowerDefense",
|
||||
[GameEnum.activityType.JointDrill] = "JointDrill",
|
||||
[GameEnum.activityType.Advertise] = "Advertise",
|
||||
[GameEnum.activityType.Task] = "ActivityTask"
|
||||
}
|
||||
function ActivityListCtrl:InitActivityList(nCurActId)
|
||||
local tbActList = PlayerData.Activity:GetSortedActList()
|
||||
local tbActGroupList = PlayerData.Activity:GetSortedActGroupList()
|
||||
self.tbActList = {}
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
for k, v in pairs(tbActList) do
|
||||
table.insert(self.tbActList, {
|
||||
nType = AllEnum.ActivityMainType.Activity,
|
||||
actData = v
|
||||
})
|
||||
end
|
||||
for k, v in pairs(tbActGroupList) do
|
||||
table.insert(self.tbActList, {
|
||||
nType = AllEnum.ActivityMainType.ActivityGroup,
|
||||
actData = v
|
||||
})
|
||||
end
|
||||
if nil ~= self.tbActList then
|
||||
if nil ~= self.nSelectActId and nil ~= self.nSelectActMainType then
|
||||
local actData
|
||||
if self.nSelectActMainType == AllEnum.ActivityMainType.Activity then
|
||||
actData = PlayerData.Activity:GetActivityDataById(self.nSelectActId)
|
||||
elseif self.nSelectActMainType == AllEnum.ActivityMainType.ActivityGroup then
|
||||
actData = PlayerData.Activity:GetActivityGroupDataById(self.nSelectActId)
|
||||
end
|
||||
local bOpen = false
|
||||
if nil ~= actData then
|
||||
if self.nSelectActMainType == AllEnum.ActivityMainType.Activity then
|
||||
bOpen = actData:CheckActivityOpen()
|
||||
elseif self.nSelectActMainType == AllEnum.ActivityMainType.ActivityGroup then
|
||||
bOpen = actData:CheckActGroupShow()
|
||||
end
|
||||
end
|
||||
if nil == actData or not bOpen then
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_2")
|
||||
})
|
||||
self.nSelectActId = nil
|
||||
end
|
||||
end
|
||||
self.nSelectIndex = 1
|
||||
if self.nSelectActId ~= nil or nCurActId ~= nil then
|
||||
local nActId = self.nSelectActId == nil and nCurActId or self.nSelectActId
|
||||
for k, actData in ipairs(self.tbActList) do
|
||||
local actId = actData.nType == AllEnum.ActivityMainType.Activity and actData.actData:GetActId() or actData.actData:GetActGroupId()
|
||||
if nil ~= nActId and actId == nActId then
|
||||
self.nSelectIndex = k
|
||||
end
|
||||
end
|
||||
end
|
||||
self.nPageCount = 0
|
||||
self._mapNode.loopSv:Init(#self.tbActList, self, self.OnRefreshGrid, self.OnGridBtnClick, true, self.GetGridPageCount)
|
||||
self._mapNode.loopSv:SetScrollGridPos(self.nSelectIndex - 1, 0.5)
|
||||
self.bPlayAnim = false
|
||||
self:RefreshSelectActivity(false)
|
||||
end
|
||||
end
|
||||
function ActivityListCtrl:GetGridPageCount(nPageCount)
|
||||
self.nPageCount = nPageCount >= #self.tbActList and #self.tbActList or nPageCount
|
||||
end
|
||||
function ActivityListCtrl:OnRefreshGrid(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
if self.nPageCount > 0 and self.bPlayAnim then
|
||||
local trans = goGrid.transform:Find("btnGrid")
|
||||
local doTweenTime = 0.25
|
||||
local delayTime = (nIndex - 1) * 0.05
|
||||
trans.anchoredPosition = Vector2(0, -200)
|
||||
local sequence = DOTween.Sequence()
|
||||
sequence:Append(trans:DOAnchorPosY(0, doTweenTime):SetUpdate(true))
|
||||
sequence:SetUpdate(true):SetDelay(delayTime)
|
||||
self.nPageCount = self.nPageCount - 1
|
||||
end
|
||||
local nInstanceId = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceId] then
|
||||
self.tbGridCtrl[nInstanceId] = self:BindCtrlByNode(goGrid, "Game.UI.ActivityList.ActivityTabCtrl")
|
||||
end
|
||||
goGrid.gameObject:SetActive(true)
|
||||
self.tbGridCtrl[nInstanceId]:Init(self.tbActList[nIndex])
|
||||
self.tbGridCtrl[nInstanceId]:SetSelect(nIndex == self.nSelectIndex)
|
||||
end
|
||||
function ActivityListCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
if nIndex == self.nSelectIndex then
|
||||
return
|
||||
end
|
||||
local actData = self.tbActList[nIndex].actData
|
||||
local bOpen = self.tbActList[nIndex].nType == AllEnum.ActivityMainType.Activity and actData:CheckActivityOpen() or actData:CheckActGroupShow()
|
||||
if not bOpen then
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Tips,
|
||||
sContent = ConfigTable.GetUIText("Activity_Invalid_Tip_1")
|
||||
})
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityList)
|
||||
return
|
||||
end
|
||||
local goSelect = self._mapNode.trSv:Find("Viewport/Content/" .. self.nSelectIndex - 1)
|
||||
if goSelect then
|
||||
self.tbGridCtrl[goSelect.gameObject:GetInstanceID()]:SetSelect(false)
|
||||
end
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
self.nSelectIndex = nIndex
|
||||
self.tbGridCtrl[nInstanceID]:SetSelect(true)
|
||||
self:RefreshSelectActivity(true)
|
||||
end
|
||||
function ActivityListCtrl:AddPeriodicActivityCtrl(actData, bResetDay)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActId()]
|
||||
if nil == actCtrl then
|
||||
local perActCfg = actData:GetPerQuestCfg()
|
||||
local sCtrlFolder = sActTypePath[GameEnum.activityType.PeriodicQuest]
|
||||
if sCtrlFolder == nil then
|
||||
return
|
||||
end
|
||||
local sPrefabPath = string.format(sEntranceFolder, perActCfg.UIAssets)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local sCtrlPath = string.format("Game.UI.Activity.%s.%s", sCtrlFolder, perActCfg.CtrlName)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData, bResetDay)
|
||||
end
|
||||
function ActivityListCtrl:AddLoginRewardActivityCtrl(actData)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActId()]
|
||||
if nil == actCtrl then
|
||||
local mapActCfg = actData:GetLoginRewardControlCfg()
|
||||
local sCtrlFolder = sActTypePath[GameEnum.activityType.LoginReward]
|
||||
if sCtrlFolder == nil then
|
||||
return
|
||||
end
|
||||
local sPrefabPath = string.format(sEntranceFolder, mapActCfg.UIAssets)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local sCtrlPath = string.format("Game.UI.Activity.%s.%s", sCtrlFolder, mapActCfg.CtrlName)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData)
|
||||
end
|
||||
function ActivityListCtrl:AddMiningActivityCtrl(actData)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActId()]
|
||||
if nil == actCtrl then
|
||||
local miningActCfg = actData:GetMiningCfg()
|
||||
local sFolder = sActTypePath[GameEnum.activityType.Mining]
|
||||
if sFolder == nil then
|
||||
return
|
||||
end
|
||||
local sPrefabPath = string.format(sEntranceFolder_old, sFolder, miningActCfg.UIAssets)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local sCtrlPath = string.format("Game.UI.Activity.%s.%s", sFolder, miningActCfg.CtrlName)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData)
|
||||
end
|
||||
function ActivityListCtrl:AddTrialActivityCtrl(actData)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActId()]
|
||||
if nil == actCtrl then
|
||||
local mapActCfg = actData:GetTrialControlCfg()
|
||||
local sFolder = mapActCfg.UIAssets
|
||||
if sFolder == nil then
|
||||
return
|
||||
end
|
||||
local sPrefabPath = string.format("UI_Activity/%s/Entrance.prefab", sFolder)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local sCtrlPath = string.format("Game.UI.Activity.%s.%s", sFolder, mapActCfg.CtrlName)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData)
|
||||
end
|
||||
function ActivityListCtrl:AddCookieActivityCtrl(actData)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActId()]
|
||||
if nil == actCtrl then
|
||||
local mapActCfg = actData:GetCookieControlCfg()
|
||||
local sFolder = sActTypePath[GameEnum.activityType.Cookie]
|
||||
local sPrefabPath = string.format(sEntranceFolder_old, sFolder, mapActCfg.UIAssets)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local sCtrlPath = string.format("Game.UI.Activity.%s.%s", sFolder, mapActCfg.CtrlName)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData)
|
||||
end
|
||||
function ActivityListCtrl:AddTowerDefenseActivityCtrl(actData)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActId()]
|
||||
if nil == actCtrl then
|
||||
local towerDefenseActCfg = actData:GetActConfig()
|
||||
local sFolder = sActTypePath[GameEnum.activityType.TowerDefense]
|
||||
if sFolder == nil then
|
||||
return
|
||||
end
|
||||
local sPrefabPath = string.format(sEntranceFolder_old, sFolder, towerDefenseActCfg.UIAssets)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local sCtrlPath = string.format("Game.UI.Activity.%s.%s", sFolder, towerDefenseActCfg.CtrlName)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData)
|
||||
end
|
||||
function ActivityListCtrl:AddJointDrillActivityCtrl(actData)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActId()]
|
||||
if nil == actCtrl then
|
||||
local jointDrillActCfg = actData:GetJointDrillActCfg()
|
||||
local sFolder = sActTypePath[GameEnum.activityType.JointDrill]
|
||||
if sFolder == nil then
|
||||
return
|
||||
end
|
||||
local sPrefabPath = string.format(sEntranceFolder, jointDrillActCfg.DrillPrefab)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local sCtrlPath = string.format("Game.UI.Activity.%s.%s", sFolder, jointDrillActCfg.CtrlName)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData)
|
||||
end
|
||||
function ActivityListCtrl:AddActivityGroupCtrl(actData)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActGroupId()]
|
||||
if nil == actCtrl then
|
||||
local actGroupCfg = actData:GetActGroupCfgData()
|
||||
local sFolder = actGroupCfg.UIAssetsPrefab
|
||||
if sFolder == nil then
|
||||
return
|
||||
end
|
||||
local sPrefabPath = string.format("UI_Activity/%s/Entrance.prefab", sFolder)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local sCtrlPath = string.format("Game.UI.ActivityTheme.%s.%s", sFolder, actGroupCfg.CtrlName)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActGroupId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData)
|
||||
end
|
||||
function ActivityListCtrl:AddAdvertisingActCtrl(actData)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActId()]
|
||||
if nil == actCtrl then
|
||||
local sFolder = sActTypePath[GameEnum.activityType.Advertise]
|
||||
if sFolder == nil then
|
||||
return
|
||||
end
|
||||
local adControlCfg = ConfigTable.GetData("AdControl", actData.nActId)
|
||||
local uiAssetPath = adControlCfg.UIAssets
|
||||
local sPrefabPath = string.format(sEntranceFolder, uiAssetPath)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local ctrlPath = adControlCfg.CtrlName
|
||||
local sCtrlPath = string.format("Game.UI.Activity.%s.%s", sFolder, ctrlPath)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData)
|
||||
end
|
||||
function ActivityListCtrl:AddActivityTaskActCtrl(actData)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActId()]
|
||||
if nil == actCtrl then
|
||||
local sAssetsFolder = "_" .. actData:GetActId()
|
||||
local sCtrlFolder = sActTypePath[GameEnum.activityType.Task]
|
||||
if sCtrlFolder == nil then
|
||||
return
|
||||
end
|
||||
local adControlCfg = CacheTable.GetData("_ActivityTaskControl", actData.nActId)
|
||||
if adControlCfg == nil then
|
||||
return
|
||||
end
|
||||
local uiAssetPath = adControlCfg.UIAssets
|
||||
if uiAssetPath == "" then
|
||||
return
|
||||
end
|
||||
local sPrefabPath = string.format(sEntranceFolder_old, sAssetsFolder, uiAssetPath)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local ctrlPath = adControlCfg.CtrlName
|
||||
local sCtrlPath = string.format("Game.UI.Activity.%s.%s", sCtrlFolder, ctrlPath)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData)
|
||||
end
|
||||
function ActivityListCtrl:AddBdConvertActivityCtrl(actData)
|
||||
local actCtrl = self.tbActCtrlObj[actData:GetActId()]
|
||||
if nil == actCtrl then
|
||||
local BdConvertActCfg = actData:GetActConfig()
|
||||
local sFolder = "_" .. actData:GetActId()
|
||||
if sFolder == nil then
|
||||
return
|
||||
end
|
||||
local sPrefabPath = string.format(sEntranceFolder_old, sFolder, BdConvertActCfg.UIAssets)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.rtContent)
|
||||
local sCtrlPath = string.format("Game.UI.Activity.%s.%s", "BdConvert", BdConvertActCfg.CtrlName)
|
||||
actCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
self.tbActCtrlObj[actData:GetActId()] = actCtrl
|
||||
end
|
||||
actCtrl.gameObject:SetActive(true)
|
||||
actCtrl:InitActData(actData)
|
||||
end
|
||||
function ActivityListCtrl:RefreshSelectActivity(bResetDay)
|
||||
for _, v in pairs(self.tbActCtrlObj) do
|
||||
v.gameObject:SetActive(false)
|
||||
end
|
||||
local actData = self.tbActList[self.nSelectIndex]
|
||||
if nil == actData then
|
||||
return
|
||||
end
|
||||
self.nSelectActMainType = actData.nType
|
||||
if actData.nType == AllEnum.ActivityMainType.Activity then
|
||||
self.nSelectActId = actData.actData:GetActId()
|
||||
local actType = actData.actData:GetActType()
|
||||
if actType == GameEnum.activityType.PeriodicQuest then
|
||||
self:AddPeriodicActivityCtrl(actData.actData, bResetDay)
|
||||
elseif actType == GameEnum.activityType.LoginReward then
|
||||
self:AddLoginRewardActivityCtrl(actData.actData)
|
||||
elseif actType == GameEnum.activityType.Mining then
|
||||
self:AddMiningActivityCtrl(actData.actData)
|
||||
elseif actType == GameEnum.activityType.Trial then
|
||||
self:AddTrialActivityCtrl(actData.actData)
|
||||
elseif actType == GameEnum.activityType.Cookie then
|
||||
self:AddCookieActivityCtrl(actData.actData)
|
||||
elseif actType == GameEnum.activityType.TowerDefense then
|
||||
self:AddTowerDefenseActivityCtrl(actData.actData)
|
||||
elseif actType == GameEnum.activityType.JointDrill then
|
||||
self:AddJointDrillActivityCtrl(actData.actData)
|
||||
elseif actType == GameEnum.activityType.Advertise then
|
||||
self:AddAdvertisingActCtrl(actData.actData)
|
||||
elseif actType == GameEnum.activityType.Task then
|
||||
self:AddActivityTaskActCtrl(actData.actData)
|
||||
elseif actType == GameEnum.activityType.BDConvert then
|
||||
self:AddBdConvertActivityCtrl(actData.actData)
|
||||
end
|
||||
elseif actData.nType == AllEnum.ActivityMainType.ActivityGroup then
|
||||
self.nSelectActId = actData.actData:GetActGroupId()
|
||||
self:AddActivityGroupCtrl(actData.actData)
|
||||
end
|
||||
if self.nSelectActId ~= nil then
|
||||
LocalData.SetPlayerLocalData("Activity_Tab_New_" .. self.nSelectActId, 1)
|
||||
RedDotManager.SetValid(RedDotDefine.Activity_New_Tab, self.nSelectActId, false)
|
||||
end
|
||||
end
|
||||
function ActivityListCtrl:FadeIn()
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
self._mapNode.animRoot:Play("ActivityPanel_in")
|
||||
end
|
||||
function ActivityListCtrl:Awake()
|
||||
self.nSelectIndex = nil
|
||||
self.nSelectActId = nil
|
||||
self.nInitActId = nil
|
||||
self.bPlayAnim = true
|
||||
local tbParams = self:GetPanelParam()
|
||||
if type(tbParams) == "table" then
|
||||
self.nInitActId = tbParams[1]
|
||||
end
|
||||
self._mapNode.goRewardList.gameObject:SetActive(false)
|
||||
end
|
||||
function ActivityListCtrl:OnEnable()
|
||||
self.tbActCtrlObj = {}
|
||||
self.tbActList = {}
|
||||
self.tbGridCtrl = {}
|
||||
self:InitActivityList(self.nInitActId)
|
||||
end
|
||||
function ActivityListCtrl:OnDisable()
|
||||
self.tbActList = {}
|
||||
for _, v in pairs(self.tbActCtrlObj) do
|
||||
v:ClearActivity()
|
||||
local obj = v.gameObject
|
||||
self:UnbindCtrlByNode(v)
|
||||
destroy(obj)
|
||||
end
|
||||
self.tbActCtrlObj = {}
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function ActivityListCtrl:OnDestroy()
|
||||
end
|
||||
function ActivityListCtrl:OnEvent_ShowActRewardList(tbReward)
|
||||
self._mapNode.goRewardList:OpenPanel(tbReward)
|
||||
end
|
||||
return ActivityListCtrl
|
||||
@@ -0,0 +1,22 @@
|
||||
local ActivityListPanel = class("ActivityListPanel", BasePanel)
|
||||
ActivityListPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "ActivityList/ActivityListPanel.prefab",
|
||||
sCtrlName = "Game.UI.ActivityList.ActivityListCtrl"
|
||||
}
|
||||
}
|
||||
function ActivityListPanel:Awake()
|
||||
self.nSelectGroup = nil
|
||||
end
|
||||
function ActivityListPanel:OnEnable()
|
||||
end
|
||||
function ActivityListPanel:OnAfterEnter()
|
||||
end
|
||||
function ActivityListPanel:OnDisable()
|
||||
end
|
||||
function ActivityListPanel:OnDestroy()
|
||||
self.nSelectGroup = nil
|
||||
end
|
||||
function ActivityListPanel:OnRelease()
|
||||
end
|
||||
return ActivityListPanel
|
||||
@@ -0,0 +1,128 @@
|
||||
local ActivityPopUpCtrl = class("ActivityPopUpCtrl", BaseCtrl)
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
ActivityPopUpCtrl._mapNodeConfig = {
|
||||
imgBlurredBg = {},
|
||||
goContent = {
|
||||
sNodeName = "---Content---"
|
||||
},
|
||||
imgActivity = {sComponentName = "Image"},
|
||||
btnGoto = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Goto"
|
||||
},
|
||||
txtBtnGoto = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Activity_PopUp_Goto"
|
||||
},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
PopUpRoot = {
|
||||
sNodeName = "---PopUpRoot---",
|
||||
sComponentName = "RectTransform"
|
||||
}
|
||||
}
|
||||
ActivityPopUpCtrl._mapEventConfig = {}
|
||||
function ActivityPopUpCtrl:ShowPopUp()
|
||||
if self.tbPopUpAct == nil or #self.tbPopUpAct <= 0 then
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityPopUp)
|
||||
if self.callback ~= nil then
|
||||
self.callback()
|
||||
end
|
||||
return
|
||||
end
|
||||
self.popUpIndex = self.popUpIndex + 1
|
||||
self.nCurActId = table.remove(self.tbPopUpAct, 1)
|
||||
local popUpCfg = PlayerData.PopUp:GetPopUpConfigData(self.nCurActId)
|
||||
self.curType = popUpCfg.PopUpType
|
||||
if popUpCfg ~= nil then
|
||||
if self.tbPopUpCtrlObj ~= nil then
|
||||
if self.tbPopUpCtrlObj.go ~= nil then
|
||||
destroy(self.tbPopUpCtrlObj.go)
|
||||
end
|
||||
if self.tbPopUpCtrlObj.ctrl ~= nil then
|
||||
self:UnbindCtrlByNode(self.tbPopUpCtrlObj.ctrl)
|
||||
end
|
||||
self.tbPopUpCtrlObj = {}
|
||||
end
|
||||
local popFloderPath = ""
|
||||
local ctrlFloderPath = ""
|
||||
if popUpCfg.PopUpType == GameEnum.PopUpType.ActivityGroup or popUpCfg.PopUpType == GameEnum.PopUpType.Activity then
|
||||
popFloderPath = "UI_Activity"
|
||||
ctrlFloderPath = "ActivityPopUp"
|
||||
elseif popUpCfg.PopUpType == GameEnum.PopUpType.OwnPopUP then
|
||||
popFloderPath = "UI"
|
||||
ctrlFloderPath = "OwnPopUp"
|
||||
end
|
||||
local sPrefabPath = string.format("%s/%s.prefab", popFloderPath, popUpCfg.PopUpRes)
|
||||
local goObj = self:CreatePrefabInstance(sPrefabPath, self._mapNode.PopUpRoot)
|
||||
local ctrlName = popUpCfg.ScriptName
|
||||
local sCtrlPath = string.format("Game.UI.%s.%s", ctrlFloderPath, ctrlName)
|
||||
local popupCtrl = self:BindCtrlByNode(goObj, sCtrlPath)
|
||||
local callback = function()
|
||||
self:OnBtnClick_Close()
|
||||
end
|
||||
popupCtrl:ShowPopUp(self.nCurActId, callback, self.popUpIndex)
|
||||
self.tbPopUpCtrlObj = {go = goObj, ctrl = popupCtrl}
|
||||
local saveTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
if popUpCfg ~= nil then
|
||||
if popUpCfg.PopRefreshType == GameEnum.PopRefreshType.WeeklyFirst then
|
||||
saveTime = GetNextWeekRefreshTime()
|
||||
end
|
||||
LocalData.SetPlayerLocalData("Act_PopUp" .. self.nCurActId, saveTime)
|
||||
self._mapNode.btnGoto.gameObject:SetActive(popUpCfg.PopJumpType ~= GameEnum.PopJumpType.None)
|
||||
PlayerData.PopUp:ReleaseCachedPopUpData(popUpCfg.Id)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivityPopUpCtrl:IsPopUpType()
|
||||
return self.curType == GameEnum.PopUpType.ActivityGroup or self.curType == GameEnum.PopUpType.Activity or self.curType == GameEnum.PopUpType.OwnPopUP
|
||||
end
|
||||
function ActivityPopUpCtrl:Awake()
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.tbPopUpAct = tbParam[1]
|
||||
self.callback = tbParam[2]
|
||||
end
|
||||
self.popUpIndex = 0
|
||||
end
|
||||
function ActivityPopUpCtrl:OnEnable()
|
||||
self._mapNode.goContent.gameObject:SetActive(false)
|
||||
self._mapNode.PopUpRoot.gameObject:SetActive(false)
|
||||
self._mapNode.imgBlurredBg.gameObject:SetActive(true)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForSeconds(0.1))
|
||||
self._mapNode.PopUpRoot.gameObject:SetActive(self:IsPopUpType())
|
||||
if self.tbPopUpCtrlObj.ctrl ~= nil and self.tbPopUpCtrlObj.ctrl.PlayOpenAnim ~= nil then
|
||||
self.tbPopUpCtrlObj.ctrl:PlayOpenAnim()
|
||||
end
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
self:ShowPopUp()
|
||||
end
|
||||
function ActivityPopUpCtrl:OnDisable()
|
||||
end
|
||||
function ActivityPopUpCtrl:OnDestroy()
|
||||
end
|
||||
function ActivityPopUpCtrl:OnRelease()
|
||||
end
|
||||
function ActivityPopUpCtrl:OnBtnClick_Close()
|
||||
self:ShowPopUp()
|
||||
end
|
||||
function ActivityPopUpCtrl:OnBtnClick_Goto()
|
||||
if nil ~= self.nCurActId then
|
||||
PopUpManager.InterruptPopUp(self.popUpIndex)
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ActivityPopUp)
|
||||
local popUpCfg = PlayerData.PopUp:GetPopUpConfigData(self.nCurActId)
|
||||
if nil ~= popUpCfg then
|
||||
if popUpCfg.PopJumpType == GameEnum.PopJumpType.ActivityJump then
|
||||
if popUpCfg.PopUpType == GameEnum.PopUpType.Activity then
|
||||
PlayerData.Activity:OpenActivityPanel(self.nCurActId)
|
||||
end
|
||||
elseif popUpCfg.PopJumpType == GameEnum.PopJumpType.NormalJump then
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return ActivityPopUpCtrl
|
||||
@@ -0,0 +1,21 @@
|
||||
local ActivityPopUpPanel = class("ActivityPopUpPanel", BasePanel)
|
||||
ActivityPopUpPanel._bIsMainPanel = false
|
||||
ActivityPopUpPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "ActivityList/ActivityPopUpPanel.prefab",
|
||||
sCtrlName = "Game.UI.ActivityList.ActivityPopUpCtrl"
|
||||
}
|
||||
}
|
||||
function ActivityPopUpPanel:Awake()
|
||||
end
|
||||
function ActivityPopUpPanel:OnEnable()
|
||||
end
|
||||
function ActivityPopUpPanel:OnAfterEnter()
|
||||
end
|
||||
function ActivityPopUpPanel:OnDisable()
|
||||
end
|
||||
function ActivityPopUpPanel:OnDestroy()
|
||||
end
|
||||
function ActivityPopUpPanel:OnRelease()
|
||||
end
|
||||
return ActivityPopUpPanel
|
||||
@@ -0,0 +1,54 @@
|
||||
local ActivityTabCtrl = class("ActivityTabCtrl", BaseCtrl)
|
||||
ActivityTabCtrl._mapNodeConfig = {
|
||||
imgActivity = {sComponentName = "Image"},
|
||||
imgChoose = {},
|
||||
imgActTime = {},
|
||||
redDotActTab = {},
|
||||
redDotActNew = {}
|
||||
}
|
||||
ActivityTabCtrl._mapEventConfig = {}
|
||||
function ActivityTabCtrl:Init(actData)
|
||||
self._mapNode.imgChoose.gameObject:SetActive(false)
|
||||
self.actData = actData.actData
|
||||
self.nType = actData.nType
|
||||
if actData.nType == AllEnum.ActivityMainType.Activity then
|
||||
self.nActId = self.actData:GetActId()
|
||||
elseif actData.nType == AllEnum.ActivityMainType.ActivityGroup then
|
||||
self.nActId = self.actData:GetActGroupId()
|
||||
end
|
||||
local actCfg = actData.nType == AllEnum.ActivityMainType.Activity and self.actData:GetActCfgData() or self.actData:GetActGroupCfgData()
|
||||
self:SetPngSprite(self._mapNode.imgActivity, actCfg.TabBgRes)
|
||||
NovaAPI.SetImageNativeSize(self._mapNode.imgActivity)
|
||||
local endTime = actData.nType == AllEnum.ActivityMainType.Activity and self.actData:GetActEndTime() or self.actData:GetActGroupEndTime()
|
||||
local curTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
local remainTime = endTime - curTime
|
||||
self._mapNode.imgActTime.gameObject:SetActive(0 < endTime and remainTime <= 259200)
|
||||
self:RegisterRedDotNode()
|
||||
end
|
||||
function ActivityTabCtrl:SetSelect(bSelect)
|
||||
self._mapNode.imgChoose.gameObject:SetActive(bSelect)
|
||||
end
|
||||
function ActivityTabCtrl:RegisterRedDotNode()
|
||||
if self.nType == AllEnum.ActivityMainType.Activity then
|
||||
RedDotManager.RegisterNode(RedDotDefine.Activity_Tab, self.nActId, self._mapNode.redDotActTab)
|
||||
RedDotManager.RegisterNode(RedDotDefine.Activity_New_Tab, self.nActId, self._mapNode.redDotActNew)
|
||||
elseif self.nType == AllEnum.ActivityMainType.ActivityGroup then
|
||||
if not self.actData:IsUnlock() then
|
||||
self._mapNode.redDotActTab:SetActive(false)
|
||||
self._mapNode.redDotActNew:SetActive(false)
|
||||
else
|
||||
local HasRedDot = RedDotManager.GetValid(RedDotDefine.Activity_Group, {
|
||||
self.nActId
|
||||
})
|
||||
local HasNew = RedDotManager.GetValid(RedDotDefine.Activity_New_Tab, {
|
||||
self.nActId
|
||||
})
|
||||
RedDotManager.SetValid(RedDotDefine.Activity_New_Tab, self.nActId, HasNew and not HasRedDot)
|
||||
self._mapNode.redDotActTab.gameObject:SetActive(HasRedDot)
|
||||
RedDotManager.RegisterNode(RedDotDefine.Activity_New_Tab, self.nActId, self._mapNode.redDotActNew)
|
||||
end
|
||||
end
|
||||
end
|
||||
function ActivityTabCtrl:OnDisable()
|
||||
end
|
||||
return ActivityTabCtrl
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user