上传项目

master
1076390229 2025-12-17 21:08:27 +08:00
commit 0865e1f0f3
6776 changed files with 792973 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
# 忽略所有文件和文件夹
*
# 上传两个文件夹
!lua_probject/
!wb_unity_pro/
!lua_probject/**
!wb_unity_pro/**
!.gitignore

View File

@ -0,0 +1,10 @@
{
"ExpandedNodes": [
"",
"\\base_project",
"\\main_project\\main",
"\\tolua_project"
],
"SelectedNode": "\\tolua_project\\event.lua",
"PreviewInSolutionExplorer": false
}

Binary file not shown.

Binary file not shown.

116
lua_probject/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,116 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Cocos2-launch",
"type": "lua",
"request": "launch",
"runtimeType": "Cocos2",
"localRoot": "${workspaceRoot}",
"commandLine": "-workdir ${workspaceRoot}/../ -file src/main.lua",
"port": 7003,
"exePath": "",
"fileExtNames": [
".lua",
".txt",
".lua.txt",
".bytes"
],
"isFoxGloryProject": false,
"printType": 1
},
{
"name": "COCOS(remote debugging)",
"type": "lua",
"request": "attach",
"runtimeType": "Cocos2",
"localRoot": "${workspaceRoot}",
"port": 7003,
"fileExtNames": [
".lua",
".txt",
".lua.txt",
".bytes"
],
"isFoxGloryProject": false,
"printType": 1
},
{
"name": "Unity-ulua",
"type": "lua",
"request": "attach",
"runtimeType": "Unity",
"localRoot": "${workspaceRoot}",
"fileExtNames": [
".lua",
".txt",
".lua.txt",
".bytes"
],
"port": 7003,
"printType": 1
},
{
"name": "Unity-slua",
"type": "lua",
"request": "attach",
"runtimeType": "Unity",
"localRoot": "${workspaceRoot}",
"fileExtNames": [
".lua",
".txt",
".lua.txt",
".bytes"
],
"port": 7003,
"printType": 1
},
{
"name": "Unity-xlua",
"type": "lua",
"request": "attach",
"runtimeType": "Unity",
"localRoot": "${workspaceRoot}",
"fileExtNames": [
".lua",
".txt",
".lua.txt",
".bytes"
],
"port": 7003,
"printType": 1
},
{
"name": "OpenResty",
"type": "lua",
"request": "attach",
"runtimeType": "OpenResty",
"localRoot": "${workspaceRoot}",
"port": 7003,
"fileExtNames": [
".lua"
],
"printType": 1
},
{
"name": "LuaTest",
"type": "lua",
"request": "launch",
"runtimeType": "LuaTest",
"mainFile": "${fileBasenameNoExtension}",
"localRoot": "${fileDirname}",
"curFileExtname": "${fileExtname}",
"fileExtNames": [
".lua",
".txt",
".lua.txt",
".bytes"
],
"port": 7003,
"printType": 1
}
]
}

8
lua_probject/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,8 @@
{
"cSpell.words": [
"card",
"clear",
"list"
],
"editor.snippetSuggestions": "bottom"
}

View File

@ -0,0 +1,17 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}

View File

@ -0,0 +1,3 @@
{
"editor.snippetSuggestions": "bottom"
}

View File

@ -0,0 +1,193 @@
--网络核心功能处理类
--author--
-- a net client
NetClient= {
}
ConnectionProtocol = {
Tcp = 0,
--http 短连接
Web = 1,
}
SocketCode = {
--连接成功
Connect = 0,
--断开
Disconnect = 1,
--未知异常
Exception = 2,
--连接服务异常
ExceptionOnConnect = 3,
--发送数据流错误
SendError = 4,
--接收服务器数据流异常
ExceptionOnReceive = 5,
--服务器连接超时
TimeoutDisconnect = 6,
--服务器断开连接
DisconnectByServer = 7,
--客户端网络异常
NetworkException = 8,
--连接安全异常,一般为防火墙阻止
SecurityExceptionOnConnect = 9
}
---
-- @type NetClient
local R = {
--网络地址
hsot = "",
--网络端口
port = 0,
--session
session = "",
--网络类型
protocol = ConnectionProtocol.Tcp,
--c#端处理类
c__netClient = nil,
--拦截
holdCallback = nil
}
local LuaNetClient = taurus.unity.LuaNetClient
--- Create a new NetClient
-- @function [parent=#NetClient] new
-- @param #string host
-- @param #string game
-- @param #number protocol
-- @return #NetClient the created NetClient
function NetClient.new(host, game,protocol)
local self = {}
self.host = host or ""
self.game = game or ""
self.protocol = protocol or ConnectionProtocol.Tcp
-- self.responseMap = {}
self.onevent = event("onevent",false)
self.onconnect = event("onconnect",false)
self.c__netClient = LuaNetClient(host,game,self,self.protocol)
self.c__netClient:SetCallBackListener(R.c__ondata)
self.c__netClient:SetNetEventListener(R.c__onevent)
self.c__netClient:SetNetConnectListener(R.c__onconnect)
setmetatable(self, {__index = R})
return self
end
function R.connect(self)
if self.c__netClient == nil then
return
end
self.c__netClient:Connect()
end
local TYPE_STRING = "string"
local TYPE_FUNC = "function"
local TYPE_TABLE = "table"
local NULL_JSON = "{}"
--- send
function R.send(self,cmd, data, callback)
if(debug_print) then
print("send host:"..self.host)
end
if self.c__netClient == nil then
return
end
if callback and type(callback) ~= TYPE_FUNC then return end
if data then
if type(data) ~= TYPE_TABLE then return end
end
local str = NULL_JSON
if data then
str = json.encode(data)
end
self.c__netClient:Send(cmd,str,callback)
end
---c#网络层回调函数
function R.c__ondata(self,cmd,result,data,func)
local _response = nil
if type(data) == TYPE_STRING and string.len(data) > 0 then
_response = json.decode(data)
end
local new_response = {}
new_response.ReturnCode = result
new_response.Data = _response
if self.holdCallback ~=nil then
if self.holdCallback(new_response) then
return
end
end
func(new_response)
end
function R.setSession(self,session)
printlog("setSession==>>>",session)
self.session = session
if self.c__netClient == nil then
return
end
self.c__netClient.Session = session
end
function R.getSession(self)
printlog("getSession===>>>",self.session)
return self.session
end
function R.getAveragePingTime(self)
if self.c__netClient == nil then
return
end
return self.c__netClient.AveragePingTime
end
---c#网络层回调函数
function R.c__onevent(self,cmd,data)
local new_response = {}
local _response = data and json.decode(data) or nil
new_response.Command = cmd
new_response.Data = _response
self.onevent(new_response)
end
function R.clearActionQueue(self)
if self.c__netClient == nil then
return
end
self.c__netClient:ClearResponse()
end
---c#网络层回调函数
function R.c__onconnect(self,code)
if(debug_print) then
print("codeccccccccccccccccccccccccccccccccccccccc"..code)
end
self.onconnect(code)
end
function R.clearEvent(self)
self.onevent:Clear()
self.onconnect:Clear()
end
function R.setHold(self,func)
self.holdcallback = func
end
function R.destroy(self)
if self.c__netClient then self.c__netClient:Destroy() end
self.onconnect:Clear()
self.onevent:Clear()
self.c__netClient=nil
end

View File

@ -0,0 +1,89 @@
Queue = {}
function Queue.new(capacity)
local self = {}
setmetatable(self,{__index = Queue})
self.capacity = capacity
self.queue = {}
self.size_ = 0
self.head = -1
self.rear = -1
return self
end
function Queue:Enqueue(element)
if self.size_ == 0 then
self.head = 0
self.rear = 1
self.size_ = 1
self.queue[self.rear] = element
else
local temp = (self.rear + 1) % self.capacity
--print("1111111111111111111====>>>>")
--print(temp)
if temp == self.head then
error("Error: capacity is full.")
ViewUtil.ErrorTip(10001,"Error: capacity is full.")
return
else
self.rear = temp
end
self.queue[self.rear] = element
self.size_ = self.size_ + 1
end
end
function Queue:Dequeue()
if self:IsEmpty() then
ViewUtil.ErrorTip(10002,"Error: The Queue is empty.")
error("Error: The Queue is empty.")
return
end
self.size_ = self.size_ - 1
self.head = (self.head + 1) % self.capacity
local value = self.queue[self.head]
return value
end
function Queue:Clear()
self.queue = nil
self.queue = {}
self.size_ = 0
self.head = -1
self.rear = -1
end
function Queue:IsEmpty()
if self.size_ == 0 then
return true
end
return false
end
function Queue:Count()
return self.size_
end
function Queue:dump()
local h = self.head
local r = self.rear
local str = nil
local first_flag = true
while h ~= r do
if first_flag == true then
str = "{"..self.queue[h]
h = (h + 1) % self.capacity
first_flag = false
else
str = str..","..self.queue[h]
h = (h + 1) % self.capacity
end
end
str = str..","..self.queue[r].."}"
if(debug_print) then
print(str)
end
end

View File

@ -0,0 +1,96 @@
TimerManager={}
local timerList={}
local isEnableTimer=false
function TimerManager.New()
timerList={}
UpdateBeat:Add(TimerManager.UpdateTimer)
isEnableTimer=true
end
function TimerManager.IsHas(funcIns)
if timerList then
for k,v in pairs(timerList) do
if v.Self==funcIns then
return true
end
end
end
return false
end
function TimerManager.AddTimer(timerFunc,funcIns)
if timerFunc then
if TimerManager.IsHas(funcIns) then
printlog("已经存在计时器对象")
return
end
local tempList={}
tempList.func=timerFunc
tempList.Self=funcIns
table.insert(timerList,tempList)
else
printlog("添加计时器失败===>>>")
if debug_print==true then
printlog(debug.traceback())
end
end
end
function TimerManager.RemoveTimer(timerFunc,Self)
if timerFunc then
for k,v in pairs(timerList) do
if v.func==timerFunc and v.Self==self then
timerList[k]=nil
--table.remove(timerList,k)
end
end
end
end
function TimerManager.IsEnableTimer(isEnabe)
isEnableTimer=isEnabe
end
function TimerManager.UpdateTimer()
if isEnableTimer and #timerList>0 then
for k,v in pairs(timerList) do
if v.func then
v.func(v.Self)
end
end
end
end
function TimerManager.Clear()
timerList={}
end
function TimerManager.EnableTimer()
isEnableTimer=true
end
function TimerManager.StopAllTimer()
isEnableTimer=false
timerList={}
end
return TimerManager

View File

@ -0,0 +1,13 @@
TweenUtils = {}
function TweenUtils.TweenFloat(from, to, duration, opupdate)
return DSTween.To(from,to,duration,opupdate)
end
function TweenUtils.OnComplete(tweener,callback)
tweener:OnComplete(callback)
end
function TweenUtils.Kill(tweener)
tweener:Stop()
end

View File

@ -0,0 +1,136 @@
--[[
]]
--bit={data32={}}
bit = bit or {}
function bit.init32()
bit.data32 = {}
for i=1,32 do
bit.data32[i]=2^(32-i)
end
end
bit.init32()
function bit:d2b(arg) --bit:d2b
local tr={}
for i=1,32 do
if arg >= self.data32[i] then
tr[i]=1
arg=arg-self.data32[i]
else
tr[i]=0
end
end
return tr
end
function bit:b2d(arg) --bit:b2d
local nr=0
for i=1,32 do
if arg[i] ==1 then
nr=nr+2^(32-i)
end
end
return nr
end
function bit:_xor(a,b) --bit:xor
local op1=self:d2b(a)
local op2=self:d2b(b)
local r={}
for i=1,32 do
if op1[i]==op2[i] then
r[i]=0
else
r[i]=1
end
end
return self:b2d(r)
end
function bit:_and(a,b) --bit:_and
local op1=self:d2b(a)
local op2=self:d2b(b)
local r={}
for i=1,32 do
if op1[i]==1 and op2[i]==1 then
r[i]=1
else
r[i]=0
end
end
return self:b2d(r)
end
function bit:_or(a,b) --bit:_or
local op1=self:d2b(a)
local op2=self:d2b(b)
local r={}
for i=1,32 do
if op1[i]==1 or op2[i]==1 then
r[i]=1
else
r[i]=0
end
end
return self:b2d(r)
end
function bit:_not(a) --bit:_not
local op1=self:d2b(a)
local r={}
for i=1,32 do
if op1[i]==1 then
r[i]=0
else
r[i]=1
end
end
return self:b2d(r)
end
function bit:_rshift(a,n) --bit:_rshift
local op1=self:d2b(a)
local r=self:d2b(0)
if n < 32 and n > 0 then
for i=1,n do
for i=31,1,-1 do
op1[i+1]=op1[i]
end
op1[1]=0
end
r=op1
end
return self:b2d(r)
end
function bit:_lshift(a,n) --bit:_lshift
local op1=self:d2b(a)
local r=self:d2b(0)
if n < 32 and n > 0 then
for i=1,n do
for i=1,31 do
op1[i]=op1[i+1]
end
op1[32]=0
end
r=op1
end
return self:b2d(r)
end
function bit:print(ta)
local sr=""
for i=1,32 do
sr=sr..ta[i]
end
print(sr)
end

View File

@ -0,0 +1,304 @@
local setmetatable = setmetatable
function class(classname, super)
local superType = type(super)
local cls
if superType ~= "function" and superType ~= "table" then
superType = nil
super = nil
end
if superType == "function" or (super and super.__ctype == 1) then
-- inherited from native C++ Object
cls = {}
if superType == "table" then
-- copy fields from super
for k,v in pairs(super) do cls[k] = v end
cls.__create = super.__create
cls.super = super
else
cls.__create = super
cls.ctor = function() end
end
cls.__cname = classname
cls.__ctype = 1
function cls.new(...)
local instance = cls.__create(...)
-- copy fields from class to native object
for k,v in pairs(cls) do instance[k] = v end
instance.class = cls
instance:ctor(...)
return instance
end
else
-- inherited from Lua Object
if super then
cls = {}
setmetatable(cls, {__index = super})
cls.super = super
else
cls = {ctor = function() end}
end
cls.__cname = classname
cls.__ctype = 2 -- lua
cls.__index = cls
function cls.new(...)
local instance = setmetatable({}, cls)
instance.class = cls
instance:ctor(...)
return instance
end
end
return cls
end
-- 刘海偏移
function get_offset(full_offset)
if full_offset then
local r = GRoot.inst.width / GRoot.inst.height
if r >= 2 then
local d = (Screen.dpi /160)
return d * 20
end
end
return 0
end
---lua table 浅拷贝
function membe_clone(orig)
local copy
if type(orig) == "table" then
copy = {}
for orig_key, orig_value in pairs(orig) do
copy[orig_key] = orig_value
end
else -- number, string, boolean, etc
copy = orig
end
return copy
end
-- lua table 深拷贝
function membe_deep_clone(orig)
local copy
if type(orig) == "table" then
copy = {}
for orig_key, orig_value in pairs(orig) do
copy[membe_deep_clone(orig_key)] = membe_deep_clone(orig_value)
end
else
copy = orig
end
return copy
end
---字符串分割函数
function split(str, delimiter)
if str==nil or str=='' or delimiter==nil then
return nil
end
local result = {}
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match)
end
return result
end
function handler( obj,func)
return function(...)
return func(obj, ...)
end
end
--重新require一个lua文件替代系统文件。
function unimport(moduleName,currentModuleName)
local package = package
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 #currentModuleNameParts > 0 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
package.loaded[moduleFullName] = nil
package.preload[moduleFullName] = nil
end
function table.nums(t)
local count = 0
for k, v in pairs(t) do
count = count + 1
end
return count
end
-- @param t 要检查的表格(t表示是table)
-- @param table 返回指定表格的所有键key,它是一个键集合的表格
--]]
function table.keys( t )
local keys = {}
for k, _ in pairs( t ) do
keys[#keys + 1] = k
end
return keys
end
function list_remove(t,item)
for i,v in ipairs(t) do
if v == item then
table.remove(t,i)
break
end
end
end
function list_check(t,item)
for i,v in ipairs(t) do
if v == item then
return true
end
end
return false
end
function list_index(t,item)
for i,v in ipairs(t) do
if v == item then
return i
end
end
return 0
end
function list_concat(des,tag)
for i = 1, #tag do
table.insert(des, tag[i])
end
return des
end
function vardump(object, label)
local lookupTable = {}
local result = {}
local function _v(v)
if type(v) == "string" then
v = "\"" .. v .. "\""
end
return tostring(v)
end
local function _vardump(object, label, indent, nest)
label = label or "<var>"
local postfix = ""
if nest > 1 then postfix = "," end
if type(object) ~= "table" then
-- if type(label) == "string" then
result[#result +1] = string.format("%s%s = %s%s", indent, label, _v(object), postfix)
-- else
-- result[#result +1] = string.format("%s%s%s", indent, _v(object), postfix)
-- end
elseif not lookupTable[object] then
lookupTable[object] = true
-- if type(label) == "string" then
result[#result +1 ] = string.format("%s%s = {", indent, label)
-- else
-- result[#result +1 ] = string.format("%s{", indent)
-- end
local indent2 = indent .. " "
local keys = {}
local values = {}
for k, v in pairs(object) do
keys[#keys + 1] = k
values[k] = v
end
table.sort(keys, function(a, b)
if type(a) == "number" and type(b) == "number" then
return a < b
else
return tostring(a) < tostring(b)
end
end)
for i, k in ipairs(keys) do
_vardump(values[k], k, indent2, nest + 1)
end
result[#result +1] = string.format("%s}%s", indent, postfix)
end
end
_vardump(object, label, "", 1)
return table.concat(result, "\n")
end
function sysrandom(min,max)
local num = math.random(min,max)
return num
end
function IsHasDictionary(currentTarget,list)
if list and #list>0 then
for k,v in ipairs(list) do
if v==currentTarget then
return true
end
end
return false
else
return false
end
end
function CheckDictionaryFromContent(target,list)
if list and #list>0 then
for k,v in pairs(list) do
if v.card==target then
return true,k
end
end
else
return false
end
end
function CombineDictionaryAndRemoveSomeItem(list1,list2)
local tempList=membe_clone(list2)
for i=1,#list1 do
if IsHasDictionary(list1[i],list2)==false then
table.insert(tempList,list1[i])
end
end
return tempList
end

View File

@ -0,0 +1,20 @@
import(".functions")
import(".string")
import(".Queue")
import(".NetClient")
import(".TweenUtils")
import(".bit")
ds = {
tween = {}
}
import(".tween.DSTweenManager")
import(".tween.DSTween")
import(".tween.DSTweenQuaternion")
DSTween = ds.tween.DSTween
DSTweenManager = ds.tween.DSTweenManager
import(".TimerManager")

View File

@ -0,0 +1,305 @@
string._htmlspecialchars_set = {}
string._htmlspecialchars_set["&"] = "&amp;"
string._htmlspecialchars_set["\""] = "&quot;"
string._htmlspecialchars_set["'"] = "&#039;"
string._htmlspecialchars_set["<"] = "&lt;"
string._htmlspecialchars_set[">"] = "&gt;"
--[[--
HTML
~~~ lua
print(string.htmlspecialchars("<ABC>"))
-- 输出 &lt;ABC&gt;
~~~
@param string input
@return string
]]
function string.htmlspecialchars(input)
for k, v in pairs(string._htmlspecialchars_set) do
input = string.gsub(input, k, v)
end
return input
end
--[[--
HTML string.htmlspecialchars()
~~~ lua
print(string.restorehtmlspecialchars("&lt;ABC&gt;"))
-- 输出 <ABC>
~~~
@param string input
@return string
]]
function string.restorehtmlspecialchars(input)
for k, v in pairs(string._htmlspecialchars_set) do
input = string.gsub(input, v, k)
end
return input
end
--[[--
\n HTML
~~~ lua
print(string.nl2br("Hello\nWorld"))
-- 输出
-- Hello<br />World
~~~
@param string input
@return string
]]
function string.nl2br(input)
return string.gsub(input, "\n", "<br />")
end
--[[--
\n HTML
~~~ lua
print(string.nl2br("<Hello>\nWorld"))
-- 输出
-- &lt;Hello&gt;<br />World
~~~
@param string input
@return string
]]
function string.text2html(input)
input = string.gsub(input, "\t", " ")
input = string.htmlspecialchars(input)
input = string.gsub(input, " ", "&nbsp;")
input = string.nl2br(input)
return input
end
--[[--
~~~ lua
local input = "Hello,World"
local res = string.split(input, ",")
-- res = {"Hello", "World"}
local input = "Hello-+-World-+-Quick"
local res = string.split(input, "-+-")
-- res = {"Hello", "World", "Quick"}
~~~
@param string input
@param string delimiter
@return array
]]
function string.split(input, delimiter)
input = tostring(input)
delimiter = tostring(delimiter)
if (delimiter=='') then return false end
local pos,arr = 0, {}
-- for each divider found
for st,sp in function() return string.find(input, delimiter, pos, true) end do
table.insert(arr, string.sub(input, pos, st - 1))
pos = sp + 1
end
table.insert(arr, string.sub(input, pos))
return arr
end
--[[--
~~~ lua
local input = " ABC"
print(string.ltrim(input))
-- 输出 ABC输入字符串前面的两个空格被去掉了
~~~
-
- \t
- \n
- \r
@param string input
@return string
@see string.rtrim, string.trim
]]
function string.ltrim(input)
return string.gsub(input, "^[ \t\n\r]+", "")
end
--[[--
~~~ lua
local input = "ABC "
print(string.ltrim(input))
-- 输出 ABC输入字符串最后的两个空格被去掉了
~~~
@param string input
@return string
@see string.ltrim, string.trim
]]
function string.rtrim(input)
return string.gsub(input, "[ \t\n\r]+$", "")
end
--[[--
@param string input
@return string
@see string.ltrim, string.rtrim
]]
function string.trim(input)
input = string.gsub(input, "^[ \t\n\r]+", "")
return string.gsub(input, "[ \t\n\r]+$", "")
end
--[[--
~~~ lua
local input = "hello"
print(string.ucfirst(input))
-- 输出 Hello
~~~
@param string input
@return string
]]
function string.ucfirst(input)
return string.upper(string.sub(input, 1, 1)) .. string.sub(input, 2)
end
local function urlencodechar(char)
return "%" .. string.format("%02X", string.byte(char))
end
--[[--
URL
~~~ lua
local input = "hello world"
print(string.urlencode(input))
-- 输出
-- hello%20world
~~~
@param string input
@return string
@see string.urldecode
]]
function string.urlencode(input)
-- convert line endings
input = string.gsub(tostring(input), "\n", "\r\n")
-- escape all characters but alphanumeric, '.' and '-'
input = string.gsub(input, "([^%w%.%- ])", urlencodechar)
-- convert spaces to "+" symbols
return string.gsub(input, " ", "+")
end
--[[--
URL
~~~ lua
local input = "hello%20world"
print(string.urldecode(input))
-- 输出
-- hello world
~~~
@param string input
@return string
@see string.urlencode
]]
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
--[[--
UTF8
~~~ lua
local input = "你好World"
print(string.utf8len(input))
-- 输出 7
~~~
@param string input
@return integer
]]
function string.utf8len(input)
if input == nil then return 0 end
if type(input) ~= "string" then return 0 end
local len = string.len(input)
local left = len
local cnt = 0
local arr = {0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}
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
--[[
utf8
@param string input
@param integer indexendIndex 1index
@return string
]]
function string.utf8sub(input, index, endIndex)
if input == nil or type(input) ~= "string" then return nil end
if not endIndex then
endIndex = index
index = 1
end
local len = string.len(input)
local left = len
local cnt = 0
local head, tail = 0, 0
local arr = {0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}
while left ~= 0 do
if cnt + 1 == index then
head = len - left + 1
end
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
if cnt == endIndex or left == 0 then
tail = len - left
break
end
end
local rt = string.sub(input, head, tail)
return rt
end
--[[--
~~~ lua
print(string.formatnumberthousands(1924235))
-- 输出 1,924,235
~~~
@param number num
@return string
]]
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.concat( ... )
local str = {}
local tem = {...}
for _,v in ipairs(tem) do
str[#str + 1] = v
end
return table.concat(str , "")
end

View File

@ -0,0 +1,398 @@
--Tween 核心基类
--author--
local DSAxis = {
None = 0,
X = 2,
Y = 4,
Z = 8,
}
local DSEase = {
Linear=0,
InSine=1,
OutSine=2,
InOutSine=3,
InQuad=4,
OutQuad=5,
InOutQuad=6,
InCubic=7,
OutCubic=8,
InOutCubic=9,
InQuart=10,
OutQuart=11,
InOutQuart=12,
InQuint=13,
OutQuint=14,
InOutQuint=15,
InExpo=16,
OutExpo=17,
InOutExpo=18,
InCirc=19,
OutCirc=20,
InOutCirc=21,
InElastic=22,
OutElastic=23,
InOutElastic=24,
InBack=25,
OutBack=26,
InOutBack=27,
InBounce=28,
OutBounce=29,
InOutBounce=30,
}
local DSTweenState = ds.tween.DSTweenState
local DSTween = {
_from = 0,
_to = 1,
_duration = 0,
_currenTime = 0,
_ease = DSEase.Linear,
_state = DSTweenState.Play,
_autoRemove=true,
_loop = 1,
_currenLoop=1,
_delay = 0,
_currenDelay = 0
}
ds.tween.DSAxis = DSAxis
ds.tween.DSEase = DSEase
ds.tween.DSTween = DSTween
local function new(duration,onUpdate)
local self = {}
setmetatable(self,{__index = DSTween})
DSTween.init(self,duration,onUpdate)
return self
end
function DSTween:init( duration,onUpdate)
self._duration = duration
self._onUpdate = onUpdate
self._ease = DSEase.Linear
self._state = DSTweenState.Play
self._autoRemove=true
self._loop = 1
self._currenLoop = 1
end
local _PiOver2 = 1.57079637
local _TwoPi = 6.28318548
local _EaseOvershootOrAmplitude = 1.70158
local _EaseOne = 1
local _EaseTwo = 2
local _EaseZPFive = 0.5
local function EaseOut(time,duration)
time = time /duration
if (time < 0.363636374) then
return 7.5625 * time * time
end
if (time < 0.727272749) then
time = time -0.545454562
return 7.5625 * time * time + 0.75
end
if (time < 0.909090936) then
time = time - 0.8181818
return 7.5625 * time * time + 0.9375
end
time =time - 0.954545438
return 7.5625 * time * time + 0.984375
end
local function EaseIn(time,duration)
return _EaseOne - EaseOut(duration - time, duration)
end
local function EaseInOut(time,duration)
if (time < duration * _EaseZPFive) then
return EaseIn(time * _EaseTwo, duration) * _EaseZPFive
end
return EaseOut(time * _EaseTwo - duration, duration) * _EaseZPFive + _EaseZPFive
end
local function Evaluate(easeType, time, duration)
local period = 0
if (easeType == DSEase.Linear) then
return time / duration
elseif (easeType == DSEase.InSine) then
return -math.cos((time / duration * _PiOver2)) + _EaseOne
elseif (easeType == DSEase.OutSine) then
return math.sin((time / duration * _PiOver2))
elseif (easeType == DSEase.InOutSine) then
return -_EaseZPFive * (math.cos((math.pi * time / duration)) - _EaseOne)
elseif (easeType == DSEase.InQuad) then
time = time /duration
return time * time
elseif (easeType == DSEase.OutQuad) then
time = time /duration
return -time * (time - _EaseTwo)
elseif (easeType == DSEase.InOutQuad) then
time = time / (duration * _EaseZPFive)
if (time < _EaseOne) then
return _EaseZPFive * time * time
end
time = time - _EaseOne
return -_EaseZPFive * (time * (time - _EaseTwo) - _EaseOne)
elseif (easeType == DSEase.InCubic) then
time = time / duration
return time * time * time
elseif (easeType == DSEase.OutCubic) then
time = time /duration - _EaseOne
return time * time * time + _EaseOne
elseif (easeType == DSEase.InOutCubic) then
time = time/(duration * _EaseZPFive)
if (time < _EaseOne) then
return _EaseZPFive * time * time * time
end
time = time - _EaseTwo
return _EaseZPFive * (time * time * time + _EaseTwo)
elseif (easeType == DSEase.InQuart) then
time = time /duration
return time* time * time * time
elseif (easeType == DSEase.OutQuart) then
time = time / duration - _EaseOne
return -(time * time * time * time - _EaseOne);
elseif (easeType == DSEase.InOutQuart) then
time = time /( duration * _EaseZPFive)
if (time < _EaseOne) then
return _EaseZPFive * time * time * time * time
end
time = time - _EaseTwo
return -_EaseZPFive * (time * time * time * time - _EaseTwo)
elseif (easeType == DSEase.InQuint) then
time = time / duration
return time * time * time * time * time;
elseif (easeType == DSEase.OutQuint) then
time = time / duration - _EaseOne
return time * time * time * time * time + _EaseOne
elseif (easeType == DSEase.InOutQuint) then
time = time / (duration * _EaseZPFive)
if (time < _EaseOne) then
return _EaseZPFive * time * time * time * time * time
end
time = time - _EaseTwo
return _EaseZPFive * (time * time * time * time * time + _EaseTwo)
elseif (easeType == DSEase.InExpo) then
if (time ~= 0) then
return math.pow(_EaseTwo, 10 * (time / duration - _EaseOne))
end
return 0
elseif (easeType == DSEase.OutExpo) then
if (time == duration) then
return 1
end
return -math.pow(_EaseTwo, (-10 * time / duration)) + _EaseOne
elseif (easeType == DSEase.InOutExpo) then
if (time == 0) then
return 0
end
if (time == duration) then
return _EaseOne
end
time = time/( duration * _EaseZPFive)
if (time < _EaseOne) then
return _EaseZPFive * math.pow(_EaseTwo, (10 * (time - _EaseOne)))
end
time = time - _EaseOne
return _EaseZPFive * (-math.pow(_EaseTwo, (-10 * time) + 2))
elseif (easeType == DSEase.InCirc) then
time = time / duration
return -(math.sqrt((_EaseOne - time * time)) - _EaseOne)
elseif (easeType == DSEase.OutCirc) then
time = time / duration - _EaseOne
return math.sqrt((_EaseOne - time * time))
elseif (easeType == DSEase.InOutCirc) then
time = time / (duration * _EaseZPFive)
if (time < _EaseOne) then
return -_EaseZPFive * (math.sqrt((_EaseOne - time * time)) - _EaseOne)
end
time = time - _EaseTwo
return _EaseZPFive * (math.sqrt((_EaseOne - time * time)) + _EaseOne)
elseif (easeType == DSEase.InElastic) then
if (time == 0) then
return 0
end
time = time / duration
if (time == _EaseOne) then
return _EaseOne
end
period = duration * 0.3
local num = period / _TwoPi * math.asin((_EaseOne / _EaseOvershootOrAmplitude))
time = time -_EaseOne
return -(_EaseOvershootOrAmplitude * math.pow(_EaseTwo, (10.0 * time)) * math.sin((time * duration - num) * _TwoPi / period))
elseif (easeType == DSEase.OutElastic) then
if (time == 0) then
return 0
end
time = time / duration
if (time == _EaseOne) then
return _EaseOne
end
period = duration * 0.3
local num2 = period / _TwoPi * math.asin((_EaseOne / _EaseOvershootOrAmplitude))
return _EaseOvershootOrAmplitude * math.pow(_EaseTwo, -10 * time) * math.sin((time * duration - num2) * _TwoPi / period) + _EaseOne
elseif (easeType == DSEase.InOutElastic) then
if (time == 0) then
return 0
end
time = time / (duration * _EaseZPFive)
if (time == _EaseTwo) then
return _EaseOne
end
period = duration * 0.450000018
local num3 = period / _TwoPi * math.asin(_EaseOne / _EaseOvershootOrAmplitude)
if (time < _EaseOne) then
time = time - _EaseOne
return -_EaseZPFive * (_EaseOvershootOrAmplitude * math.pow(_EaseTwo, (10 * time)) * math.sin(((time * duration - num3) * _TwoPi / period)))
end
time = time - _EaseOne
return _EaseOvershootOrAmplitude * math.pow(_EaseTwo, (-10 * time)) * math.sin(((time * duration - num3) * _TwoPi / period)) * _EaseZPFive + _EaseOne;
elseif (easeType == DSEase.InBack) then
time = time / duration
return time * time * ((_EaseOvershootOrAmplitude + _EaseOne) * time - _EaseOvershootOrAmplitude)
elseif (easeType == DSEase.OutBack) then
time = time / duration - _EaseOne
return time * time * ((_EaseOvershootOrAmplitude + _EaseOne) * time + _EaseOvershootOrAmplitude) + _EaseOne
elseif (easeType == DSEase.InOutBack) then
local overshootOrAmplitude = _EaseOvershootOrAmplitude
time = time / (duration * _EaseZPFive)
if (time < _EaseOne) then
overshootOrAmplitude = overshootOrAmplitude * 1.525
return _EaseZPFive * (time * time * ((overshootOrAmplitude + _EaseOne) * time - overshootOrAmplitude))
end
time = time -_EaseTwo
overshootOrAmplitude = overshootOrAmplitude * 1.525
return _EaseZPFive * (time * time * ((overshootOrAmplitude + _EaseOne) * time + overshootOrAmplitude) + _EaseTwo)
elseif (easeType == DSEase.InBounce) then
return _EaseOne - EaseOut(duration - time, duration)
elseif (easeType == DSEase.OutBounce) then
return EaseOut(time, duration)
elseif (easeType == DSEase.InOutBounce) then
return EaseInOut(time, duration)
else
time = time / duration
return -time * (time - _EaseTwo)
end
end
function DSTween:CallUpdate(value)
if (self._onUpdate ~= nil) then
self._onUpdate(value)
end
end
function DSTween:Update(deltaTime)
local _state = self._state
local _currenTime = self._currenTime
local _duration = self._duration
if (_state == DSTweenState.Stop) then
return
end
if (_state == DSTweenState.Delay) then
if (_currenDelay >= _delay) then
_state = DSTweenState.Play
else
self._currenDelay = self._currenDelay + deltaTime
return
end
end
_currenTime = math.min(_currenTime, _duration)
local value = Evaluate(self._ease, _currenTime, _duration)
local tem = self._from + (self._to - self._from) * value
self:CallUpdate(tem)
if (_currenTime >= _duration) then
if (self._loop == -1 or self._currenLoop < self._loop) then
self._currenTime = 0
self._currenLoop = self._currenLoop + 1
return
end
self._state = DSTweenState.Stop
if (self._onComplete ~= nil) then
self._onComplete(self)
end
return
end
self._currenTime = _currenTime + deltaTime
end
-- 停止
function DSTween:Stop()
self._state = DSTweenState.Stop
self._currenDelay = 0
self._currenTime = 0
self._currenLoop = 1
return self
end
-- 重新启动
function DSTween:Play()
self._state = self._delay>0 and DSTweenState.Delay or DSTweenState.Play
self._currenDelay = 0
self._currenTime = 0
self._currenLoop = 1
return self
end
-- 重新启动
function DSTween:Restart()
return self:Play()
end
-- 设置循环次数
function DSTween:SetLoop(loop)
self._loop = loop
return self
end
-- 重新设置Tween参数
function DSTween:ChangeValues(from,to,duration)
self._from = from
self._to = to
self._duration = duration
return self
end
---设置Tween补间类型
function DSTween:SetEase(ease)
self._ease = ease
return self
end
-- 设置完成事件监听
function DSTween:OnComplete(onComplete)
self._onComplete = onComplete
return self
end
function DSTween:SetDelay(delay)
self._delay = delay
return self
end
function DSTween:GetState()
return self._state
end
local DSTweenManager = ds.tween.DSTweenManager
function DSTween.To(from,to,duration,onUpdate)
local tween = new(duration, onUpdate)
tween._from = from
tween._to = to
DSTweenManager.AddActiveTween(tween);
return tween
end

View File

@ -0,0 +1,51 @@
--Tween 管理
--author--
local _MaxActiveTween=200
local _totActiveTweens = 0
local _activeTweens = {}
local DSTweenManager = {}
local DSTweenState = {
Play = 0,
Stop = 1,
Delay = 2
}
ds.tween.DSTweenState = DSTweenState
function DSTweenManager.Update(deltaTime)
if (deltaTime == 0) then
return
end
local i = 1
while i <= #_activeTweens do
local t = _activeTweens[i]
if t ~=nil then
if (not (t._autoRemove and t._state == DSTweenState.Stop)) then
t:Update(deltaTime)
i = i +1
else
table.remove(_activeTweens,i)
i = i -1
_totActiveTweens = _totActiveTweens - 1
end
else
i = i +1
end
end
end
function DSTweenManager.AddActiveTween(t)
_activeTweens[#_activeTweens+1] = t
t:Play()
_totActiveTweens = _totActiveTweens + 1
end
function DSTweenManager.ClearTween()
_activeTweens = {}
_totActiveTweens = 0
end
ds.tween.DSTweenManager = DSTweenManager

View File

@ -0,0 +1,62 @@
--Tween Quaternion
--author--
local DSTween = ds.tween.DSTween
local DSTweenQuaternion = {}
ds.tween.DSTweenQuaternion = DSTweenQuaternion
local function new(duration,onUpdate)
local self = {}
setmetatable(DSTweenQuaternion,{__index = DSTween})
setmetatable(self,{__index = DSTweenQuaternion})
DSTween.init(self,duration,onUpdate)
return self
end
function DSTweenQuaternion:CallUpdate(value)
local vector = self._startValue
vector = self._startValue + self._changeValue * value
local r = Quaternion.Euler(vector.x,vector.y,vector.z)
if (self._target ~= null) then
self._target.rotation = r
end
if (self._onUpdate ~= nil) then
self._onUpdate(r)
end
end
local DSTweenManager = ds.tween.DSTweenManager
function DSTweenQuaternion.To(target,to,duration,onUpdate)
local tween = new(duration, onUpdate)
tween._startValue = target.rotation.eulerAngles
tween._target = target
local endValue = to
if (endValue.x > 360) then
endValue.x = endValue.x % 360
end
if (endValue.y > 360) then
endValue.y = endValue.y % 360
end
if (endValue.z > 360) then
endValue.z = endValue.z % 360
end
local changeValue = endValue - tween._startValue
local num = (changeValue.x > 0) and changeValue.x or (-changeValue.x)
if (num > 180) then
changeValue.x = ((changeValue.x > 0) and (-(360 - num)) or (360 - num))
end
num = ((changeValue.y > 0) and changeValue.y or (-changeValue.y))
if (num > 180) then
changeValue.y = ((changeValue.y > 0) and (-(360 - num)) or (360 - num))
end
num = ((changeValue.z > 0) and changeValue.z or (-changeValue.z))
if (num > 180) then
changeValue.z = ((changeValue.z > 0) and (-(360 - num)) or (360 - num))
end
tween._changeValue = changeValue
DSTweenManager.AddActiveTween(tween)
return tween
end

View File

@ -0,0 +1,626 @@
--- Base GameEvent
GameEvent = {
-- 状态
PlayerState = 'PlayerState',
-- 聊天
Interaction = 'Interaction',
-- 玩家离开
PlayerLeave = 'PlayerLeave',
-- 玩家进入
PlayerEnter = 'PlayerEnter',
-- 玩家准备
PlayerReady = 'PlayerReady',
-- 解散
DeskBreak = 'DeskBreak',
-- 被踢出房间
OnKicked = 'OnKicked',
-- 更新玩家信息
OnUpdateInfo = 'OnUpdateInfo',
--打开托管
TupGuanOpen='TupGuanOpen',
--关闭托管
TupGuanClose='TupGuanClose',
--麻将修改牌大小
MJModifySzie='MJModifySzie',
}
--- Base GameController
GameController = {
_name = '',
--事件MAP
_eventmap = nil,
--事件缓存
_cacheEvent = nil,
--事件发送器
_dispatcher = nil
}
local M = GameController
setmetatable(M, {__index = IController})
function M:init(name)
self._name = name
self.baseType = GameController
self._cacheEvent = Queue.new(1000)
self._eventmap = {}
self._dispatcher = {}
self._eventmap[Protocol.FGMGR_EVT_UPDATE_RECONECT]=self.ResetConnect
self._eventmap[Protocol.GAME_EVT_PLAYER_JOIN] = self.OnEventPlayerEnter
self._eventmap[Protocol.GAME_EVT_PLAYER_NET_STATE] = self.OnEventOnlineState
self._eventmap[Protocol.GAME_EVT_PLAYER_EXIT] = self.OnEventPlayerLeave
self._eventmap[Protocol.GAME_EVT_READY] = self.OnEventPlayerReady
self._eventmap[Protocol.GAME_EVT_READY_AND_XIPAI] = self.OnEventPlayerXiPaiReady
self._eventmap[Protocol.GAME_EVT_EXIT_ROOM_DISMISS] = self.OnEventExitRoomDismiss
self._eventmap[Protocol.GAME_EVT_DISMISS_ROOM] = self.OnEventDismissRoom
self._eventmap[Protocol.GAME_EVT_DISMISS_ROOM_VOTE] = self.OnEventDismissRoomVote
self._eventmap[Protocol.GAME_EVT_DISMISS_ROOM_FAIL] = self.OnEventDismissRoomFail
self._eventmap[Protocol.GAME_EVT_INTERACTION] = self.OnEventInteraction
self._eventmap[Protocol.GAME_EVT_UPDATE_GPS] = self.OnEventUpdateGPS
self._eventmap[Protocol.GAME_EVT_KICKED] = self.OnEventKicked
self._eventmap[Protocol.GAME_EVT_UPDATE_PLAYERINFO] = self.OnEvtUpdateInfo
self._eventmap[Protocol.GAME_EVT_READY_ENTRUST] = self.OnEvtOpenTupGTips
self._eventmap[Protocol.GAME_EVT_CANCEL_READY_ENTRUST] = self.OnEvtCloseTupGTips
--self._eventmap[Protocol.GAME_AUTO_CARD] = self.OnEvtOpenGameHuTuoGtips
end
function DispatchEvent(_dispatcher, evt_name, ...)
local func = _dispatcher[evt_name]
if func then
func(...)
end
end
function M:AddEventListener(evt_name, func)
self._dispatcher[evt_name] = func
end
function M:ResetConnect()
-- print("断线重连================")
--ControllerManager.OnConnect(SocketCode.TimeoutDisconnect)
ViewManager.refreshGameView()
end
----------------------请求------------------------------------
--请求准备
function M:PlayerReady()
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
_client:send(Protocol.GAME_READY)
end
function M:PlayerXiPai()
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
_client:send(Protocol.GAME_READY_AND_XIPAI)
end
--请求准备
function M:StartGame()
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
_client:send(Protocol.GAME_START)
end
--聊天
--<param name="playid"></param>
--<param name="type">1表情 2固定语音 3语音 4文本 5互动</param>
--<param name="parm"></param>
function M:SendInteraction(playid, type, parm, callback)
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
local _data = {}
_data['playerid'] = playid
_data['type'] = type
_data['parm'] = parm
_client:send(Protocol.GAME_INTERACTION, _data)
end
--请求离开房间
function M:LevelRoom(callBack)
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
_client:send(
Protocol.GAME_EXIT_ROOM,
nil,
function(res)
if res.ReturnCode == 0 then
ControllerManager.ChangeController(LoddyController)
end
callBack(res)
end
)
end
--请求解散房间
function M:AskDismissRoom()
local _curren_msg = MsgWindow.new(self._root_view, '是否发起解散?', MsgWindow.MsgMode.OkAndCancel)
_curren_msg.onOk:Add(function()
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
_client:send(Protocol.GAME_ASK_DISMISS_ROOM,nil,function (res)
if res.ReturnCode == 84 then
ViewUtil.ErrorTip(res.ReturnCode,"解散失败")
end
end)
end)
_curren_msg:Show()
end
--解散房间投票
function M:DismissRoomVote(agree)
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
-- print(agree)
local _data = {}
_data['result'] = agree
_client:send(Protocol.GAME_DISMISS_ROOM_VOTE, _data)
end
--发送GPS坐标
function M:SendGPS(str)
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
local _data = {}
_data['pos'] = str
_client:send(Protocol.GAME_SEND_GPS, _data)
end
--------------------事件-----------------------------------
-- 房主退出 房间解散
function M:OnEventExitRoomDismiss(evt_data)
self._cacheEvent:Enqueue(
function()
ControllerManager.ChangeController(LoddyController)
DispatchEvent(self._dispatcher, GameEvent.DeskBreak, 1)
end
)
end
-- 显示投票选择
function M:OnEventDismissRoom(evt_data)
self._cacheEvent:Enqueue(
function()
local room = DataManager.CurrenRoom
local req_aid = evt_data['req_aid']
evt_data.req_p = room:GetPlayerById(req_aid)
local player_list = room.player_list
local tem_list = {}
local list = evt_data['list']
for k = 1, #player_list do
local p = nil
for i = 1, #list do
local tem = list[i]
if tem.aid == player_list[k].self_user.account_id then
tem.player = player_list[k]
p = tem
break
end
end
if not p then
p = {}
p.player = player_list[k]
p.result = 0
end
tem_list[k] = p
end
evt_data['list'] = tem_list
DispatchEvent(self._dispatcher, GameEvent.DeskBreak, 0, evt_data)
end
)
end
-- -- 投票结果
-- function M:OnEventDismissRoomVote(evt_data)
-- local aid = evt_data["aid"]
-- local result = evt_data["result"]
-- local p = DataManager.CurrenRoom:GetPlayerById(aid)
-- DispatchEvent(self._dispatcher,GameEvent.DeskBreak, 2,p,result)
-- end
-- 解散失敗
function M:OnEventDismissRoomFail(evt_data)
self._cacheEvent:Enqueue(
function()
DispatchEvent(self._dispatcher, GameEvent.DeskBreak, 3)
end
)
end
-- 玩家进
function M:OnEventPlayerEnter(evt_data)
--print("进入房间++++++++++++++++++++++++++++++++++++++")
self._cacheEvent:Enqueue(
function()
local p = self._room:NewPlayer()
local _user
_user = User.new()
_user.account_id = evt_data['aid']
_user.host_ip = evt_data['ip']
_user.nick_name = evt_data['nick']
_user.head_url = evt_data['portrait']
_user.sex = evt_data['sex']
_user.location = Location.new(evt_data['pos'] or '')
p.seat = evt_data['seat']
p.ready = evt_data['ready'] == 1 and true or false
p.cur_hp = evt_data['cur_hp'] or 0
p.spectator = evt_data['spectator']
-- p.total_hp = evt_data["total_hp"] or 0
if evt_data['hp_info'] then
p.cur_hp = evt_data.hp_info.cur_hp
-- p.total_hp = evt_data.hp_info.total_hp
end
p.self_user = _user
p.line_state = 1
DataManager.CurrenRoom:AddPlayer(p)
DispatchEvent(self._dispatcher, GameEvent.PlayerEnter, p)
end
)
end
-- 玩家离开
function M:OnEventPlayerLeave(evt_data)
self._cacheEvent:Enqueue(
function()
local playerid = evt_data['aid']
local p = DataManager.CurrenRoom:GetPlayerById(playerid)
self._room:RemovePlayer(p)
DispatchEvent(self._dispatcher, GameEvent.PlayerLeave, p)
end
)
end
-- 网络状态更新
function M:OnEventOnlineState(evt_data)
self._cacheEvent:Enqueue(
function()
local playerid = evt_data['aid']
local online = evt_data['online']
local player = DataManager.CurrenRoom:GetPlayerById(playerid)
if player ~= nil then
player.line_state = online
DispatchEvent(self._dispatcher, GameEvent.PlayerState, player)
end
end
)
end
-- 玩家准备
function M:OnEventPlayerReady(evt_data)
self._cacheEvent:Enqueue(
function()
local pid = evt_data['aid']
local p = self._room:GetPlayerById(pid)
p.ready = true
if evt_data.start~=nil then
if evt_data.start==1 then
p.isSendCardState=true
else
p.isSendCardState=false
end
else
p.isSendCardState=false
end
DispatchEvent(self._dispatcher, GameEvent.PlayerReady, p)
end
)
end
function M:OnEventPlayerXiPaiReady(evt_data)
self._cacheEvent:Enqueue(
function()
local pid = evt_data['aid']
local p = self._room:GetPlayerById(pid)
p.ready = true
if evt_data.start~=nil then
if evt_data.start==1 then
p.isSendCardState=true
else
p.isSendCardState=false
end
else
p.isSendCardState=false
end
DispatchEvent(self._dispatcher, GameEvent.PlayerReady, p)
end
)
end
-- 聊天事件
function M:OnEventInteraction(evt_data)
if self._room.ban_chat1 == false or self._room.ban_chat2 == false then
self._cacheEvent:Enqueue(
function()
local playerid = evt_data['playerid']
local p = self._room:GetPlayerById(playerid)
local type1 = evt_data['type']
local parm = evt_data['parm']
DispatchEvent(self._dispatcher, GameEvent.Interaction, p, type1, parm)
end
)
end
end
-- GPS更新事件
function M:OnEventUpdateGPS(evt_data)
self._cacheEvent:Enqueue(
function()
local seat = evt_data['seat']
local pos = evt_data['pos']
if seat == 0 or seat == 'skip' then
return
end
local p = self._room:GetPlayerBySeat(seat)
p.self_user.location = Location.new(pos)
end
)
end
-- 被踢出房间事件
function M:OnEventKicked()
if ViewManager.GetCurrenView().dview_class == LobbyView then
DataManager.CurrenRoom = nil
ControllerManager.SetGameNetClient(nil, true)
ControllerManager.ChangeController(LoddyController)
return
end
self._cacheEvent:Enqueue(
function()
DataManager.CurrenRoom = nil
ControllerManager.SetGameNetClient(nil, true)
ControllerManager.ChangeController(LoddyController)
DispatchEvent(self._dispatcher, GameEvent.OnKicked)
end
)
end
-- 托管
function M:Entrust(ok, info)
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
local data = {}
data.ok = ok
data.info = info
_client:send(Protocol.GAME_ENTRUST, data)
end
-- 入座
function M:JoinSeat(callback)
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
_client:send(Protocol.GAME_JOIN_SEAT, nil, function(res)
if res.ReturnCode == 0 then
self._room.self_player.spectator = false
end
if callback then
callback(res)
end
end)
end
-- 更新事件
function M:OnEvtUpdateInfo(evt_data)
self._cacheEvent:Enqueue(
function()
local pid = evt_data['aid']
local p = self._room:GetPlayerById(pid)
local t = evt_data['type']
if t == 5 then
p.entrust = evt_data['entrust']
end
DispatchEvent(self._dispatcher, GameEvent.OnUpdateInfo, p, t)
end
)
end
function M:ClearPlayerData()
local _room = self._room
for i = 1, #_room.player_list do
_room.player_list[i]:Clear()
end
end
function M:PopEvent()
local _cacheEvent = self._cacheEvent
if (_cacheEvent:Count() > 0) then
return _cacheEvent:Dequeue()
end
end
local function list_add(list, val)
if not list_check(list, val) then
table.insert(list, val)
end
end
-- 检查 gps距离、ip地址
function M:CheckGPS()
local plist = {}
local warnList = {}
local ipList = {}
local player_list = self._room.player_list
-- GPS
for i = 1, #player_list do
local player1 = player_list[i]
if player1.self_user ~= DataManager.SelfUser then
local loc1 = player1.self_user.location
if not loc1 or loc1.default then
-- 数据类型gps警告只有此处使用了
-- type0.没有打开gps1.距离过近2.ip地址一样
local warn = {}
warn.type = 0
warn.seat = player1.seat
return true
elseif i < #player_list then
for j = i + 1, #player_list do
local player2 = player_list[j]
if player2.self_user ~= DataManager.SelfUser then
local loc2 = player2.self_user.location
if not loc2 or loc2.default then
local warn = {}
warn.type = 0
warn.seat = player2.seat
return true
else
local dist = loc1:CalcDistance(loc2)
if dist < 0.2 then
local warn = {}
warn.type = 1
warn.seat = player1.seat
warn.seat2 = player2.seat
return true
end
end
end
end
end
end
local p = player1
if p.self_user ~= DataManager.SelfUser then
local ip = p.self_user.host_ip
if not list_check(ipList, ip) then
table.insert(ipList, ip)
else
return true
end
end
end
return false
end
function M:GetGPS()
-- if not DataManager.SelfUser.location.default then return end
-- 获取GPS
get_gps(
function()
self:SendGPS(DataManager.SelfUser.location:Location2String())
end
)
end
function M:OnEnter()
if (debug_print) then
print(self._name .. '进入Game控制器')
end
self._room = DataManager.CurrenRoom
local _client = ControllerManager.GameNetClinet
_client.onevent:Add(self.__OnNetEvent, self)
-- self:GetGPS()
end
function M:OnExit()
if (debug_print) then
print(self._name .. ' 离开Game控制器')
end
ControllerManager.SetGameNetClient(nil)
self._cacheEvent:Clear()
end
function M:__OnNetEvent(msg)
--print("Game消息ID===>>"..msg.Command)
local func = self._eventmap[msg.Command]
if (func ~= nil) then
func(self, msg.Data)
end
end
function M:ReturnToRoom()
local roomCtr = ControllerManager.GetController(RoomController)
roomCtr:PublicJoinRoom(
Protocol.WEB_FG_JOIN_ROOM,
self.tmpRoomID,
false,
function(response)
if (response.ReturnCode == -1) then
ViewUtil.CloseModalWait('join_room')
RestartGame()
return
end
ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id)
ViewUtil.CloseModalWait('join_room')
end,
self.tmpGroupID
)
end
function M:OnEvtOpenTupGTips(msg)
--print("显示托管倒计时=====================")
pt(msg)
local pid = msg['aid']
local p = self._room:GetPlayerById(pid)
local t=msg['time']
DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p,true, t)
end
function M:OnEvtCloseTupGTips(msg)
--print("关闭托管倒计时=================")
--pt(msg)
local pid = msg['aid']
local p = self._room:GetPlayerById(pid)
local t=msg['time']
DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p,false, t)
end
function M:DispatchEventTuoGuan(p,isShow,t)
DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p,isShow, t)
end
function M:OnEvtOpenGameHuTuoGtips(isAuto)
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
local data = {}
data.autoCard = isAuto
_client:send(Protocol.GAME_AUTO_CARD, data)
end

View File

@ -0,0 +1,380 @@
--- Base GameEvent
GroupMgrEvent = {
AddPlay = "add_play",
DelPlay = "del_play",
UpdatePlay = "update_play",
AddRoom = "add_room",
DelRoom = "del_room",
UpdateRoom = "update_room",
UpdatePlayerInfo = "update_player_info",
UpdateMessage = "update_msg",
BeInvited = "be_invited",
UpdateGroup = "UpdateGroup",
NewMailTip = "NewMailTip",
}
GroupMgrController = {
_name = "",
--事件MAP
_eventmap = nil,
--事件缓存
_cacheEvent = nil,
--事件发送器
_dispatcher = nil
}
local M = GroupMgrController
--- Create a new GroupMgrController
function GroupMgrController.new()
setmetatable(M, {__index = IController})
local self = setmetatable({}, {__index = M})
self.baseType = GroupMgrController
self._cacheEvent = Queue.new(1000)
self._eventmap = {}
self._dispatcher = {}
self._eventmap[Protocol.FGMGR_EVT_ADD_PLAY] = self.OnEvtAddPlay
self._eventmap[Protocol.FGMGR_EVT_DEL_PLAY] = self.OnEvtDelPlay
self._eventmap[Protocol.FGMGR_EVT_UPDATE_PLAY] = self.OnEvtUpdatePlay
self._eventmap[Protocol.FGMGR_EVT_ADD_ROOM] = self.OnEvtAddRoom
self._eventmap[Protocol.FGMGR_EVT_DEL_ROOM] = self.OnEvtDelRoom
self._eventmap[Protocol.FGMGR_EVT_UPDATE_ROOM] = self.OnEvtUpdateRoom
self._eventmap[Protocol.FGMGR_EVT_UPDATE_PLAYER_INFO] = self.OnEvtUpdatePlayerInfo
self._eventmap[Protocol.FGMGR_EVT_MESSAGE] = self.OnEvtMessage
self._eventmap[Protocol.FGMGR_EVT_INVITED] = self.OnEvtInvited
self._eventmap[Protocol.FGMGR_EVT_UPDATE_GROUP] = self.OnEvtUpdateGroup
self._eventmap[Protocol.FGMGR_EVT_NEW_MAIL] = self.OnEvtNewMailTip
-- self:connect(callback)
return self
end
function DispatchEvent(_dispatcher,evt_name,...)
local func = _dispatcher[evt_name]
if func then
func(...)
end
end
function M:AddEventListener(evt_name,func)
self._dispatcher[evt_name] = func
end
----------------------请求------------------------------------
function M:connect(host,groupId,callback)
self.host = host
self.groupId = groupId
self.connecting = true
if self._mgr_client then
self._mgr_client:destroy()
self._mgr_client = nil
end
--print("666666666666666666666666666 ",host)
local _mgr_client = NetClient.new(self.host, "mgr_group")
self._mgr_client = _mgr_client
_mgr_client:connect()
_mgr_client.onconnect:Add(function(code)
self.code = code
if (code == SocketCode.Connect) then
local _data = {}
_data.session = ControllerManager.WebClient:getSession()
if _data.session==nil then
self.connecting = false
_mgr_client:destroy()
ViewUtil.ErrorTip(1234567,"圈子数据异常!!!")
return
end
_data.groupId = self.groupId
--printlog(debug.traceback())
--printlog("session===1111111111>>>", _data.session)
--pt(_data)
_mgr_client:send(Protocol.FGMGR_ENTER_GROUP,_data,function(res)
self.connecting = false
if res.ReturnCode == 0 then
-- printlog("2222222222222222222222222222222")
-- pt(res)
_mgr_client.onevent:Add(self.__OnNetEvent,self)
_mgr_client.onconnect:Add(self.__OnConnect,self)
if callback then
self:OnEnter()
end
local group = DataManager.groups:get(groupId)
group:clearPlay()
local play_list = res.Data.play_list
printlog("2222222222222222")
pt(play_list)
for i=1,#play_list do
local m = play_list[i]
group:addPlay(m)
end
local rooms = res.Data.rooms
for i=1,#rooms do
local m = rooms[i]
if m.status ~= 2 then
group:addRoom(m)
end
end
group.ban = res.Data.ban
group.ban_ip = res.Data.ban_ip
group.ban_gps = res.Data.ban_gps
group.hp = res.Data.hp
group.lev = res.Data.lev
group.joins = res.Data.joins
group.kick_opt = res.Data.kick_opt
group.partnerLev = res.Data.partnerLev
group.dissolve_opt = res.Data.dissolve_opt
group.permission = res.Data.permission
group.diamo = res.Data.diamo or 0
group.apply = res.Data.ban_apply or 0
group.update_room = true
group.mail_tip = res.Data.mail_tip
group.ban_chat1 = res.Data.ban_chat1
group.ban_chat2 = res.Data.ban_chat2
group.isvip = res.Data.isvip
else
self.code = SocketCode.ExceptionOnConnect
_mgr_client:destroy()
end
if callback then
callback(res)
end
end)
else
self.connecting = false
_mgr_client:destroy()
if callback then
callback({ReturnCode = 101})
end
end
end)
end
function M:disconnect()
self.connecting = false
if self._mgr_client then
self._mgr_client:destroy()
end
self.host = nil
self.groupId = nil
if self._reconnect then
self._reconnect:Stop()
self._reconnect = nil
end
end
--------------------事件-----------------------------------
-- 添加玩法
function M:OnEvtAddPlay(evt_data)
local group = DataManager.groups:get(self.groupId)
group:addPlay(evt_data)
local pid = evt_data.id
DispatchEvent(self._dispatcher,GroupMgrEvent.AddPlay, pid)
end
-- 删除玩法
function M:OnEvtDelPlay(evt_data)
local pid = evt_data.pid
local group = DataManager.groups:get(self.groupId)
group:delPlay(pid)
DispatchEvent(self._dispatcher,GroupMgrEvent.DelPlay)
end
-- 更新玩法
function M:OnEvtUpdatePlay(evt_data)
--print("更新玩法=============》》》")
--pt(evt_data)
local pid = evt_data.pid
local group = DataManager.groups:get(self.groupId)
group:addPlay(evt_data)
group.update_play = true
DispatchEvent(self._dispatcher,GroupMgrEvent.UpdatePlay)
end
-- 添加房间
function M:OnEvtAddRoom(evt_data)
-- local group = DataManager.groups:get(self.groupId)
-- group:addRoom(evt_data)
-- group.update_room = true
-- DispatchEvent(self._dispatcher,GroupMgrEvent.AddRoom)
end
-- 删除玩法
function M:OnEvtDelRoom(evt_data)
-- local roomid = evt_data.roomid
-- local group = DataManager.groups:get(self.groupId)
-- group:delRoom(roomid)
-- group.update_room = true
-- DispatchEvent(self._dispatcher,GroupMgrEvent.DelRoom)
end
-- 更新房间
function M:OnEvtUpdateRoom(evt_data)
local group = DataManager.groups:get(self.groupId)
local cmds = evt_data.cmds
for i=1,#cmds do
local cmd = cmds[i]
local ct = cmd["$ct"]
if ct == 3 then
group:delRoom(cmd.roomid)
else
group:addRoom(cmd)
end
end
group.update_room = true
end
function M:OnEvtUpdatePlayerInfo(evt_data)
--type1体力值 2管理员等级 3合伙人等级
local itype = evt_data.type
local value = evt_data.value
local group = DataManager.groups:get(self.groupId)
local memb = group:getMember(DataManager.SelfUser.account_id)
if itype == 1 then
if memb then
memb.hp = value
end
group.hp = value
elseif itype == 2 then
memb.lev = value
group.lev = value
elseif itype == 3 then
memb.partnerLev = value
group.partnerLev = value
elseif itype == 4 then
group.diamo = evt_data.diamo
end
group.update_info = true
-- DispatchEvent(self._dispatcher,GroupMgrEvent.UpdatePlayerInfo)
end
-- 更新申请列表
function M:OnEvtMessage(evt_data)
local group = DataManager.groups:get(self.groupId)
group.joins = evt_data.joins
group.update_joins = true
end
-- 被邀请事件
function M:OnEvtInvited(evt_data)
DispatchEvent(self._dispatcher, GroupMgrEvent.BeInvited, evt_data)
end
-- 更新圈子
function M:OnEvtUpdateGroup(evt_data)
local group = DataManager.groups:get(self.groupId)
group.name = evt_data.name
group.ban = evt_data.ban == 1
group.notice = evt_data.notice
group.option = evt_data.option
group.show_num = evt_data.show_num
DispatchEvent(self._dispatcher, GroupMgrEvent.UpdateGroup, evt_data)
end
-- 未读邮件通知
function M:OnEvtNewMailTip(evt_data)
local group = DataManager.groups:get(self.groupId)
group.mail_tip = 1
DispatchEvent(self._dispatcher, GroupMgrEvent.NewMailTip, evt_data)
end
-- 获取在线玩家
function M:FG_GetOnlinePlayers(callback)
self._mgr_client:send(Protocol.FGMGR_GET_ONLINE_PLAYERS, nil, function(res)
callback(res)
end)
end
-- 邀请在线玩家
function M:FG_InvitePlayer(tag, roomid, pid, game_name, callback)
local _data = {}
_data.tagId = tag
_data.roomid = roomid
_data.pid = pid
_data.g_name = game_name
self._mgr_client:send(Protocol.FGMGR_INVITE_PLAYER, _data, function(res)
callback(res)
end)
end
-- 回复邀请
function M:FG_ResponseInvited(id, refuse)
local _data = {}
_data.invi_id = id
_data.refuse = refuse
self._mgr_client:send(Protocol.FGMGR_RESPONSE_INVITE, _data)
end
function M:PopEvent()
local _cacheEvent = self._cacheEvent
if (_cacheEvent:Count() > 0) then
return _cacheEvent:Dequeue()
end
end
function M:OnEnter()
self._reconnect = Timer.New(function()
if not self.connecting and self.code ~= SocketCode.Connect then
local _client = self._mgr_client
if _client then
_client:destroy()
end
if not self.host or not self.groupId then return end
self:connect(self.host, self.groupId)
end
end,2,-1,true)
self._reconnect:Start()
-- self._reconnect = coroutine.start(function()
-- while true do
-- coroutine.wait(2)
-- if not self.connecting and self.code ~= SocketCode.Connect then
-- self:connect()
-- end
-- end
-- end)
local _client = self._mgr_client
end
function M:OnExit()
if self._reconnect then
self._reconnect:Stop()
self._reconnect = nil
end
local _client = self._mgr_client
if _client then
_client:destroy()
end
local group = DataManager.groups:get(self.groupId)
group:clear()
self._cacheEvent:Clear()
end
function M:__OnNetEvent(msg)
--print("消息ID===>>"..msg.Command)
local func = self._eventmap[msg.Command]
if (func ~= nil) then func(self,msg.Data) end
end
function M:__OnConnect(code)
self.code = code
if code ~=SocketCode.Connect then
local _client = self._mgr_client
self._mgr_client = nil
_client:destroy()
self._cacheEvent:Clear()
end
end
return M

View File

@ -0,0 +1,16 @@
--控制器基类
--author--
---
--@type IController
IController = {
}
function IController.OnEnter(self)
end
function IController.OnExit(self)
end

View File

@ -0,0 +1,436 @@
LoddyController = {}
local M = {}
--- Create a new LoddyController
function LoddyController.new()
setmetatable(M, {__index = IController})
local self = setmetatable({}, {__index = M})
self.baseType = LoddyController
self.class = "Loddy"
self.recordList = {}
return self
end
function M.OnEnter(self)
--print(vardump(self,"loddy controller enter"))
end
function M.OnExit(self)
--print(vardump(self,"loddy controller exit"))
end
local function __FillRoomData(s2croom)
local room = DataManager.CurrenRoom
local extend = ExtendManager.GetExtendConfig(room.game_id)
extend:FillRoomData(s2croom)
end
local function __ConntectGameServer(cmd,room, host, _data,callback)
-- local _data = {}
_data["session"] = room.session
local _game_client = NetClient.new(host, "game")
_game_client:connect()
ControllerManager.SetGameNetClient(_game_client)
_game_client.onconnect:Add(function(code)
if (code == SocketCode.Connect) then
_game_client:send(cmd, _data, function (response)
if (response.ReturnCode == 0) then
_game_client.onconnect:Clear()
_game_client.onconnect:Add(ControllerManager.OnConnect)
callback(response)
return
end
_game_client:destroy()
if ControllerManager.GameNetClinet == _game_client then
ControllerManager.GameNetClinet =nil
end
callback(response)
end)
else
if ControllerManager.GameNetClinet == _game_client then
ControllerManager.GameNetClinet =nil
end
_game_client:destroy()
callback({ReturnCode = 101})
end
end)
end
function M:CreateRoom(game_id, _data, callback)
local _client = ControllerManager.WebClient
local data = {}
data.game_id = game_id
data["platform"] = GetPlatform()
data.config_data = _data
-- local runtime = os.clock()
_client:send(Protocol.WEB_CREATE_ROOM, data, function(res)
if ( res.ReturnCode == Table_Error_code.ERR_IN_ROOM or res.ReturnCode == Table_Error_code.ERR_CREATE_ROOM) then
self:JoinRoom("000000",callback)
return
end
if (res.ReturnCode == 0) then
local json = res.Data
local game_info = json["game_info"]
if ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then
ExtendHotupdate.UpdateGame(game_info,function()
res.ReturnCode = -2
callback(res)
end)
return
end
local game_id = game_info.game_id
local room_id = json["room_id"]
local server_ip = json["server_ip"]
local server_port = json["server_port"]
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
room.game_id = game_id
room.room_id = room_id
room.server_host = string.concat(server_ip, ":", server_port)
room.session = _client:getSession()
DataManager.CurrenRoom = room
local game_net = nil
local j_data = {}
j_data["session"] = room.session
if not DataManager.SelfUser.location then
DataManager.SelfUser.location = Location.new()
end
j_data["pos"] = DataManager.SelfUser.location:Location2String()
-- game_net =
__ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data, function (response)
if (response.ReturnCode == 0) then
-- game_net:clearEvent()
local _s2croom = response.Data
-- ControllerManager.SetGameNetClient(game_net)
room.owner_id = _s2croom["owner"]
room.banker_seat = _s2croom["manor"]
if _s2croom.createTime then
room.create_time = _s2croom["createTime"]
end
room.agent = _s2croom.agent == 1 and true or false
local extend = ExtendManager.GetExtendConfig(room.game_id)
extend:FillRoomData(_s2croom)
ControllerManager.ChangeController(GameController)
-- print("create room:"..(os.clock()-runtime))
callback(response)
return
end
-- game_net:destroy()
callback(response)
end)
else
if callback then callback(res) end
end
end)
end
local join_room_frame = 0
function M:PublicJoinRoom(cmd,room_id,callback,group_id,group_layer)
-- 同一帧不重复调用
local last_frame = join_room_frame
join_room_frame = Time.frameCount
if join_room_frame == last_frame then
return
end
-- 防止游戏没有离开控制器
ControllerManager.ChangeController(LoddyController)
local _data = {}
_data["room_id"] = room_id
_data["group_id"] = group_id
_data["floor"] = group_layer
_data["platform"] = GetPlatform()
local _client = ControllerManager.WebClient;
_client:send(cmd, _data, function( res)
if (res.ReturnCode == 0) then
local json = res.Data
local game_info = json["game_info"]
if ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then
ExtendHotupdate.UpdateGame(game_info,function()
res.ReturnCode = -2
callback(res)
end)
return
end
local game_id = game_info.game_id
local server_ip = json["server_ip"]
local server_port = json["server_port"]
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
room.lev = json["lev"] -- 自己在当前房间所在圈子的职位1盟主2管理员3用户非圈子房间就是3
room.room_id = json["room_id"]
room.game_id = game_id
room.status = json["status"]
room.server_host = string.concat(server_ip, ":", server_port)
room.session = _client:getSession()
room.group_id = json["groupId"]
room.play_id = json["pid"]
-- 体力值开关
room.hpOnOff = json["hpOnOff"]
-- 体力值倍数
room.score_times = json.hp_times and d2ad(json.hp_times) or 1
DataManager.CurrenRoom = room
local j_data = {}
if not DataManager.SelfUser.location then
DataManager.SelfUser.location = Location.new()
end
j_data["pos"] = DataManager.SelfUser.location:Location2String()
-- local game_net = nil
--print(vardump(room))
-- game_net =
__ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data,function ( res1)
if (res1.ReturnCode ~= 0 ) then
if (callback) then callback(res1) end
else
local _s2croom = res1.Data
room.owner_id = _s2croom["owner"]
if _s2croom.createTime then
room.create_time = _s2croom["createTime"]
end
if _s2croom.manor then
room.banker_seat = _s2croom.manor
end
room.agent = _s2croom.agent == 1 and true or false
-- ControllerManager.SetGameNetClient(game_net)
local extend = ExtendManager.GetExtendConfig(room.game_id)
extend:FillRoomData(_s2croom)
ControllerManager.ChangeController(GameController)
if callback then callback(res1) end
end
end)
-- callback(res)
else
if callback then callback(res) end
end
end)
end
function M:JoinRoom(room_id,callback,group_id,group_layer)
self:PublicJoinRoom(Protocol.WEB_JOIN_ROOM,room_id,callback,group_id,group_layer)
end
function M:ResetJionRoom(callback)
local _game = ControllerManager.GetController(GameController)
local o_room = DataManager.CurrenRoom
local j_data = {}
if not DataManager.SelfUser.location then
DataManager.SelfUser.location = Location.new()
end
j_data["pos"] = DataManager.SelfUser.location:Location2String()
local room = ExtendManager.GetExtendConfig(o_room.game_id):NewRoom()
room.lev = o_room.lev
room.room_id = o_room.room_id
room.game_id = o_room.game_id
room.status = o_room.status
room.server_host = o_room.server_host
room.session = o_room.session
room.group_id = o_room.group_id
-- 体力值倍数
room.score_times = o_room.score_times
room.play_id = o_room.play_id
-- 体力值开关
room.hpOnOff = o_room.hpOnOff
room.owner_id = o_room.owner_id
room.create_time = o_room.create_time
room:SetReloadStatus(true)
DataManager.CurrenRoom = room
__ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data,function ( res1)
room:SetReloadStatus(false)
if (res1.ReturnCode ~= 0 ) then
if (callback) then callback(res1) end
else
printlog("ResetJionRoom==>>>")
pt(res1)
ControllerManager.enterPlayerData=res1.Data.tableInfo.playerData
local _s2croom = res1.Data
local extend = ExtendManager.GetExtendConfig(room.game_id)
extend:FillRoomData(_s2croom)
ControllerManager.ChangeController(GameController)
if callback then callback(res1) end
end
end)
end
function M:UpdatePlayerInfo(callback)
local _client = ControllerManager.WebClient
_client:send(Protocol.WEB_UPDATE_INFO, nil, function (res)
if res.ReturnCode == 0 then
DataManager.SelfUser.diamo = res.Data.diamo
DataManager.SelfUser.invited = res.Data.invitation
if callback then callback(true, res.Data) end
-- DataManager.SelfUser.raffle = res.Data.raffle
else
if callback then callback(false) end
end
end)
end
function M:UpdateNotice(id,callback)
local _client = ControllerManager.WebClient
local _data = {}
_data.id = id
_client:send(Protocol.WEB_UPDATE_NOTICE, _data, function (res)
--pt(res)
if res.ReturnCode == 0 and #res.Data.notice_list > 0 then
callback(true, res.Data)
else
callback(false)
end
end)
end
function M:RequestRecordList(callback, roomid)
local _client = ControllerManager.WebClient
local _data = {}
_data["platform"] = GetPlatform()
local proto
if not roomid then
proto = Protocol.WEB_GET_MILITARY
else
proto = Protocol.WEB_GET_MILITARY_BY_ROOMID
_data.roomId = roomid
end
_client:send(proto, _data, function (res)
self.recordList = nil
-- print(vardump(res))
if (res.ReturnCode == 0 or res.ReturnCode == 19 ) then
--self:RequestRankList(callback)
self.recordList = {}
if res.ReturnCode == 19 then return end
local recordData = res.Data
local record_info_list = recordData["military_list"]
if record_info_list ~= nil then
for i = 1, #record_info_list do
local record_list_item = record_info_list[i]
local record_list = MResult.new() -- new 战绩
record_list.GameId = tonumber(record_list_item["game_id"])
record_list.GameInfo = record_list_item["game_info"]
record_list.RoomId = record_list_item["room_id"]
record_list.group_id = record_list_item["groupId"]
record_list.Time = record_list_item["create_time"]
record_list.PlayBackId = record_list_item["military_id"]
record_list.hpData = record_list_item["hpData"]
record_list.hpOnOff = record_list_item["hpOnOff"]
record_list.hp_times = d2ad(record_list_item["hp_times"])
local total_score_str = record_list_item["totalScore"]
if total_score_str then
local total_score_item = json.decode(total_score_str)
for j = 1, #total_score_item do
local m_playerScore = MPlayerScore.new()
local total_score_str = total_score_item[j]
m_playerScore.Name = total_score_str["nick"]
m_playerScore.Score = total_score_str["score"]
m_playerScore.Id = total_score_str["accId"]
m_playerScore.Portrait = total_score_str["portrait"]
record_list.TotalScoreList[#record_list.TotalScoreList + 1] = m_playerScore
end
end
local round_count = record_list_item["round"]
for j = 1,round_count do
local round_score_str = record_list_item["round_"..j]
local m_round_game = MGameTimes.new()
if round_score_str then
local round_score_item = json.decode(round_score_str)
for k = 1, #round_score_item do
local m_player_score = MPlayerScore.new()
m_player_score.Name = round_score_item[k]["nick"]
m_player_score.Score = round_score_item[k]["score"]
m_round_game.PlayerList[#m_round_game.PlayerList + 1] = m_player_score
end
record_list.GameTimes[#record_list.GameTimes + 1] = m_round_game
end
end
self.recordList[#self.recordList + 1] = record_list
end
end
callback(res.ReturnCode)
else
callback(res.ReturnCode)
end
end)
end
function M:RequestPlayBack(_data,callback,game_info)
if game_info and ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then
ExtendHotupdate.UpdateGame(game_info,function()
self:RequestPlayBack(_data,callback)
end)
return
else
local _client = ControllerManager.WebClient
_client:send(Protocol.WEB_GET_PLAY_BACK , _data , function (res)
if res.ReturnCode == 0 then
local data = json.decode(res.Data.playback)
local cmdList = data.cmdList
local info = data.info
local extend = ExtendManager.GetExtendConfig(info.game_id)
local room = extend:NewRoom()
room.game_id = info.game_id
DataManager.CurrenRoom = room
extend:FillPlayBackData(data)
if not room.self_player then
room.self_player = room:GetPlayerBySeat(1)
end
callback(res.ReturnCode,data)
else
callback(res.ReturnCode,nil)
end
end)
end
end
--获取手机验证码
function M:GetPhoneCode(phone,callback)
local _client = ControllerManager.WebClient
local _data = {}
_data["phone"]=phone
_client:send(Protocol.WEB_GET_VERIFCATION_CODE, _data, function(res)
callback(res)
end)
end
function M:GetUserInfo(callback)
local _client = ControllerManager.WebClient
_client:send(Protocol.WEB_GET_USER_INFO, nil, function(res)
if res.ReturnCode == 0 then
local user = DataManager.SelfUser
local data = res.Data
user.real_info = data.real_info
user.address = data.address
user.invitation = data.invitation
user.phone = data.phone
user.password = data.password
end
callback(res)
end)
end
function M:UpdateUserInfo(_data,callback)
local _client = ControllerManager.WebClient
_client:send(Protocol.WEB_UPDATE_USER_INFO, _data, function(res)
callback(res)
end)
end
-- 设置被邀请开关
function M:SetInvited(on, callback)
local _client = ControllerManager.WebClient
local _data = {}
_data["invitation"] = on
_client:send(Protocol.WEB_SET_GROUP_INVITATED, _data, function(res)
callback(res)
end)
end

View File

@ -0,0 +1,145 @@
LoginController = {}
local M = {}
--- Create a new LoginController
function LoginController.new()
setmetatable(M, { __index = IController })
local self = setmetatable({}, { __index = M })
self.baseType = LoginController
self.class = "Login"
return self
end
local _LocalConfigAllGame = {
10, 13, 14, 15, 16, 17, 22,
30, 31, 33, 34, 35,
50, 51, 52, 53, 54,
60, 61, 62, 63, 64, 65, 66, 67, 77, 88,
101, 102, 103, 104, 105, 106, 107, 108,
301, 201, 202, 203
}
local FilterGame = function(games)
local tempGames = {}
for k, v in pairs(games) do
if IsHasDictionary(v.game_id, _LocalConfigAllGame) then
table.insert(tempGames, v)
end
end
print("服务器不存在的资源!!!!!!!!临时资源=======================")
for k, v in pairs(games) do
local ttemp = {}
v.bundle = "extend.poker.dezhou"
v.version = "1.0.0"
table.insert(ttemp, v)
return ttemp
end
return tempGames
end
local function __Login(cmd, _data, callBack)
local _client = ControllerManager.WebClient
_client:send(cmd, _data, function(res)
if (res.ReturnCode == 0) then
local data = res.Data
print("游戏列表:\n" .. serialize(res.Data))
local account = data["account"]
local user = DataManager.SelfUser
user.acc = account.acc
user.account_id = account["id"]
user.diamo = account["diamo"]
user.nick_name = account["nick"]
user.sex = account["sex"]
user.head_url = account["portrait"]
user.room_id = account["roomid"]
user.group_id = account["groupId"]
user.type = account["type"]
user.agent = account["mng"]
user.real_info = account.real_info
user.phone = account.phone
user.address = account.address
user.games = FilterGame(data.games)
if Application.platform == RuntimePlatform.WindowsPlayer or Application.platform == RuntimePlatform.WindowsEditor then
--GameApplication.Instance.printLog = true
else
--GameApplication.Instance.printLog = user.type == 2
end
_client:setSession(data["session_id"] .. "," .. data["token"])
pt(data)
ControllerManager.GroupClient = NetClient.new(data.groupWeb, "web_group", ConnectionProtocol.Web)
ControllerManager.GroupClient:setSession((data["session_id"] .. "," .. data["token"]))
end
if (callBack ~= nil) then
callBack(res)
end
end)
end
local function __getCode(cmd, _data, callBack)
local _client = ControllerManager.WebClient
_data["uuidCode"] = 0 --res.Data.code
_client:send(Protocol.WEB_GET_CODE, { id = _data.id }, function(res)
if (res.ReturnCode == 0) then
_data["uuidCode"] = res.Data.code
__Login(cmd, _data, callBack)
end
end)
end
--手机登录
function M:PhoneLogin(phone, code, callback)
local _data = {}
_data["phone"] = phone
_data["code"] = code
__Login(Protocol.WEB_PHONE_LOGIN, _data, callback)
end
--手机密码登录
function M:PhonePasswordLogin(phone, password, callback)
local _data = {}
_data["phone"] = phone
_data["password"] = password
__Login(Protocol.WEB_PHONE_PASSWORD_LOGIN, _data, callback)
end
function M:IdPasswordLogin(uid, password, callback)
local _data = {}
_data["id"] = tonumber(uid)
_data["password"] = password
_data["deviceCode"] = UnityEngine.SystemInfo.deviceUniqueIdentifier
__getCode(Protocol.WEB_ID_PASSWORD_LOGIN, _data, callback)
end
function M:Login(callback)
local user = DataManager.SelfUser
local _data = {}
_data["acc"] = user.acc
_data["nick"] = user.nick_name
_data["sex"] = user.sex
_data["portrait"] = user.head_url
_data["deviceCode"] = UnityEngine.SystemInfo.deviceUniqueIdentifier
__Login(Protocol.WEB_USER_LOGIN, _data, callback)
end
function M:QuickLogin(session_id, callback)
local _data = {}
local _client = ControllerManager.WebClient
_client:setSession(session_id)
-- ControllerManager.GroupClient:setSession(session_id)
__Login(Protocol.WEB_QUICK_LOGIN, _data, callback)
end
function M.OnEnter(self)
--print("login controller enter")
end
function M.OnExit(self)
--print("login controller exit")
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,226 @@
RoomController = {}
local M = {}
--- Create a new RoomController
function RoomController.new()
setmetatable(M, {__index = IController})
local self = setmetatable({}, {__index = M})
self.baseType = RoomController
self.class = "Room"
return self
end
local function __ConntectGameServer(cmd,room, host, _data,callback)
-- local _data = {}
_data["session"] = room.session
local _game_client = NetClient.new(host, "game")
_game_client:connect()
ControllerManager.SetGameNetClient(_game_client)
_game_client.onconnect:Add(function(code)
if (code == SocketCode.Connect) then
_game_client:send(cmd, _data, function (response)
if (response.ReturnCode == 0) then
_game_client.onconnect:Clear()
_game_client.onconnect:Add(ControllerManager.OnConnect)
callback(response)
return
end
_game_client:destroy()
if ControllerManager.GameNetClinet == _game_client then
ControllerManager.GameNetClinet =nil
end
callback(response)
end)
else
if ControllerManager.GameNetClinet == _game_client then
ControllerManager.GameNetClinet =nil
end
_game_client:destroy()
callback({ReturnCode = 101})
end
end)
-- return _game_client
end
function M:CreateRoom(game_id, _data, callback)
local _client = ControllerManager.WebClient
local data = {}
data.game_id = game_id
data["platform"] = GetPlatform()
data.config_data = _data
-- local runtime = os.clock()
_client:send(Protocol.WEB_CREATE_ROOM, data, function(res)
-- if ( res.ReturnCode == Table_Error_code.ERR_IN_ROOM or res.ReturnCode == Table_Error_code.ERR_CREATE_ROOM) then
-- self:JoinRoom("000000",callback)
-- return
-- end
if (res.ReturnCode == 0) then
local json = res.Data
local game_info = json["game_info"]
if ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then
ExtendHotupdate.UpdateGame(game_info,function()
res.ReturnCode = -2
callback(res)
end)
return
end
local game_id = game_info.game_id
local room_id = json["room_id"]
local server_ip = json["server_ip"]
local server_port = json["server_port"]
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
room.game_id = game_id
room.room_id = room_id
room.server_host = string.concat(server_ip, ":", server_port)
room.session = _client:getSession()
DataManager.CurrenRoom = room
local game_net = nil
local j_data = {}
j_data["session"] = room.session
if not DataManager.SelfUser.location then
DataManager.SelfUser.location = Location.new()
end
j_data["pos"] = DataManager.SelfUser.location:Location2String()
-- game_net =
__ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data, function (response)
if (response.ReturnCode == 0) then
-- game_net:clearEvent()
local _s2croom = response.Data
-- ControllerManager.SetGameNetClient(game_net)
room.owner_id = _s2croom["owner"]
room.banker_seat = _s2croom["manor"]
if _s2croom.createTime then
room.create_time = _s2croom["createTime"]
end
room.agent = _s2croom.agent == 1 and true or false
local extend = ExtendManager.GetExtendConfig(room.game_id)
extend:FillRoomData(_s2croom)
ControllerManager.ChangeController(GameController)
-- print("create room:"..(os.clock()-runtime))
callback(response)
return
end
-- game_net:destroy()
callback(response)
end)
else
if callback then callback(res) end
end
end)
end
local join_room_frame = 0
function M:PublicJoinRoom(cmd,roomid,tem,callback,group_id,pid)
printlog("公共进入房间接口=============PublicJoinRoom")
-- 同一帧不重复调用
local last_frame = join_room_frame
join_room_frame = Time.frameCount
if join_room_frame == last_frame then
return
end
-- 防止游戏没有离开控制器
ControllerManager.ChangeController(LoddyController)
local _data = {}
if cmd == Protocol.WEB_FG_MATCH_ROOM then
_data["is_null"] = tem
elseif cmd == Protocol.WEB_FG_QUEUE_ROOM then
_data["is_null"] = tem
_data["room_id"] = roomid
else
_data["room_id"] = roomid
end
_data["id"] = group_id
_data["pid"] = pid
_data["platform"] = GetPlatform()
pt(_data)
local _client = ControllerManager.GroupClient
_client:send(cmd, _data, function( res)
pt(res)
if (res.ReturnCode == 0) then
local json = res.Data
local game_info = json["game_info"]
if ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then
ExtendHotupdate.UpdateGame(game_info,function()
res.ReturnCode = -2
callback(res)
end)
return
end
local game_id = game_info.game_id
local server_ip = json["server_ip"]
local server_port = json["server_port"]
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
room.lev = json["lev"] -- 自己在当前房间所在圈子的职位1盟主2管理员3用户非圈子房间就是3
room.room_id = json["room_id"]
room.game_id = game_id
room.status = json["status"]
room.server_host = string.concat(server_ip, ":", server_port)
room.session = _client:getSession()
-- 圈子信息圈子id和玩法id
room.group_id = json["groupId"]
-- 圈子禁止文字聊天,禁止语音聊天
room.ban_chat1 = json["ban_chat1"]
room.ban_chat2 = json["ban_chat2"]
-- 玩法id
room.play_id = json["pid"]
-- 体力值开关
room.hpOnOff = json["hpOnOff"]
-- 体力值倍数
room.score_times = d2ad(json.hp_times) or 1
DataManager.CurrenRoom = room
local j_data = {}
if not DataManager.SelfUser.location then
DataManager.SelfUser.location = Location.new()
end
j_data["pos"] = DataManager.SelfUser.location:Location2String()
__ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data,function ( res1)
pt(res1)
ControllerManager.IsSendCard=false
if (res1.ReturnCode ~= 0 ) then
if (callback) then callback(res1) end
else
ControllerManager.enterPlayerData=res1.Data.tableInfo.playerData
local _s2croom = res1.Data
room.owner_id = _s2croom["owner"]
if _s2croom.createTime then
room.create_time = _s2croom["createTime"]
end
if _s2croom.manor then
room.banker_seat = _s2croom.manor
end
room.agent = _s2croom.agent == 1 and true or false
-- ControllerManager.SetGameNetClient(game_net)
local extend = ExtendManager.GetExtendConfig(room.game_id)
extend:FillRoomData(_s2croom)
ControllerManager.ChangeController(GameController)
local gamectr = ControllerManager.GetCurrenController()
gamectr.tmpRoomID = room.room_id
gamectr.tmpGroupID = room.group_id
if callback then callback(res1) end
end
end)
else
if callback then callback(res) end
end
end)
end
function M:JoinRoom(room_id,callback)
self:PublicJoinRoom(Protocol.WEB_JOIN_ROOM,room_id,false,callback,group_id,group_layer)
end
function M:ResetJionRoom(callback)
local _game = ControllerManager.GetController(GameController)
local o_room = DataManager.CurrenRoom
self:JoinRoom(o_room.room_id,callback)
end

View File

@ -0,0 +1,113 @@
import(".Protocol")
import(".Controller.IController")
import(".Controller.LoginController")
import(".Controller.LoddyController")
import(".Controller.GameController")
import(".Controller.NewGroupController")
import(".Controller.RoomController")
import(".Controller.GroupMgrController")
---
-- a net ControllerManager
ControllerManager = {
-- http网络连接
WebClient = nil,
-- game网络长连接
GameNetClinet = nil,
reset_join_room = 0
}
local _currenController = nil
local _controllerMap = {}
function ControllerManager.Init()
_controllerMap[LoginController] = LoginController.new()
_controllerMap[LoddyController] = LoddyController.new()
_controllerMap[NewGroupController] = NewGroupController.new()
_controllerMap[RoomController] = RoomController.new()
_controllerMap[GroupMgrController] = GroupMgrController.new()
local hostIp = GetGameInfo("login_url")
if(debug_print) then
print("hostIp:::"..hostIp)
end
ControllerManager.WebClient = NetClient.new(hostIp, "majiang", ConnectionProtocol.Web)
--ControllerManager.GroupClient = nil--NetClient.new("http://192.168.0.1:8081/", "web_group", ConnectionProtocol.Web)
end
function ControllerManager.ChangeController(type)
if (_currenController ~= nil) then
_currenController:OnExit()
end
_currenController = ControllerManager.GetController(type)
_currenController:OnEnter()
return _currenController
end
-- 获取当前控制器
function ControllerManager.GetCurrenController()
return _currenController
end
---
--@function [parent=#ControllerManager] GetController
--@return Game.Controller.IController#IController description
function ControllerManager.GetController(cls)
if(cls == GameController) then
if DataManager.CurrenRoom then
local exconfig = ExtendManager.GetExtendConfig(DataManager.CurrenRoom.game_id)
return exconfig.GetGameController()
end
end
local c =_controllerMap[cls]
return c
end
function ControllerManager.SetGameNetClient(client)
if (ControllerManager.GameNetClinet ~= nil) then
ControllerManager.GameNetClinet:destroy()
end
ControllerManager.GameNetClinet = client
-- if (client ) then
-- client.onconnect:Add(ControllerManager.OnConnect)
-- end
end
function ControllerManager.OnConnect(code)
if (code ~= SocketCode.Connect) then
ControllerManager.SetGameNetClient(nil)
if code ~= SocketCode.DisconnectByServer then
ControllerManager.OnGameConnect(SocketCode.TimeoutDisconnect)
ControllerManager.reset_join_room = 0
ControllerManager.ResetJionRoom()
else
ControllerManager.OnGameConnect(SocketCode.DisconnectByServer)
end
else
ControllerManager.OnGameConnect(SocketCode.Connect)
end
end
function ControllerManager.ResetJionRoom()
ControllerManager.reset_join_room = ControllerManager.reset_join_room + 1
if ControllerManager.reset_join_room > 3 then
ControllerManager.OnGameConnect(SocketCode.NetworkException)
return
end
ControllerManager.ChangeController(LoddyController)
local loddyctr = ControllerManager.GetController(LoddyController)
loddyctr:ResetJionRoom(function( res)
if res.ReturnCode == 11 or res.ReturnCode == 81 or res.ReturnCode == 1005 then
ControllerManager.OnGameConnect(SocketCode.Disconnect)
return
elseif res.ReturnCode ~=0 then
ControllerManager.ResetJionRoom()
return
end
ControllerManager.OnGameConnect(SocketCode.Connect)
end)
end

View File

@ -0,0 +1,284 @@
local M = class("GroupData")
function M:ctor()
self.id = 0
self.name = ""
-- 盟主ID
self.owner = 0
--盟主昵称
self.o_nick = ""
--盟主头像
self.o_portrait = ""
--自己在圈子的职位
self.lev = 3
self.top_time = 0
--已获取成员数
self.member_num = 0
-- 总成员数
self.total_member_num = 0
--圈子房间数
self.room_num = 0
-- 1普通圈子2大联盟
self.type = 1
-- 1是房主支付2AA支付
self.pay_type = 1
--成员列表
self.members = {}
self.memberMap = {}
--房间列表
self.rooms = {}
--默认房间列表
self.default_rooms = {}
--玩法列表
self.playList = {}
--加圈子申请数
self.joins = 0
--自动解散
self.dissolve_opt = 1
--占座踢出
self.kick_opt = 1
--玩家申请
self.apply = 0
--盟主钻石
self.diamo = 0
--隐藏功能
self.hide_action = 0
--是否开启全民推广
self.promote = false
end
-- 添加成员
function M:addMember(member)
local _tem = self.memberMap[member.uid]
if _tem then
for k, v in pairs(member) do
_tem[k] = v
end
else
self.memberMap[member.uid] = member
self.members[#self.members + 1] = member
self.member_num = #self.members
end
end
-- 删除成员
function M:delMember(id)
local _tem = self.memberMap[id]
if _tem then
self.memberMap[id] = nil
for i=1,#self.members do
local member = self.members[i]
if member.uid == id then
table.remove(self.members,i)
break
end
end
self.member_num = #self.members
end
end
function M:clearMember()
self.members = {}
self.memberMap = {}
self.member_num = 0
end
function M:getMember(id)
return self.memberMap[id]
end
-- 添加房间
function M:addRoom(room)
local pid = room.pid
local play = self:getPlay(pid)
print("jefe addRoom")
if not play then return end
for i=1,#self.rooms do
local tem = self.rooms[i]
if room.id == tem.id then
self.rooms[i] = room
for j = 1, #play.rooms do
if room.id == play.rooms[j].id then
play.rooms[j] = room
return
end
end
return
end
end
self.rooms[#self.rooms+1] = room
-- 把房间加入对应的玩法下的列表
play.rooms[#play.rooms + 1] = room
end
-- 删除房间
function M:delRoom(id)
local pid = 0
for i=1,#self.rooms do
local room = self.rooms[i]
if room.id == id then
pid = room.pid
table.remove(self.rooms,i)
break
end
end
if pid == 0 then return end
local play = self:getPlay(pid)
if not play then return end
for i = 1, #play.rooms do
local room = play.rooms[i]
if room.id == id then
table.remove(play.rooms, i)
break
end
end
end
-- 添加玩法
function M:addPlay(play)
--printlog("添加玩法addPlay===>>>")
--pt(play)
local maxRound=0
if play.maxRound then
maxRound=play.maxRound
else
local hpdata = json.decode(play.hpData)
maxRound=hpdata.maxRound
end
local pnum = play.maxPlayers
local room = {maxPlayers = pnum, status = -1, default = true, pid = play.id,times=maxRound}
play.rooms = {}
local index = self:getPlayIndex(play.id)
if index ~= -1 then
self.playList[index] = play
self.default_rooms[index] = room
return
end
self.playList[#self.playList + 1] = play
-- 房间列表中,给每个玩法添加一个对应的空房间
self.default_rooms[#self.default_rooms + 1] = room
--self.playList=self:SortPlay(self.playList)
--pt(self.playList)
--self.default_rooms=self:SortDefaultPlay(self.default_rooms)
end
function M:SortPlay(list)
local singlePlayList={}
local otherPlayList={}
for i=1,#list do
local hpdata=json.decode(list[i].hpData)
if hpdata.maxRound and hpdata.maxRound==1 then
table.insert(singlePlayList,list[i])
else
table.insert(otherPlayList,list[i])
end
end
for i=1,#otherPlayList do
table.insert(singlePlayList,otherPlayList[i])
end
return singlePlayList
end
function M:SortDefaultPlay(list)
local singlePlayList={}
local otherPlayList={}
for i=1,#list do
if list[i].times and list[i].times==1 then
table.insert(singlePlayList,list[i])
else
table.insert(otherPlayList,list[i])
end
end
for i=1,#otherPlayList do
table.insert(singlePlayList,otherPlayList[i])
end
return singlePlayList
end
-- 删除玩法
function M:delPlay(pid)
local index = self:getPlayIndex(pid)
if index ~= -1 then
table.remove(self.playList,index)
table.remove(self.default_rooms, index)
return true
end
return false
end
-- 禁止玩法
function M:banPlay(pid, ban)
local play = self:getPlay(pid)
--printlog("禁止玩法===>>>")
--pt(play)
play.ban = ban
end
-- 标记玩法
function M:markPlay(pid, ban)
local play = self:getPlay(pid)
--printlog("标记玩法===>>>")
play.mark = ban
--pt(play)
end
function M:getPlay(pid)
local index = self:getPlayIndex(pid)
if index ~= -1 then
return self.playList[index]
end
return nil
end
function M:getPlayName(pid)
local index = self:getPlayIndex(pid)
if index ~= -1 then
return self.playList[index].name
end
return "已删除"
end
function M:getPlayIndex(pid)
for i=1,#self.playList do
local tem = self.playList[i]
if tem.id == pid then
return i
end
end
return -1
end
function M:clearPlay()
self.playList = {}
self.rooms = {}
self.default_rooms={}
for i = 1, #self.playList do
self.playList[i].rooms = {}
end
end
function M:clear()
self.playList = {}
self.members = {}
self.memberMap = {}
self.rooms = {}
self.default_rooms = {}
end
return M

View File

@ -0,0 +1,46 @@
local M = class("Groups")
function M:ctor()
self.groupList = {}
self.groupMap = {}
end
function M:add(group)
local _tem = self.groupMap[group.id]
if _tem then
for k, v in pairs(group) do
_tem[k] = v
end
else
self.groupMap[group.id] = group
self.groupList[#self.groupList + 1] = group
end
end
function M:del(id)
local _tem = self.groupMap[id]
if _tem then
local list = self.groupList
self.groupMap[id] = nil
for i=1,#list do
local group = list[i]
if group.id == id then
table.remove(list,i)
self.groupMap[id] = nil
break
end
end
end
end
function M:get(id)
local _tem = self.groupMap[id]
return _tem
end
function M:clear()
self.groupMap = {}
self.groupList = {}
end
return M

View File

@ -0,0 +1,83 @@
-- Edit By ChenGY
-- 记录玩家位置,距离计算
Location = {
longitude = 0,
latitude = 0,
default = true,
address = nil,
}
local M = Location
function M.new(str)
local self = {}
setmetatable(self, {__index = M})
self:LoadLocation(str)
if str and str ~= "" then
self.default = false
else
self.default = true
end
return self
end
-- 获取详细地址
function M:GetAddress(obj)
if self.address then
obj.text = self.address
else
coroutine.start(self.DownloadAddressInfo, self, obj)
end
end
function M:DownloadAddressInfo(obj)
-- bd09ll gcj02 wgs84ll
local coordtype = "&coordtype=wgs84ll"
-- if Application.platform == RuntimePlatform.Android then
-- coordtype = ""
-- end
local url = string.format("http://api.map.baidu.com/geocoder/v2/?ak=Z6qXIddQtwO8xaKunX4CURbwcV0GLSrG&location=%s,%s&output=json%s", self.latitude, self.longitude, coordtype)
local www = UnityEngine.WWW(url)
coroutine.www(www)
if string.utf8len(www.error) == 0 then
local txt = www.text
local json_add = json.decode(txt)
self.address = json_add.result.formatted_address
obj.text = self.address
end
end
-- 计算距离
function M:CalcDistance(loc)
local EARTH_RADIUS = 6378.137
local radLat1 = math.rad(self.latitude)
local radLat2 = math.rad(loc.latitude)
local a = radLat1 - radLat2
local b = math.rad(self.longitude) - math.rad(loc.longitude)
local s = 2 * math.asin(math.sqrt(math.pow(math.sin(a/2),2) + math.cos(radLat1)*math.cos(radLat2)*math.pow(math.sin(b/2),2)))
s = s * EARTH_RADIUS
local dist = math.floor(s * 10000 +.5) / 10000
return dist
end
function M:Location2String()
if self.default then return "" end
local str = self.longitude .. "," .. self.latitude
return str
end
function M:String2Location()
local loc = string.split(str, ",")
return loc
end
function M:LoadLocation(str)
local loc = string.split(str, ",")
self.longitude = tonumber(loc[1])
self.latitude = tonumber(loc[2])
end
return M

View File

@ -0,0 +1,38 @@
--玩家数据对象
local Player ={
-- 玩家对应的User对象
self_user = nil,
-- 网络状态 1 在线 0 离线
line_state = 1,
-- 座位号
seat = 0,
-- 是否准备
ready = false,
-- 当前局积分
curren_score = 0,
-- 总积分
total_score = 0,
-- 托管
entrust = false,
}
---
-- @type Player
local M = Player
--- Create a new Player
function Player.new()
local self = {}
setmetatable(self, {__index = M})
self.hand_cards = {}
return self
end
-- 清理玩家数据
function M:Clear()
end
return M

View File

@ -0,0 +1,45 @@
RecordData = class ("RecordData")
function RecordData:ctor()
self.Result_Map = {}
end
MResult = class ("MResult")
function MResult:ctor()
-- 游戏类型
self.GameId = 0
-- 房间ID
self.RoomId = 0
-- 回放ID
self.PlayBackId = ""
-- 对战时间
self.Time = ""
-- 玩家列表
self.TotalScoreList = {}
-- 每一小局列表
self.GameTimes = {}
end
MPlayerScore = class ("MPlayerScore")
function MPlayerScore:ctor()
-- 玩家名称
self.Name = ""
-- 分数
self.Score = 0
end
MGameTimes = class ("MGameTimes")
function MGameTimes:ctor()
self.PlayerList = {}
end

View File

@ -0,0 +1,219 @@
-- 房间基本数据类
--author--
StateType =
{
Ready = 0,
Palying = 1,
PalyingWait = 2
}
---房间数据对象
local Room = {
-- 房间ID
room_id = "",
-- 游戏ID
game_id = 0,
-- 服务器地址
server_host = "",
-- 玩家session
session = "",
-- 自己
self_player = nil,
-- 房主ID
owner_id = "",
-- 庄家座位号
banker_seat = 0,
-- 当前回合
curren_round = 0,
-- 当前转向的座位号
curren_turn_seat = 0,
-- 房间配置
room_config = nil,
-- 玩家列表
player_list = nil,
-- 游戏中
playing = false,
create_time = "",
group_id = 0,
-- 自己在当前房间所在圈子的职位1盟主2管理员3用户非圈子房间就是3
lev = 3,
-- 房间倍数
score_times = 1,
-- 体力值开关
hpOnOff = 0,
-- 牌友圈的游戏id
pid = 0,
-- 房间重连标记
reloading = false,
}
---
-- a RoomConfig
RoomConfig = {
-- 人数
people_num = 2,
-- 回合数
opt_round = 1,
}
---
-- @type Room
local M = Room
--- Create a new Room
function Room.new()
local self = {}
setmetatable(self, {__index = M})
self:init()
return self
end
function M:init()
self.player_list = {}
self.room_config ={}
end
-- 创建玩家
function M:NewPlayer()
return Player.new()
end
-- 添加玩家
function M:AddPlayer(player)
if (not player) then return end
for k , tem in ipairs(self.player_list) do
if(tem.self_user.account_id == player.self_user.account_id) then
-- tem = player
self.player_list[k] = player
return
end
end
self.player_list[#self.player_list+1] = player
end
-- 是否为不可负分房间
function M:checkHpNonnegative()
local isNonnegative = self.room_config.isNonnegative
if isNonnegative and isNonnegative == 1 then
return true
end
return false
end
-- 删除指定玩家
-- <param name="player"></param>
function M:RemovePlayer(player)
for i , _player in ipairs(self.player_list) do
if _player == player then
table.remove(self.player_list , i)
return
end
end
end
-- 获取指定玩家_userid
-- <param name="id"></param>
-- <returns></returns>
function M:GetPlayerById(id)
for _ , tem in pairs(self.player_list) do
if (tem.self_user.account_id == id) then
return tem
end
end
return nil;
end
-- 获取指定玩家_桌号
-- <param name="id"></param>
-- <returns></returns>
function M:GetPlayerBySeat(seat)
for _ , tem in ipairs(self.player_list) do
if (tem.seat == seat) then
return tem
end
end
return nil
end
-- 获取大结算显示的积分
function M:GetTotalScore(score)
if self.hpOnOff == 1 then
return d2ad(score)
else
return score
end
end
-- 获取乘倍数前的积分
function M:GetOriginScore(total_score)
if self.hpOnOff == 1 then
return total_score / self.score_times
else
return total_score
end
end
-- 设置房间重连状态
function M:SetReloadStatus(flag)
self.reloading = flag
end
-- 获取房间重连状态
function M:GetReloadStatus()
return self.reloading
end
--- Create a new RoomConfig
function RoomConfig:init(config)
--人数
self.people_num = config["maxPlayers"]
--支付类型
self.AA = config["AA"] == 1 and true or false
--托管
self.tuoguan = config["tuoguan"]
self.tuoguan_active_time = config["tuoguan_active_time"]
self.tuoguan_result_type = config["tuoguan_result_type"]
--不可负分
self.isNonnegative = config["isNonnegative"]
self.pid = config["pid"]
return self
end
local str_tuoguan = {"当局结算", "二局结算", "三局结算","满局结算"}
function RoomConfig:GetDes(sp, str_people_num)
local str = ""
if not str_people_num and self.people_num then
str = str .. self.people_num .. ""
--str = str .. sp
end
-- if self.AA then
-- str = str .. "AA支付" .. sp
-- else
-- str = str .. "房主支付" .. sp
-- end
-- if self.isNonnegative == 1 then
-- str = str .. "不可负分" .. sp
-- end
if self.tuoguan then
str = str .. "托管" .. sp
str = str .. "离线" .. self.tuoguan_active_time .. "秒托管" .. sp
str = str .. str_tuoguan[self.tuoguan_result_type] .. sp
end
return str
end
function RoomConfig:GetGameName()
end
return M

View File

@ -0,0 +1,29 @@
--结算数据对象
local m = class("RoomResult")
function m:ctor()
-- 房间ID
self.RoomID = 0
-- 结果类型
self.Type = RoomResultType.Normal
-- 庄家
self.BankerSeat = 0
-- 剩余牌数
self.LeftNum = 0
-- 当前局
self.CurrenRound = 0
-- 总局
self.ToalRound = 0
-- 玩家列表
-- list.new()
self.PlayerList = {}
end
return m

View File

@ -0,0 +1,92 @@
-- Edit By ChenGY
-- 记录各游戏的桌面背景
local TableBG = {}
local M = TableBG
local bg_config = {
{id = 1, url = "base/tablebg/bg/bg1", thumb = "ui://Common/b04"},
{id = 2, url = "base/tablebg/bg/bg2", thumb = "ui://Common/b05"},
{id = 3, url = "base/tablebg/bg/bg3", thumb = "ui://Common/b06"},
{id = 4, url = "base/tablebg/bg/bg7", thumb = "ui://Common/b01"},
{id = 5, url = "base/tablebg/bg/bg5", thumb = "ui://Common/b02"},
{id = 6, url = "base/tablebg/bg/bg4", thumb = "ui://Common/b03"},
}
function TableBG.GetBGConfig(config)
return config or bg_config
end
local function GetBG(data, game_id)
local bg_id = 0
for i = 1, #data do
if data[i].game_id == game_id then
bg_id = data[i].bg_id
break
end
end
return bg_id
end
local function SetBG(data, game_id, bg_id)
local contain_key = false
for i = 1, #data do
if data[i].game_id == game_id then
contain_key = true
if data[i].bg_id ~= bg_id then
data[i].bg_id = bg_id
break
end
end
end
if not contain_key then
local _data = {}
_data.game_id = game_id
_data.bg_id = bg_id
table.insert(data, _data)
end
end
function TableBG.GetTableBG(game_id)
local id = -1
local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code)
-- print(DataManager.SelfUser.invite_code, DataManager.SelfUser.account_id)
if json_data ~= nil then
local config_data = json.decode(json_data)
id = GetBG(config_data, game_id)
end
return id
end
function TableBG.LoadTableBG(id, game_id, main_view, config)
local bg_id = M.GetTableBG(game_id)
local index
if not bg_id then
index = 1
elseif bg_id > 0 then
index = bg_id
else
index = id
end
local con
if config then
con = config[index]
else
con = bg_config[index]
end
LoadGameBg(con and con.url or bg_config[1].url, main_view)
end
function TableBG.SaveTableBG(game_id, bg_id)
local config_data
local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code)
if json_data ~= nil then
config_data = json.decode(json_data)
else
config_data = {}
end
SetBG(config_data, game_id, bg_id)
Utils.SaveLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code, json.encode(config_data))
end
return M

View File

@ -0,0 +1,110 @@
--用户账号数据类
--author--
---
-- a user
User = {
account_id = "",
-- acc
acc ="",
--头像
head_url = "",
-- 用户IP
host_ip = "",
-- 经纬度坐标
location = nil,
-- 昵称
nick_name = "",
--性别
sex = 0,
-- 房间ID
room_id = "",
-- 房卡数
diamo = 0,
-- 代理类型0不是代理1普通代理2大联盟代理
agent = 0,
invite_code = "1",
-- 当前圈子
cur_group = nil,
-- 圈子id重连时用来标记是否在圈子房间中
group_id = 0,
playback = {},
--弹窗公告
notices = {},
}
---
-- @type User
local M = User
--- Create a new User
function User.new()
local self = {}
setmetatable(self, {__index = M})
return self
end
function M:getGameData(game_id)
local game_list = self.games
for i=1,#game_list do
local game = game_list[i]
if game.game_id == game_id then
return game
end
end
end
function M:addGameData(data)
local game_list = self.games
for i=1,#game_list do
local game = game_list[i]
if game.game_id == data.game_id then
game_list[i] = data
return
end
end
game_list[#game_list+1] = data
end
function M:removeGameData(game_id)
local game_list = self.games
for i=1,#game_list do
local game = game_list[i]
if game.game_id == game_id then
table.remove(game_list,i)
return
end
end
end
--[[
local GuildData = {
--公会ID
id = 1,
--公会区名
zone = "",
--公会名称
name = "",
--游戏列表
games =nil
}
local GameInfo = {
--游戏ID
game_id = 1,
--服务器版本
version = "1.0.0",
table_data = nil
}
]]

View File

@ -0,0 +1,13 @@
local DATA_MODEL_NAME = ...
Player = import(".Player")
import(".RecordData")
Room = import(".Room")
RoomResult = import(".RoomResult")
import(".User")
RecordData = import(".RecordData")
Location = import(".Location")
GroupData = import(".GroupData")
Groups = import(".Groups")

View File

@ -0,0 +1,22 @@
require "Game.Data.init"
---
--@module Game.DataManager
DataManager= {
--my user
SelfUser = User.new(),
CurrenRoom = nil,
-- 互动表情时间,控制cd
InteractTime = 0,
-- 记录各游戏使用牌型的列表,现暂时只保存了麻将的数据.
CardTypeList = nil,
-- 牌友圈列表
groups = Groups.new(),
-- 禁止互动的房间ID
BanInteractRoom = nil,
-- app版本
AppVersion = "",
}

View File

@ -0,0 +1,125 @@
local function __ShowTip(_version_view, text, callback)
local ctr_state = _version_view:GetController("state")
ctr_state.selectedIndex = 1
_version_view:GetChild("tex_tip").text = text
_version_view:GetChild("btn_ok").onClick:Set(function()
ctr_state.selectedIndex = 0
if (callback ~= null) then
callback:DynamicInvoke()
end
end)
local btn_close = _version_view:GetChild("btn_close")
if btn_close then
btn_close.onClick:Set(function()
_version_view:Dispose()
_version_view = nil
end)
end
end
local function __update_check(data, onback, _version_view)
-- local tex_tip = _version_view:GetChild("tex_info")
for k, game_data in ipairs(data) do
local asset_path = game_data["bundle"]
asset_path = string.gsub(asset_path, "%.", "/")
local local_version = Version.DEFUALT
local server_version = Version(game_data["version"])
local version_update = Hotupdate(asset_path .. "/", local_version, server_version)
version_update.AssetName = game_data["name"]
version_update:SetTipCallback(function(text, callback)
-- __ShowTip(_version_view,text, callback)
end)
version_update:LoadAsset()
while (not version_update.Done) do
onback(version_update.Progress, false)
-- tex_tip.text = version_update.TextTip
coroutine.step()
end
ResourcesManager.ReadAssetConfig(asset_path)
onback(0, false)
end
onback(1, true)
end
ExtendHotupdate = {
-- 正常
VERSION_NORMAL = 0,
-- 下载
VERSION_DOWN = 1,
-- 更新
VERSION_UPDATE = 2,
}
function ExtendHotupdate.UpdateGameList(list, callback)
if (not GameApplication.Instance.buildApp) then
callback()
return
end
-- local _version_view = UIPackage.CreateObjectFromURL("ui://Hotupdate/Version")
local v_wait = UIManager.ShowUI(UIManager.ViewWait)
-- _version_view.x = (GRoot.inst.width - _version_view.width) / 2
v_wait.textTitle.text = "正在检查资源。。。"
-- local _pd = _version_view:GetChild("pb_progress")
-- _pd.value = 0
-- GRoot.inst:AddChild(_version_view)
coroutine.start(__update_check, list, function(progress, finish)
v_wait.textInfo.text = progress * 100
if (finish) then
callback()
UIManager.HideUI(UIManager.ViewWait)
end
end)
end
function ExtendHotupdate.UpdateGame(data, callback)
if (not GameApplication.Instance.buildApp) then
ExtendManager.UpdateExtend(data)
if callback then callback() end
return
end
ViewUtil.CloseModalWait()
NetResetConnectWindow.CloseNetReset()
local _version_view = UIPackage.CreateObjectFromURL("ui://Common/ExtendHotUpdate")
_version_view:GetChild("tex_info").text = "正在检查资源。。。"
local _pd = _version_view:GetChild("pb_progress")
_pd.value = 0
_version_view:AddRelation(GRoot.inst, RelationType.Size)
GRoot.inst:AddChild(_version_view)
_version_view:MakeFullScreen()
coroutine.start(__update_check, { data }, function(progress, finish)
_pd.value = progress * 100
if (finish) then
ExtendManager.UpdateExtend(data)
if callback then callback() end
_version_view:Dispose()
end
end, _version_view)
end
function ExtendHotupdate.CheckVersion(game_data)
if (not GameApplication.Instance.buildApp) then
ExtendManager.UpdateExtend(game_data)
return ExtendHotupdate.VERSION_NORMAL
end
if (not game_data) then
return ExtendHotupdate.VERSION_DOWN
end
local asset_path = game_data.bundle
asset_path = string.gsub(asset_path, '%.', '/')
local local_version = Hotupdate.GetLocalVersion(asset_path .. "/")
local server_version = Version(game_data.version)
if not local_version then
return ExtendHotupdate.VERSION_DOWN
end
if local_version:ContainAll(server_version) then
return ExtendHotupdate.VERSION_UPDATE
end
ResourcesManager.ReadAssetConfig(asset_path)
ExtendManager.UpdateExtend(game_data)
return ExtendHotupdate.VERSION_NORMAL
end

View File

@ -0,0 +1,71 @@
require "Game.IExtendConfig"
require "Game.IGameInfo"
---
-- a net ExtendManager
ExtendManager = {
}
local _extendMap = {}
local _isUpdate = false
local _isInit = false
local function __new_config(data)
local ec = reimport(data.bundle .. ".ExtendConfig")
print("初始化ExtendManager===>>>" .. data.bundle)
--pt(data)
local config = ec.new()
ec.game_data = data
_extendMap[data.game_id] = config
return config
end
function ExtendManager.Init(game_list)
if _isInit then return end
for i = 1, #game_list do
local game = game_list[i]
__new_config(game)
end
_isInit = true
end
-- 更新扩展玩法到最新数据
function ExtendManager.UpdateExtend(data)
if not data then return end
local tem = _extendMap[data.game_id]
if tem and (not GameApplication.Instance.buildApp) then
return
end
if tem and tem.game_data.version ~= data.version then
GameApplication.Instance:UnExtendLua(data)
tem:UnAllAssets()
end
__new_config(data)
end
function ExtendManager.RemoveExtend(data)
local tem = _extendMap[data.game_id]
if tem then
GameApplication.Instance:UnExtendLua(data)
tem:UnAllAssets()
end
end
function ExtendManager.GetExtendConfig(id)
return _extendMap[id]
end
function ExtendManager.GetGameData(id)
local data = _extendMap[id]
if not data then
return nil
end
return data.game_data
end
function ExtendManager.Destroy()
_extendMap = {}
_isInit = false
end

View File

@ -0,0 +1,74 @@
---
IExtendConfig = {
extend_id = 0,
_viewMap = nil
}
local M = IExtendConfig
--
function M:GetGameInfo()
end
--卸载资源
function M:UnAssets()
end
function M:NewRoom()
return Room.new()
end
function M:GetGameController()
end
function M:FillRoomData(s2croom)
end
function M:FillPlayerData(info, player)
local room = DataManager.CurrenRoom
local playerList = info
local NewPlayer = player
if not NewPlayer then
NewPlayer = room:NewPlayer()
end
for i = 1,#playerList do
local _jp = playerList[i]
local p = NewPlayer.new()
p.seat = _jp["seat"]
local online = _jp["online"]
p.line_state = online
p.ready = _jp["ready"] == 1 and true or false
local pid = _jp["aid"]
if (DataManager.SelfUser.account_id == pid) then
room.self_player = p
p.self_user = DataManager.SelfUser
else
local u = User.new()
u.account_id = pid
p.self_user = u
u.nick_name = _jp["nick"]
u.head_url = _jp["portrait"]
u.sex = _jp["sex"]
end
p.self_user.location = Location.new(_jp["pos"] or "")
p.self_user.host_ip = _jp["ip"]
p.total_score = _jp["score"] or 0
p.cur_hp = _jp["cur_hp"] or 0
p.total_hp = _jp["total_hp"] or 0
if _jp["hp_info"] then
p.cur_hp = _jp.hp_info.cur_hp
p.total_hp = _jp.hp_info.total_hp
end
if _jp["entrust"] then
p.entrust = _jp.entrust
end
room:AddPlayer(p)
end
end
function M:GetView(id)
local dview_class = self._viewMap[id]
return dview_class
end

View File

@ -0,0 +1,71 @@
-- Edit by ChenGY
--@type IGameInfo
--扩展UI
--需要两个控制器agent控制支付类型显示Cost控制目前选中的支付类型
--回合数对应的显示价格组件统一命名为tex_price1、tex_price2、...
--房主支付、AA支付显示价格的组件需要统一名称tex_owner、tex_aa
IGameInfo = {
-- 回合选项数量,必填
_roundChoice = 2,
-- 玩家数量,在子类中赋值,如果玩家数量可选,需要重载 OnChangeOption 方法, 详见长沙麻将
_maxPlayer = 2,
_game_data = nil,
}
local M = IGameInfo
function M:SelectedCardNum()
return 0
end
function M:SelectedConfigData()
return {}
end
function M:FillData()
end
function M:ShowRoomPrice(ctype)
local list = DataManager.SelfUser.games
if not self._game_data then
for i = 1, #list do
if list[i].game_id == self.game_data.game_id then
self._game_data = list[i]
end
end
end
self:ShowVariablePrice(ctype)
end
function M:OnChangeOption(ctype)
self:ShowRoomPrice(ctype)
local round = self._config:GetController("round")
round.onChanged:Set(function ()
self:ShowVariablePrice(ctype)
end)
end
function M:ShowVariablePrice(ctype)
-- 显示回合数后面的价格tex_price1、tex_price2
for i = 1, self._roundChoice do
local price = "0"
price = self._game_data[string.format("pay%s_%s", i, self._maxPlayer)]
local tex_price = self._config:GetChild("tex_price" .. i)
if tex_price then
tex_price.text = price
end
end
-- 显示房主支付、aa支付的价格tex_aa/tex_owner
-- local tex_aa = self._config:GetChild("tex_aa")
-- local tex_owner = self._config:GetChild("tex_owner")
-- local opt = self._config:GetController("round").selectedIndex
-- local price = self._game_data[string.format("pay%s_%s", opt + 1, self._maxPlayer)]
-- tex_aa.text = math.ceil(price / self._maxPlayer)
-- tex_owner.text = price
end
return M

View File

@ -0,0 +1,450 @@
Protocol = {
-------------------- Web --------------------------
-------------- acc -----------
-- 用户登录
WEB_USER_LOGIN = "acc/regist_login",
-- 快速登录
WEB_QUICK_LOGIN = "acc/quick_login",
-- 手机密码
WEB_PHONE_PASSWORD_LOGIN = "acc/phone_pw_login",
-- 手机登录
WEB_PHONE_LOGIN = "acc/phone_login",
-- ID密码
WEB_ID_PASSWORD_LOGIN = "acc/id_login",
-- 获取手机验证码
WEB_GET_VERIFCATION_CODE="acc/get_verification_code",
--绑定手机号码
WEB_BINDING_PHONE="acc/binding_phone",
--更换微信
WEB_change_weChat="acc/change_weChat",
-- 更新用户信息
WEB_UPDATE_USER_INFO = "acc/update_user_info",
-- 获取用户信息
WEB_GET_USER_INFO = "acc/get_user_info",
WEB_UPDATE_INFO = "acc/update_player_info",
-- 实名认证
WEB_REAL_NAME_IDENTIFY = "acc/certification",
-- getcode
WEB_GET_CODE = "acc/get_code",
----map mode----
WEB_GET_PROVINCES = "acc/get_provinces",
WEB_GET_CITIES = "acc/get_citys",
WEB_ADD_GAME = "acc/add_game",
WEB_DEL_GAME = "acc/del_game",
WEB_GET_AGENT_SECRET = "acc/agent_secret",
-- 设置被邀请开关
WEB_SET_GROUP_INVITATED = "acc/set_group_invitation",
----index----
-- 获取公告
WEB_UPDATE_NOTICE = "index/get_notice",
----rank----
WEB_GET_MILITARY = "military/get_military",
WEB_GET_MILITARY_BY_ROOMID = "military/get_militaryByRoomId",
--回放
WEB_GET_PLAY_BACK = "military/get_playBack",
-- 牌友圈排行
WEB_FG_RANK_LIST = "military/get_rankListByGroup",
-- 局数统计
WEB_FG_ROUND_LIST = "military/get_roundListByGroup",
-- 设置排行是否可访问
WEB_FG_SET_RANK_ACCESSIBLE = "military/set_randListRightByGroup",
----room----
-- 创建房间
WEB_CREATE_ROOM = "room/create_room",
-- 加入房间
WEB_JOIN_ROOM = "room/join_room",
--start::::::::::::::牌友圈协议::::::::::::::::::::
--牌友圈获取组列表
WEB_FG_GROUP_LIST = "group/get_groups",
--牌友圈创建组
WEB_FG_CREATE_GROUP = "group/create_group",
--牌友圈加入组
WEB_FG_JOIN_GROUP = "group/join_group",
--牌友圈删除组
WEB_FG_REMOVE_GROUP = "group/del_group",
--牌友圈退出圈子
WEB_FG_EXIT_GROUP = "group/exit_group",
--牌友圈更改组名
WEB_FG_GROUP_RENAME = "group/group_rename",
--牌友圈邀请列表
WEB_FG_GROUP_JOINS = "group/get_group_joins",
--牌友圈审核玩家加入
WEB_FG_GROUP_VERIFY_JOIN = "group/verify_join_group",
--牌友圈玩家列表
WEB_FG_GROUP_MEMBERS = "group/get_group_members",
--牌友圈玩家列表1
WEB_FG_GROUP_MEMBERS1 = "group/get_my_members",
--踢出玩家列表
WEB_FG_GROUP_TICHU = "group/get_kick_log",
--牌友圈删除玩家
WEB_FG_GROUP_KICK = "group/group_kick",
--牌友圈获取房间列表
WEB_FG_GROUP_ROOMS = "group/get_group_rooms",
--牌友圈创建房间
WEB_FG_GROUP_CREATE_ROOM = "group/create_group_room",
--牌友圈删除房间
WEB_FG_GROUP_DEL_ROOM = "group/del_group_room",
--牌友圈获取战绩列表
WEB_FG_GROUP_RECORD = "group/group_game_record",
-- 牌友圈创建机器人
WEB_FG_CREATE_BOT = "group/create_group_bot",
-- 牌友圈获取机器人列表
WEB_FG_GET_BOTS = "group/get_group_bots",
-- 牌友圈删除机器人
WEB_FG_DEL_BOT = "group/del_group_bot",
-- 授权副盟主
WEB_FG_SET_MANAGER = "group/set_member_mgr",
-- 设置合伙人
WEB_FG_SET_PARTNER = "group/set_partner",
-- 禁止娱乐
WEB_FG_BAN_MEMBER = "group/ban_member",
--获取heibai
GROUP_GET_BLACK_MEMBER= "group/get_black_member",
--heibai调动
GROUP_BLACK_MEMBER = "group/black_member",
-- 设置vip
WEB_FG_SET_GROUP_VIP = "group/set_group_vip",
-- 禁止同桌
WEB_FG_SET_BAN_TABLE = "group/set_ban_desk",
-- 添加玩家
WEB_FG_INVITE_MEMBER = "group/invite_group_member",
--获取添加玩家
GET_PLAYER_INFO = "group/get_player_info",
-- 玩家备注
WEB_FG_NOTE_MEMBER = "group/note_group_member",
-- 圈子备注
WEB_FG_NOTE_GROUP = "group/group_note",
-- 获取禁止同桌列表
WEB_FG_GET_BAN_TABLE = "group/get_ban_desk_list",
-- 克隆牌友圈
WEB_FG_CLONE_GROUP = "group/clone_group",
-- 改变体力值
WEB_FG_CHANGE_FAG ="group/update_member_hp",
-- 体力值详情
WEB_FG_FAG_LOG ="group/get_hp_log",
-- 体力值记录
WEB_FG_FAG_UPDATE_LOG ="group/get_hpUpdate_log",
-- 体力值设置
WEB_FG_FAG_HPDATA ="group/set_group_hpData",
-- 设置体力值权限
WEB_FG_SHOW_FAG ="group/show_hp",
-- 查看整线体力值
GET_HP_TOTAL = "group/get_hp_total",
-- 添加层
WEB_FG_CREATE_SUB_GROUP = "group/create_subGroup",
-- 删除层
WEB_FG_DEL_SUB_GROUP = "group/del_subGroup",
-- 置顶
WEB_FG_GROUP_TOP ="group/stick_group",
-- 查看预览
WEB_FG_GROUP_PREVIEW = "group/group_preview",
-- 获取排名列表
WEB_FG_GROUP_HPRANK = "group/group_hp_ranking",
-- 核实转让对象
WEB_FG_CHECK_REMIT_MEMBER = "group/transfer_accounts_query",
-- 转让体力值
WEB_FG_REMIT = "group/transfer_accounts",
-- 添加玩法
WEB_FG_ADD_PLAY = "group/add_play",
-- 删除玩法
WEB_FG_DEL_PLAY = "group/del_play",
-- 更新玩法
WEB_FG_UPDATE_PLAY = "group/update_play",
-- 禁止、恢复玩法
WEB_FG_BAN_PLAY = "group/ban_play",
-- 进入圈子
WEB_ENTER_GROUP = "group/enter_group",
-- 获取上级合伙人
WEB_GET_SUPERIOR_PARTNERS = "group/get_member_parents",
--获取积分转移限制
WEB_GET_TRANS_HP_LIMIT = "group/get_trans_hp_limit",
--设置积分转移限制
WEB_SET_TRANS_HP_LIMIT = "group/set_trans_hp_limit",
-- 查询成员
WEB_FG_FIND_MEMBER = "group/find_member",
--搜索
WEB_FG_FIND_PARTNER_STAT = "group/log/find_partner_stat",
--搜索
WEB_FG_FIND_COST_COUNT_STAT = "group/log/find_partner_stat_cost_count",
--find_partner_stat_member
WEB_FG_FIND_PARTNER_STAT_Member = "group/log/find_partner_stat_member",
WEB_FG_FIND_PARTNER_COST_COUNT_Member = "group/log/find_partner_stat_member_cost_count",
-- 强制提取
WEB_FG_TAKE_HP = "group/group_take_hp",
-- 修改牌友圈信息
WEB_FG_UPDATE_GROUP_INFO = "group/update_info",
-- 获取合伙人列表(推广奖励)
WEB_FG_GET_PARTNERS = "group/get_group_partners",
-- 获取推广奖励值
WEB_FG_GET_REWARDS = "group/get_rewards",
-- 设置推广奖励值
WEB_FG_SET_REWARDS = "group/set_reward",
WEB_FG_SET_XIPAI = "group/set_xipai_reward",
-- 获取全民推广
WEB_FG_GET_PROMOTE = "group/get_promotion",
-- 设置全民推广
WEB_FG_SET_PROMOTE = "group/update_promotion",
-- 牌友圈预览
WEB_FG_PREVIEW = "group/group_preview",
-- 调配成员
WEB_FG_DEPLOY_MEMBER = "group/distribute_member",
-- 转移合伙人
WEB_FG_MOVE_PARTNER = "group/move_partner",
-- 获取合伙人列表(合伙人管理)
WEB_FG_GET_PARTNER_DATA = "group/get_partner_data",
-- 获取合伙人列表(合伙人管理)
WEB_FG_QUERY_PARTNER_DATA = "group/query_partner_data",
-- 获取合伙人成员
WEB_FG_GET_PARTNER_MEMBERS = "group/get_partner_members",
-- 设置合伙人权限
WEB_FG_SET_PARTNER_HPOPT = "group/set_partner_hpopt",
-- 查询成员(转账)
WEB_FG_REMIT_FIND_MEMBER = "group/find_member1",
-- 转账
WEB_FG_REMIT = "group/trade_hp",
-- 获取能量包数据
WEB_FG_GET_TAKE_INFO = "group/get_take_info",
-- 提取体力值
WEB_FG_TAKE_FAG = "group/take_hp",
-- 获取能量包统计
WEB_FG_FAG_PACK_INFO = "group/log/get_hp_count_info",
-- 设置管理员权限
WEB_FG_SET_MNG_PERMISSION = "group/set_mgr_permission",
-- 获取圈子邮件
WEB_FG_GET_MAIL_LIST = "group/get_mail_list",
-- 删除圈子邮件
WEB_FG_DEL_ALL_MAIL = "group/del_mail_all",
-- 设置成员备注
WEB_FG_SET_MEMBER_TAG = "group/update_member_score",
-- 设置成员标注
WEB_FG_SET_MEMBER_BIND = "group/update_member_bind",
--设置亲友圈合伙人阀值
WEB_FG_SET_AUTO_SCORE = "group/set_auto_score",
--标记玩法排行
GROUP_MARK_PLAY = "group/mark_play",
GET_BANK_HP = "group/get_bank_hp", --获取银行信息
TAKE_BANK_HP = "group/take_bank_hp",
SAVE_BANK_HP = "group/save_bake_hp",
-------------- group-log---------------------
-- 获取奖励日志
WEB_FG_GET_REWARDS_LOG = "group/log/get_reward_log",
-- 获取奖励统计
WEB_FG_GET_REWARDS_STATISTIC = "group/log/get_reward_count",
-- 获取成员排名
WEB_FG_MEMBER_RANK = "group/log/get_member_rank",
-- 获取局数统计
WEB_FG_GET_ROUND_STATISTIC = "group/log/get_round_count",
-- 成员体力值详情
WEB_FG_GET_MEMBER_HP_LOG = "group/log/get_hplog_info",
-- 获取玩法局数统计
WEB_FG_GET_GAME_ROUND_STATISTIC = "group/log/get_play_round_count",
-- 获取消耗统计
WEB_FG_GET_CONSUME_STATISTIC = "group/log/get_cost_count",
-- 获取抽水记录
WEB_FG_GET_PROPORTION_LOG = "group/log/get_hplog_pump",
-- 获取战绩
WEB_FG_GET_RECORD = "group/log/get_records",
-- 获取个人战绩
WEB_FG_GET_PERSON_RECORD = "group/log/get_person_records",
-- 获取成员战绩
WEB_FG_GET_MEMBER_STAT = "group/log/get_member_stat",
-- 获取合伙人统计
WEB_FG_GET_PARTNER_STAT = "group/log/get_partner_stat",
--获取钻石消耗统计
WEB_FG_GET_COST_COUNT_STAT = "group/log/get_partner_stat_cost_count",
--幸运号数据
WEB_FG_GET_XINGYUNHAO_INFO = "group/get_xingyunhao_info",
--获取玩家和积分
WEB_FG_GET_MEMBERS_COUNT = "group/get_members_count",
-- 获取合伙人统计
WEB_FG_GET_PARTNER_STAT_MEMBER = "group/log/get_partner_stat_member",
-- 获取直属下级统计
WEB_FG_GET_DIRECT_MEMBER_STAT = "group/log/get_direct_stat_member",
WEB_FG_GET_DIRECT_COST_COUNT = "group/log/get_direct_stat_member_cost_count",
WEB_FG_GET_PARTNER_COST_COUNT = "group/log/get_partner_stat_member_cost_count",
-- 获取合伙人统计
WEB_FG_GET_PARTNER_STAT_PLAY = "group/log/get_partner_stat_play",
-- 根据房间号查询战绩
WEB_FG_GET_RECORD_BY_ROOMID = "group/log/find_record_room",
-- 获取提取记录
WEB_FG_FAG_TAKE_LOG = "group/log/get_take_log",
--提取银行记录
WEB_FG_GET_BANK_LOG = "group/log/get_bank_log",
-- 获取管理上下分记录
WEB_FG_GET_MNG_HP_LOG = "group/log/get_hplog_mgr",
-- 获取管理员上下分统计
WEB_FG_MNG_HP_STATISTIC = "group/log/get_hplog_mgr_count",
-- 获取管理员个人上下分统计
WEB_FG_MNG_HP_INFO = "group/log/get_hplog_mgr_info",
-- 获得玩家输赢分日统计
WEB_FG_GET_PLAYER_DAILY_COUNT = "group/log/get_hpconsume_count",
-- 体力值日志牌局明细
WEB_FG_HPLOG_DETAIL_INFO = "group/log/get_hplog_detail_info",
------------- group-room ------------
-- 圈子匹配房间
WEB_FG_MATCH_ROOM = "group/room/match_room",
-- 圈子排队房间
WEB_FG_QUEUE_ROOM = "group/room/queue_room",
-- 圈子加入房间
WEB_FG_JOIN_ROOM = "group/room/join_room",
-- 圈子删除房间
WEB_FG_DEL_ROOM = "group/room/del__room",
-------------- group-mgr --------------------
-- 进入圈子
FGMGR_ENTER_GROUP = "11001",
-- 更新房间
FGMGR_EVT_UPDATE_ROOM = "12001",
-- 删除房间
FGMGR_EVT_DEL_ROOM = "12002",
-- 添加房间
FGMGR_EVT_ADD_ROOM = "12003",
-- 删除玩法
FGMGR_EVT_DEL_PLAY = "12004",
-- 添加玩法
FGMGR_EVT_ADD_PLAY = "12005",
-- 更新玩法
FGMGR_EVT_UPDATE_PLAY = "12006",
-- 圈子消息
FGMGR_EVT_MESSAGE = "12007",
-- 刷新圈子
FGMGR_EVT_UPDATE_GROUP = "12008",
-- 更新体力值
FGMGR_EVT_UPDATE_PLAYER_INFO = "12009",
-- 获取在线列表
FGMGR_GET_ONLINE_PLAYERS = "11002",
-- 邀请玩家
FGMGR_INVITE_PLAYER = "11003",
-- 邀请回复
FGMGR_RESPONSE_INVITE = "11004",
-- 收到邀请
FGMGR_EVT_INVITED = "12010",
-- 未读邮件提示事件
FGMGR_EVT_NEW_MAIL = "update_mail_tip",
--end::::::::::::::牌友圈协议::::::::::::::::::::
-------------------Game ----------------------------
-- 进入房间
GAME_JOIN_ROOM = "1002",
-- 玩家进入房间
GAME_EVT_PLAYER_JOIN = "2001",
-- 玩家退出
GAME_EVT_PLAYER_EXIT = "2002",
-- 玩家网络状态
GAME_EVT_PLAYER_NET_STATE = "2003",
-- 发送聊天
GAME_INTERACTION = "1006",
-- 聊天事件
GAME_EVT_INTERACTION = "2017",
-- 退出房间
GAME_EXIT_ROOM = "1005",
-- 房主退出房间解散
GAME_EVT_EXIT_ROOM_DISMISS = "2008",
-- 发送准备
GAME_READY = "1003",
-- 准备事件
GAME_EVT_READY = "2009",
--洗牌
GAME_READY_AND_XIPAI = "201004",
GAME_EVT_READY_AND_XIPAI = "202009",
-- 请求开始游戏
GAME_START = "1004",
-- 请求解散房间
GAME_ASK_DISMISS_ROOM = "1007",
-- 解散房间
GAME_EVT_DISMISS_ROOM = "2005",
-- 请求解散房间投票
GAME_DISMISS_ROOM_VOTE = "1008",
-- 解散房间投票事件
GAME_EVT_DISMISS_ROOM_VOTE = "2006",
-- 解散房间失败
GAME_EVT_DISMISS_ROOM_FAIL = "2027",
-- 发送GPS坐标
GAME_SEND_GPS = "1001",
-- GPS更新事件
GAME_EVT_UPDATE_GPS = "2000",
-- 更新庄家协议
GAME_EVT_UPDATE_BANKER = "2031",
-- 删除代理房间
GAME_REMOVE_AGENT_ROOM = "1000",
-- 获得红包
GAME_EVT_HONGBAO = "3000",
-- 被踢出房间
GAME_EVT_KICKED = "3001",
--托管
GAME_ENTRUST = "1301",
--入座
GAME_JOIN_SEAT = "1302",
--玩家进入观众席
GAME_EVT_JOIN_SPECTATOR = "3002",
--更新玩家信息
GAME_EVT_UPDATE_PLAYERINFO = "3003",
FGMGR_EVT_UPDATE_RECONECT = "3005",
GAME_EVT_READY_ENTRUST = "22010", --显示托管倒计时
GAME_EVT_CANCEL_READY_ENTRUST = "22011", --关闭托管倒计时
GAME_AUTO_CARD = "1303", --开启游戏托管
}

View File

@ -0,0 +1,94 @@
require "Game.View.init"
require "Game.View.LobbyNew.FilterData"
UIManager = {
ViewLogin = 1,
LobbyView = 2,
ViewCreateCardGame = 4,
ViewCreateUnit = 5,
ViewGameGroup = 6,
ViewMatch = 7,
ViewFilter = 8,
ViewShop = 9,
ViewWallet = 10,
ViewOther = 11,
ViewWait = 12,
ViewSetting = 13,
ViewGame = 20,
ViewToolsTip = 100 --提示
}
local _viewMap = {}
function UIManager.Init()
_viewMap[UIManager.ViewLogin] = { view = LoginViewNew, isload = false, path = "base/login/" }
_viewMap[UIManager.ViewLogin].name = "ViewLogin.prefab"
_viewMap[UIManager.LobbyView] = { view = LobbyView, isload = false, path = "base/lobby/" }
_viewMap[UIManager.LobbyView].name = "Lobby.prefab"
_viewMap[UIManager.ViewCreateCardGame] = { view = CreateCardGameView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewCreateCardGame].name = "ViewCreateCardGame.prefab"
_viewMap[UIManager.ViewCreateUnit] = { view = CreateUnitView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewCreateUnit].name = "ViewCreateUnit.prefab"
_viewMap[UIManager.ViewGameGroup] = { view = GameGroupView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewGameGroup].name = "ViewGameGroup.prefab"
_viewMap[UIManager.ViewMatch] = { view = MatchView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewMatch].name = "ViewMatch.prefab"
_viewMap[UIManager.ViewFilter] = { view = FilterView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewFilter].name = "ViewFilter.prefab"
_viewMap[UIManager.ViewShop] = { view = ShopView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewShop].name = "ViewShop.prefab"
_viewMap[UIManager.ViewWallet] = { view = WalletView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewWallet].name = "ViewWallet.prefab"
_viewMap[UIManager.ViewOther] = { view = OtherView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewOther].name = "ViewOther.prefab"
_viewMap[UIManager.ViewWait] = { view = WaitView, isload = false, path = "base/common/" }
_viewMap[UIManager.ViewWait].name = "ViewWait.prefab"
_viewMap[UIManager.ViewSetting] = { view = SettingViewNew, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewSetting].name = "ViewSetting.prefab"
_viewMap[UIManager.ViewGame] = { view = GameView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewGame].name = "ViewGame.prefab"
_viewMap[UIManager.ViewToolsTip] = { view = ToolsTipView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewToolsTip].name = "ViewToolsTip.prefab"
end
function UIManager.ShowUI(v, callback)
if not _viewMap[v].isload then
_viewMap[v].isload = true
local view = _viewMap[v].view.new()
print("加载UI资源" .. _viewMap[v].path .. _viewMap[v].name)
local pref = ResourcesManager.LoadObject(_viewMap[v].path .. _viewMap[v].name, typeof(UnityEngine.GameObject))
local go = UnityEngine.GameObject.Instantiate(pref, UGUIRootCanvas.transform, false)
view._view = go
_viewMap[v].view = view
_viewMap[v].view.path = _viewMap[v].path
view.callback = callback
view:InitView()
view:init()
end
_viewMap[v].view._view:SetActive(true)
LuaUIHelper:SetGameObjectLastSibling(_viewMap[v].view._view)
return _viewMap[v].view
end
function UIManager.HideUI(v)
if _viewMap[v] and _viewMap[v].view._view then
_viewMap[v].view._view:SetActive(false)
end
end
function UIManager.GetGo(path, transform)
local pref = ResourcesManager.LoadObject(path, typeof(UnityEngine.GameObject))
return UnityEngine.GameObject.Instantiate(pref, transform, false)
end

View File

@ -0,0 +1,88 @@
---聊天View对象
local ChatView = {}
local M = ChatView
function ChatView.new(main_view)
UIPackage.AddPackage("base/chat/ui/Chat")
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "ChatView"
self._main_view = main_view
self._blur_view = main_view._root_view
self:init("ui://Chat/Main")
return self
end
function M:init(url)
BaseWindow.init(self,url)
local lit_biaoqing1 = self._view:GetChild("lit_biaoqing1")
lit_biaoqing1.onClickItem:Set(function (context)
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:SendInteraction(DataManager.SelfUser.account_id, 1, context.data.name )
self:Close()
end)
-- local lit_biaoqing2 = self._view:GetChild("lit_biaoqing2")
-- lit_biaoqing2.onClickItem:Set(function (context)
-- local _gamectr = ControllerManager.GetController(GameController)
-- _gamectr:SendInteraction(DataManager.SelfUser.account_id, 1, context.data.name )
-- self:Close()
-- end)
-- local lit_biaoqing3 = self._view:GetChild("lit_biaoqing3")
-- lit_biaoqing3.onClickItem:Set(function (context)
-- local _gamectr = ControllerManager.GetController(GameController)
-- _gamectr:SendInteraction(DataManager.SelfUser.account_id, 1, context.data.name )
-- self:Close()
-- end)
-- lit_biaoqing3:RemoveChildrenToPool()
self:FillChatMsg()
local tex_chat = self._view:GetChild("tex_chat")
local btn_send = self._view:GetChild("btn_send")
btn_send.onClick:Set(function( ... )
local chat_text = tex_chat.text
if string.utf8len(chat_text) >0 then
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:SendInteraction(DataManager.SelfUser.account_id, 4,chat_text)
self:Close()
end
end)
end
function M:FillChatMsg()
local chat_msg
local language = self._main_view:GetLanguage()
if language == 1 then
chat_msg = self._main_view.Fix_Msg_Chat2
else
chat_msg = self._main_view.Fix_Msg_Chat
end
local lit_yuyin = self._view:GetChild("lit_yuyin")
lit_yuyin:RemoveChildrenToPool()
for i = 1 , #chat_msg do
local btn = lit_yuyin:AddItemFromPool()
btn.data = tostring(i)
btn.text = chat_msg[i]
btn.onClick:Set(function(context)
local g = context.sender
local _gamectr = ControllerManager.GetController(GameController)
local msg = g.data + language * 100
_gamectr:SendInteraction(DataManager.SelfUser.account_id, 2, msg)
self:Close()
end)
end
end
function M:HideInputField()
self._view:GetController("sdk").selectedIndex = 1
end
return M

View File

@ -0,0 +1,91 @@
--view 基类
--author--
---
--@type BaseView
BaseView = {
-- Id View ID
Id = 0,
-- View 是否被销毁
_is_destroy = false,
--关闭摧毁
_close_destroy = false,
-- 全屏
_full = false,
--全屏偏移
_full_offset = true,
--view description
_view = nil,
}
local M = BaseView
local view_url = {
"ui://Common/Gcm_BaseView",
"ui://Common/Gcm_BaseView_Full"
}
---
--@function [parent=#BaseView] InitView
--@param self
--@param #string url
-- function M:InitView(url)
-- self._root_view = UIPackage.CreateObjectFromURL(self._full and view_url[2] or view_url[1])
-- local contentPane = self._root_view:GetChild("contentPane")
-- self._view = UIPackage.CreateObjectFromURL(url)
-- printlog(self._view)
-- self._close_destroy = true
-- -- self._view.fairyBatching = true
-- self._view:AddRelation(contentPane, RelationType.Size)
-- contentPane:AddChild(self._view)
-- self._contentPane = contentPane
-- end
function M:InitView()
self.languageText = {}
local texts = LuaUIHelper:GetAllText(self._view)
for index = 0, texts.Length - 1 do
local tempText = texts[index].text
if self.languageText[tempText] == nil then
self.languageText[tempText] = {}
end
local temp = self.languageText[tempText]
temp[#temp + 1] = { v = tempText, t = texts[index] }
end
self:ChangeLanguage()
end
function M:Show()
self._view:SetActive(true)
end
function M:ChangeLanguage()
for index, value in pairs(self.languageText) do
for i, v in ipairs(value) do
v.t.text = LanguageManager.Tex(v.v)
end
end
end
function M:Close()
self._view:SetActive(false)
end
--游戏暂停
function M:OnApplicationPause()
end
--游戏暂停
function M:OnApplicationActive()
end
---
--@function [parent=#BaseView] Destroy
--@param self
function M:Destroy()
self._is_destroy = true
UnityEngine.GameObject.Destroy(self._view)
-- self._root_view:Dispose()
end

View File

@ -0,0 +1,79 @@
--view 基类
--author--
---
--@type BaseView
BaseView = {
-- Id View ID
Id = 0,
-- View 是否被销毁
_is_destroy = false,
--关闭摧毁
_close_destroy = false,
-- 全屏
_full = false,
--全屏偏移
_full_offset = true,
--view description
_view = nil,
}
local M = BaseView
local view_url = {
"ui://Common/Gcm_BaseView",
"ui://Common/Gcm_BaseView_Full"
}
---
--@function [parent=#BaseView] InitView
--@param self
--@param #string url
function M:InitView(url)
self._root_view = UIPackage.CreateObjectFromURL(self._full and view_url[2] or view_url[1])
local contentPane = self._root_view:GetChild("contentPane")
self._view = UIPackage.CreateObjectFromURL(url)
printlog(self._view)
self._close_destroy = true
-- self._view.fairyBatching = true
self._view:AddRelation(contentPane, RelationType.Size)
contentPane:AddChild(self._view)
self._contentPane = contentPane
end
function M:Show()
self._root_view.visible = true
if not self._root_view.parent then
AddPanel(self._root_view)
if self._full then
local offset = get_offset(self._full_offset)
self._contentPane.width = GRoot.inst.width - (offset * 2)
self._contentPane.height = GRoot.inst.height
self._contentPane.x = offset
end
end
end
function M:Close()
self._root_view.visible = false
end
--游戏暂停
function M:OnApplicationPause()
end
--游戏暂停
function M:OnApplicationActive()
end
---
--@function [parent=#BaseView] Destroy
--@param self
function M:Destroy()
self._is_destroy = true
self._root_view:Dispose()
end

View File

@ -0,0 +1,252 @@
--window 窗口基类
--author--
BaseWindow = {
--view description
_view = nil,
--View 是否被销毁
_is_destroy = false,
--是否播放动画
_animation = true,
--弹出动画0关闭1左边2右边
_anim_pop = 0,
--关闭摧毁
_close_destroy = false,
--点击窗口以外关闭
_close_zone = true,
--队列
_queue = true,
--全屏
_full = false,
--全屏偏移
_full_offset = true,
--新窗口隐藏队列
_new_hide = true,
--模糊组件对象
_put_map = true
}
--window 列表
local WindowMap = {
}
local WindowQueue= {
}
local M = BaseWindow
function BaseWindow.new(url,blur_view)
local self = setmetatable({}, {__index = M})
self.class = "BaseWindow"
-- self._blur_view = blur_view
self:init(url)
return self
end
local win_url = {
"ui://Common/Gcm_Window",
"ui://Common/Gcm_Window_Full"
}
function M:init(url)
self._root_view = UIPackage.CreateObjectFromURL(self._full and win_url[2] or win_url[1])
local contentPane = self._root_view:GetChild("contentPane")
local ctr_hide_bg = self._root_view:GetController("hide_bg")
if self._anim_pop ~= 0 then
ctr_hide_bg.selectedIndex = 1
PopPanel = contentPane:GetChild("PopPanel")
else
ctr_hide_bg.selectedIndex = 0
end
self._view = UIPackage.CreateObjectFromURL(url)
-- self._view.fairyBatching = true
local btn_close = self._view:GetChild("btn_close")
if(btn_close) then
btn_close.onClick:Set(function()
self:CloseEvent()
end)
end
local win_mode = self._root_view:GetChild("win_mode")
win_mode.onClick:Set(function()
if not self._close_zone then
return
end
win_mode.touchable = false
self:CloseEvent()
end)
if self._full then
local offset = get_offset(self._full_offset)
if self._anim_pop == 0 then
self._view:AddRelation(contentPane, RelationType.Size)
contentPane:AddChild(self._view)
else
contentPane:RemoveRelation(self._root_view, RelationType.Center_Center)
contentPane:AddRelation(self._root_view, RelationType.Middle_Middle)
PopPanel:AddChild(self._view)
local click_item = PopPanel:GetChild("click_item")
if self._anim_pop == 1 then
contentPane:AddRelation(self._root_view, RelationType.Left_Left)
self._view.x = 0
elseif self._anim_pop == 2 then
contentPane:AddRelation(self._root_view, RelationType.Right_Right)
self._view.x = GRoot.inst.width - self._view.width - offset
end
self._view.y = (PopPanel.height - self._view.height) * 0.5
click_item.xy = self._view.xy
click_item.width = self._view.width
click_item.height = self._view.height
end
else
contentPane:AddChild(self._view)
contentPane.height = self._view.height
contentPane.width = self._view.width
contentPane:Center()
end
self._contentPane = contentPane
if self._put_map then
WindowMap[#WindowMap + 1] = self
end
end
-- 显示窗口
function M:Show()
local contentPane = self._root_view:GetChild("contentPane")
if self._anim_pop == 1 then
contentPane:GetTransition("left_pop"):Play()
elseif self._anim_pop == 2 then
contentPane:GetTransition("right_pop"):Play()
elseif self._animation then
local ani_in = self._root_view:GetTransition("in")
if ani_in then
ani_in:Play()
end
end
-- if self._blur_view then
-- BlurView(self._blur_view,true)
-- end
-- 判断当前窗口是否已经在队列中,如果在就不重复添加
local _inQueue = false
if self._new_hide then
for i=1,#WindowQueue do
local win = WindowQueue[i]
if win == self then
_inQueue = true
end
if win._queue then
win._root_view:RemoveFromParent()
end
end
end
if self._queue and not _inQueue then
WindowQueue[#WindowQueue + 1] = self
end
AddPanel(self._root_view)
if self._full then
local offset = get_offset(self._full_offset)
self._contentPane.width = GRoot.inst.width - 2 * offset
self._contentPane.height = GRoot.inst.height
self._contentPane.x = offset
end
end
-- 关闭窗口
function M:Close()
-- if self._blur_view then
-- BlurView(self._blur_view,false)
-- end
if self._queue then
for i,v in ipairs(WindowQueue) do
if v == self then
table.remove(WindowQueue,i)
break
end
end
end
if self._new_hide then
local win = WindowQueue[#WindowQueue]
if win and win._queue then
AddPanel(win._root_view)
end
end
self._root_view:RemoveFromParent()
end
local _destroy_all = false
-- 销毁窗口
function M:Destroy()
if self._is_destroy then
return
end
if not _destroy_all then
self:Close()
if self._put_map then
for i,v in ipairs(WindowMap) do
if v == self then
table.remove(WindowMap,i)
break
end
end
end
end
self._is_destroy = true
self._root_view:Dispose()
end
function M:CloseEvent()
local win_mode = self._root_view:GetChild("win_mode")
if self._anim_pop == 0 then
if self._close_destroy then
self:Destroy()
else
self:Close()
win_mode.touchable = true
end
else
self:ActionWithAnim(function()
if self._close_destroy then
self:Destroy()
else
self:Close()
win_mode.touchable = true
end
end)
end
end
function M:ActionWithAnim(callback)
local contentPane = self._root_view:GetChild("contentPane")
if self._anim_pop == 1 then
contentPane:GetTransition("left_pop_back"):Play()
elseif self._anim_pop == 2 then
contentPane:GetTransition("right_pop_back"):Play()
end
if callback then
coroutine.start(function()
coroutine.wait(0.3)
callback()
end)
end
end
function BaseWindow.DestroyAll()
_destroy_all = true
local list = WindowMap
for i=1,#list do
local win = list[i]
win:Destroy()
end
_destroy_all = false
WindowQueue = {}
WindowMap = {}
end

View File

@ -0,0 +1,109 @@
EventManager = {
Language = 1
}
-- 兼容 Lua 5.1 和 5.2+
local unpack = unpack or table.unpack
function EventManager:Init()
EventManager._events = {}
end
-- 注册事件监听器
function EventManager:EventAdd(eventName, callback)
if not self._events[eventName] then
self._events[eventName] = {}
end
-- 防止重复添加
for _, listener in ipairs(self._events[eventName]) do
if listener == callback then
return false
end
end
table.insert(self._events[eventName], callback)
return true
end
-- 取消注册
function EventManager:EventRemove(eventName, callback)
if not self._events[eventName] then
return false
end
for i, listener in ipairs(self._events[eventName]) do
if listener == callback then
table.remove(self._events[eventName], i)
return true
end
end
return false
end
-- 触发事件(使用兼容的 unpack
function EventManager:Call(eventName, ...)
if not self._events[eventName] then
return 0
end
local count = 0
-- 使用兼容的 unpack 函数
local listeners = { unpack(self._events[eventName]) }
for _, callback in ipairs(listeners) do
if type(callback) == "function" then
local success, result = pcall(callback, ...)
if not success then
print("事件回调错误:", result)
end
count = count + 1
end
end
return count
end
-- 替代方案:使用更安全的方式(推荐)
function EventManager:CallSafe(eventName, ...)
if not self._events[eventName] then
return 0
end
local count = 0
-- 安全复制数组
local listeners = {}
for i, v in ipairs(self._events[eventName]) do
listeners[i] = v
end
for _, callback in ipairs(listeners) do
if type(callback) == "function" then
local success, result = pcall(callback, ...)
if not success then
print("事件回调错误:", result)
end
count = count + 1
end
end
return count
end
-- 清空事件
function EventManager:clear(eventName)
if eventName then
self._events[eventName] = nil
else
self._events = {}
end
end
-- 获取监听器数量
function EventManager:getListenerCount(eventName)
if not self._events[eventName] then
return 0
end
return #self._events[eventName]
end

View File

@ -0,0 +1,88 @@
ImageLoad = {}
local imgAssetMap = {}
local imgQueue = Queue.new(2000)
local function DownLoadImg(url, icon)
local www = UnityEngine.WWW(url)
coroutine.www(www)
if string.utf8len(www.error) == 0 then
local obj = imgAssetMap[url]
if obj and not obj.load then
local texture = www.texture
-- www:Dispose()
if (texture ~= null) then
-- local ntexture = FairyGUI.NTexture(texture)
obj.ntexture = texture
obj.load = true
obj.co = nil
icon.texture = texture
end
end
end
end
local function SetTexture()
if (imgQueue:Count() > 0) then
local tem = imgQueue:Dequeue()
local obj = imgAssetMap[tem.url]
if not tem._iconObject and obj then
if obj.load then
tem._iconObject.texture = obj.ntexture
if tem.callback then
tem.callback()
end
else
imgQueue:Enqueue(tem)
end
end
end
end
UpdateBeat:Add(SetTexture)
-- group 图片分组
function ImageLoad.Load(url, _iconObject, group, callback)
if string.utf8len(url) == 0 then
return
end
if not group then
group = "common"
end
local asset = imgAssetMap[url]
if (asset ~= nil) then
if asset.load then
_iconObject.texture = asset.ntexture
if callback then callback() end
else
imgQueue:Enqueue({ url = url, _iconObject = _iconObject, callback = callback })
end
return
end
local _co = coroutine.start(DownLoadImg, url, _iconObject)
-- local _co_load = coroutine.start(SetTexture,_iconObject,url,callback)
imgAssetMap[url] = { group = group, load = false, co = _co }
imgQueue:Enqueue({ url = url, _iconObject = _iconObject, callback = callback })
end
function ImageLoad.Clear(group)
for i, v in pairs(imgAssetMap) do
if v.group == group then
if v.co then
coroutine.stop(v.co)
end
-- if v.co_load then
-- coroutine.stop(v.co_load)
-- end
if v.load then
imgAssetMap[i].ntexture:Unload(true)
end
imgAssetMap[i] = nil
end
end
end

View File

@ -0,0 +1,58 @@
LanguageManager = {
ChineseSim = 1,
ChineseTrad = 2,
English = 3
}
local languageType = LanguageManager.ChineseSim
local _languageMap = {}
function LanguageManager.Tex(s)
if _languageMap[s] then
return _languageMap[s][languageType]
end
return s
end
function LanguageManager.GetLanguageType()
return languageType
end
function LanguageManager.SetLanaguageType(t)
languageType = t
EventManager:Call(EventManager.Language)
end
function LanguageManager.Init()
-- 中文 繁体 英文
_languageMap["是的"] = { [1] = "是的", [2] = "是的", [3] = "Confirm" }
_languageMap["请输入手机号码"] = { [1] = "请输入手机号码", [2] = "請輸入手機號碼", [3] = "Phone No." }
_languageMap["请输入密码"] = { [1] = "请输入密码", [2] = "請輸入密碼", [3] = "Password" }
_languageMap["马上注册"] = { [1] = "马上注册", [2] = "馬上註冊", [3] = "Sign Up" }
_languageMap["忘记密码"] = { [1] = "忘记密码", [2] = "忘記密碼", [3] = "Forgot Pwd" }
_languageMap["登录"] = { [1] = "登录", [2] = "登入", [3] = "Login" }
_languageMap["请输入邮箱"] = { [1] = "请输入邮箱", [2] = "請輸入郵箱", [3] = "Email" }
_languageMap["上一步"] = { [1] = "上一步", [2] = "上一步", [3] = "Back" }
_languageMap["下一步"] = { [1] = "下一步", [2] = "下一步", [3] = "Next Step" }
_languageMap["请输入短信验证码"] = { [1] = "请输入短信验证码", [2] = "請輸入簡訊驗證碼", [3] = "Please enter the SMS verification code" }
_languageMap["设置密码"] = { [1] = "设置密码", [2] = "設置密碼", [3] = "New Password" }
_languageMap["完成"] = { [1] = "完成", [2] = "完成", [3] = "Completed" }
_languageMap["联盟币"] = { [1] = "联盟币", [2] = "聯盟幣", [3] = "Alliance Coin" }
_languageMap["钱包"] = { [1] = "钱包", [2] = "錢包", [3] = "Wallet" }
_languageMap["好友"] = { [1] = "好友", [2] = "好友", [3] = "Good friend" }
_languageMap["战绩"] = { [1] = "战绩", [2] = "戰績", [3] = "Records" }
_languageMap["牌谱"] = { [1] = "牌谱", [2] = "牌譜", [3] = "Handbook" }
_languageMap["反馈"] = { [1] = "反馈", [2] = "反饋", [3] = "Feedback" }
_languageMap["消息"] = { [1] = "消息", [2] = "消息", [3] = "" }
_languageMap["切换线路"] = { [1] = "切换线路", [2] = "切換線路", [3] = "Switch Line" }
_languageMap["设置"] = { [1] = "设置", [2] = "設定", [3] = "Settings" }
_languageMap["德州"] = { [1] = "德州", [2] = "德州", [3] = "Texas" }
_languageMap["切换"] = { [1] = "切换", [2] = "切換", [3] = "Switch" }
_languageMap["修复"] = { [1] = "修复", [2] = "修復", [3] = "Repair" }
_languageMap["奖金"] = { [1] = "奖金", [2] = "獎金", [3] = "Bonus" }
_languageMap["请输入手机号码"] = { [1] = "", [2] = "?", [3] = "3" }
_languageMap["请输入手机号码"] = { [1] = "", [2] = "?", [3] = "3" }
_languageMap["请输入手机号码"] = { [1] = "", [2] = "?", [3] = "3" }
_languageMap["请输入手机号码"] = { [1] = "", [2] = "?", [3] = "3" }
end

View File

@ -0,0 +1,58 @@
ModalWaitingWindow = {
}
local M = ModalWaitingWindow
local modal_wait_win_url = "ui://Common/GlobalModalWaiting"
local modal_panel = nil
function ModalWaitingWindow.new()
local self = setmetatable({}, {__index = M})
self.class = "ModalWaitingWindow"
local pref = LoadPrefabData("base/prefab/ViewWait.prefab", "base/prefab/ViewWait")
self._view = UnityEngine.GameObject.Instantiate(pref, UGUIRootCanvas.transform, false)
-- self._view = UIPackage.CreateObjectFromURL(modal_wait_win_url)
self.txt_title = self._view.transform:Find("image/textInfo")--self._view:GetChild("title")
self.txt_title=self.txt_title:GetComponent(typeof(UnityEngine.UI.Text))
-- if not modal_panel then
-- modal_panel = UIPackage.CreateObjectFromURL("ui://Common/UIPanel")
-- modal_panel.name = "GlobalModalWaiting_Win"
-- modal_panel:MakeFullScreen()
-- modal_panel:AddRelation(GRoot.inst, RelationType.Size)
-- end
-- modal_panel:AddChild(self._view)
-- self._view:Center()
-- GRoot.inst:AddChild(modal_panel)
return self
end
function M:Show()
self._view:SetActive(true)
-- modal_panel.visible = true
end
function M:Close()
self._view:SetActive(false)
-- modal_panel.visible = false
end
local _inst = nil
local _msg = "正在获取数据..."
function ModalWaitingWindow.ShowModal(title)
if (_inst == nil) then
_inst = ModalWaitingWindow.new()
end
if title then
_inst.txt_title.text = title
else
_inst.txt_title.text = _msg
end
_inst:Show()
end
function ModalWaitingWindow.CloseModal()
if(_inst) then
_inst:Close()
end
end

View File

@ -0,0 +1,71 @@
--通用消息弹出框View
--author--
MsgWindow = {}
MsgWindow.MsgMode = {
OkAndCancel = 1,
OnlyOk = 2
}
MsgWindow.RES_LIST = {
"MessageBox",
"MessageBox1"
}
local M = MsgWindow
function MsgWindow.new(blur_view,tip,mode,url,showCheck)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "MsgWindow"
self._blur_view = blur_view
self._close_destroy = true
self._tip = tip
self._mode = mode
self.onOk = event("onOk",true)
self.onCancel = event("onCancel",true)
self.showCheck = showCheck
local self_url = url and url or "ui://Common/"..MsgWindow.RES_LIST[self._mode]
self:init(self_url)
return self
end
function M:init(url)
BaseWindow.init(self,url)
self._close_destroy = true
self._close_zone = false
local view = self._view
local btn_ok = view:GetChild("btn_ok")
btn_ok.onClick:Add(function()
self.onOk()
self:Destroy()
end)
local tex_message = view:GetChild("tex_message")
if (self._tip) then tex_message.text = self._tip end
local btn_close = view:GetChild('btn_close1')
if (btn_close~=nil) then
btn_close.onClick:Add(
function()
self:CloseEvent()
end
)
end
self.btnCheck = view:GetChild("btnCheck")
if self.btnCheck then
self.btnCheck.visible = false
if self.showCheck then
self.btnCheck.selected = true
self.btnCheck.visible = true
end
end
end
function M:Close()
BaseWindow.Close(self)
if(self._mode == MsgWindow.MsgMode.OkAndCancel) then
self.onCancel()
end
end

View File

@ -0,0 +1,49 @@
--通用消息弹出框View
--author--
NetResetConnectWindow = {}
local modal_wait_win_url = "ui://Common/GlobalModalWaiting"
local modal_panel = nil
function NetResetConnectWindow.new()
local self = setmetatable({}, {__index = NetResetConnectWindow})
self.class = "NetResetConnectWindow"
self._view = UIPackage.CreateObjectFromURL(modal_wait_win_url)
self._view:GetChild("title").text = "网络信号太差,正在检查网络中..."
if not modal_panel then
modal_panel = UIPackage.CreateObjectFromURL("ui://Common/UIPanel")
modal_panel.name = "NetResetConnectWindow_Win"
modal_panel:MakeFullScreen()
modal_panel:AddRelation(GRoot.inst, RelationType.Size)
end
-- self._circleLoader = CircleLoader.new(self._view:GetChild("gcm_qiu"))
-- self._circleLoader:start()
modal_panel:AddChild(self._view)
self._view:Center()
GRoot.inst:AddChild(modal_panel)
return self
end
function NetResetConnectWindow:Show()
modal_panel.visible = true
end
function NetResetConnectWindow:Close()
modal_panel.visible = false
end
local _inst = nil
function NetResetConnectWindow.ShowNetReset()
if (_inst == nil) then
_inst = NetResetConnectWindow.new()
end
_inst:Show()
end
function NetResetConnectWindow.CloseNetReset()
if(_inst) then
_inst:Close()
end
end

View File

@ -0,0 +1,278 @@
CreateCardGameView = {}
local M = CreateCardGameView
function CreateCardGameView.new()
setmetatable(M, { __index = BaseView })
local self = setmetatable({}, { __index = M })
self.class = "CreateCardGameView"
self._full = true
-- self:init()
return self
end
function M:init()
-- self:InitView("base/prefab/ViewCreateCardGame.prefab", "base/prefab/ViewCreateCardGame")
local view = self._view
self.pageSlider = view.transform:Find("pageSlider")
self.pageSlider = self.pageSlider:GetComponent("PageSliderManager")
-- self.pageSlider:SetMoveAction(function(val)
-- self:SetPageSlider(val)
-- end)
local bg = view.transform:Find("imageBG")
bg = bg:GetComponent(typeof(UnityEngine.UI.Image))
bg.sprite = CommonUISprite:GetSprite("bg1")
self.imagePoint = view.transform:Find("imagePoint")
self.create_table = view.transform:Find("createtable")
self.create_table.position = self.imagePoint.position
self.select = view.transform:Find("select") --选择玩法界面
self.imageTop = self.create_table:Find("imageTop")
self.imageTop.gameObject:SetActive(false)
self.topCopy = self.create_table:Find("imageTop/scroll/Viewport/Content/btnItem")
self.topCopy.gameObject:SetActive(false)
local select_btnDezhou = self.select:Find("btnDezhou")
select_btnDezhou = select_btnDezhou:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(select_btnDezhou, function()
self.select.gameObject:SetActive(false)
self.imageTop.gameObject:SetActive(true)
self:ShowPage(self.subView.room)
end)
local select_btnShort = self.select:Find("btnShort")
select_btnShort = select_btnShort:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(select_btnShort, function()
self.select.gameObject:SetActive(false)
self.imageTop.gameObject:SetActive(true)
self:ShowPage(self.subView.room)
end)
local select_btnAomaha = self.select:Find("btnAomaha")
select_btnAomaha = select_btnAomaha:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(select_btnAomaha, function()
self.select.gameObject:SetActive(false)
self.imageTop.gameObject:SetActive(true)
self:ShowPage(self.subView.room)
end)
self.subView = {
none = 0,
room = 1,
rank = 2,
dairu = 3,
daichu = 4,
gamePlay = 5,
otherPlay = 6,
safety = 7,
money = 8,
total = 9
}
self.arr_subView = {}
self.arr_subView[self.subView.room] = { name = "房间", with = 136, v = self.subView.room }
self.arr_subView[self.subView.rank] = { name = "级别", with = 136, v = self.subView.rank }
self.arr_subView[self.subView.dairu] = { name = "带入", with = 136, v = self.subView.dairu }
self.arr_subView[self.subView.daichu] = { name = "带出", with = 136, v = self.subView.daichu }
self.arr_subView[self.subView.gamePlay] = { name = "特色玩法", with = 220, v = self.subView.gamePlay }
self.arr_subView[self.subView.otherPlay] = { name = "其他玩法", with = 220, v = self.subView.otherPlay }
self.arr_subView[self.subView.safety] = { name = "安全性", with = 188, v = self.subView.safety }
self.arr_subView[self.subView.money] = { name = "费用", with = 136, v = self.subView.money }
self.arr_subView[self.subView.total] = { name = "总览", with = 136, v = self.subView.total }
self.arr_subView[self.subView.room].goView = view.transform:Find("room")
self.arr_subView[self.subView.rank].goView = view.transform:Find("rank")
self.arr_subView[self.subView.dairu].goView = view.transform:Find("dairu")
self.arr_subView[self.subView.daichu].goView = view.transform:Find("daichu")
self.arr_subView[self.subView.gamePlay].goView = view.transform:Find("gamePlay")
self.arr_subView[self.subView.otherPlay].goView = view.transform:Find("otherPlay")
self.arr_subView[self.subView.safety].goView = view.transform:Find("safety")
self.arr_subView[self.subView.money].goView = view.transform:Find("money")
self.arr_subView[self.subView.total].goView = view.transform:Find("total")
for index, value in ipairs(self.arr_subView) do
local goTopTemp = UnityEngine.GameObject.Instantiate(self.topCopy.gameObject, self.topCopy.parent, false)
goTopTemp:SetActive(true)
local textTop = goTopTemp.transform:Find("Text")
self.arr_subView[index].Animator = textTop:GetComponent(typeof(UnityEngine.Animator))
self.arr_subView[index].Animator:Play("stop", -1, 0)
textTop = textTop:GetComponent(typeof(UnityEngine.UI.Text))
textTop.text = value.name
local rectUITemp = goTopTemp:GetComponent(typeof(UnityEngine.RectTransform))
rectUITemp.sizeDelta = Vector2.New(rectUITemp.sizeDelta.x, value.with)
self.arr_subView[index].goTitle = goTopTemp.transform
local btnSubTitleTemp = goTopTemp.transform:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnSubTitleTemp, function(vTemp)
self:ShowPage(vTemp)
end, index)
-- self.arr_subView[index].goView.position = self.imagePoint.position
local backTemp = self.arr_subView[index].goView:Find("imageDown/btnBack")
backTemp = backTemp:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(backTemp, function(btnVar)
local tempBackNum = btnVar - 1
if tempBackNum == 0 then
self.select.gameObject:SetActive(true)
self.imageTop.gameObject:SetActive(false)
self:ShowPage(self.subView.none)
else
self:ShowPage(tempBackNum)
end
end, index)
local nextTemp = self.arr_subView[index].goView:Find("imageDown/btnNext")
nextTemp = nextTemp:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(nextTemp, function(btnVar)
local tempNextNum = btnVar + 1
if tempNextNum == self.subView.total + 1 then
UIManager.ShowUI(UIManager.ViewGame)
else
self:ShowPage(tempNextNum)
end
end, index)
end
local count = #self.arr_subView
local transformArray = {}
local indexTransform = 0
for int, value in ipairs(self.arr_subView) do
transformArray[indexTransform] = value.goTitle -- Lua索引1开始C#索引0开始
indexTransform = indexTransform + 1
end
self.pageSlider:SetTitleSpacing(transformArray)
local create_table_btnBack = self.create_table:Find("btnBack")
local create_table_btnBackBg = create_table_btnBack:GetComponent(typeof(UnityEngine.UI.Image))
create_table_btnBackBg.sprite = CommonUISprite:GetSprite("arrow1")
create_table_btnBack = create_table_btnBack:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(create_table_btnBack, function()
local viewMainNew = UIManager.ShowUI(UIManager.LobbyView)
viewMainNew:ShowPage(1)
end)
self.selectPage = self.subView.none
self.select.gameObject:SetActive(true)
self.select.position = self.imagePoint.position
self:ShowPage(self.selectPage)
end
function M:ShowPage(val)
-- if val == self.subView.none then
-- self.pageSlider.enableSwipe = false
-- else
-- self.pageSlider.enableSwipe = true
-- end
self.pageSlider:JumpToPage(val - 1)
for index, value in ipairs(self.arr_subView) do
if val == self.subView.none then
value.goView.gameObject:SetActive(false)
else
value.goView.gameObject:SetActive(true)
end
if value.v == val then
-- value.goView.gameObject:SetActive(true)
local scaleTemp1 = LuaUIHelper:GetAnimatorAormalizedTime(value.Animator, true)
local scaleTemp2 = 0
if self.selectPage ~= self.subView.none then
scaleTemp2 = LuaUIHelper:GetAnimatorAormalizedTime(self.arr_subView[self.selectPage].Animator, false)
end
if not LuaUIHelper:GetAnimatorIsName(self.arr_subView[val].Animator, "open") then
if scaleTemp1 > 1 then
scaleTemp1 = 1
scaleTemp2 = 1
end
self.arr_subView[val].Animator:Play("open", -1, 1 - scaleTemp1)
if self.arr_subView[self.selectPage] then
if not LuaUIHelper:GetAnimatorIsName(self.arr_subView[self.selectPage].Animator, "open") then
self.arr_subView[self.selectPage].Animator:Play("close", -1, 1 - scaleTemp2)
end
end
else
self.arr_subView[val].Animator:Play("open", -1, 0.5)
end
else
-- value.goView.gameObject:SetActive(false)
if LuaUIHelper:GetAnimatorIsName(value.Animator, "open") then
local scaleTemp3 = LuaUIHelper:GetAnimatorAormalizedTime(value.Animator, true)
if scaleTemp3 > 1 then
scaleTemp3 = 1
end
value.Animator:Play("close", -1, 1 - scaleTemp3)
end
end
end
self.selectPage = val
self:SetPageSlider(0)
end
function M:SetPageSlider(val)
local last = nil
local lastV = nil
local next = nil
local nextV = nil
local now = nil
local nowV = nil
if self.selectPage == self.subView.room and self.selectPage ~= self.subView.none then
last = nil
lastV = nil
next = self.arr_subView[self.selectPage + 1].goView:GetComponent(typeof(UnityEngine.RectTransform))
nextV = nil
now = self.arr_subView[self.selectPage].goView:GetComponent(typeof(UnityEngine.RectTransform))
nowV = nil
elseif self.selectPage == self.subView.total and self.selectPage ~= self.subView.none then
last = self.arr_subView[self.selectPage - 1].goView:GetComponent(typeof(UnityEngine.RectTransform))
lastV = nil
next = nil
nextV = nil
now = self.arr_subView[self.selectPage].goView:GetComponent(typeof(UnityEngine.RectTransform))
nowV = nil
elseif self.selectPage == self.subView.none then
last = self.arr_subView[self.subView.room].goView:GetComponent(typeof(UnityEngine.RectTransform))
lastV = nil
next = self.arr_subView[self.subView.room + 1].goView:GetComponent(typeof(UnityEngine.RectTransform))
nextV = nil
now = self.arr_subView[self.subView.room + 2].goView:GetComponent(typeof(UnityEngine.RectTransform))
nowV = nil
else
last = self.arr_subView[self.selectPage - 1].goView:GetComponent(typeof(UnityEngine.RectTransform))
lastV = nil
next = self.arr_subView[self.selectPage + 1].goView:GetComponent(typeof(UnityEngine.RectTransform))
nextV = nil
now = self.arr_subView[self.selectPage].goView:GetComponent(typeof(UnityEngine.RectTransform))
nowV = nil
end
if val == -1 then
self.selectPage = self.selectPage - 1
elseif val == 1 then
self.selectPage = self.selectPage + 1
else
end
-- self.pageSlider:SetPageLast(last)
-- self.pageSlider:SetPageNext(next)
-- self.pageSlider:SetPageNow(now)
end
function M:SetTuoGuanState()
-- printlog("初始化设置托管状态")
if ControllerManager.enterPlayerData and #ControllerManager.enterPlayerData > 0 then
-- pt(ControllerManager.enterPlayerData)
for i = 1, #ControllerManager.enterPlayerData do
local p = self._player_info[self:GetPos(
ControllerManager.enterPlayerData[i].seat)]
-- p.seat=ControllerManager.enterPlayerData[i].seat
local t = ControllerManager.enterPlayerData[i].entrust_time
-- local isShow=ControllerManager.enterPlayerData[i].entrust
-- if isShow==nil then return end
if t and t > 0 then
p:IsShowTGTips(true, t)
else
end
end
ControllerManager.enterPlayerData = nil
end
end

View File

@ -0,0 +1,105 @@
-- MainViewNew
CreateUnitView = {}
local M = CreateUnitView
function CreateUnitView.new()
setmetatable(M, {
__index = BaseView
})
local self = setmetatable({}, {
__index = M
})
self.class = "CreateCardGameView"
self._full = true
self:init()
return self
end
function M:init()
self:InitView("base/prefab/ViewCreateUnit.prefab", "base/prefab/ViewCreateUnit")
local view = self._view
local bg = view.transform:GetComponent(typeof(UnityEngine.UI.Image))
bg.sprite = CommonUISprite:GetSprite("bg1")
self.imagePoint = view.transform:Find("imagePoint")
self.join = view.transform:Find("Unitjoin")
self.create = view.transform:Find("create_play") -- 目前 联盟和俱乐部的创建界面一模一样
bg = self.join:GetComponent(typeof(UnityEngine.UI.Image))
bg.sprite = CommonUISprite:GetSprite("bg1")
bg = self.create:GetComponent(typeof(UnityEngine.UI.Image))
bg.sprite = CommonUISprite:GetSprite("bg1")
self.join.gameObject:SetActive(false)
self.create.gameObject:SetActive(false)
self.textTitleCreate = view.transform:Find("create_play/textName")
self.textTitleCreate = self.textTitleCreate:GetComponent(typeof(UnityEngine.UI.Text))
local btnGB = view.transform:Find("btnGB")
btnGB = btnGB:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnGB, function()
local viewMainNew = ViewManager.ChangeView(ViewManager.View_MainNew)
viewMainNew:ShowPage(1)
end)
local btnJoinPlay = view.transform:Find("imageDown/btnJoinPlay")
btnJoinPlay = btnJoinPlay:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnJoinPlay, function()
self.join.gameObject:SetActive(true)
self.create.gameObject:SetActive(false)
end)
local btnCreatePlay = view.transform:Find("imageDown/btnCreatePlay")
btnCreatePlay = btnCreatePlay:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnCreatePlay, function()
self.join.gameObject:SetActive(false)
self.create.gameObject:SetActive(true)
self.textTitleCreate.text = "创建俱乐部"
end)
local btnCreateUint = view.transform:Find("imageDown/btnCreateUnit")
btnCreateUint = btnCreateUint:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnCreateUint, function()
self.join.gameObject:SetActive(false)
self.create.gameObject:SetActive(true)
self.textTitleCreate.text = "创建联盟"
end)
-- 加入界面 返回按钮
local join_btnBack = self.join:Find("btnBack")
join_btnBack = join_btnBack:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(join_btnBack, function()
local viewMainNew = ViewManager.ChangeView(ViewManager.View_MainNew)
viewMainNew:ShowPage(1)
end)
-- 创建界面 返回按钮
local create_btnBack = self.create:Find("btnBack")
create_btnBack = create_btnBack:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(create_btnBack, function()
local viewMainNew = ViewManager.ChangeView(ViewManager.View_MainNew)
viewMainNew:ShowPage(1)
end)
end
function M:SetTuoGuanState()
-- printlog("初始化设置托管状态")
if ControllerManager.enterPlayerData and #ControllerManager.enterPlayerData > 0 then
-- pt(ControllerManager.enterPlayerData)
for i = 1, #ControllerManager.enterPlayerData do
local p = self._player_info[self:GetPos(ControllerManager.enterPlayerData[i].seat)]
-- p.seat=ControllerManager.enterPlayerData[i].seat
local t = ControllerManager.enterPlayerData[i].entrust_time
-- local isShow=ControllerManager.enterPlayerData[i].entrust
-- if isShow==nil then return end
if t and t > 0 then
p:IsShowTGTips(true, t)
else
end
end
ControllerManager.enterPlayerData = nil
end
end

View File

@ -0,0 +1,88 @@
local DismissRoomWindow = {}
local M = DismissRoomWindow
function DismissRoomWindow.new(blur_view)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "DismissRoomWindow"
self._currenIndex = 0
self._blur_view = blur_view
self._animation = false
self.onCallback = event("onCallback",true)
self._close_zone = false
self.time = 180
self:init("ui://Common/dismiss_room")
return self
end
function M:init(url)
BaseWindow.init(self,url)
local view = self._view
self.tex_time = view:GetChild("tex_time")
local _btn_aggree = view:GetChild("btn_aggree")
_btn_aggree.onClick:Add(function()
local _gamectr = ControllerManager.GetController(GameController)
if _gamectr then
_gamectr:DismissRoomVote(true)
end
end)
local _btn_reject = view:GetChild("btn_reject")
_btn_reject.onClick:Add(function()
local _gamectr = ControllerManager.GetController(GameController)
if _gamectr then
_gamectr:DismissRoomVote(false)
end
end)
end
function M:FillData(data)
self.time = data.time
self.tex_time.text = data.time
local room = DataManager.CurrenRoom
local isHidden = false
if room.room_config and room.room_config.isHidden and room.room_config.isHidden == 1 then
isHidden = true
end
if isHidden then
self._view:GetChild("tex_tip").text = string.format("[color=#ff9d02]【%s】[/color]发起了解散房间申请,是否同意?","玩家" .. data.req_p.seat)
else
self._view:GetChild("tex_tip").text = string.format("[color=#ff9d02]【%s】[/color]发起了解散房间申请,是否同意?",data.req_p.self_user.nick_name)
end
local ctr_falg = self._view:GetController("falg")
local lst_player = self._view:GetChild("lst_player")
lst_player:RemoveChildrenToPool()
local list = data.list
for i=1,#list do
local tem = list[i]
if tem.player == DataManager.CurrenRoom.self_player then
ctr_falg.selectedIndex = tem.result
end
-- elseif tem.player ~= data.req_p then
local item = lst_player:AddItemFromPool()
if isHidden then
item:GetChild("tex_name").text = "玩家"..tem.player.seat
else
item:GetChild("tex_name").text = tem.player.self_user.nick_name
end
local ctr_item_falg = item:GetController("falg")
ctr_item_falg.selectedIndex = tem.result
-- end
end
end
function M:OnUpdate(deltaTime)
if self.time > 0 then
self.time = self.time - deltaTime
self.time = math.max(0, self.time)
end
self.tex_time.text = tostring(math.floor(self.time))
end
return M

View File

@ -0,0 +1,131 @@
-- 牌友圈助手邀请界面
local FGAssistInviteView = {}
local M = FGAssistInviteView
setmetatable(M, {__index = BaseWindow})
function FGAssistInviteView.new(blur_view, callback)
local self = setmetatable({}, {__index = M})
self.class = "FGAssistInviteView"
self._blur_view = blur_view
self._animation = true
self._new_hide = false
self._put_map = false
self._close_destroy = true
self.callback = callback
self:initView("ui://FGAssist/panel_invite")
return self
end
function M:initView(url)
self:init(url)
self.lst_player = self._view:GetChild("lst_player")
local btn_refresh = self._view:GetChild("btn_refresh")
btn_refresh.onClick:Set(function()
self.lst_player:RemoveChildrenToPool()
self:FillData()
end)
self._timer = 0
self:FillData()
UpdateBeat:Add(self.OnUpdate,self)
end
function M:FillData()
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
if not mgr_ctr._mgr_client then
return
else
self:GetOnlinePlayers()
end
end
function M:GetOnlinePlayers()
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
mgr_ctr:FG_GetOnlinePlayers(function(res)
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode, "获取在线成员失败")
else
self.players = res.Data.onlines
self._view:GetController("empty").selectedIndex = #self.players == 0 and 1 or 0
self:ShowOnlinePlayers()
end
end)
end
local function _showLeftTime(item, time)
item:GetChild("tex_left_time").text = time .. "s"
end
local _list_invite_time = {}
function M:ShowOnlinePlayers()
local players = self.players
for i = 1, #players do
if self.lst_player.isDisposed then return end
local item = self.lst_player:AddItemFromPool()
local p = players[i]
item:GetChild("tex_name").text = p.nick
item:GetChild("tex_id").text = "ID:" .. ViewUtil.HideID(p.uid)
local btn_head = item:GetChild("btn_head")
ImageLoad.Load(p.portrait, btn_head._iconObject)
local ctr_enable = item:GetController("enable")
ctr_enable.selectedIndex = 0
item:GetChild("btn_invite").onClick:Set(function()
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
local room = DataManager.CurrenRoom
mgr_ctr:FG_InvitePlayer(p.uid, room.room_id, room.play_id, room.room_config:GetGameName(), function()
end)
local time = os.time()
_list_invite_time[p.uid] = time
ctr_enable.selectedIndex = 1
_showLeftTime(item, 15)
end)
local invite_time = _list_invite_time[p.uid]
if invite_time then
local i_timer = os.time() - invite_time
if i_timer < 15 then
ctr_enable.selectedIndex = 1
_showLeftTime(item, 15 - i_timer)
else
_list_invite_time[p.uid] = nil
ctr_enable.selectedIndex = 0
end
end
end
end
function M:OnUpdate()
local deltaTime = Time.deltaTime
self._timer = self._timer + deltaTime
if self._timer >= 1 then
self._timer = 0
if self.lst_player.numChildren == 0 then return end
for i = 1, #self.players do
local p = self.players[i]
local invite_time = _list_invite_time[p.uid]
if invite_time then
local i_timer = os.time() - invite_time
local item = self.lst_player:GetChildAt(i - 1)
if not item then break end
if i_timer < 15 then
_showLeftTime(item, 15 - i_timer)
else
item:GetController("enable").selectedIndex = 0
_list_invite_time[p.uid] = nil
end
end
end
end
end
function M:Destroy()
UpdateBeat:Remove(self.OnUpdate, self)
BaseWindow.Destroy(self)
if self.callback then
self.callback()
end
end
return M

View File

@ -0,0 +1,153 @@
-- 牌友圈助手界面
local FGAssistInviteView = import(".FGAssistInviteView")
local FGAssistView = {}
local M = FGAssistView
setmetatable(M, {__index = BaseWindow})
function FGAssistView.new(blur_view, callback)
local self = setmetatable({}, {__index = M})
self.class = "FGAssistView"
self._blur_view = blur_view
self._full = true
self._anim_pop = 1
self._animation = true
self.callback = callback
self:init("ui://FGAssist/panel_assist")
return self
end
function M:ReloadView()
self._view:GetChild("btn_auto_invite").onClick:Clear()
self.lst_player:RemoveChildrenToPool()
self:FillData()
end
function M:init(url)
BaseWindow.init(self, url)
self.lst_player = self._view:GetChild("lst_player")
local btn_refresh = self._view:GetChild("btn_refresh")
btn_refresh.onClick:Set(function()
self:ReloadView()
end)
self._timer = 0
UpdateBeat:Add(self.OnUpdate,self)
end
function M:FillData()
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
if not mgr_ctr._mgr_client then
return
else
self:GetOnlinePlayers()
end
end
function M:GetOnlinePlayers()
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
mgr_ctr:FG_GetOnlinePlayers(function(res)
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode, "获取在线成员失败")
else
self.players = res.Data.onlines
-- self._view:GetController("empty").selectedIndex = #self.players == 0 and 1 or 0
self:ShowOnlinePlayers()
end
end)
end
local function _showLeftTime(item, time)
item:GetChild("tex_left_time").text = time .. "s"
end
local _list_invite_time = {}
function M:ShowOnlinePlayers()
local players = self.players
for i = 1, #players do
if self.lst_player.isDisposed then return end
local item = self.lst_player:AddItemFromPool()
local p = players[i]
item:GetChild("tex_name").text = p.nick
item:GetChild("tex_id").text = "ID:" .. ViewUtil.HideID(p.uid)
local btn_head = item:GetChild("btn_head")
ImageLoad.Load(p.portrait, btn_head._iconObject)
local ctr_enable = item:GetController("enable")
ctr_enable.selectedIndex = 0
item:GetChild("btn_invite").onClick:Set(function()
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
local room = DataManager.CurrenRoom
mgr_ctr:FG_InvitePlayer(p.uid, room.room_id, room.play_id, room.room_config:GetGameName(), function()
end)
local time = os.time()
_list_invite_time[p.uid] = time
ctr_enable.selectedIndex = 1
_showLeftTime(item, 15)
end)
local invite_time = _list_invite_time[p.uid]
if invite_time then
local i_timer = os.time() - invite_time
if i_timer < 15 then
ctr_enable.selectedIndex = 1
_showLeftTime(item, 15 - i_timer)
else
_list_invite_time[p.uid] = nil
ctr_enable.selectedIndex = 0
end
end
end
local btn_auto_invite = self._view:GetChild("btn_auto_invite")
btn_auto_invite.onClick:Set(function()
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
local room = DataManager.CurrenRoom
for i = 1, #players do
local p = players[i]
mgr_ctr:FG_InvitePlayer(p.uid, room.room_id, room.play_id, room.room_config:GetGameName(), function()
end)
local time = os.time()
_list_invite_time[p.uid] = time
item = self.lst_player:GetChildAt(i - 1)
item:GetController("enable").selectedIndex = 1
_showLeftTime(item, 15)
end
end)
end
function M:OnUpdate()
local deltaTime = Time.deltaTime
self._timer = self._timer + deltaTime
if self._timer >= 1 then
self._timer = 0
if self.lst_player.numChildren == 0 then return end
for i = 1, #self.players do
local p = self.players[i]
local invite_time = _list_invite_time[p.uid]
if invite_time then
local i_timer = os.time() - invite_time
local item = self.lst_player:GetChildAt(i - 1)
if not item then break end
if i_timer < 15 then
_showLeftTime(item, 15 - i_timer)
else
item:GetController("enable").selectedIndex = 0
_list_invite_time[p.uid] = nil
end
end
end
end
end
function M:Close()
BaseWindow.Close(self)
if self.callback then
self.callback()
end
end
return M

View File

@ -0,0 +1,79 @@
FilterView = {}
local M = FilterView
function FilterView.new()
setmetatable(M, { __index = BaseView })
local self = setmetatable({}, { __index = M })
self.class = "FilterView"
self._full = true
self:init()
return self
end
function M:Init()
self:InitView("base/prefab/ViewFilter.prefab", "base/prefab/ViewFilter")
local view = self._view
local bg = view.transform:GetComponent(typeof(UnityEngine.UI.Image))
bg.sprite = CommonUISprite:GetSprite("bg1")
local btnBack = view.transform:Find("btnBack")
local btnBackBg = btnBack:GetComponent(typeof(UnityEngine.UI.Image))
btnBackBg.sprite = CommonUISprite:GetSprite("arrow1")
btnBack = btnBack:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnBack, function()
ViewManager.ChangeView(ViewManager.View_MainNew)
end)
self.filter = view.transform:Find("imagefilter")
self.filter.position = self.imagePoint.position
self.filter.gameObject:SetActive(false)
self.filter_itemCopy = self.filter:Find("scroll/Viewport/Content/item")
self.filter_itemCopy.gameObject:SetActive(false)
for index, value in ipairs(self.gamePlayData) do
local goFilterTemp = self.filter_itemCopy.gameObject
goFilterTemp = UnityEngine.GameObject.Instantiate(goFilterTemp, self.filter_itemCopy.parent, false)
goFilterTemp:SetActive(true)
end
self.titleCopy = view.transform:Find("scroll/Viewport/Content/imageTitle")
self.itemCopy = view.transform:Find("scroll/Viewport/Content/item")
self.titleCopy.gameObject:SetActive(false)
self.itemCopy.gameObject:SetActive(false)
self.list = {}
end
function M:SetList(v)
for index, value in ipairs(self.list) do
value.goTitle:SetActive(false)
value.goItem:SetActive(false)
end
for index, value in ipairs(v) do
if index > #self.list then
local tempCount = #self.list + 1
self.list[tempCount] = {}
local title = UnityEngine.GameObject.Instantiate(self.titleCopy, self.titleCopy.parent, false)
self.list[tempCount].goTitle = title
title = title.transform:Find("textTitle")
self.list[tempCount].textTitle = title:GetComponent(typeof(UnityEngine.UI.Text))
self.list[tempCount].listItem = {}
end
self:ShowData(self.list[index], value)
self.list[index].goTitle:SetActive(true)
self.lsit[index].goItem:SetActive(true)
end
end
function M:ShowData(val, v)
local data = FilterData[v]
val.textTitle.text = data.name
for index,value in ipairs(val.listItem) do
value.goItem:SetActive(false)
-- value.
end
val.goItem = UnityEngine.GameObject.Instantiate(self.titleItemCopy, self.titleItemCopy.transform.parent, false)
end
return M

View File

@ -0,0 +1,22 @@
GameGroupView = {}
local M = GameGroupView
function GameGroupView.new()
setmetatable(M, { __index = BaseView })
local self = setmetatable({}, { __index = M })
self.class = "GameGroupView"
self._full = true
self:init()
return self
end
function M:init()
self:InitView("base/prefab/ViewGameGroup.prefab", "base/prefab/ViewGameGroup")
local view = self._view
local bg = view.transform:Find("imageBG")
bg = bg:GetComponent(typeof(UnityEngine.UI.Image))
bg.sprite = CommonUISprite:GetSprite("bg1")
end

View File

@ -0,0 +1,290 @@
-- MainViewNew
GameView = {}
local M = GameView
function GameView.new()
setmetatable(M, { __index = BaseView })
local self = setmetatable({}, { __index = M })
self.class = "GameView"
self._full = true
-- self:init()
return self
end
function M:init()
-- self:InitView("base/prefab/ViewGame.prefab", "base/prefab/ViewGame")
local view = self._view
self.option = view.transform:Find("imageList") --菜单
self.moneyInto = view.transform:Find("imageInto") --申请带入
self.moneyOut = view.transform:Find("imageOut") --申请带出
self.tableSet = view.transform:Find("imageSetTable") --设置牌桌
self.seeBattle = view.transform:Find("imageSeeBattle") --查看战报
self.roundSee = view.transform:Find("imageRoundSee") --牌局回放
self.share = view.transform:Find("imageShare") --分享
self.shuoming = view.transform:Find("imageShuoming") --说明
self.cardinformation = view.transform:Find("imageCardInformation") --牌型介绍
self.option.position = view.transform.position
self.moneyInto.position = view.transform.position
self.moneyOut.position = view.transform.position
self.tableSet.position = view.transform.position
self.seeBattle.position = view.transform.position
self.roundSee.position = view.transform.position
self.share.position = view.transform.position
self.option.gameObject:SetActive(false)
self.moneyInto.gameObject:SetActive(false)
self.moneyOut.gameObject:SetActive(false)
self.tableSet.gameObject:SetActive(false)
self.seeBattle.gameObject:SetActive(false)
self.roundSee.gameObject:SetActive(false)
self.share.gameObject:SetActive(false)
local btnOptionList = view.transform:Find("btnOptionList")
btnOptionList = btnOptionList:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnOptionList, function()
self.option.gameObject:SetActive(true)
end)
--菜单
-- --本手结束站起
local option_btnRoundOverStand = self.option:Find("imageCentre/btnRoundOverStand")
option_btnRoundOverStand = option_btnRoundOverStand:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnRoundOverStand, function()
end)
-- -- 牌桌设置
local option_btnSettingTable = self.option:Find("imageCentre/btnSettingTable")
option_btnSettingTable = option_btnSettingTable:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnSettingTable, function()
self.option.gameObject:SetActive(false)
self.tableSet.gameObject:SetActive(true)
end)
-- -- 保险说明
local option_btnSafetyInformation = self.option:Find("imageCentre/btnSafetyInformation")
option_btnSafetyInformation = option_btnSafetyInformation:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnSafetyInformation, function()
self.option.gameObject:SetActive(false)
self.shuoming.gameObject:SetActive(true)
self.textTitleShuoMing.text = "保险说明"
end)
-- -- 特色玩法说明
local option_btnTeSePlay = self.option:Find("imageCentre/btnTeSePlay")
option_btnTeSePlay = option_btnTeSePlay:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnTeSePlay, function()
self.option.gameObject:SetActive(false)
self.shuoming.gameObject:SetActive(true)
self.textTitleShuoMing.text = "特色玩法说明"
end)
-- -- 牌型介绍
local option_btnCardInformation = self.option:Find("imageCentre/btnCardInformation")
option_btnCardInformation = option_btnCardInformation:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnCardInformation, function()
end)
-- -- 游戏商城
local option_btnPlayShop = self.option:Find("imageCentre/btnPlayShop")
option_btnPlayShop = option_btnPlayShop:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnPlayShop, function()
end)
-- -- 申请带入
local option_btnMoneyInto = self.option:Find("imageCentre/btnMoneyInto")
option_btnMoneyInto = option_btnMoneyInto:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnMoneyInto, function()
end)
-- -- 申请带出
local option_btnMoneyOut = self.option:Find("imageCentre/btnMoneyOut")
option_btnMoneyOut = option_btnMoneyOut:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnMoneyOut, function()
end)
-- -- 站起围观
local option_btnStandSee = self.option:Find("imageCentre/btnStandSee")
option_btnStandSee = option_btnStandSee:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnStandSee, function()
end)
-- -- 留位离开
local option_btnLeaveTable = self.option:Find("imageCentre/btnLeaveTable")
option_btnLeaveTable = option_btnLeaveTable:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnLeaveTable, function()
end)
-- --退出牌桌
local option_btnExit = self.option:Find("imageCentre/btnExitTable")
option_btnExit = option_btnExit:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnExit, function()
UIManager.ShowUI(UIManager.LobbyView)
end)
-- --关闭
local option_btnClose = self.option:Find("imageCentre/btnClose")
option_btnClose = option_btnClose:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(option_btnClose, function()
self.option.gameObject:SetActive(false)
end)
--申请带入
local into_btnClose = self.moneyInto:Find("imageCentre/btnClose")
into_btnClose = into_btnClose:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(into_btnClose, function()
self.moneyInto.gameObject:SetActive(false)
end)
local into_btnEnter = self.moneyInto:Find("imageCentre/btnEnter")
into_btnEnter = into_btnEnter:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(into_btnEnter, function()
end)
--申请带出
local out_btnClose = self.moneyOut:Find("imageCentre/btnClose")
out_btnClose = out_btnClose:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(out_btnClose, function()
self.moneyOut.gameObject:SetActive(false)
end)
local out_btnCancel = self.moneyOut:Find("imageCentre/btnCancel")
out_btnCancel = out_btnCancel:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(out_btnCancel, function()
self.moneyOut.gameObject:SetActive(false)
end)
local out_btnConfirm = self.moneyOut:Find("imageCentre/btnConfirm")
out_btnConfirm = out_btnConfirm:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(out_btnConfirm, function()
end)
--牌桌设置
self.table_subTable = self.tableSet:Find("imageCentre/cardSet")
self.table_subMoneySet = self.tableSet:Find("imageCentre/moneySet")
self.table_subOnoff = self.tableSet:Find("imageCentre/onOffSet")
self.table_subMosterSet = self.tableSet:Find("imageCentre/mosterFunctionSet")
self.table_subTable.position = view.transform.position
self.table_subMoneySet.position = view.transform.position
self.table_subOnoff.position = view.transform.position
self.table_subMoneySet.position = view.transform.position
self.table_subTable.gameObject:SetActive(true)
self.table_subMoneySet.gameObject:SetActive(false)
self.table_subOnoff.gameObject:SetActive(false)
self.table_subMoneySet.gameObject:SetActive(false)
local setTable_btnClose = self.tableSet:Find("imageCentre/btnClose")
setTable_btnClose = setTable_btnClose:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(setTable_btnClose, function()
self.tableSet.gameObject:SetActive(false)
end)
local setTable_cardTable = self.tableSet:Find("imageCentre/btnTable") --牌桌
setTable_cardTable = setTable_cardTable:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(setTable_cardTable, function()
end)
local setTable_speedAdd = self.tableSet:Find("imageCentre/btnSpeedAdd") --快捷加注
setTable_speedAdd = setTable_speedAdd:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(setTable_speedAdd, function()
end)
local setTable_onoff = self.tableSet:Find("imageCentre/btnOnOff") --开关
setTable_onoff = setTable_onoff:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(setTable_onoff, function()
end)
local setTable_mosterFunction = self.tableSet:Find("imageCentre/btnMosterFunction") --房主功能
setTable_mosterFunction = setTable_mosterFunction:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(setTable_mosterFunction, function()
end)
--说明
self.textTitleShuoMing = self.shuoming:Find("imageCentre/textTitle")
self.textTitleShuoMing = self.textTitleShuoMing:GetComponent(typeof(UnityEngine.UI.Text))
local aar_cardinformation = {}
local aar_cardinformationIndex = 0
--牌型介绍
for i = 1, 10 do
local cardtypeinformationtemp = self.cardinformation:Find("imageCentre/imagebg/item" .. i)
for v = 1, 5 do
local cardTypeImageTemp = cardtypeinformationtemp:Find("imageCard" .. v)
cardTypeImageTemp = cardTypeImageTemp:GetComponent(typeof(UnityEngine.UI.Image))
aar_cardinformation[aar_cardinformationIndex] = cardTypeImageTemp
aar_cardinformationIndex = aar_cardinformationIndex + 1
end
end
local cardTypeInformationNames = GameUIText:GetText("cardinformation", "|")
for i = 0, cardTypeInformationNames.Length - 1 do
aar_cardinformation[i].sprite = GameCardSprite:GetSprite(cardTypeInformationNames[i])
end
--查看战报
local seeBattle_btnClose = self.seeBattle:Find("imageCentre/btnClose")
seeBattle_btnClose = seeBattle_btnClose:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(seeBattle_btnClose, function()
self.seeBattle.gameObject:SetActive(false)
end)
local seeBattle_btnYinKui = self.seeBattle:Find("imageCentre/btnYinKui")
seeBattle_btnYinKui = seeBattle_btnYinKui:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(seeBattle_btnYinKui, function()
self.moneyOut.gameObject:SetActive(false)
end)
local seeBattle_btnBaoXian = self.seeBattle:Find("imageCentre/btnBaoXian")
seeBattle_btnBaoXian = seeBattle_btnBaoXian:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(seeBattle_btnBaoXian, function()
self.moneyOut.gameObject:SetActive(false)
end)
--牌局回放
local round_btnClose = self.roundSee:Find("imageCentre/btnClose")
round_btnClose = round_btnClose:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(round_btnClose, function()
self.roundSee.gameObject:SetActive(false)
end)
local round_btnMe = self.roundSee:Find("imageCentre/btnMe")
round_btnMe = round_btnMe:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(round_btnMe, function()
end)
local round_btnKey = self.roundSee:Find("imageCentre/btnKey")
round_btnKey = round_btnKey:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(round_btnKey, function()
end)
local round_btnSave = self.roundSee:Find("imageCentre/btnSave")
round_btnSave = round_btnSave:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(round_btnSave, function()
end)
local round_btnShare = self.roundSee:Find("imageCentre/btnShare")
round_btnShare = round_btnShare:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(round_btnShare, function()
end)
local round_btnOther = self.roundSee:Find("imageCentre/btnOther")
round_btnOther = round_btnOther:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(round_btnOther, function()
end)
--
self.arr_cardback = {}
for i = 1, 5 do
self.arr_cardback[i] = GameCardSprite:GetSprite("cardback" .. i .. "")
end
self.cardtype_enum = {
f = "f", --方块
h = "h", --黑桃
m = "m", --梅花
r = "r" --红桃
}
self.arr_cardface = {}
self.arr_cardface[1] = { cardtype = {} }
self.arr_cardface[2] = { cardtype = {} }
self.arr_cardface[3] = { cardtype = {} }
self.arr_cardface[4] = { cardtype = {} }
for index, value in ipairs(self.arr_cardface) do
value.cardtype[self.cardtype_enum.f] = { t = self.cardtype_enum.f }
value.cardtype[self.cardtype_enum.h] = { t = self.cardtype_enum.h }
value.cardtype[self.cardtype_enum.m] = { t = self.cardtype_enum.m }
value.cardtype[self.cardtype_enum.r] = { t = self.cardtype_enum.r }
local card_type_path = "cardtype" .. index .. "_"
for subIndex, subValue in ipairs(value.cardtype) do
for i = 1, 13 do
value.cardtype[subValue.t][i] = GameCardSprite:GetSprite(card_type_path .. subValue.t .. i)
end
end
end
end

View File

@ -0,0 +1,124 @@
--玩家头像窗口
HeadView = {}
local M = HeadView
function HeadView.new(blur_view, user, isHideIpAdds)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = 'HeadView'
self._blur_view = blur_view
self._user = user
self._isHideIpAdds = isHideIpAdds
self:init('ui://Common/Win_headinfo')
return self
end
function M:init(url)
BaseWindow.init(self, url)
self._close_destroy = true
self._close_zone = true
local view = self._view
local ct_state = view:GetController('state')
view:GetChild('tex_nickname').text = self._user.nick_name
local str_playerid = ViewUtil.HideID(self._user.account_id)
if DataManager.SelfUser.account_id == self._user.account_id or DataManager.CurrenRoom.lev < 3 then
str_playerid = self._user.account_id
end
view:GetChild('tex_id').text = str_playerid
view:GetChild('tex_ip').text = self._user.host_ip
local tex_add = view:GetChild('tex_add')
if self._isHideIpAdds then
view:GetChild('tex_ip').visible = false
view:GetChild('n12').visible = false
view:GetChild('n54').visible = false
tex_add.visible = false
else
view:GetChild('tex_ip').visible = true
view:GetChild('n12').visible = true
view:GetChild('n54').visible = true
tex_add.visible = true
end
-- view:GetChild("tex_distance").text = ""
local btn_head = view:GetChild('btn_head')
ImageLoad.Load(self._user.head_url, btn_head._iconObject)
if DataManager.CurrenRoom and not DataManager.CurrenRoom.playback then
-- 显示3人、4人玩法距离
-- local n = 0
-- if DataManager.CurrenRoom.room_config.people_num <= 4 and DataManager.CurrenRoom.room_config.people_num >= 3 then
-- n = 2
-- -- 显示玩家间距离
-- self:ShowPlayerDistance()
-- end
if DataManager.CurrenRoom.self_player.seat ~= 0 then
-- if self._user.account_id ~= DataManager.SelfUser.account_id and DataManager.CurrenRoom.self_player.seat ~= 0 then
ct_state.selectedIndex = 1
if self._user.account_id == DataManager.SelfUser.account_id then
view:GetChild('btn_all').selected = true
view:GetChild('btn_all').touchable = false
end
-- 桌面投掷物面板
local lst_missile = view:GetChild('lst_missile')
lst_missile.onClickItem:Add(
function(context)
if os.time() - DataManager.InteractTime > 3 then
local bAll = view:GetChild('btn_all').selected
local targetId = self._user.account_id
if bAll then
targetId = DataManager.SelfUser.account_id
end
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:SendInteraction(
DataManager.SelfUser.account_id,
5,
context.data.name .. '_' .. targetId
)
-- cd
DataManager.InteractTime = os.time()
ct_state.selectedIndex = 3
end
self:Destroy()
end
)
else
ct_state.selectedIndex = 2
end
-- 显示详细地址
-- self._user.location:GetAddress()
if self._user.location and not self._user.location.default then
self._user.location:GetAddress(tex_add)
else
tex_add.text = '无法获取玩家位置'
end
end
if os.time() - DataManager.InteractTime < 3 and DataManager.CurrenRoom.self_player.seat ~= 0 then
ct_state.selectedIndex = 3
UpdateBeat:Add(self.OnUpdate, self)
end
end
function M:OnUpdate()
if os.time() - DataManager.InteractTime > 3 and DataManager.CurrenRoom.self_player.seat ~= 0 then
self._view:GetController('state').selectedIndex = 1
-- UpdateBeat.Remove(self.OnUpdate, self)
end
end
function M:Destroy()
if self._verifyView then
self._verifyView:Destroy()
end
BaseWindow.Destroy(self)
UpdateBeat:Remove(self.OnUpdate, self)
end

View File

@ -0,0 +1,92 @@
---创建房间View对象
local GameListView = import(".GameListView")
local CreateRoomView = {}
local M = CreateRoomView
function CreateRoomView.new(index)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "CreateRoomView"
self._animation = false
self._full = true
self._full_offset = false
self._modeMap = {}
self.selectedIndex = index
self._close_destroy = true
self._put_map = false
self._new_hide = false
self._queue = false
self:init("ui://Lobby/Win_CreateRoom")
return self
end
function M:init(url)
BaseWindow.init(self,url)
self.gl_view = GameListView.new(self._view,self.selectedIndex,nil,function(mode_data)
self:OnCreateRoom(mode_data)
end,true)
--self.gl_view.IsHallGame=true
end
function M:OnCreateRoom(mode_data)
if mode_data.type == 0 then
local mode = mode_data.data
--点击建房按钮后保存当前游戏的config
local _data = mode:SelectedConfigData()
--pt(_data)
if not _data["stamina"] then _data["stamina"] = 0 end
local user_id = DataManager.SelfUser.account_id
local config_data = {}
local game_id = mode.game_data.game_id
config_data["game_id"] = game_id
config_data["version"] = mode.game_data.version
config_data["config"] = _data
Utils.SaveLocalFile(user_id, json.encode(config_data))
local loddyCtr = ControllerManager.GetController(LoddyController)
-- 对强制开启gps的玩法进行判断
if not DataManager.SelfUser.location then
DataManager.SelfUser.location = Location.new()
end
if _data["GPSDetection"] and _data["GPSDetection"] > 0 and DataManager.SelfUser.location:Location2String() == "" then
-- if DataManager.SelfUser.location:Location2String() == "" then
ViewUtil.ErrorTip(nil, "正在获取GPS定位请稍候重试。")
get_gps()
return
end
ViewUtil.ShowModalWait(self._root_view,"正在创建房间...")
loddyCtr:CreateRoom(game_id,_data, function (res)
self:__OnCreateRoomAction(res)
end)
end
end
function M:__OnCreateRoomAction(response)
ViewUtil.CloseModalWait()
if (response.ReturnCode == -2) then
return
end
if (response.ReturnCode ~= 0) then
ViewUtil.ErrorTip(response.ReturnCode,"创建房间失败")
return
end
self:Destroy()
if self.onCeateRoom then self.onCeateRoom() end
end
function M:Destroy()
self.gl_view:Destroy()
BaseWindow.Destroy(self)
end
return M

View File

@ -0,0 +1,49 @@
--修改玩家昵称
local EditNickView = {}
local M = EditNickView
function EditNickView.new(callback)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "EditNickView"
self._callback = callback
self._close_destroy = true
self:init("ui://Lobby/win_edit_nick")
return self
end
function M:init(url)
BaseWindow.init(self,url)
local tex_edit = self._view:GetChild("tex_edit")
tex_edit.text = DataManager.SelfUser.nick_name
local btn_confirm = self._view:GetChild("btn_confirm")
btn_confirm.onClick:Set(function()
local nick = tex_edit.text
if nick == "" then
ViewUtil.ErrorTip(nil, "昵称不能为空")
return
end
ViewUtil.ShowModalWait(self._root_view, "正在连接服务器")
local loddyctr = ControllerManager.GetController(LoddyController)
local _data = {}
_data.type = 7
_data.nick = nick
loddyctr:UpdateUserInfo(_data,function( res)
ViewUtil.CloseModalWait()
if (res.ReturnCode ==0) then
DataManager.SelfUser.nick_name = nick
else
ViewUtil.ErrorTip(res.ReturnCode, "修改失败")
end
self._callback()
self:Destroy()
end)
end)
end
return M

View File

@ -0,0 +1,28 @@
--修改玩家头像
local EditPortraitView = {}
local M = EditPortraitView
function EditPortraitView.new(callback)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "EditPortraitView"
self._callback = callback
self._close_destroy = true
self:init("ui://Lobby/win_edit_portrait")
return self
end
function M:init(url)
BaseWindow.init(self,url)
local lst_portrait = self._view:GetChild("lst_portrait")
lst_portrait.selectedIndex = 0
local btn_confirm = self._view:GetChild("btn_confirm")
end
return M

View File

@ -0,0 +1,173 @@
---创建房间View对象
local GameListView = {}
local M = GameListView
function GameListView.new(view,index,room_config,callback,isHall)
local self = {}
setmetatable(self, {__index = M})
self._view = view
self._modeMap = {}
self.selectedIndex = index
self.room_config = room_config
self.IsHallGame=isHall or false
self._callback = callback
self:init()
return self
end
function M:init()
local btn_createroom = self._view:GetChild("btn_create")
btn_createroom.onClick:Set(function()
if self._callback then
local index = self.selectedIndex
local mode_data = self._modeMap[index]
if not mode_data then return end
self._callback(mode_data)
end
end)
self.create_panel = self._view:GetChild("create_panel")
self.lst_play = self._view:GetChild("lst_play")
self:__sysinit()
end
function M:__fill_panel()
local create_panel = self.create_panel
-- local ctr_update = self.ctr_update
local mode_data = self._modeMap[self.selectedIndex]
-- ctr_update.selectedIndex = mode_data.type
create_panel:RemoveChildren()
local mode = mode_data.data
if mode and not mode._config then
mode:FillData()
if self.room_config and self.room_config.game_id ==mode.game_data.game_id then
mode:LoadConfigData(self.room_config)
end
end
--local ctr_play_list = mode._config:GetController("play_list")
--self.lst_play:RemoveChildrenToPool()
--[[local p_list = mode:GetPlayList()
for i = 1, #p_list do
local item = self.lst_play:AddItemFromPool()
item.text = p_list[i]
end--]]
--self.lst_play.onClickItem:Set(function ()
--ctr_play_list.selectedIndex = self.lst_play.selectedIndex
-- end)
--self.lst_play.selectedIndex = ctr_play_list.selectedIndex
self:ShowPayOption(mode)
create_panel:AddChild(mode_data.data._config)
--mode._config:AddRelation(create_panel, RelationType.Size)
end
function M:__sysinit()
local games = DataManager.SelfUser.games
local tempGame={}
for k,v in ipairs(games) do
if v.game_id==201 and self.IsHallGame==true then
else
table.insert(tempGame,v)
end
end
local create_panel = self.create_panel
local lst_game = self._view:GetChild("lst_game")
for i = 1, #tempGame do
local tem = tempGame[i]
local item = lst_game:AddItemFromPool()
item.text = tem.name
local config = ExtendManager.GetExtendConfig(tem.game_id)
config.game_data = tem
local mode = config:GetGameInfo()
item.icon = mode:GetIconUrl()
local mode_data = {}
mode_data.type = 0
mode_data.data = mode
mode.game_data = tem
self._modeMap[i] = mode_data
end
lst_game.selectedIndex = self.selectedIndex - 1
lst_game.onClickItem:Set(function ()
self.selectedIndex = lst_game.selectedIndex + 1
self:__fill_panel()
end)
local btn_game_info = self._view:GetChild("btn_game_info")
btn_game_info.onClick:Set(function()
self:__ShowHelp()
end)
if lst_game.numChildren > 0 then
lst_game:ScrollToView(self.selectedIndex - 1)
self:__fill_panel()
end
end
function M:__ShowHelp()
local index = self.selectedIndex
if #self._modeMap == 0 then return end
local mode = self._modeMap[index]
if mode.type == 0 then
local url = mode.data:GetHelpUrl()
local help_win = BaseWindow.new("ui://Lobby/Win_help",self._root_view)
help_win._close_destroy = true
help_win:Show()
local info_panel = help_win._view:GetChild("info_panel")
local info_obj = UIPackage.CreateObjectFromURL(url)
info_panel:AddChild(info_obj)
end
end
function M:ShowPayType(mode)
end
-- 显示支付类型
function M:ShowPayOption(mode)
self:ShowPayType(mode)
mode:OnChangeOption(self._ctype)
end
function M:GetModeData()
local index = self.selectedIndex
local mode_data = self._modeMap[index]
return mode_data
end
function M:__dispose_mode()
for i = 1, #self._modeMap do
local mode_data = self._modeMap[i]
if mode_data.type == 0 then
local mode = mode_data.data
if mode._config then
mode._config:Dispose()
mode._config = nil
end
end
end
self._modeMap = {}
end
function M:Destroy()
local create_panel = self.create_panel
create_panel:RemoveChildren()
self:__dispose_mode()
end
return M

View File

@ -0,0 +1,85 @@
--进入房间View对象
local JoinRoomView = {}
local M = JoinRoomView
local KEY_DEL = "del"
local KEY_CLEAR = "c"
function JoinRoomView.new()
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "JoinRoomView"
self._currenIndex = 0
self._close_destroy = true
self:init("ui://Lobby/Win_JoinRoom")
return self
end
function M:init(url)
BaseWindow.init(self,url)
self.tex_num = self._view:GetChild("tex_num")
self:ClearNumTex()
local cnt = self._view.numChildren - 1
for i = 0 , 9 do
local obj = self._view:GetChild("btn_"..i)
obj.onClick:Add(handler(self , self.OnNumButtonAction))
i = i + 1
end
local btn_c = self._view:GetChild("btn_c")
btn_c.onClick:Add(handler(self , self.OnNumButtonAction))
local btn_del = self._view:GetChild("btn_del")
btn_del.onClick:Add(handler(self , self.OnNumButtonAction))
end
function M:OnNumButtonAction(context)
local typer = string.sub(context.sender.name ,5)
if typer == KEY_DEL then
if (self._currenIndex > 0) then
self._currenIndex = self._currenIndex - 1
self._texnum_str = string.sub(self._texnum_str,0,self._currenIndex)
self.tex_num.text = self._texnum_str
end
elseif typer == KEY_CLEAR then
self:ClearNumTex()
else
if (self._currenIndex < 6) then
self._currenIndex = self._currenIndex + 1
self._texnum_str = self._texnum_str .. typer
self.tex_num.text = self._texnum_str
if(self._currenIndex == 6) then
self:JoinRoom(self._texnum_str)
end
end
end
end
function M:JoinRoom(str)
ViewUtil.ShowModalWait(self._root_view,"正在加入房间...")
local boddyCtr = ControllerManager.GetController(LoddyController)
boddyCtr:JoinRoom(str, function (response)
ViewUtil.CloseModalWait()
if response.ReturnCode == -2 then
self:JoinRoom(str)
return
elseif response.ReturnCode ~=0 then
ViewUtil.ErrorTip(response.ReturnCode,"进入房间失败")
return
end
self:Destroy()
ViewManager.ChangeView(ViewManager.View_Main,DataManager.CurrenRoom.game_id)
end)
end
function M:ClearNumTex()
self._texnum_str = ""
self._currenIndex = 0
self.tex_num.text = self._texnum_str
end
return JoinRoomView

View File

@ -0,0 +1,168 @@
-- 玩家信息窗口(大厅点击头像进入)
local RealAddressView = import(".RealAddressView")
local PhoneBindView = import(".PhoneBindView")
local PhonePasswordView = import(".PhonePasswordView")
local WeChatView = import(".WeChatView")
local UserEditView = import(".UserEditView")
local LobbyHeadView = {}
local M = LobbyHeadView
function LobbyHeadView.new(user,agent,callback)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "LobbyHeadView"
self._user = user
self._agent = agent
--self._full = true
self._full_offset = false
self._animation = false
self._put_map = false
self._new_hide = false
self._queue = false
self.callback = callback
-- self:init("ui://Lobby/UserInfo")
return self
end
function M:fill_item(item_name, title, callback)
local item = self.user_info:GetChild(item_name)
local btn_opt = item:GetChild("btn_opt")
local ctr_c1 = item:GetController("c1")
if title then
item.text = title
ctr_c1.selectedIndex = 1
end
btn_opt.onClick:Set(function ()
callback()
end)
end
function M:fill_user_info()
local real_info = self._user.real_info
self:fill_item("item_real",real_info and real_info.name or nil,function ()
local real_view = RealAddressView.new(0,function ()
self:fill_user_info()
end)
real_view:Show()
end)
local address = self._user.address
self:fill_item("item_address",address,function ()
local real_view = RealAddressView.new(1,function ()
self:fill_user_info()
end)
real_view:Show()
end)
local phone = self._user.phone
self:fill_item("item_phone",phone and ViewUtil.phone_hide(phone) or nil,function ()
local phone_view = PhoneBindView.new(function ()
self:fill_user_info()
end)
phone_view:Show()
end)
local password = self._user.password
self:fill_item("item_password",password,function ()
-- if not phone then
-- ViewUtil.ShowTips("请绑定手机号")
-- return
-- end
local pw_view = PhonePasswordView.new(function()
self:fill_user_info()
end)
pw_view:Show()
end)
local invitation = self._user.invitation
local item_invte = self.user_info:GetChild("item_invte")
local ctr_invte = item_invte:GetController("c1")
ctr_invte.selectedIndex = invitation
ctr_invte.onChanged:Set(function ()
ViewUtil.ShowModalWait()
local loddyctr = ControllerManager.GetController(LoddyController)
local _data = {}
_data.type =5
_data.invitation = ctr_invte.selectedIndex
loddyctr:UpdateUserInfo(_data,function( res)
ViewUtil.CloseModalWait()
if (res.ReturnCode ==0) then
DataManager.SelfUser.invitation = ctr_invte.selectedIndex
else
ViewUtil.ErrorTip(res.ReturnCode,"提交失败")
end
end)
end)
local acc = self._user.acc
self:fill_item("item_wx",acc and "(绑定:"..self._user.nick_name..")" or "",function ()
local wx_view = WeChatView.new(function()
self:fill_user_info()
end)
wx_view:Show()
end)
local _btn_logout = self._view:GetChild('btn_logout')
_btn_logout.onClick:Set(function()
local _curren_msg = MsgWindow.new(self._root_view, '您是否退出当前账号?', MsgWindow.MsgMode.OkAndCancel)
_curren_msg.onOk:Add(function()
PlayerPrefs.DeleteKey('session_id')
PlayerPrefs.Save()
RestartGame()
end)
_curren_msg:Show()
end)
end
function M:ChangeToLogin()
local _curren_msg = MsgWindow.new(self._root_view, '您是否退出当前账号?', MsgWindow.MsgMode.OkAndCancel)
_curren_msg.onOk:Add(function()
PlayerPrefs.DeleteKey('session_id')
PlayerPrefs.Save()
RestartGame()
end)
_curren_msg:Show()
end
function M:init(url)
BaseWindow.init(self,url)
self._close_destroy = true
self._close_zone = true
local view = self._view
local ctr_nav = view:GetController("nav")
--ctr_nav.selectedIndex = self._agent and 1 or 0
local ct_state = view:GetController("state")
view:GetChild("tex_nickname").text = self._user.nick_name
local str_playerid = self._user.account_id
view:GetChild("tex_id").text = "ID:"..str_playerid
local btn_head = view:GetChild("btn_head")
ImageLoad.Load(self._user.head_url, btn_head._iconObject)
btn_head.onClick:Set(function()
local user_edit_view = UserEditView.new(function()
view:GetChild("tex_nickname").text = self._user.nick_name
ImageLoad.Load(self._user.head_url, btn_head._iconObject)
self.callback()
end)
user_edit_view:Show()
end)
local ctr_load = view:GetController("load")
local loddyCtr1 = ControllerManager.GetController(LoddyController)
loddyCtr1:GetUserInfo(function(res)
if res.ReturnCode == 0 then
ctr_load.selectedIndex = 1
self:fill_user_info()
end
end)
self.user_info = view:GetChild("user_info")
end
return M

View File

@ -0,0 +1,74 @@
--设置窗口对象
local LobbySettingView = {}
local M = LobbySettingView
setmetatable(M, {__index = BaseWindow})
function LobbySettingView.new()
local self = setmetatable({}, {__index = M})
self.class = 'SettingView'
self._close_destroy = true
self:init('ui://Lobby/SettingWindow1')
return self
end
function M:init(url)
BaseWindow.init(self, url)
local view = self._view
local slider_sound = view:GetChild('slider_sound')
local slider_music = view:GetChild('slider_music')
local btn_music = view:GetChild('btn_music')
local btn_sound = view:GetChild('btn_sound')
btn_music.selected = (GameApplication.Instance.MusicValue < 5 and false or true)
slider_sound.value = GameApplication.Instance.SoundValue
slider_music.value = GameApplication.Instance.MusicValue
btn_sound.selected = GameApplication.Instance.SoundValue < 5 and false or true
btn_sound.icon = btn_sound.selected and 'ui://Common/on' or 'ui://Common/off'
btn_music.icon = btn_music.selected and 'ui://Common/on' or 'ui://Common/off'
slider_music.onChanged:Add(function()
GameApplication.Instance.MusicValue = slider_music.value
btn_music.selected = GameApplication.Instance.MusicValue < 5 and false or true
end)
slider_sound.onChanged:Add(function()
GameApplication.Instance.SoundValue = slider_sound.value
btn_sound.selected = GameApplication.Instance.SoundValue < 5 and false or true
end)
btn_sound.onChanged:Add(function()
GameApplication.Instance.SoundValue = btn_sound.selected and 50 or 0
slider_sound.value = GameApplication.Instance.SoundValue
btn_sound.icon = btn_sound.selected and 'ui://Common/on' or 'ui://Common/off'
end)
btn_music.onChanged:Add(function()
GameApplication.Instance.MusicValue = btn_music.selected and 50 or 0
slider_music.value = GameApplication.Instance.MusicValue
btn_music.icon = btn_music.selected and 'ui://Common/on' or 'ui://Common/off'
end)
local _btn_logout = self._view:GetChild('btn_del')
_btn_logout.onClick:Set(function()
local _curren_msg = MsgWindow.new(self._root_view, '您是否退出当前账号?', MsgWindow.MsgMode.OkAndCancel)
_curren_msg.onOk:Add(function()
PlayerPrefs.DeleteKey('session_id')
PlayerPrefs.Save()
RestartGame()
end)
_curren_msg:Show()
end)
end
return M

View File

@ -0,0 +1,69 @@
local NoticeView = {}
local M = NoticeView
function NoticeView.new(blur_view)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "NoticeView"
-- self._blur_view = blur_view
self:init("ui://Lobby/pop_notice")
return self
end
function M:init(url)
BaseWindow.init(self,url)
self._close_destroy = true
self._close_zone = true
end
function M:FillData(data)
if not data then return end
self._notices = data
local list = self._view:GetChild("list")
for i = 1, #data do
local info = data[i]
local item = list:AddItemFromPool()
item:GetChild("title").text = info.name
if info.type == "NEW" then
item:GetChild("icon").url = "ui://27vd145bildu7e"
elseif info.type == "ACTIVITY" then
item:GetChild("icon").url = "ui://27vd145bildu74"
else
item:GetChild("icon").url = ""
end
item.onClick:Add(function()
self:ShowIndex(i)
end)
end
list.selectedIndex = 0
self:ShowIndex(1)
end
function M:ShowIndex(index)
local title = self._view:GetChild("tex_title")
local pic = self._view:GetChild("img")
local content = self._view:GetChild("com_content"):GetChild("tex_content")
local notices = self._notices
if index <= #notices then
title.text = notices[index].title
content.text = notices[index].content
end
-- pic.text = "<img src=\""..notices[index].picture.."\"></img>"
-- pic.text = "<img src=\"".."http://www.w3school.com.cn/i/eg_tulip.jpg".."\"></img>"
-- print(pic.text)
end
function M:Destroy(flag)
-- ImageLoad.Clear(self.class)
BaseWindow.Destroy(self, flag)
end
return M

View File

@ -0,0 +1,119 @@
local PhoneBindView = {}
local M = PhoneBindView
function PhoneBindView.new(callback)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "PhoneBindView"
self._callback = callback
self._close_destroy = true
local url = "ui://Lobby/win_phone"
self:init(url)
return self
end
function M:init(url)
BaseWindow.init(self,url)
if DataManager.SelfUser.phone then
local ctr_update = self._view:GetController("update")
ctr_update.selectedIndex = 1
end
local btn_getCode = self._view:GetChild("btn_getCode")
btn_getCode.onClick:Set(function()
self:GetCode()
end)
local btn_ok = self._view:GetChild("btn_ok")
btn_ok.onClick:Set(function()
self:Bind()
end)
end
--获取验证码
function M:GetCode()
local phone = self:CheckInputPhone()
if not phone then
return
end
local loddyctr = ControllerManager.GetController(LoddyController)
loddyctr:GetPhoneCode(phone,function( res)
if res.ReturnCode == 0 then
self._view:GetController("code").selectedIndex = 1
self._left_time = 120
UpdateBeat:Add(self.OnUpdate, self)
else
ViewUtil.ErrorTip(res.ReturnCode, "请输入正确的手机号")
end
end)
end
function M:OnUpdate()
local deltaTime = Time.deltaTime
local _left_time = self._left_time
if (_left_time > 0) then
_left_time = _left_time - deltaTime
_left_time = math.max(0, _left_time)
local leftTime = math.floor(_left_time)
self._view:GetChild("tex_time").text = tostring(leftTime).."后重新发送"
self._left_time = _left_time
else
self._view:GetController("code").selectedIndex=0
UpdateBeat:Remove(self.OnUpdate, self)
end
end
function M:Destroy()
BaseWindow.Destroy(self)
UpdateBeat:Remove(self.OnUpdate, self)
end
--绑定
function M:Bind()
local phone = self:CheckInputPhone()
if not phone then
return
end
local code = self:CheckInputCode()
if not code then
return
end
ViewUtil.ShowModalWait(self._root_view,"正在提交...")
local loddyctr = ControllerManager.GetController(LoddyController)
local _data = {}
_data.type =4
_data.phone = phone
_data.code = code
loddyctr:UpdateUserInfo(_data,function( res)
ViewUtil.CloseModalWait()
if (res.ReturnCode ==0) then
DataManager.SelfUser.phone = phone
if self._callback then self._callback() end
else
ViewUtil.ErrorTip(res.ReturnCode,"提交失败")
end
self:Close()
end)
end
function M:CheckInputPhone()
local phone = self._view:GetChild("tex_phone").text
if not (string.len(phone) == 11 or string.len(phone) == 12) then
ViewUtil.ShowTips("请输入正确的手机号")
return
end
return phone
end
function M:CheckInputCode()
local code = self._view:GetChild("tex_code").text
if not (string.len(code) == 6) then
ViewUtil.ShowTips("请输入正确的验证码")
return
end
return code
end
return M

View File

@ -0,0 +1,123 @@
local PhonePasswordView = {}
local M = PhonePasswordView
function PhonePasswordView.new(callback)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "PhonePasswordView"
self._callback = callback
self._close_destroy = true
local url = "ui://Lobby/win_phone_password"
self:init(url)
return self
end
function M:init(url)
BaseWindow.init(self,url)
self.ctr_update = self._view:GetController("update")
if DataManager.SelfUser.password then
--self.ctr_update.selectedIndex = 1
--print("DataManager.SelfUser.account_idDataManager.SelfUser.account_idDataManager.SelfUser.account_id ",DataManager.SelfUser.account_id)
--self._view:GetChild("tex_phone").text = DataManager.SelfUser.account_id--ViewUtil.phone_hide(DataManager.SelfUser.phone)
end
self._view:GetChild("tex_phone").text = DataManager.SelfUser.account_id
local btn_getCode = self._view:GetChild("btn_getCode")
btn_getCode.onClick:Set(function()
self:GetCode()
end)
local btn_ok = self._view:GetChild("btn_ok")
btn_ok.onClick:Set(function()
self:Bind()
end)
end
--获取验证码
function M:GetCode()
local phone = self:CheckInputPhone()
if not phone then
return
end
local loddyctr = ControllerManager.GetController(LoddyController)
loddyctr:GetPhoneCode(phone,function( res)
if res.ReturnCode == 0 then
self._view:GetController("code").selectedIndex = 1
self._left_time = 120
UpdateBeat:Add(self.OnUpdate, self)
else
ViewUtil.ErrorTip(res.ReturnCode, "请输入正确的手机号")
end
end)
end
function M:OnUpdate()
local deltaTime = Time.deltaTime
local _left_time = self._left_time
if (_left_time > 0) then
_left_time = _left_time - deltaTime
_left_time = math.max(0, _left_time)
local leftTime = math.floor(_left_time)
self._view:GetChild("tex_time").text = tostring(leftTime).."后重新发送"
self._left_time = _left_time
else
self._view:GetController("code").selectedIndex=0
UpdateBeat:Remove(self.OnUpdate, self)
end
end
function M:Destroy()
BaseWindow.Destroy(self)
UpdateBeat:Remove(self.OnUpdate, self)
end
--绑定
function M:Bind()
local tex_passwd = self._view:GetChild("tex_passwd")
local password = tex_passwd.text
if string.len(password) <6 then
ViewUtil.ShowTips("请输入5位以上的密码")
return
end
local _data = {}
-- if self.ctr_update.selectedIndex == 1 then
-- local code = self:CheckInputCode()
-- if not code then
-- return
-- end
-- _data.phone = DataManager.SelfUser.phone
-- _data.code = code
-- end
ViewUtil.ShowModalWait(self._root_view,"正在提交...")
local loddyctr = ControllerManager.GetController(LoddyController)
_data.password = password
_data.type =3
loddyctr:UpdateUserInfo(_data,function( res)
ViewUtil.CloseModalWait()
if (res.ReturnCode ==0) then
DataManager.SelfUser.password = "123"
if self._callback then self._callback() end
else
ViewUtil.ErrorTip(res.ReturnCode,"提交失败")
end
self:Close()
end)
end
function M:CheckInputCode()
local code = self._view:GetChild("tex_code").text
if not (string.len(code) == 6) then
ViewUtil.ShowTips("请输入正确的验证码")
return
end
return code
end
return M

View File

@ -0,0 +1,401 @@
-- 排行和战绩窗口
-- author谌建军
RankView = {}
local M = RankView
function RankView.new( main_view,video )
UIPackage.AddPackage("base/rank/ui/Rank")
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "RankView"
self._animation = false
self._full = true
self._full_offset = false
self._close_destroy = true
self._main_view = main_view
self._video = video
self._put_map = false
self._new_hide = false
self._queue = false
self:init("ui://Rank/Main")
return self
end
function M:init( url )
BaseWindow.init(self,url)
self._view:GetController("tab").selectedIndex = self._video and 1 or 0
self._curren_tex = ""
self._curren_len = 0
local develop_panel = self._view:GetChild("n70")
self.tex_roomid = develop_panel:GetChild("tex_roomid")
self.tex_roomid.text = ""
for i = 0, 9 do
local btn = develop_panel:GetChild("btn_" .. i)
btn.onClick:Add(function()
if self._curren_len < 6 then
self._curren_tex = self._curren_tex .. i
self._curren_len = self._curren_len + 1
self.tex_roomid.text = self._curren_tex
if self._curren_len == 6 then
ViewUtil.ShowModalWait(self._root_view)
local loddyCtr1 = ControllerManager.GetController(LoddyController)
loddyCtr1:RequestRecordList(function (result)
ViewUtil.CloseModalWait()
if self._is_destroy then
return
end
if result == Table_Error_code.ERR_TIMEOUT then
self:readData()
return
end
if result == 0 then
self:InitRecord1(loddyCtr1.recordList, true)
end
end, self._curren_tex)
end
end
end)
end
develop_panel:GetChild("btn_del").onClick:Add(function()
if self._curren_len > 0 then
self._curren_len = self._curren_len - 1
self._curren_tex = string.sub(self._curren_tex, 0, self._curren_len)
self.tex_roomid.text = self._curren_tex
end
end)
develop_panel:GetChild("btn_retype").onClick:Add(function()
self._curren_tex = ""
self._curren_len = 0
self.tex_roomid.text = self._curren_tex
end)
end
function M:readData()
local view = self._view
local record_list_1 = view:GetChild("n26")
record_list_1:RemoveChildrenToPool()
local loddyCtr1 = ControllerManager.GetController(LoddyController)
loddyCtr1:RequestRecordList(function (result)
if self._is_destroy then
return
end
if result == Table_Error_code.ERR_TIMEOUT then
self:readData()
return
end
self:InitRecord1(loddyCtr1.recordList)
end)
end
function M:Show()
BaseWindow.Show(self)
UpdateBeat:Remove(self._main_view.OnUpdate, self._main_view)
-- self:readData()
end
function M:Destroy()
BaseWindow.Destroy(self)
UpdateBeat:Add(self._main_view.OnUpdate, self._main_view)
end
local load_head_num = 0
function M:InitRecord1(recordList, develop_tool)
--print("InitRecord1=========")
pt(recordList)
local main_view = self._view
-- 战绩 list
local record_list_1, ctr_recored, ctr_no_record
if develop_tool then
ctr_recored = main_view:GetController("developer")
ctr_recored.selectedIndex = 1
record_list_1 = main_view:GetChild("lst_record")
local btn_backto_search = main_view:GetChild("btn_backto_search")
btn_backto_search.onClick:Set(function()
ctr_recored.selectedIndex = 0
self._curren_tex = ""
self._curren_len = 0
self.tex_roomid.text = ""
end)
ctr_no_record = self._view:GetController("noRecordData2")
else
record_list_1 = main_view:GetChild("n26")
ctr_no_record = self._view:GetController("noRecordData")
end
record_list_1:RemoveChildrenToPool()
ctr_no_record.selectedIndex = #recordList == 0 and 1 or 0
for i=1, #recordList do
local record_list_item = recordList[i]
local total_score_list = record_list_item.TotalScoreList
local item = record_list_1:AddItemFromPool()
local player_item_list = item:GetChild("big_round")
local more_person = #total_score_list >= 6
if more_person then
item:GetController("person_num").selectedIndex = 1
else
item:GetController("person_num").selectedIndex = 0
end
local game_id = record_list_item.GameId
local game_data = ExtendManager.GetGameData(game_id)
local room_type_str = record_list_item.GameInfo.name
local room_id_str = record_list_item.RoomId
local time =tonumber(record_list_item.Time)
local room_time_str = os.date("%Y-%m-%d %H:%M", time)
local item_score_list = record_list_item.GameTimes
local play_back_id = record_list_item.PlayBackId
-- 显示 房间号 房间类型 时间
item:GetChild("RoomType").asTextField.text = room_type_str
item:GetChild("RoomID").asTextField.text = room_id_str
item:GetChild("Time").asTextField.text = room_time_str
if record_list_item.hp_times and record_list_item.hp_times ~= 0 then
item:GetChild("tex_times").text = record_list_item.hp_times .. ""
else
item:GetChild("tex_times").text = ""
end
player_item_list:RemoveChildrenToPool()
local hpOnOff = record_list_item.hpOnOff
local hpType = record_list_item.GameInfo.hpType
-- 显示 每个玩家的 名字和 分数
-- player_list 是聊天室数据
local player_list = {}
for j=1,#total_score_list do
local player_list_item = total_score_list[j]
local player_item = player_item_list:AddItemFromPool()
player_item:GetChild("n0").text = player_list_item.Name
local player_score = player_item:GetChild("n1")
local score = player_list_item.Score
if hpOnOff == 1 and hpType > 1 then
score = score / 10
end
if score < 0 then
player_item:GetController("num_color").selectedIndex = 1
else
player_item:GetController("num_color").selectedIndex = 0
end
player_score.text = score >= 0 and "+"..score or score
player_list[j] = {}
player_list[j].id = player_list_item.Id
player_list[j].score = score
player_list[j].house = 0
player_list[j].nick = player_list_item.Name
end
-- 点击事件
item.onClick:Add(function ()
self:ShowRecord2(play_back_id, room_type_str, room_id_str, room_time_str,item_score_list, game_id, develop_tool, record_list_item)
end)
-- 分享
item:GetChild("btn_screenshot").onClick:Set(function()
ViewUtil.ShowModalWait(self._view, "正在分享...")
local result_view = UIPackage.CreateObjectFromURL("ui://Rank/ResultView")
result_view.visible = false
self._view:AddChild(result_view)
result_view:GetChild("tex_roomnum").text = room_id_str .. " " .. room_type_str
result_view:GetChild("tex_data").text = room_time_str
result_view:GetChild("btn_confirm").onClick:Set(function() result_view:Dispose() end)
local lst_p = result_view:GetChild("list_result")
local lst_p2 = result_view:GetChild("list_result2")
load_head_num = #total_score_list
local count = #total_score_list
for j = 1, count do
local p = total_score_list[j]
local item = nil
if count < 6 or (count >= 6 and j <= math.ceil(count / 2)) then
item = lst_p:AddItemFromPool()
else
item = lst_p2:AddItemFromPool()
end
item:GetChild("name").text = p.Name
local score = p.Score
if hpOnOff == 1 and hpType > 1 then
score = score / 10
end
item:GetChild("score").text = score
if score < 0 then item:GetController("di").selectedIndex = 1 end
if p.Portrait and p.Portrait ~= "" then
ImageLoad.Load(p.Portrait, item:GetChild("n9")._iconObject, 1, function( ... )
load_head_num = load_head_num - 1
end)
else
load_head_num = load_head_num - 1
end
end
coroutine.start(function ( ... )
local left_time = 4
while (true) do
if load_head_num == 0 or left_time == 0 then
result_view.visible = true
coroutine.wait(0.2)
ShareScreenShotWithOption(function()
result_view:Dispose()
end)
ViewUtil.CloseModalWait()
break
end
coroutine.wait(1)
left_time = left_time - 1
end
end)
end)
item:GetChild("btn_link").onClick:Set(function()
local group_id = record_list_item.group_id and tonumber(record_list_item.group_id) or 0
ShareChatRoom(record_list_item.RoomId, tostring(os.time()), #item_score_list, room_type_str, group_id, player_list, self._root_view)
end)
end
end
function M:ShowRecord2(playback_id, room_type, room_id, room_time, item_score, game_id, develop_tool, record_item)
local record_list_2
if develop_tool then
record_list_2 = self._view:GetChild("lst_round")
self._view:GetController("developer").selectedIndex = 2
else
record_list_2 = self._view:GetChild("n29")
self._view:GetController("Record").selectedIndex = 1
end
local hpOnOff = record_item.hpOnOff
local hpType = record_item.GameInfo.hpType
record_list_2:RemoveChildrenToPool()
for i=1,#item_score do
local item_player_info = item_score[i]
local play_back_id = item_player_info.PlayBackId
local player_score = item_player_info.PlayerList
local record_item_2 = record_list_2:AddItemFromPool("ui://Rank/Record_Item_2")
local player_item_list = record_item_2:GetChild("List")
local more_person = #player_score >= 6
if more_person then
record_item_2:GetController("person_num").selectedIndex = 1
else
record_item_2:GetController("person_num").selectedIndex = 0
end
-- 设置房间信息
record_item_2:GetChild("RoomType").text = room_type
record_item_2:GetChild("RoomID").text = room_id
--record_item_2:GetChild("Time").text = room_time
record_item_2:GetChild("Number").text = tostring(i)
player_item_list:RemoveChildrenToPool()
for j=1,#player_score do
local player_item = player_item_list:AddItemFromPool()
player_item:GetChild("n0").text = player_score[j].Name
local player_score_text = player_item:GetChild("n1")
local score = player_score[j].Score
if hpOnOff == 1 and hpType > 1 then
score = score / 10
end
if score < 0 then
player_item:GetController("num_color").selectedIndex = 1
else
player_item:GetController("num_color").selectedIndex = 0
end
player_score_text.text = score >= 0 and "+"..score or score
end
local btn_play_back = record_item_2:GetChild("btn_play_back")
btn_play_back.onClick:Set(function()
--print("点击进入回放=====")
if DataManager.SelfUser.playback[playback_id] ~= nil and DataManager.SelfUser.playback[playback_id][i] ~= nil then
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
DataManager.CurrenRoom = room
room.game_id = game_id
local extend = ExtendManager.GetExtendConfig(game_id)
extend:FillPlayBackData(DataManager.SelfUser.playback[playback_id][i])
if not room.self_player then
room.self_player = room:GetPlayerBySeat(1)
end
local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id)
main._currentId = playback_id
main._currentRound = i
main._totalRound = #item_score
main:FillRoomData(DataManager.SelfUser.playback[playback_id][i])
else
ViewUtil.ShowModalWait(self._view)
local _data = {}
_data["military_id"] = playback_id
_data["round"] = tostring(i)
local loddyCtr1 = ControllerManager.GetController(LoddyController)
loddyCtr1:RequestPlayBack(_data,function(code,data)
ViewUtil.CloseModalWait()
if code == 0 then
if DataManager.SelfUser.playback[playback_id] ~= nil then
DataManager.SelfUser.playback[playback_id][i] = data
else
local playback_data = {}
playback_data[i] = data
DataManager.SelfUser.playback[playback_id] = playback_data
end
local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id)
main._currentId = playback_id
main._currentRound = i
main._totalRound = #item_score
--print(main)
main:FillRoomData(data)
elseif code == 25 then
ViewUtil.ErrorTip(code, "回放未找到!")
btn_play_back.grayed = true
end
end, record_item.GameInfo)
end
end)
end
end
function M:GenaratePlayBack(id, game_id, ...)
local tem =nil
local dview_class = nil
if not dview_class then
local exconfig = ExtendManager.GetExtendConfig(game_id)
dview_class = exconfig:GetView(id)
--print(dview_class)
end
if not dview_class then
return
end
local arg = {...}
tem = dview_class.new(...)
tem.Id = id
tem:Show()
return tem
end
function M:Destroy()
BaseWindow.Destroy(self)
UIPackage.RemovePackage("base/rank/ui/Rank")
end
return M

View File

@ -0,0 +1,143 @@
--实名认证窗口
local RealAddressView = {}
local M = RealAddressView
function RealAddressView.new(type,callback)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "RealAddressView"
self._type = type
self._callback = callback
self._close_destroy = true
self:init("ui://Lobby/win_real_address")
return self
end
function M:init(url)
BaseWindow.init(self,url)
local view = self._view
local btn_real = view:GetChild("btn_real")
btn_real.onClick:Set(function()
self:real_action()
end)
local btn_address = view:GetChild("btn_address")
btn_address.onClick:Set(function ()
self:address_action()
end)
self.ctr_update = view:GetController("update")
local ctr_nav = view:GetController("nav")
ctr_nav.onChanged:Set(function()
if ctr_nav.selectedIndex ==0 then
self:fill_real()
else
local user = DataManager.SelfUser
if user.address then
self._view:GetChild("tex_address").text = user.address
end
end
end)
if self._type == 0 then
self:fill_real()
end
ctr_nav.selectedIndex = self._type
end
function M:fill_real()
local user = DataManager.SelfUser
if user.real_info then
self.ctr_update.selectedIndex = 1
self._view:GetChild("tex_name1").text ="姓名:".. user.real_info.name
self._view:GetChild("tex_identity1").text = "身份证号:"..ViewUtil.identity_hide(user.real_info.identity)
else
self.ctr_update.selectedIndex = 0
end
end
function M:SetCallBack(callback)
self._CB = callback
end
function M:real_action()
local check,str = self:CheckInputValidity()
if not check then
ViewUtil.ShowTips(str)
return
end
ViewUtil.ShowModalWait(self._root_view,"正在提交认证...")
local loddyctr = ControllerManager.GetController(LoddyController)
local _data = {}
_data.type =1
local real_info = {}
real_info.name =self._view:GetChild("tex_name").text
real_info.identity = self._view:GetChild("tex_identity").text
_data.real_info = real_info
loddyctr:UpdateUserInfo(_data,function( res)
ViewUtil.CloseModalWait()
if (res.ReturnCode ==0) then
DataManager.SelfUser.real_info = real_info
if self._callback then self._callback() end
else
ViewUtil.ErrorTip(res.ReturnCode, "认证失败,请重试")
end
self:Close()
end)
end
function M:CheckInputValidity()
local name = self._view:GetChild("tex_name").text
local id = self._view:GetChild("tex_identity").text
if name then
local l = string.len(name)
if l == 0 then return false, "请输入名字" end
-- 中文长度是3
if l == 3 then return false, "名字过短" end
for i = 1, l do
local c = string.byte(string.sub(name, i, i))
--if not ((65 <= c and c <= 90) or (97 <= c and c <= 122) or c > 127) then
if not (c > 127) then
return false, "名字中不能包含英文、数字或特殊符号"
end
end
end
if id then
local l = string.len(id)
if l ~= 18 then return false, "请输入18位身份证号码" end
if not (tonumber(id) or string.sub(id,18,18) == "X") then
return false, "请输入正确的身份证号码"
end
end
return true
end
function M:address_action()
local tex_address = self._view:GetChild("tex_address").text
if string.len(tex_address) <=0 then
ViewUtil.ShowTips("请输入详细地址")
return
end
ViewUtil.ShowModalWait(self._root_view,"正在提交...")
local loddyctr = ControllerManager.GetController(LoddyController)
local _data = {}
_data.type =2
_data.address = tex_address
loddyctr:UpdateUserInfo(_data,function( res)
ViewUtil.CloseModalWait()
if (res.ReturnCode ==0) then
DataManager.SelfUser.address = _data.address
if self._callback then self._callback() end
else
ViewUtil.ErrorTip(res.ReturnCode,"提示失败")
end
self:Close()
end)
end
return M

View File

@ -0,0 +1,52 @@
--修改玩家昵称头像
local EditPortraitView = import(".EditPortraitView")
local EditNickView = import(".EditNickView")
local UserEditView = {}
local M = UserEditView
function UserEditView.new(callback)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "UserEditView"
self._callback = callback
self._close_destroy = true
self:init("ui://Lobby/win_user_edit")
return self
end
function M:init(url)
BaseWindow.init(self,url)
local btn_head = self._view:GetChild("btn_head")
ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
local tex_nick = self._view:GetChild("tex_nick")
tex_nick.text = DataManager.SelfUser.nick_name
local tex_id = self._view:GetChild("tex_id")
tex_id.text = string.format("玩家ID:%s", DataManager.SelfUser.account_id)
local btn_edit_nick = self._view:GetChild("btn_edit_nick")
btn_edit_nick.onClick:Set(function()
local edit_nick_view = EditNickView.new(function()
tex_nick.text = DataManager.SelfUser.nick_name
self._callback()
end)
edit_nick_view:Show()
end)
local btn_edit_portrait = self._view:GetChild("btn_edit_portrait")
btn_edit_portrait.onClick:Set(function()
-- local edit_portrait_view = EditPortraitView.new(function()
-- ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
-- --print(DataManager.SelfUser.head_url)
-- self._callback()
-- end)
-- edit_portrait_view:Show()
end)
end
return M

View File

@ -0,0 +1,79 @@
-- 同步微信信息
local WeChatView = {}
local M = WeChatView
function WeChatView.new(callback)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "WeChatView"
self._close_destroy = true
self._close_zone = true
self._callback =callback
self:init("ui://Lobby/win_user_wx")
return self
end
function M:init(url)
BaseWindow.init(self,url)
local btn_ok = self._view:GetChild("btn_ok")
btn_ok.onClick:Set(function ()
ViewUtil.ShowModalWait(self._root_view,"正在同步数据...")
GameApplication.Instance:WXLogin(handler(self,self.WXCallBack))
end)
end
function M:WXCallBack(result,data)
if (not result) or result ~= 0 then
if result == 10 then
ViewUtil.ShowModalWait(self._root_view)
return
end
ViewUtil.CloseModalWait()
return
end
if not data then
ViewUtil.CloseModalWait()
return
end
local jd = json.decode(data)
local headurl = jd["headimgurl"]
local unionid = jd["unionid"]
local sex = jd["sex"]
if (sex == 0) then sex = 1 end
local nickname = jd["nickname"]
if not unionid or string.len(unionid)<1 then
ViewUtil.CloseModalWait()
return
end
local _data = {}
_data.type =6
_data["acc"] = unionid
_data["nick"] = nickname
_data["sex"] = sex
_data["portrait"] = headurl
local loddyctr = ControllerManager.GetController(LoddyController)
loddyctr:UpdateUserInfo(_data,function( res)
ViewUtil.CloseModalWait()
if (res.ReturnCode ==0) then
local user = DataManager.SelfUser
user.acc = unionid
user.nick_name = nickname
user.sex = sex
user.head_url = headurl
if self._callback then self._callback() end
else
ViewUtil.ErrorTip(res.ReturnCode, "同步失败,请重试")
end
self:Close()
end)
end
return M

View File

@ -0,0 +1,92 @@
local deZhouCard = {
name = "德州扑克",
ts = {
name = "特色玩法",
data = { { name = "强抓" }, { name = "暴击" }, { name = "鱿鱼" }, { name = "AOF" } }
},
rank = {
name = "级别",
data = {
{ name = "微<2" },
{ name = "小 2-9" },
{ name = "中 10-99" },
{ name = "大 100+" },
{ name = "0.1/0.2" },
{ name = "1/2" },
{ name = "5/10" },
{ name = "50/100" },
{ name = "0.25/0.5" },
{ name = "2/4" },
{ name = "10/20" },
{ name = "100/200" },
{ name = "0.5/1.0" },
{ name = "3/6" },
{ name = "20/40" },
{ name = "500/1000" } }
}
}
local duanPaiCard = {
name = "短牌",
ts = {
name = "特色玩法",
data = { { name = "鱿鱼" }, { name = "AOF" } }
},
rank = {
name = "级别",
data = {
{ name = "微 <2" },
{ name = "小 1-9" },
{ name = "中 10-99" },
{ name = "大 100+" },
{ name = "0.1" },
{ name = "1" },
{ name = "10" },
{ name = "100" },
{ name = "0.2" },
{ name = "2" },
{ name = "20" },
{ name = "200" },
{ name = "0.5" },
{ name = "5" },
{ name = "50" },
{ name = "500" } }
}
}
local aomahaCard = {
name = "奥马哈",
ts = {
name = "特色玩法",
data = { { name = "强抓" }, { name = "暴击" }, { name = "鱿鱼" } }
},
rank = {
name = "级别",
data = {
{ name = "微<2" },
{ name = "小 2-9" },
{ name = "中 10-99" },
{ name = "大 100+" },
{ name = "0.1/0.2" },
{ name = "1/2" },
{ name = "5/10" },
{ name = "50/100" },
{ name = "0.25/0.5" },
{ name = "2/4" },
{ name = "10/20" },
{ name = "100/200" },
{ name = "0.5/1.0" },
{ name = "3/6" },
{ name = "20/40" },
{ name = "500/1000" } }
}
}
FilterType = {
DeZhou = 1,
DuanPai = 2,
Aomah = 3,
}
FilterData = {
[FilterType.DeZhou] = deZhouCard,
[FilterType.DuanPai] = duanPaiCard,
[FilterType.Aomah] = aomahaCard
}

View File

@ -0,0 +1,9 @@
local LobbyGame = {}
local M = LobbyGame
function LobbyGame.new(path, transform)
local self = setmetatable({}, { __index = M })
self.view = UIManager.GetGo(path, transform)
return self
end
return M

View File

@ -0,0 +1,73 @@
local LobbyHome = {}
local M = LobbyHome
function LobbyHome.new(path, transform)
local self = setmetatable({}, { __index = M })
self.view = UIManager.GetGo(path, transform)
self:init(self.view.transform)
return self
end
function M:init(view)
self.titleItemCopy = view:Find("scrollTitle/Viewport/Content/btnItem")
self.titleItemCopy.gameObject:SetActive(false)
local btnNews = view:Find("btnNews")
self.btn__activepoint = btnNews:Find("imagePoint")
btnNews = btnNews:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper.AddButtonClick(btnNews, function()
local viewTemp = UIManager.ShowUI(UIManager.ViewFilter)
viewTemp:SetList(self.aar_title[self.enumTitle.Home].page)
end)
self.aar_title = {}
self.enumTitle = {
Home = 1,
Poker = 2,
Cowboy = 3,
Short = 4,
Omaha = 5
}
self.aar_title[self.enumTitle.Home] = { title = "首页", h = 162, v = self.enumTitle.Home, page = { [1] = FilterType.DeZhou, [2] = FilterType.DuanPai, [3] = FilterType.Aomah } }
self.aar_title[self.enumTitle.Poker] = { title = "德州扑克", h = 188, v = self.enumTitle.Poker, page = { [1] = FilterType.DeZhou } }
self.aar_title[self.enumTitle.Cowboy] = { title = "德州牛仔", h = 188, v = self.enumTitle.Cowboy, page = {} }
self.aar_title[self.enumTitle.Short] = { title = "短牌", h = 162, v = self.enumTitle.Short, page = { [1] = FilterType.DuanPai } }
self.aar_title[self.enumTitle.Omaha] = { title = "奥马哈", h = 162, v = self.enumTitle.Omaha, page = { [1] = FilterType.Aomah } }
for index, value in ipairs(self.aar_title) do
local goTemp = UnityEngine.GameObject.Instantiate(self.titleItemCopy.gameObject, self.titleItemCopy.parent, false)
local rectTemp = goTemp.transform:GetComponent(typeof(UnityEngine.RectTransform))
local vecTemp = rectTemp.sizeDelta
vecTemp.y = value.h
rectTemp.sizeDelta = vecTemp
rectTemp = goTemp.transform:Find("Image")
rectTemp = rectTemp:GetComponent(typeof(UnityEngine.RectTransform))
vecTemp = rectTemp.sizeDelta
vecTemp.x = value.h
rectTemp.sizeDelta = vecTemp
rectTemp = goTemp.transform:Find("imageShow")
rectTemp = rectTemp:GetComponent(typeof(UnityEngine.RectTransform))
vecTemp = rectTemp.sizeDelta
vecTemp.x = value.h
rectTemp.sizeDelta = vecTemp
value.goSelect = rectTemp.gameObject
value.textTitle = goTemp.transform:Find("Text")
value.textTitle = value.textTitle:GetComponent(typeof(UnityEngine.UI.Text))
value.textTitle.text = value.title
goTemp:SetActive(true)
goTemp = goTemp:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(goTemp, function(val)
self:OnShowPage(val)
end, index)
end
self.selectTitle = self.enumTitle.Home
self:OnShowPage(self.selectTitle)
end
function M:OnShowPage(val)
end
return M

View File

@ -0,0 +1,10 @@
local LobbyMatch = {}
local M = LobbyMatch
function LobbyMatch.new(path, transform)
local self = setmetatable({}, { __index = M })
self.view = UIManager.GetGo(path, transform)
return self
end
return M

View File

@ -0,0 +1,96 @@
local LobbyMe = {}
local M = LobbyMe
function LobbyMe.new(path, transform)
local self = setmetatable({}, { __index = M })
self.view = UIManager.GetGo(path, transform)
self:init(self.view.transform)
return self
end
function M:init(view)
local btnHead = view:Find("btnHead")
self.iconHead = btnHead:GetComponent(typeof(UnityEngine.UI.RawImage))
ImageLoad.Load(DataManager.SelfUser.head_url, self.iconHead)
self.textName = view:Find("textUserName")
self.textName = self.textName:GetComponent(typeof(UnityEngine.UI.Text))
self.textName.text = DataManager.SelfUser.nick_name
self.textID = view:Find("textUserID")
self.textID = self.textID:GetComponent(typeof(UnityEngine.UI.Text))
self.textID.text = DataManager.SelfUser.account_id
self.textDiamond = view:Find("textDiamond")
self.textDiamond = self.textDiamond:GetComponent(typeof(UnityEngine.UI.Text))
self.textDiamond.text = DataManager.SelfUser.diamo
local btnShopUnit = view:Find("btnShopUnit")
local btnShopUnitBg = btnShopUnit:Find("imageArrow")
btnShopUnitBg = btnShopUnitBg:GetComponent(typeof(UnityEngine.UI.Image))
btnShopUnitBg.sprite = CommonUISprite:GetSprite("arrow1")
btnShopUnit = btnShopUnit:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnShopUnit, function()
UIManager.ShowUI(UIManager.ViewShop)
end)
local btnMoney = view:Find("btnMoney")
local btnMoneyBg = btnMoney:Find("imageArrow")
btnMoneyBg = btnMoneyBg:GetComponent(typeof(UnityEngine.UI.Image))
btnMoneyBg.sprite = CommonUISprite:GetSprite("arrow1")
btnMoney = btnMoney:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnMoney, function()
UIManager.ShowUI(UIManager.ViewWallet)
end)
local btnFeedback = view:Find("btnFeedback")
local btnFeedbackBg = btnFeedback:Find("imageArrow")
btnFeedbackBg = btnFeedbackBg:GetComponent(typeof(UnityEngine.UI.Image))
btnFeedbackBg.sprite = CommonUISprite:GetSprite("arrow1")
btnFeedback = btnFeedback:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnFeedback, function()
local viewOtherFeedBack = UIManager.ShowUI(UIManager.ViewOther)
viewOtherFeedBack:ShowFanKui()
end)
local btnNews = view:Find("btnNews")
local btnNewsBg = btnNews:Find("imageArrow")
btnNewsBg = btnNewsBg:GetComponent(typeof(UnityEngine.UI.Image))
btnNewsBg.sprite = CommonUISprite:GetSprite("arrow1")
btnNews = btnNews:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnNews, function()
end)
local btnLine = view:Find("btnLine")
local btnLineBg = btnLine:Find("imageArrow")
btnLineBg = btnLineBg:GetComponent(typeof(UnityEngine.UI.Image))
btnLineBg.sprite = CommonUISprite:GetSprite("arrow1")
btnLine = btnLine:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnLine, function()
end)
local btnSetting = view:Find("btnSetting")
local btnSettingBg = btnSetting:Find("imageArrow")
btnSettingBg = btnSettingBg:GetComponent(typeof(UnityEngine.UI.Image))
btnSettingBg.sprite = CommonUISprite:GetSprite("arrow1")
btnSetting = btnSetting:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnSetting, function()
end)
local btnFightInformation = view:Find("btnFightInformation")
btnFightInformation = btnFightInformation:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnFightInformation, function()
local viewOtherBattleRecord = UIManager.ShowUI(UIManager.ViewOther)
viewOtherBattleRecord:ShowBattleRecord()
end)
local btnFriendChat = view:Find("btnFrient")
btnFriendChat = btnFriendChat:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnFriendChat, function()
local viewOtherFriendChat = UIManager.ShowUI(UIManager.ViewOther)
viewOtherFriendChat:ShowFriendChat()
end)
local imageGold = view:Find("imageGold")
imageGold = imageGold:GetComponent(typeof(UnityEngine.UI.Image))
imageGold.sprite = CommonUISprite:GetSprite("gold1")
local imageDiamond = view:Find("imageDiamond")
imageDiamond = imageDiamond:GetComponent(typeof(UnityEngine.UI.Image))
imageDiamond.sprite = CommonUISprite:GetSprite("diamond1")
end
return M

View File

@ -0,0 +1,58 @@
local UnitJoin = import(".UnitJoin")
local UnitJoinNone = import(".UnitJoinNone")
local UnitJoinTable = import(".UnitJoinTable")
local UnitList = import(".UnitList")
local UnitMain = import(".UnitMain")
local LobbyUnit = {
Main = 1, --主页
JoinUnit = 2, --搜索加入
JoinNone = 3, --没有加入状态
JoinTable = 4, --创建或加入牌桌
List = 5, --俱乐部列表
}
local M = LobbyUnit
function LobbyUnit.new(path, pref, transform)
local self = setmetatable({}, { __index = M })
self.view = UIManager.GetGo(path .. pref, transform)
self.path = path
self:init(self.view.transform)
return self
end
function M:init(view)
self.subView = {}
self.subView[LobbyUnit.Main] = UnitMain.new(self.path .. "lobby/Unit/unitMain.prefab", view)
self.subView[LobbyUnit.JoinUnit] = UnitJoin.new(self.path .. "lobby/Unit/unitJoin.prefab", view)
self.subView[LobbyUnit.JoinNone] = UnitJoinNone.new(self.path .. "lobby/Unit/unitJoinNone.prefab", view)
self.subView[LobbyUnit.JoinTable] = UnitJoinTable.new(self.path .. "lobby/Unit/unitJoinTable.prefab", view)
self.subView[LobbyUnit.List] = UnitList.new(self.path .. "lobby/Unit/unitList.prefab", view)
for index, value in pairs(self.subView) do
value.LobbyUnit = LobbyUnit
value.CallBack = function(subOpen, subClose)
self:SubViewControl(subOpen, subClose)
end
end
local open = { [1] = LobbyUnit.Main }
local close = {
[1] = LobbyUnit.List,
[2] = LobbyUnit.JoinNone,
[3] = LobbyUnit.JoinTable,
[4] = LobbyUnit.JoinUnit
}
self:SubViewControl(open, close)
end
function M:SubViewControl(subOpen, subClose)
for index, value in pairs(subOpen) do
self.subView[value].view.gameObject:SetActive(true)
end
for index, value in pairs(subClose) do
self.subView[value].view.gameObject:SetActive(false)
end
end
return M

View File

@ -0,0 +1,15 @@
local UnitJoin = {}
local M = UnitJoin
function UnitJoin.new(path, transform)
local self = setmetatable({}, { __index = M })
self.view = UIManager.GetGo(path, transform)
self:init(self.view.transform)
return self
end
function M:init(view)
end
return M

View File

@ -0,0 +1,35 @@
local UnitJoinNone = {}
local M = UnitJoinNone
function UnitJoinNone.new(path, transform)
local self = setmetatable({}, { __index = M })
self.view = UIManager.GetGo(path, transform)
self:init(self.view.transform)
return self
end
function M:init(view)
local btnCreateUnit = view:Find("imageUnitHead/btnCreate")
btnCreateUnit = btnCreateUnit:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnCreateUnit, function()
UIManager.ShowUI(UIManager.ViewCreateUnit)
end)
local btnJoinUnit = view:Find("imageUnitHead/btnJoin")
btnJoinUnit = btnJoinUnit:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnJoinUnit, function()
UIManager.ShowUI(UIManager.ViewCreateUnit)
end)
local btnCreateTable = view:Find("btnCreate")
btnCreateTable = btnCreateTable:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnCreateTable, function()
UIManager.ShowUI(UIManager.ViewCreateCardGame)
end)
local btnJoinTable = view:Find("btnJoin")
btnJoinTable = btnJoinTable:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnJoinTable, function()
end)
end
return M

View File

@ -0,0 +1,28 @@
local UnitJoinTable = {}
local M = UnitJoinTable
function UnitJoinTable.new(path, transform)
local self = setmetatable({}, { __index = M })
self.view = UIManager.GetGo(path, transform)
self:init(self.view.transform)
return self
end
function M:init(view)
self.bg = view:Find("btnBG")
self.bg = self.bg:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(self.bg, function()
local open = { [1] = self.LobbyUnit.Main }
local close = {
[1] = self.LobbyUnit.List,
[2] = self.LobbyUnit.JoinNone,
[3] = self.LobbyUnit.JoinTable,
[4] = self.LobbyUnit.JoinUnit
}
self.CallBack(open, close)
end)
end
return M

View File

@ -0,0 +1,42 @@
local UnitList = {}
local M = UnitList
function UnitList.new(path, transform)
local self = setmetatable({}, { __index = M })
self.view = UIManager.GetGo(path, transform)
self:init(self.view.transform)
return self
end
function M:init(view)
local btnBack = view:Find("btnBack")
local unit_list_btnBackBg = btnBack:GetComponent(typeof(UnityEngine.UI.Image))
unit_list_btnBackBg.sprite = CommonUISprite:GetSprite("arrow1")
btnBack = btnBack:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnBack, function()
local open = { [1] = self.LobbyUnit.Main }
local close = {
[1] = self.LobbyUnit.List,
[2] = self.LobbyUnit.JoinNone,
[3] = self.LobbyUnit.JoinTable,
[4] = self.LobbyUnit.JoinUnit
}
self.CallBack(open, close)
end)
local btnJoin = view:Find("btnJoin")
btnJoin = btnJoin:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnJoin, function()
local open = {}
local close = {
[1] = self.LobbyUnit.List,
[2] = self.LobbyUnit.JoinNone,
[3] = self.LobbyUnit.JoinTable,
[4] = self.LobbyUnit.JoinUnit,
[5] = self.LobbyUnit.Main
}
self.CallBack(open, close)
end)
end
return M

View File

@ -0,0 +1,155 @@
local UnitMain = {}
local M = UnitMain
function UnitMain.new(path, transform)
local self = setmetatable({}, { __index = M })
self.view = UIManager.GetGo(path, transform)
self:init(self.view.transform)
return self
end
function M:init(view)
local btnNews = view:Find("btnNews")
local btnNewsbg = btnNews:GetComponent(typeof(UnityEngine.UI.Image))
btnNewsbg.sprite = CommonUISprite:GetSprite("new1")
self.btnNews_activepoint = btnNews:Find("imagePoint")
self.btnNews_activepoint = self.btnNews_activepoint:GetComponent(typeof(UnityEngine.UI.Image))
self.btnNews_activepoint.sprite = CommonUISprite:GetSprite("activepoint")
btnNews = btnNews:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnNews, function()
end)
local btnInfor = view:Find("btnInfor")
local btnInforBg = btnInfor:GetComponent(typeof(UnityEngine.UI.Image))
btnInforBg.sprite = CommonUISprite:GetSprite("list1")
self.btnInfor_activepoint = btnInfor:Find("imagePoint")
self.btnInfor_activepoint = self.btnInfor_activepoint:GetComponent(typeof(UnityEngine.UI.Image))
self.btnInfor_activepoint.sprite = CommonUISprite:GetSprite("activepoint")
btnInfor = btnInfor:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnInfor, function()
end)
local btnChange = view:Find("btnChange")
btnChange = btnChange:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnChange, function()
local open = { [1] = self.LobbyUnit.List }
local close = {
[1] = self.LobbyUnit.Main,
[2] = self.LobbyUnit.JoinUnit,
[3] = self.LobbyUnit.JoinNone,
[4] = self.LobbyUnit.JoinTable
}
self.CallBack(open, close)
end)
local btnPrivate = view:Find("btnPrivate")
btnPrivate = btnPrivate:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnPrivate, function()
local open = { [1] = self.LobbyUnit.JoinTable, [2] = self.LobbyUnit.Main }
local close = {
[1] = self.LobbyUnit.List,
[2] = self.LobbyUnit.JoinNone,
[3] = self.LobbyUnit.JoinUnit
}
self.CallBack(open, close)
end)
local btnCreate = view:Find("btnCreate")
btnCreate = btnCreate:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnCreate, function()
UIManager.ShowUI(UIManager.ViewCreateCardGame)
end)
local btnEnter = view:Find("friends/btnEnter")
local btnEnterbg = btnEnter:GetComponent(typeof(UnityEngine.UI.Image))
btnEnterbg.sprite = CommonUISprite:GetSprite("arrow1")
btnEnter = btnEnter:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnEnter, function()
end)
local btnFilter = view:Find("btnFilter")
local btnFilterbg = btnFilter:GetComponent(typeof(UnityEngine.UI.Image))
btnFilterbg.sprite = CommonUISprite:GetSprite("filter1")
btnFilter = btnFilter:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnFilter, function()
end)
self.ItemCopy = view:Find("scroll/Viewport/Content/btnItem")
local btnCopy = self.ItemCopy:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnCopy, function()
local vTemp = UIManager.ShowUI(UIManager.ViewGame)
end)
self.titleItemCopy = view:Find("imageFilter/scroll/Viewport/Content/btnItem")
self.titleItemCopy.gameObject:SetActive(false)
self.aar_title = {}
self.enumTitle = {
Home = 1,
Poker = 2,
Cowboy = 3,
Short = 4,
Omaha = 5
}
self.aar_title[self.enumTitle.Home] = { title = "首页", h = 162, v = self.enumTitle.Home }
self.aar_title[self.enumTitle.Poker] = { title = "德州扑克", h = 188, v = self.enumTitle.Poker }
self.aar_title[self.enumTitle.Cowboy] = { title = "德州牛仔", h = 188, v = self.enumTitle.Cowboy }
self.aar_title[self.enumTitle.Short] = { title = "短牌", h = 162, v = self.enumTitle.Short }
self.aar_title[self.enumTitle.Omaha] = { title = "奥马哈", h = 162, v = self.enumTitle.Omaha }
for index, value in ipairs(self.aar_title) do
local goTemp = UnityEngine.GameObject.Instantiate(self.titleItemCopy.gameObject, self.titleItemCopy.parent, false)
goTemp:SetActive(true)
local rectTemp = goTemp.transform:GetComponent(typeof(UnityEngine.RectTransform))
local vecTemp = rectTemp.sizeDelta
vecTemp.y = value.h
rectTemp.sizeDelta = vecTemp
value.text = goTemp.transform:Find("Text")
value.Animator = value.text:GetComponent(typeof(UnityEngine.Animator))
value.Animator:Play("stop", -1, 0)
value.text = value.text:GetComponent(typeof(UnityEngine.UI.Text))
value.text.text = value.title
goTemp = goTemp:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(goTemp, function(val)
self:OnShowPage(val)
end, index)
end
self.selectTitle = self.enumTitle.Home
self:OnShowPage(self.selectTitle)
print("??" .. self.selectTitle)
end
function M:OnShowPage(val)
for index, value in ipairs(self.aar_title) do
if value.v == val then
local scaleTemp1 = LuaUIHelper:GetAnimatorAormalizedTime(value.Animator, true)
local scaleTemp2 = 0
if not LuaUIHelper:GetAnimatorIsName(self.aar_title[val].Animator, "open") then
if scaleTemp1 > 1 then
scaleTemp1 = 1
scaleTemp2 = 1
end
self.aar_title[val].Animator:Play("open", -1, 1 - scaleTemp1)
if self.aar_title[self.selectTitle] then
if not LuaUIHelper:GetAnimatorIsName(self.aar_title[self.selectTitle].Animator, "open") then
self.aar_title[self.selectTitle].Animator:Play("close", -1, 1 - scaleTemp2)
end
end
else
self.aar_title[val].Animator:Play("open", -1, 0.5)
end
else
if LuaUIHelper:GetAnimatorIsName(value.Animator, "open") then
local scaleTemp3 = LuaUIHelper:GetAnimatorAormalizedTime(value.Animator, true)
if scaleTemp3 > 1 then
scaleTemp3 = 1
end
value.Animator:Play("close", -1, 1 - scaleTemp3)
end
end
end
self.selectTitle = val
end
return M

View File

@ -0,0 +1,516 @@
--大厅View对象
--author--
local CreateRoomView = import(".Lobby.CreateRoomView")
local JoinRoomView = import(".Lobby.JoinRoomView")
local LobbySettingView = import(".Lobby.LobbySettingView")
local RankView = import(".Lobby.RankView")
local GroupMainView = import(".NewGroup.GroupMainView")
local NoticeView = import(".Lobby.NoticeView")
local HeadView = import(".Lobby.LobbyHeadView")
local PhoneBindView = import(".Lobby.PhoneBindView")
local RealAddressView = import(".Lobby.RealAddressView")
local LobbyHeadView = import(".Lobby.LobbyHeadView")
local LobbyGame = import(".LobbyNew.LobbyGame")
local LobbyHome = import(".LobbyNew.LobbyHome")
local LobbyMatch = import(".LobbyNew.LobbyMatch")
local LobbyMe = import(".LobbyNew.LobbyMe")
local LobbyUnit = import(".LobbyNew.LobbyUnit")
LobbyView = {
Game = 4,
Home = 3,
Match = 2,
Me = 5,
Unit = 1
}
local M = {}
function LobbyView.new()
setmetatable(M, { __index = BaseView })
local self = setmetatable({}, { __index = M })
self.class = "LobbyView"
self.lobby_pause_time = 0
self._full = true
return self
end
function M:init(url)
local view = self._view
local bg = view.transform:GetComponent(typeof(UnityEngine.UI.Image))
bg.sprite = CommonUISprite:GetSprite("bg1")
self.isJoinPlay = true
self.imagePoint = view.transform:Find("imagePoint")
self.aar_subView = {}
local localView = view.transform:Find("sub")
self.aar_subView.down = view.transform:Find("down")
self.aar_subView[LobbyView.Game] = LobbyGame.new(self.path .. "lobby/lobbyGame.prefab", localView)
self.aar_subView[LobbyView.Home] = LobbyHome.new(self.path .. "lobby/lobbyHome.prefab", localView)
self.aar_subView[LobbyView.Match] = LobbyMatch.new(self.path .. "lobby/lobbyMatch.prefab", localView)
self.aar_subView[LobbyView.Me] = LobbyMe.new(self.path .. "lobby/lobbyMe.prefab", localView)
self.aar_subView[LobbyView.Unit] = LobbyUnit.new(self.path, "lobby/lobbyUnit.prefab", localView)
self.down_arrBtnDown = {}
for i = 1, self.aar_subView.down.childCount do
self.down_arrBtnDown[i] = {}
local temp = self.down_arrBtnDown[i]
local down_btnTemp = self.aar_subView.down:GetChild(i - 1)
temp.AnimatorCircle = down_btnTemp:Find("circle")
temp.AnimatorCircle = temp.AnimatorCircle:GetComponent(typeof(UnityEngine.Animator))
temp.AnimatorCircle:Play("stop", -1, 0)
temp.AnimatorMax = down_btnTemp:Find("max")
temp.AnimatorMax = temp.AnimatorMax:GetComponent(typeof(UnityEngine.Animator))
temp.AnimatorMax:Play("stop", -1, 0)
down_btnTemp = down_btnTemp:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(down_btnTemp, function(btnVar)
self:ShowPage(btnVar)
end, i)
end
for index, value in pairs(self.aar_subView) do
if type(value) == "table" then
value.view:SetActive(false)
end
end
self.down_selectbtn = 3
self:ShowPage(self.down_selectbtn)
if true then
return
end
-- print("init lobbyView!!!!")
BaseView.InitView(self, url)
self._full_offset = false
local view = self._view
local btn_head = view:GetChild("btn_head")
ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
btn_head.onClick:Set(function()
-- local headView = HeadView.new(DataManager.SelfUser, nil, function()
-- view:GetChild("tex_name").text = DataManager.SelfUser.nick_name
-- ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
-- end)
-- headView:Show()
local lobbyHeadView = LobbyHeadView.new(DataManager.SelfUser, DataManager.SelfUser.agent, function()
ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
end)
lobbyHeadView:Show()
end)
local btn_teamwork = view:GetChild("btn_teamwork")
btn_teamwork.onClick:Set(function()
-- local headView = HeadView.new(DataManager.SelfUser, nil, function()
-- view:GetChild("tex_name").text = DataManager.SelfUser.nick_name
-- ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
-- end)
-- headView:Show()
local lobbyHeadView = LobbyHeadView.new(DataManager.SelfUser, DataManager.SelfUser.agent, function()
ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
end)
lobbyHeadView:Show()
end)
view:GetChild("tex_name").text = DataManager.SelfUser.nick_name
view:GetChild("tex_id").text = tostring(DataManager.SelfUser.account_id)
view:GetChild("gcm_diamo").text = tostring(DataManager.SelfUser.diamo)
local btn_joinroom = self._view:GetChild("btn_joinroom")
btn_joinroom.onClick:Add(handler(self, self.OnJoinRoomAction))
--btn_joinroom.displayObject.gameObject:SetActive(false)
local createRoomBtn = self._view:GetChild("btn_ChuangJian")
createRoomBtn.touchable = true
createRoomBtn.onClick:Set(function()
local _createRoomView = CreateRoomView.new(1)
_createRoomView.onCeateRoom = function()
ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id)
end
_createRoomView:Show()
end)
local btn_agent = self._view:GetChild("btn_agent")
--[[ btn_agent.onClick:Set(function()
local headView = HeadView.new(DataManager.SelfUser,true)
headView:Show()
end)--]]
btn_agent.displayObject.gameObject:SetActive(false)
local btn_record = self._view:GetChild("btn_record")
btn_record.onClick:Add(handler(self, function()
local _rankView = RankView.new(self, true)
_rankView:Show()
end))
--btn_record.displayObject.gameObject:SetActive(false)
local btn_video = self._view:GetChild("btn_video")
--[[btn_video.onClick:Set(function ()
local _rankView = RankView.new(self,true)
_rankView:Show()
end)--]]
btn_video.displayObject.gameObject:SetActive(false)
local btn_setting = self._view:GetChild("btn_setting")
btn_setting.onClick:Set(handler(self, function()
local settingView = LobbySettingView.new()
settingView:Show()
end))
local btn_exit = self._view:GetChild("btn_exit")
btn_exit.onClick:Set(handler(self, function()
local _curren_msg = MsgWindow.new(self._root_view, '确认退出游戏', MsgWindow.MsgMode.OkAndCancel)
_curren_msg.onOk:Add(function()
Application.Quit()
end)
_curren_msg:Show()
end))
local lst_userBG = self._view:GetChild("n118")
lst_userBG.displayObject.gameObject:SetActive(false)
local lst_user = self._view:GetChild("lst_user")
lst_user.displayObject.gameObject:SetActive(false)
--[[ lst_user.onClickItem:Set(function (context)
if context.data.name == "real" then
local real_view = RealAddressView.new(0)
real_view:Show()
elseif context.data.name == "address" then
local real_view = RealAddressView.new(1)
real_view:Show()
elseif context.data.name == "phone" then
local phone_view = PhoneBindView.new()
phone_view:Show()
end
end)--]]
-- self:__ShowShare()
local btn_notice = self._view:GetChild("btn_notice")
--[[ btn_notice.onClick:Set(function()
local noticeView = NoticeView.new(self._root_view)
noticeView:FillData(DataManager.SelfUser.notices.data)
noticeView:Show()
end)
--]]
btn_notice.displayObject.gameObject:SetActive(false)
local btn_service = self._view:GetChild("btn_service")
--[[btn_service.onClick:Set(function()
self:__show_service()
end)--]]
btn_service.displayObject.gameObject:SetActive(false)
self.groupMainView = GroupMainView.new(self._view:GetChild("group"), self._root_view, self._view)
--self.groupMainView:Show()
local btn_more_group = self._view:GetChild("btn_more_group")
btn_more_group.onClick:Set(function()
--self.groupMainView._view.visible = true
ViewUtil.ShowModalWait(self._root_view, "请稍等,获取牌友圈中...")
local enterGroupCallBackFunc = function(code)
ViewUtil.CloseModalWait()
if code == 0 then
self.groupMainView._view.visible = true
else
ViewUtil.ErrorTip(10000000, "获取牌友圈失败,请检查网络设置!")
printlog("获取圈子数据失败=======>>>>")
end
end
self.groupMainView:Show(nil, enterGroupCallBackFunc)
end)
-- local btn_more_group = self._view:GetChild("btn_more_group")
-- btn_more_group.touchable = true
-- btn_more_group.onClick:Set(function()
-- local groups = DataManager.groups.groupList
-- if #groups == 0 then
-- self.groupMainView._view.visible = true
-- self.groupMainView:Show()
-- -- if not DataManager.SelfUser.phone then
-- -- local phone_view = PhoneBindView.new()
-- -- phone_view:Show()
-- -- return
-- -- end
-- else
-- self.groupMainView:DEnterGroup()
-- end
-- --self.groupMainView:DEnterGroup()
-- end)
-- self.btn_joingroup.onClick:Set(function()
-- local groups = DataManager.groups.groupList
-- if #groups == 0 then
-- local jgv = JoinGroupView.new(self._root_view)
-- jgv:Show()
-- else
-- local info = GroupInfoView.new(groups[1], self.fg_info)
-- self._groupInfoView = info
-- info:SetCallBack(function()
-- self._groupInfoView = nil
-- self:Show()
-- self._view.visible = true
-- end)
-- info:Show()
-- self._view.visible = false
-- end
-- if not DataManager.SelfUser.phone then
-- --local phone_view = PhoneBindView.new()
-- --phone_view:Show()
-- -- return
-- end
-- end)
-- self.btn_joingroup.touchable = true
local lst_game = self._view:GetChild("lst_game")
lst_game.displayObject.gameObject:SetActive(false)
--[[local games = DataManager.SelfUser.games
for i = 1, math.min( 4,#games ) do
local tem = games[i]
local item = lst_game:AddItemFromPool()
item.text = tem.name
local config = ExtendManager.GetExtendConfig(tem.game_id)
config.game_data = tem
local mode = config:GetGameInfo()
item.icon = mode:GetIconUrl()
item.onClick:Set(function ()
local _createRoomView = CreateRoomView.new(i)
_createRoomView.onCeateRoom = function ()
ViewManager.ChangeView(ViewManager.View_Main,DataManager.CurrenRoom.game_id)
end
_createRoomView:Show()
end)
end--]]
local message = self._view:GetChild("com_message")
--message.visible = true
self._message = message:GetChild("message")
self._tex_message = self._message:GetChild("tex_message")
self:__GetMessage()
end
function M:ShowPage(btnVar)
self.down_arrBtnDown[self.down_selectbtn].AnimatorMax:Play("close", -1, 0)
self.aar_subView[self.down_selectbtn].view:SetActive(false)
self.down_selectbtn = btnVar
self.down_arrBtnDown[btnVar].AnimatorCircle:Play("open", -1, 0)
self.down_arrBtnDown[btnVar].AnimatorMax:Play("open", -1, 0)
self.aar_subView[btnVar].view:SetActive(true)
self.aar_subView[btnVar].position = self.imagePoint.position
local Unit = self.aar_subView[LobbyView.Unit]
if btnVar == 1 then
if self.isJoinPlay then
Unit.subView[Unit.Main].view:SetActive(true)
Unit.subView[Unit.JoinNone].view:SetActive(false)
else
Unit.subView[Unit.Main].view.gameObject:SetActive(false)
Unit.subView[Unit.JoinNone].view.gameObject:SetActive(true)
end
Unit.subView[Unit.List].view:SetActive(false)
Unit.subView[Unit.JoinUnit].view:SetActive(false)
elseif btnVar == 2 then
elseif btnVar == 3 then
elseif btnVar == 4 then
elseif btnVar == 5 then
end
end
function M:OnJoinRoomAction(context)
local joinRoomView = JoinRoomView.new(self._root_view)
joinRoomView:Show()
end
function M:__show_service()
local _buy_win = BaseWindow.new("ui://Lobby/Win_service", self._root_view)
_buy_win:Show()
local sview = _buy_win._view
local btn_copy = sview:GetChild("btn_copy")
btn_copy.onClick:Set(function()
GameApplication.Instance:CopyToClipboard("xbkf888108") --湘北
_buy_win:Destroy()
end)
end
function M:__GetMessage(data)
if not data or not data.notice_list then
self._mesList = ""
else
local message = self._view:GetChild("com_message")
message.visible = true
local mesl = {}
for i = 1, #data.notice_list do
mesl[i] = data.notice_list[i].informContent
end
self._mesList = mesl
end
self:__moveMsg(0)
end
function M:__PopMsg(index)
local num = #self._mesList
index = index + 1
if index > num then index = 1 end
local str = tostring(self._mesList[index])
if str == nil or str == "nil" then str = "" end
return index, string.gsub(str, "\r", "")
end
function M:__moveMsg(index)
if not self._tex_message then return end
index, self._tex_message.text = self:__PopMsg(index)
self._tex_message.x = self._message.width
if self._mesTw then
TweenUtils.Kill(self._mesTw)
end
local change = -self._message.width * 2
local dd = self._tex_message.width / self._message.width
if dd < 1 then dd = 1 end
self._mesTw = TweenUtils.TweenFloat(0, 1 * dd, 10 * dd, function(value)
self._tex_message.x = self._message.width + (change * value)
end)
TweenUtils.OnComplete(self._mesTw, function()
self._mesTw = nil
if (#self._mesList == 0) then
self:__GetMessage()
else
self:__PopMsg(index)
self:__moveMsg(index)
end
end)
end
function M:__ShowShare()
local pop_share = self._view:GetChild("pop_share")
local shareUrl = GetGameInfo("invite_link") .. "?uid=" .. DataManager.SelfUser.account_id
local btn_wx_session = pop_share:GetChild("btn_wx_session")
btn_wx_session.onClick:Add(function()
shareQRCodePicture(shareUrl, 0)
end)
local btn_wx_line = pop_share:GetChild("btn_wx_line").asButton
btn_wx_line.onClick:Add(function()
shareQRCodePicture(shareUrl, 1)
end)
end
function M:OnUpdate()
local roomid = GameApplication.Instance:GetRoomID()
if roomid and string.len(roomid) > 1 then
ControllerManager.WebClient:clearActionQueue()
local joinRoomView = JoinRoomView.new(self._root_view)
joinRoomView:JoinRoom(roomid)
end
end
function M:Close()
BaseView.Close(self)
UpdateBeat:Remove(self.OnUpdate, self)
coroutine.stopAll()
if self._mesTw then
TweenUtils.Kill(self._mesTw)
end
BaseWindow.DestroyAll()
DSTweenManager.ClearTween()
end
function M:Destroy()
UpdateBeat:Remove(self.OnUpdate, self)
if self._mesTw then
TweenUtils.Kill(self._mesTw)
end
self._tex_message = nil
coroutine.stopAll()
BaseView.Destroy(self)
BaseWindow.DestroyAll()
DSTweenManager.ClearTween()
end
function M:Show()
BaseView.Show(self)
ViewUtil.PlaySoundBg()
UpdateBeat:Add(self.OnUpdate, self)
-- 如果在圈子内的房间显示tip
local user = DataManager.SelfUser
local tem = user.notices
if user.group_id ~= 0 then
local msg_tip = MsgWindow.new(self._root_view, "还在圈子的房间中,现在重连吗?", MsgWindow.MsgMode.OkAndCancel)
msg_tip.onOk:Add(function()
if self.groupMainView ~= nil then
self.groupMainView:Show(user.group_id)
end
end)
msg_tip:Show()
tem.auto_show = false
else
local lobbyCtr1 = ControllerManager.GetController(LoddyController)
lobbyCtr1:UpdateNotice(DataManager.SelfUser.account_id, function(result, data)
if result then
self:__GetMessage(data)
end
end)
end
local loddyCtr1 = ControllerManager.GetController(LoddyController)
self:GetPlayerInfoData()
-- 获取GPS坐标
if not DataManager.SelfUser.location or DataManager.SelfUser.location:Location2String() == "" then
get_gps()
end
if self.groupMainView and self.groupMainView._groupInfoView then
self.groupMainView._groupInfoView:hidePipei()
end
end
function M:GetPlayerInfoData()
local loddyCtr1 = ControllerManager.GetController(LoddyController)
loddyCtr1:UpdatePlayerInfo(function(result, data)
if result then
self:ShowPlayerInfo(data.raffle, data.diamo, data.newMail)
end
end)
end
function M:ShowPlayerInfo(raffle, diamo, newMail)
self._view:GetChild("gcm_diamo"):GetChild("title").text = diamo or 0
end
function M:OnApplicationPause()
ControllerManager.WebClient:clearActionQueue()
-- 切后台时间
if DataManager.SelfUser.cur_group then
self.lobby_pause_time = os.time()
DataManager.SelfUser.cur_group.pause = true
end
end
function M:OnApplicationActive()
ControllerManager.WebClient:clearActionQueue()
self:GetPlayerInfoData()
-- 切后台太久牌友圈重连
if DataManager.SelfUser.cur_group then
DataManager.SelfUser.cur_group.pause = false
if os.time() - self.lobby_pause_time > 15 then
self.lobby_pause_time = os.time()
DataManager.SelfUser.cur_group:Reconnect()
end
end
end

View File

@ -0,0 +1,256 @@
local PhoneLoginView = import(".PhoneLoginView")
LoginView = {}
local M = {}
--- Create a new LoginView
function LoginView.new()
setmetatable(M, { __index = BaseView })
local self = setmetatable({}, { __index = M })
self.class = "LoginView"
self._full = true
self:init()
return self
end
---
--@function [parent=#LoginView] init
--@param self
function M:init()
UIPackage.AddPackage("base/login/ui/Login")
--UIPackage.AddPackage("UI/Card")
ViewUtil.PlaySoundBg()
self:InitView("ui://Login/Main")
local view = self._view
view:GetChild("tex_version").text = "Version" .. GetGameInfoPlatform("version")
-- print(GameApplication.Instance.accountTest and 1 or 0)
view:GetController("test").selectedIndex = GameApplication.Instance.accountTest and 1 or 0
-- Utils.LoadBg("loginbg", view)
if GameApplication.Instance.accountTest then
local json_data = Utils.LoadLocalFile("userId")
if json_data then
local _data = json.decode(json_data)
view:GetChild("tex_unionid").text = _data.userId
end
end
local _btn_login = view:GetChild("btn_wx")
_btn_login.onClick:Add(function()
ViewUtil.ShowModalWait(self._root_view, "正在登录游戏...")
coroutine.start(function()
coroutine.wait(8)
if self.isWXCallBackMark then
return
end
ViewUtil.CloseModalWait()
ViewUtil.ErrorTip(10000, "微信登录失败!")
end)
if (not GameApplication.Instance.accountTest) then
GameApplication.Instance:WXLogin(handler(self, self.LoginCallBack))
else
--local ctr_user = view:GetController("user")
local _tex_unionid = view:GetChild("tex_unionid")
local utez = _tex_unionid.text --.. (ctr_user.selectedIndex + 1)
local _data = {}
_data["userId"] = utez
local key = "userId"
local s, e = pcall(function()
Utils.SaveLocalFile(key, json.encode(_data))
end)
if not s then
print("Error:" .. e)
end
DataManager.SelfUser.acc = utez
DataManager.SelfUser.nick_name = utez
DataManager.SelfUser.sex = 1
DataManager.SelfUser.head_url = ""
self:LoginCallBack(0)
end
end)
local btn_phone = view:GetChild("btn_phone")
btn_phone.onClick:Set(function()
self:PhoneLogin()
end)
end
function M:Destroy()
if self._agreement then
self._agreement:Destroy()
end
BaseView.Destroy(self)
end
function M:Show()
BaseView.Show(self)
self:QuickLogin()
end
local function __goto_lobby(response)
if response.Data then
local notices = response.Data.notice_list
if notices and #notices > 0 then
local tem = {}
tem.data = notices
tem.auto_show = true
DataManager.SelfUser.notices = tem
end
end
ControllerManager.ChangeController(LoddyController)
ViewManager.ChangeView(ViewManager.View_Lobby)
end
local function __join_room(roomid, res)
local loddyctr = ControllerManager.GetController(LoddyController)
loddyctr:JoinRoom(roomid, function(res1)
ViewUtil.CloseModalWait()
if res1.ReturnCode == -2 then
__join_room(roomid, res)
elseif res1.ReturnCode == 0 then
ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id)
elseif res1.ReturnCode == 101 or res1.ReturnCode == 6 then
__goto_lobby(res)
else
ViewUtil.ErrorTip(res1.ReturnCode, "登录失败!")
end
end)
end
local function __login_response(self, response)
ViewUtil.CloseModalWait()
local skey = "session_id"
if (response.ReturnCode == 0) then
local user = DataManager.SelfUser
-- if (user.guild) then
ExtendManager.Destroy()
local function f_enterLobby(...)
-- body
local _client = ControllerManager.WebClient
PlayerPrefs.SetString(skey, _client:getSession())
PlayerPrefs.Save()
ExtendManager.Init(user.games)
local roomid = user.room_id
if (string.len(roomid) > 1) then
if user.group_id == 0 then
ViewUtil.ShowModalWait(self._root_view, "正在加入房间...")
__join_room(roomid, response)
return
end
end
__goto_lobby(response)
end
if user.update ~= 0 then
ExtendHotupdate.UpdateGameList(user.games, f_enterLobby)
else
f_enterLobby()
end
else
if (response.ReturnCode == Table_Error_code.ERR_SERVER or response.ReturnCode == Table_Error_code.ERR_LOGOUT) then
PlayerPrefs.DeleteKey(skey)
PlayerPrefs.Save()
end
ViewUtil.ErrorTip(response.ReturnCode, "登录失败!")
end
end
function M:PhoneLogin()
local _phoneView = nil
_phoneView = PhoneLoginView.new(function(res)
if res.ReturnCode == 0 then
_phoneView:Destroy()
end
__login_response(self, res)
end)
_phoneView:Show()
end
function M:IDLogin()
local _idView = nil
_idView = IDLoginView.new(function(res)
if res.ReturnCode == 0 then
_idView:Destroy()
end
__login_response(self, res)
end)
_idView:Show()
end
function M:QuickLogin()
if (not GameApplication.Instance.accountTest) then
local session_id = PlayerPrefs.GetString("session_id")
print("session_id:" .. session_id)
if session_id and string.len(session_id) > 3 then
ViewUtil.ShowModalWait(self._root_view, "正在登录游戏...")
local loginCtr = ControllerManager.GetController(LoginController)
loginCtr:QuickLogin(session_id, function(response)
__login_response(self, response)
end)
end
end
end
function M:LoginCallBack(result, data)
self.isWXCallBackMark = true
print("微信登录返回================================================================")
print("jefe:result===>" .. result)
--pt(data)
if (not result) or result ~= 0 then
if result == 10 then
ViewUtil.ShowModalWait(self._root_view)
return
end
ViewUtil.CloseModalWait()
return
end
print("jefe data:", data)
if data then
local jd = json.decode(data)
pt(jd)
local headurl = jd["headimgurl"]
local unionid = jd["unionid"]
local sex = jd["sex"]
if (sex == 0) then sex = 1 end
local nickname = jd["nickname"]
DataManager.SelfUser.acc = unionid
DataManager.SelfUser.nick_name = nickname
DataManager.SelfUser.sex = sex
DataManager.SelfUser.head_url = headurl
if not DataManager.SelfUser.acc or string.len(DataManager.SelfUser.acc) < 1 then
ViewUtil.CloseModalWait()
return
end
end
local loginCtr = ControllerManager.GetController(LoginController)
loginCtr:Login(function(response)
__login_response(self, response)
end)
end
function M:Destroy()
BaseView.Destroy(self)
-- UIPackage.RemovePackage("base/embed/ui/Hotupdate")
UIPackage.RemovePackage("base/login/ui/Login")
-- ResourcesManager.UnLoad("base/ui/Login.bytes")
end

View File

@ -0,0 +1,597 @@
local PhoneLoginView = import(".PhoneLoginView")
LoginViewNew = {}
local M = {}
--- Create a new LoginViewNew
function LoginViewNew.new()
setmetatable(M, { __index = BaseView })
local self = setmetatable({}, { __index = M })
self.class = "LoginViewNew"
self._full = true
-- self:init()
return self
end
---
--@function [parent=#LoginViewNew] init
--@param self
function M:init()
-- UIPackage.AddPackage("base/login/ui/Login")
--UIPackage.AddPackage("UI/Card")
ViewUtil.PlaySoundBg()
-- self:InitView("ui://Login/Main")
-- self:InitView("base/prefab/ViewLogin.prefab", "base/prefab/ViewLogin")
local view = self._view
local bg = view.transform:GetComponent(typeof(UnityEngine.UI.Image))
bg.sprite = CommonUISprite:GetSprite("bg1")
self.login = view.transform:Find("login")
self.forget_password = view.transform:Find("forget_password")
self.iphone_message = view.transform:Find("iphone_message")
self.setpassword = view.transform:Find("setpassword");
self.register = view.transform:Find("register")
self.login.position = view.transform.position
self.forget_password.position = view.transform.position
self.iphone_message.position = view.transform.position
self.setpassword.position = view.transform.position
self.register.position = view.transform.position
self.login.gameObject:SetActive(true)
self.forget_password.gameObject:SetActive(false)
self.iphone_message.gameObject:SetActive(false)
self.setpassword.gameObject:SetActive(false)
self.register.gameObject:SetActive(false)
local btnChange = view.transform:Find("btnChange")
btnChange = btnChange:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnChange, function()
if LanguageManager.GetLanguageType() == LanguageManager.ChineseSim then
LanguageManager.SetLanaguageType(LanguageManager.English)
elseif LanguageManager.GetLanguageType() == LanguageManager.English then
LanguageManager.SetLanaguageType(LanguageManager.ChineseSim)
end
end)
self.login_btnAgree = {}
self.login_btnAgree.btn = self.login:Find("agreement/btnUserAgreement")
self.login_btnAgree.sprites = self.login_btnAgree.btn:GetComponent("LuaUIHelperSprite")
self.login_btnAgree.sprites = self.login_btnAgree.sprites:GetSprites()
self.login_btnAgree.img = self.login_btnAgree.btn:GetComponent(typeof(UnityEngine.UI.Image))
self.login_agreement = {}
self.login_agreement.sprites = self.login:Find("agreement/Image")
self.login_agreement.img = self.login_agreement.sprites:GetComponent(typeof(UnityEngine.UI.Image))
self.login_agreement.sprites = self.login_agreement.sprites:GetComponent("LuaUIHelperSprite")
self.login_agreement.sprites = self.login_agreement.sprites:GetSprites()
self.login_inputemail = self.login:Find("input_email")
self.login_inputemail = self.login_inputemail:GetComponent(typeof(UnityEngine.UI.InputField))
self.login_inputiphone = self.login:Find("input_iphone")
self.login_inputiphone = self.login_inputiphone:GetComponent(typeof(UnityEngine.UI.InputField))
self.login_inputpassword = self.login:Find("inputpassword")
self.login_inputpassword = self.login_inputpassword:GetComponent(typeof(UnityEngine.UI.InputField))
if PlayerPrefs.HasKey("account") then
self.login_inputiphone.text = PlayerPrefs.GetString("account")
self.login_inputpassword.text = PlayerPrefs.GetString("passwd")
end
self.LoginType = 1
self.arr_btnlogin = {}
self.arr_btnlogin[1] = {}
self.arr_btnlogin[2] = {}
self.arr_btnlogin[1].vec = { [1] = { x = 293, y = 36 }, [2] = { x = 340, y = 36 } }
self.arr_btnlogin[2].vec = { [1] = { x = 293, y = 36 }, [2] = { x = 315, y = 36 } }
local login_btnLoginIphone = self.login:Find("btnLoginIphone")
self.arr_btnlogin[1].Animator = login_btnLoginIphone:GetComponent(typeof(UnityEngine.Animator))
self.arr_btnlogin[1].sprites = login_btnLoginIphone:GetComponent("LuaUIHelperSprite")
self.arr_btnlogin[1].sprites = self.arr_btnlogin[1].sprites:GetSprites()
self.arr_btnlogin[1].rectBar = login_btnLoginIphone:Find("imagebar")
self.arr_btnlogin[1].rectBar = self.arr_btnlogin[1].rectBar:GetComponent(typeof(UnityEngine.RectTransform))
self.arr_btnlogin[1].imagesize = login_btnLoginIphone:Find("imagesize")
self.arr_btnlogin[1].imagesize = self.arr_btnlogin[1].imagesize:GetComponent(typeof(UnityEngine.UI.Image))
login_btnLoginIphone = login_btnLoginIphone:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(login_btnLoginIphone, function()
self.LoginType = 1
self.login_inputemail.gameObject:SetActive(false)
self.login_inputiphone.gameObject:SetActive(true)
local inforTemp1 = LuaUIHelper:GetAnimatorAormalizedTime(self.arr_btnlogin[1].Animator, true)
local inforTemp2 = LuaUIHelper:GetAnimatorAormalizedTime(self.arr_btnlogin[2].Animator, false)
if not LuaUIHelper:GetAnimatorIsName(self.arr_btnlogin[1].Animator, "open") then
if inforTemp1 > 1 then
inforTemp1 = 1
inforTemp2 = 1
end
self.arr_btnlogin[1].Animator:Play("open", -1, 1 - inforTemp1)
self.arr_btnlogin[2].Animator:Play("close", -1, 1 - inforTemp2)
else
self.arr_btnlogin[1].Animator:Play("open", -1, 0.5)
end
end)
local login_btnLoginEmail = self.login:Find("btnLoginEmail")
self.arr_btnlogin[2].Animator = login_btnLoginEmail:GetComponent(typeof(UnityEngine.Animator))
self.arr_btnlogin[2].sprites = login_btnLoginEmail:GetComponent("LuaUIHelperSprite")
self.arr_btnlogin[2].sprites = self.arr_btnlogin[2].sprites:GetSprites()
self.arr_btnlogin[2].rectBar = login_btnLoginEmail:Find("imagebar")
self.arr_btnlogin[2].rectBar = self.arr_btnlogin[2].rectBar:GetComponent(typeof(UnityEngine.RectTransform))
self.arr_btnlogin[2].imagesize = login_btnLoginEmail:Find("imagesize")
self.arr_btnlogin[2].imagesize = self.arr_btnlogin[2].imagesize:GetComponent(typeof(UnityEngine.UI.Image))
login_btnLoginEmail = login_btnLoginEmail:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(login_btnLoginEmail, function()
self.LoginType = 2
self.login_inputemail.gameObject:SetActive(true)
self.login_inputiphone.gameObject:SetActive(false)
local inforTemp1 = LuaUIHelper:GetAnimatorAormalizedTime(self.arr_btnlogin[1].Animator, false)
local inforTemp2 = LuaUIHelper:GetAnimatorAormalizedTime(self.arr_btnlogin[2].Animator, true)
if not LuaUIHelper:GetAnimatorIsName(self.arr_btnlogin[2].Animator, "open") then
if inforTemp2 > 1 then
inforTemp1 = 1
inforTemp2 = 1
end
self.arr_btnlogin[1].Animator:Play("close", -1, 1 - inforTemp1)
self.arr_btnlogin[2].Animator:Play("open", -1, 1 - inforTemp2)
else
if LuaUIHelper:GetAnimatorIsName(self.arr_btnlogin[1].Animator, "open") then
self.arr_btnlogin[1].Animator:Play("close", -1, 1 - inforTemp1)
end
self.arr_btnlogin[2].Animator:Play("open", -1, 0.5)
end
end)
local login_btnRegister = self.login:Find("btnRegister")
login_btnRegister = login_btnRegister:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(login_btnRegister, function()
self.login.gameObject:SetActive(false)
self.forget_password.gameObject:SetActive(false)
self.iphone_message.gameObject:SetActive(false)
self.setpassword.gameObject:SetActive(false)
self.register.gameObject:SetActive(true)
self:SetLanguage()
end)
local login_btnNoRemember = self.login:Find("btnNoRemember")
login_btnNoRemember = login_btnNoRemember:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(login_btnNoRemember, function()
self.login.gameObject:SetActive(false)
self.forget_password.gameObject:SetActive(true)
self.iphone_message.gameObject:SetActive(false)
self.setpassword.gameObject:SetActive(false)
self.register.gameObject:SetActive(false)
end)
local login_btnLogin = self.login:Find("btnLogin")
login_btnLogin = login_btnLogin:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(login_btnLogin, function()
-- ViewManager.ChangeView(ViewManager.View_MainNew)
-- ViewUtil.ShowModalWait(self._root_view,"正在登录游戏...")
local loginCtr = ControllerManager.GetController(LoginController)
local account = self:CheckInputIphone()
if not account then
return
end
local passwd = self:CheckInputPasswd()
if not passwd then
return
end
if self.LoginType == 0 then
elseif self.LoginType == 1 then
PlayerPrefs.SetString("account", account)
PlayerPrefs.SetString("passwd", passwd)
loginCtr:IdPasswordLogin(account, passwd, function(res)
-- ViewUtil.CloseModalWait()
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode, "ID或者密码错误")
return
end
self:LoginResponse(res)
end)
elseif self.LoginType == 2 then
else
end
end)
local register_btnBack = self.register:Find("btnBack")
local register_btnBackbg = register_btnBack:GetComponent(typeof(UnityEngine.UI.Image))
register_btnBackbg.sprite = CommonUISprite:GetSprite("arrow1")
register_btnBack = register_btnBack:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(register_btnBack, function()
self.login.gameObject:SetActive(true)
self.forget_password.gameObject:SetActive(false)
self.iphone_message.gameObject:SetActive(false)
self.setpassword.gameObject:SetActive(false)
self.register.gameObject:SetActive(false)
self:SetLanguage()
end)
local register_btnNext = self.register:Find("btnNext")
register_btnNext = register_btnNext:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(register_btnNext, function()
self.login.gameObject:SetActive(false)
self.forget_password.gameObject:SetActive(false)
self.iphone_message.gameObject:SetActive(false)
self.setpassword.gameObject:SetActive(true)
self.register.gameObject:SetActive(false)
end)
self.register_inputemail = self.register:Find("input_email")
self.register_inputphone = self.register:Find("input_iphone")
self.RegisterType = 1
self.arr_btnRegister = {}
self.arr_btnRegister[1] = {}
self.arr_btnRegister[2] = {}
self.arr_btnRegister[1].vec = { [1] = { x = 293, y = 36, angle = -7.26 }, [2] = { x = 380, y = 36, angle = -4.66 } }
self.arr_btnRegister[2].vec = { [1] = { x = 293, y = 36, angle = -7.26 }, [2] = { x = 380, y = 36, angle = -4.66 } }
local register_btnPhone = self.register:Find("btnIphone")
self.arr_btnRegister[1].Animator = register_btnPhone:GetComponent(typeof(UnityEngine.Animator))
self.arr_btnRegister[1].sprites = register_btnPhone:GetComponent("LuaUIHelperSprite")
self.arr_btnRegister[1].sprites = self.arr_btnRegister[1].sprites:GetSprites()
self.arr_btnRegister[1].rectBar = register_btnPhone:Find("imagebar")
self.arr_btnRegister[1].rectBar = self.arr_btnRegister[1].rectBar:GetComponent(typeof(UnityEngine.RectTransform))
self.arr_btnRegister[1].imagesize = register_btnPhone:Find("imagesize")
self.arr_btnRegister[1].imagesize = self.arr_btnRegister[1].imagesize:GetComponent(typeof(UnityEngine.UI.Image))
register_btnPhone = register_btnPhone:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(register_btnPhone, function()
self.RegisterType = 1
self.register_inputemail.gameObject:SetActive(false)
self.register_inputphone.gameObject:SetActive(true)
local inforTemp1 = LuaUIHelper:GetAnimatorAormalizedTime(self.arr_btnRegister[1].Animator, true)
local inforTemp2 = LuaUIHelper:GetAnimatorAormalizedTime(self.arr_btnRegister[2].Animator, false)
if not LuaUIHelper:GetAnimatorIsName(self.arr_btnRegister[1].Animator, "open") then
if inforTemp1 > 1 then
inforTemp1 = 1
inforTemp2 = 1
end
self.arr_btnRegister[1].Animator:Play("open", -1, 1 - inforTemp1)
self.arr_btnRegister[2].Animator:Play("close", -1, 1 - inforTemp2)
else
self.arr_btnRegister[1].Animator:Play("open", -1, 0.5)
end
end)
local register_btnEmail = self.register:Find("btnEmail")
self.arr_btnRegister[2].Animator = register_btnEmail:GetComponent(typeof(UnityEngine.Animator))
self.arr_btnRegister[2].sprites = register_btnEmail:GetComponent("LuaUIHelperSprite")
self.arr_btnRegister[2].sprites = self.arr_btnRegister[2].sprites:GetSprites()
self.arr_btnRegister[2].rectBar = register_btnEmail:Find("imagebar")
self.arr_btnRegister[2].rectBar = self.arr_btnRegister[2].rectBar:GetComponent(typeof(UnityEngine.RectTransform))
self.arr_btnRegister[2].imagesize = register_btnEmail:Find("imagesize")
self.arr_btnRegister[2].imagesize = self.arr_btnRegister[2].imagesize:GetComponent(typeof(UnityEngine.UI.Image))
register_btnEmail = register_btnEmail:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(register_btnEmail, function()
self.RegisterType = 2
self.register_inputemail.gameObject:SetActive(true)
self.register_inputphone.gameObject:SetActive(false)
local inforTemp1 = LuaUIHelper:GetAnimatorAormalizedTime(self.arr_btnRegister[1].Animator, false)
local inforTemp2 = LuaUIHelper:GetAnimatorAormalizedTime(self.arr_btnRegister[2].Animator, true)
if not LuaUIHelper:GetAnimatorIsName(self.arr_btnRegister[2].Animator, "open") then
if inforTemp2 > 1 then
inforTemp1 = 1
inforTemp2 = 1
end
self.arr_btnRegister[1].Animator:Play("close", -1, 1 - inforTemp1)
self.arr_btnRegister[2].Animator:Play("open", -1, 1 - inforTemp2)
else
self.arr_btnRegister[2].Animator:Play("open", -1, 0.5)
end
end)
local forget_btnNext = self.forget_password:Find("btnNext")
forget_btnNext = forget_btnNext:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(forget_btnNext, function()
self.login.gameObject:SetActive(false)
self.forget_password.gameObject:SetActive(false)
self.iphone_message.gameObject:SetActive(true)
self.setpassword.gameObject:SetActive(false)
self.register.gameObject:SetActive(false)
end)
local forget_btnBack = self.forget_password:Find("btnBack")
local forget_btnBackbg = forget_btnBack:GetComponent(typeof(UnityEngine.UI.Image))
forget_btnBackbg.sprite = CommonUISprite:GetSprite("arrow1")
forget_btnBack = forget_btnBack:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(forget_btnBack, function()
self.login.gameObject:SetActive(true)
self.forget_password.gameObject:SetActive(false)
self.iphone_message.gameObject:SetActive(false)
self.setpassword.gameObject:SetActive(false)
self.register.gameObject:SetActive(false)
end)
local message_btnBack = self.iphone_message:Find("btnBack")
local message_btnBackbg = message_btnBack:GetComponent(typeof(UnityEngine.UI.Image))
message_btnBackbg.sprite = CommonUISprite:GetSprite("arrow1")
message_btnBack = message_btnBack:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(message_btnBack, function()
self.login.gameObject:SetActive(false)
self.forget_password.gameObject:SetActive(true)
self.iphone_message.gameObject:SetActive(false)
self.setpassword.gameObject:SetActive(false)
self.register.gameObject:SetActive(false)
end)
local setpassword_btnBack = self.setpassword:Find("btnBack")
local setpassword_btnBackbg = setpassword_btnBack:GetComponent(typeof(UnityEngine.UI.Image))
setpassword_btnBackbg.sprite = CommonUISprite:GetSprite("arrow1")
setpassword_btnBack = setpassword_btnBack:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(setpassword_btnBack, function()
self.login.gameObject:SetActive(false)
self.forget_password.gameObject:SetActive(true)
self.iphone_message.gameObject:SetActive(false)
self.setpassword.gameObject:SetActive(false)
self.register.gameObject:SetActive(false)
end)
self:SetLanguage()
EventManager:EventAdd(EventManager.Language, function()
self:ChangeLanguage()
self:SetLanguage()
end)
end
function M:SetLanguage()
if self.LoginType == 1 then
self.arr_btnlogin[1].Animator:Play("open", -1, 0)
self.arr_btnlogin[2].Animator:Play("close", -1, 0)
self.login_inputemail.gameObject:SetActive(false)
self.login_inputiphone.gameObject:SetActive(true)
else
self.arr_btnlogin[1].Animator:Play("close", -1, 0)
self.arr_btnlogin[2].Animator:Play("open", -1, 0)
self.login_inputemail.gameObject:SetActive(true)
self.login_inputiphone.gameObject:SetActive(false)
end
if self.RegisterType == 1 then
self.arr_btnRegister[1].Animator:Play("open", -1, 0)
self.arr_btnRegister[2].Animator:Play("close", -1, 0)
self.register_inputemail.gameObject:SetActive(false)
self.register_inputphone.gameObject:SetActive(true)
else
self.arr_btnRegister[1].Animator:Play("close", -1, 0)
self.arr_btnRegister[2].Animator:Play("open", -1, 0)
self.register_inputemail.gameObject:SetActive(true)
self.register_inputphone.gameObject:SetActive(false)
end
local languageType = LanguageManager.GetLanguageType()
local indexTemp = 1
if languageType == LanguageManager.English then
indexTemp = 2
else
indexTemp = 1
end
self.login_btnAgree.img.sprite = self.login_btnAgree.sprites[indexTemp - 1]
self.login_btnAgree.img:SetNativeSize()
self.login_agreement.img.sprite = self.login_agreement.sprites[indexTemp - 1]
self.login_agreement.img:SetNativeSize()
local vTemp = self.arr_btnlogin[1].vec[indexTemp]
self.arr_btnlogin[1].rectBar.sizeDelta = Vector2.New(vTemp.x, vTemp.y)
self.arr_btnlogin[1].imagesize.sprite = self.arr_btnlogin[1].sprites[indexTemp - 1]
self.arr_btnlogin[1].imagesize:SetNativeSize()
vTemp = self.arr_btnlogin[2].vec[indexTemp]
self.arr_btnlogin[2].rectBar.sizeDelta = Vector2.New(vTemp.x, vTemp.y)
self.arr_btnlogin[2].imagesize.sprite = self.arr_btnlogin[2].sprites[indexTemp - 1]
self.arr_btnlogin[2].imagesize:SetNativeSize()
vTemp = self.arr_btnRegister[1].vec[indexTemp]
self.arr_btnRegister[1].rectBar.sizeDelta = Vector2.New(vTemp.x, vTemp.y)
self.arr_btnRegister[1].rectBar.localEulerAngles = Vector3.New(0, 0, vTemp.angle)
self.arr_btnRegister[1].imagesize.sprite = self.arr_btnRegister[1].sprites[indexTemp - 1]
self.arr_btnRegister[1].imagesize:SetNativeSize()
vTemp = self.arr_btnRegister[2].vec[indexTemp]
self.arr_btnRegister[2].rectBar.sizeDelta = Vector2.New(vTemp.x, vTemp.y)
self.arr_btnRegister[2].rectBar.localEulerAngles = Vector3.New(0, 0, vTemp.angle)
self.arr_btnRegister[2].imagesize.sprite = self.arr_btnRegister[2].sprites[indexTemp - 1]
self.arr_btnRegister[2].imagesize:SetNativeSize()
end
function M:CheckInputIphone()
local tex_iphone = self.login_inputiphone.text
tex_iphone = string.gsub(tex_iphone, " ", "")
if string.len(tex_iphone) < 3 then
ViewUtil.ShowTips("请输入11位的手机号")
return
end
return tex_iphone
end
function M:CheckIputEmail()
local tex_email = self.login_inputemail.text
tex_email = string.gsub(tex_email, " ", "")
if not string.find(tex_email, "@") or string.len(tex_email) < 3 then
ViewUtil.ShowTips("请输入正确的邮箱")
return
end
return tex_email
end
function M:CheckInputPasswd()
local tex_passwd = self.login_inputpassword.text
tex_passwd = string.gsub(tex_passwd, " ", "")
if string.len(tex_passwd) < 6 then
ViewUtil.ShowTips("密码最少六位")
return
end
return tex_passwd
end
function M:Destroy()
if self._agreement then
self._agreement:Destroy()
end
BaseView.Destroy(self)
end
function M:Show()
BaseView.Show(self)
self:QuickLogin()
end
local function __goto_lobby(response)
if response.Data then
local notices = response.Data.notice_list
if notices and #notices > 0 then
local tem = {}
tem.data = notices
tem.auto_show = true
DataManager.SelfUser.notices = tem
end
end
ControllerManager.ChangeController(LoddyController)
-- ViewManager.ChangeView(ViewManager.View_Lobby)
UIManager.ShowUI(UIManager.LobbyView)
end
local function __join_room(roomid, res)
local loddyctr = ControllerManager.GetController(LoddyController)
loddyctr:JoinRoom(roomid, function(res1)
ViewUtil.CloseModalWait()
if res1.ReturnCode == -2 then
__join_room(roomid, res)
elseif res1.ReturnCode == 0 then
ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id)
elseif res1.ReturnCode == 101 or res1.ReturnCode == 6 then
__goto_lobby(res)
else
ViewUtil.ErrorTip(res1.ReturnCode, "登录失败!")
end
end)
end
local function __login_response(self, response)
ViewUtil.CloseModalWait()
local skey = "session_id"
print("申请的表格\n" .. TableToString(response))
if (response.ReturnCode == 0) then
local user = DataManager.SelfUser
-- if (user.guild) then
ExtendManager.Destroy()
local function f_enterLobby(...)
-- body
local _client = ControllerManager.WebClient
PlayerPrefs.SetString(skey, _client:getSession())
PlayerPrefs.Save()
print("游戏列表\n" .. TableToString(user.games))
-- 列表太多,容易报错
-- ExtendManager.Init(t)
local roomid = user.room_id
if (string.len(roomid) > 1) then
if user.group_id == 0 then
ViewUtil.ShowModalWait(self._root_view, "正在加入房间...")
print("正在加入房间----------------")
__join_room(roomid, response)
return
end
end
__goto_lobby(response)
end
print(user.update)
if user.update ~= 0 then
ExtendHotupdate.UpdateGameList(user.games, f_enterLobby)
else
f_enterLobby()
end
-- print("申请的表格\n" .. TableToString(user))
else
if (response.ReturnCode == Table_Error_code.ERR_SERVER or response.ReturnCode == Table_Error_code.ERR_LOGOUT) then
PlayerPrefs.DeleteKey(skey)
PlayerPrefs.Save()
end
ViewUtil.ErrorTip(response.ReturnCode, "登录失败!")
end
end
function M:LoginResponse(response)
__login_response(self, response)
end
function M:PhoneLogin()
local _phoneView = nil
_phoneView = PhoneLoginView.new(function(res)
if res.ReturnCode == 0 then
_phoneView:Destroy()
end
__login_response(self, res)
end)
_phoneView:Show()
end
function M:IDLogin()
local _idView = nil
_idView = IDLoginView.new(function(res)
if res.ReturnCode == 0 then
_idView:Destroy()
end
__login_response(self, res)
end)
_idView:Show()
end
function M:QuickLogin()
if (not GameApplication.Instance.accountTest) then
local session_id = PlayerPrefs.GetString("session_id")
print("session_id:" .. session_id)
if session_id and string.len(session_id) > 3 then
ViewUtil.ShowModalWait(self._root_view, "正在登录游戏...")
local loginCtr = ControllerManager.GetController(LoginController)
loginCtr:QuickLogin(session_id, function(response)
__login_response(self, response)
end)
end
end
end
function M:LoginCallBack(result, data)
self.isWXCallBackMark = true
print("微信登录返回================================================================")
print("jefe:result===>" .. result)
--pt(data)
if (not result) or result ~= 0 then
if result == 10 then
ViewUtil.ShowModalWait(self._root_view)
return
end
ViewUtil.CloseModalWait()
return
end
print("用户登录数据" .. TableToString(data))
if data then
local jd = json.decode(data)
pt(jd)
local headurl = jd["headimgurl"]
local unionid = jd["unionid"]
local sex = jd["sex"]
if (sex == 0) then sex = 1 end
local nickname = jd["nickname"]
DataManager.SelfUser.acc = unionid
DataManager.SelfUser.nick_name = nickname
DataManager.SelfUser.sex = sex
DataManager.SelfUser.head_url = headurl
if not DataManager.SelfUser.acc or string.len(DataManager.SelfUser.acc) < 1 then
ViewUtil.CloseModalWait()
return
end
end
local loginCtr = ControllerManager.GetController(LoginController)
loginCtr:Login(function(response)
__login_response(self, response)
end)
end
function M:Destroy()
BaseView.Destroy(self)
-- UIPackage.RemovePackage("base/embed/ui/Hotupdate")
-- UIPackage.RemovePackage("base/login/ui/Login")
ResourcesManager.UnLoad("base/ui/Login.bytes")
end

View File

@ -0,0 +1,127 @@
local MainRightPanelView = {
-- 查看记录
onLogCallback = nil
}
local M = MainRightPanelView
local function __init(self, mainView, view)
local right_panel = view
local btn_setting = right_panel:GetChild('btn_setting')
btn_setting.onClick:Set(
function()
local _settingView = mainView:NewSettingView()
_settingView.stateIndex = (mainView._room.curren_round >= 1 and mainView._allow_dissmiss) and 2 or 1
_settingView.cd_time = mainView.dismiss_room_cd_time
_settingView:Show()
local room = DataManager.CurrenRoom
_settingView.onCallback:Add(
function(context)
local _gamectr = ControllerManager.GetController(GameController)
if (room.CurnrenState == StateType.Ready) then
_gamectr:LevelRoom(
function(response)
if (response.ReturnCode == 0) then
ViewManager.ChangeView(ViewManager.View_Lobby)
GameApplication.Instance:ShowTips('房间已解散!')
end
end
)
else
_gamectr:AskDismissRoom()
end
end
)
end
)
self._tex_data = right_panel:GetChild('tex_data')
self._tex_time = right_panel:GetChild('tex_time')
self._pb_batteryLevel = right_panel:GetChild('pb_batteryLevel')
self._xinhao = right_panel:GetController('xinhao')
self.ctr_xh = right_panel:GetChild('gcm_xinhao'):GetController('c1')
self.ctr_wifi = right_panel:GetChild('gcm_wifi'):GetController('c1')
self._tex_ping = right_panel:GetChild('gcm_xinhao'):GetChild('n7')
self.ctr_log = right_panel:GetController('log')
local btn_log = right_panel:GetChild('btn_log')
btn_log.onClick:Set(
function()
if self.onLogCallback then
self.onLogCallback()
end
end
)
self._total_time = 0
self:__UpdateTime()
-- self._timer = Timer.New(handler(self,self.__UpdateTime),10,-1,true)
-- self._timer:Start()
end
--- Create a new MainRightPanelView
function MainRightPanelView.new(mainView, view)
local self = setmetatable({}, {__index = M})
self.class = 'MainRightPanelView'
-- 显示选项1是正常2的ping没有括号
self._opt = 1
__init(self, mainView, view)
return self
end
function M:__UpdateTime()
if self._total_time >= 10 then
self._total_time = 0
else
return
end
self:_ShowTime()
end
function M:_ShowTime()
self._tex_data.text = os.date('%Y-%m-%d')
self._tex_time.text = os.date('%H:%M')
if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then
self._pb_batteryLevel.value = GameApplication.Instance:GetBatteryLevel()
end
local NetworkReachability = UnityEngine.NetworkReachability
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
local ping = _client:getAveragePingTime()
if not ping then
return
end
ping = math.floor(ping / 2)
if ping > 300 then
ping = 300
end
if ping <= 100 then
self.ctr_xh.selectedIndex = 0
elseif ping <= 300 then
self.ctr_xh.selectedIndex = 1
else
self.ctr_xh.selectedIndex = 2
end
local str_ping = '' .. ping .. 'ms'
if self._opt == 2 then
str_ping = ping .. 'ms'
end
self._tex_ping.text = str_ping
end
--
function M:OnUpdate(deltaTime)
self:__UpdateTime()
self._total_time = self._total_time + deltaTime
end
function M:Destroy()
-- self._timer:Stop()
end
return M

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,216 @@
-- MainViewNew
MainViewNew = {}
local M = MainViewNew
local Unit = {}
function MainViewNew.new()
setmetatable(M, { __index = BaseView })
local self = setmetatable({}, { __index = M })
self.class = "MainViewNew"
self._full = true
return self
end
-- 语音是否禁止
local record_baned = 0
function M:init()
-- self:InitView("base/prefab/ViewMain.prefab", "base/prefab/ViewMain")
local view = self._view
local bg = view.transform:GetComponent(typeof(UnityEngine.UI.Image))
bg.sprite = CommonUISprite:GetSprite("bg1")
self.isJoinPlay = true
self.imagePoint = view.transform:Find("imagePoint")
self.down = view.transform:Find("down")
self.home = {}
self.home.view = view.transform:Find("imageHome")
self.match = view.transform:Find("imageMatch")
self.unit = {}
self.unit.view = view.transform:Find("imageUnit")
Unit.new(self.unit.view)
self.game = view.transform:Find("imageGame")
self.me = view.transform:Find("imageMe")
-- 界面模块
self.go_arrUI = {}
self.go_arrUI[1] = self.unit.view
self.go_arrUI[2] = self.match
self.go_arrUI[3] = self.home.view
self.go_arrUI[4] = self.game
self.go_arrUI[5] = self.me
self.home.view.position = self.imagePoint.position
-- 界面模块 切换按钮
self.down_arrBtnDown = {}
for i = 1, self.down.childCount do
self.down_arrBtnDown[i] = {}
local down_btnTemp = self.down:GetChild(i - 1)
self.down_arrBtnDown[i].AnimatorCircle = down_btnTemp:Find("circle")
self.down_arrBtnDown[i].AnimatorCircle = self.down_arrBtnDown[i].AnimatorCircle:GetComponent(typeof(UnityEngine
.Animator))
self.down_arrBtnDown[i].AnimatorCircle:Play("stop", -1, 0)
self.down_arrBtnDown[i].AnimatorMax = down_btnTemp:Find("max")
self.down_arrBtnDown[i].AnimatorMax = self.down_arrBtnDown[i].AnimatorMax:GetComponent(typeof(UnityEngine
.Animator))
self.down_arrBtnDown[i].AnimatorMax:Play("stop", -1, 0)
down_btnTemp = down_btnTemp:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(down_btnTemp, function(btnVar)
self:ShowPage(btnVar)
end, i)
end
--首页
self.home.btnFilter = self.home.view:Find("btnFilter")
self.home.btnFilterbg = self.home.btnFilter:GetComponent(typeof(UnityEngine.UI.Image))
self.home.btnFilterbg.sprite = CommonUISprite:GetSprite("filter1")
self.home_btnFilter_activepoint = self.home.btnFilter:Find("imagePoint")
self.home.btnFilter = self.home.btnFilter:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(self.home.btnFilter, function()
end)
self.home.btnNews = self.home.view:Find("btnNews")
local home_btnNewbg = self.home.btnNews:GetComponent(typeof(UnityEngine.UI.Image))
home_btnNewbg.sprite = CommonUISprite:GetSprite("new1")
self.home_btnNews_activepoint = self.home.btnNews:Find("imagePoint")
self.home.btnNews = self.home.btnNews:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(self.home.btnNews, function()
end)
-- local btnPlay = self.down:Find("btnPlay")
-- btnPlay = btnPlay:GetComponent(typeof(UnityEngine.UI.Button))
-- LuaUIHelper:AddButtonClick(btnPlay, function()
-- end)
--比赛
self.match_itemCopy = self.match:Find("scroll/Viewport/Content/btnItem")
local match_btnTemp = self.match_itemCopy:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(match_btnTemp, function()
UIManager.ShowUI(UIManager.ViewMatch)
end)
--主页
local home_btnNews = self.home.view:Find("btnNews")
local home_btnNewsBg = home_btnNews:GetComponent(typeof(UnityEngine.UI.Image))
home_btnNewsBg.sprite = CommonUISprite:GetSprite("new1")
self.home_btnNews_activepoint = home_btnNews:Find("imagePoint")
self.home_btnNews_activepoint = self.home_btnNews_activepoint:GetComponent(typeof(UnityEngine.UI.Image))
self.home_btnNews_activepoint.sprite = CommonUISprite:GetSprite("activepoint")
home_btnNews = home_btnNews:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(home_btnNews, function()
end)
local home_btnFilter = self.home.view:Find("btnFilter")
local home_btnFilterBg = home_btnFilter:GetComponent(typeof(UnityEngine.UI.Image))
home_btnFilterBg.sprite = CommonUISprite:GetSprite("filter1")
self.home_btnFilter_activepoint = home_btnFilter:Find("imagePoint")
self.home_btnFilter_activepoint = self.home_btnFilter_activepoint:GetComponent(typeof(UnityEngine.UI.Image))
self.home_btnFilter_activepoint.sprite = CommonUISprite:GetSprite("activepoint")
home_btnFilter = home_btnFilter:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(home_btnFilter, function()
end)
self.home_selectItemCopy = self.home.view:Find("scroll/Viewport/Content/btnItem")
local home_btnTemp = self.home_selectItemCopy:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(home_btnTemp, function()
UIManager.ShowUI(UIManager.ViewGame)
end)
--游戏
local game_btnFilter = self.game:Find("btnFilter")
local game_btnFilterBg = game_btnFilter:GetComponent(typeof(UnityEngine.UI.Image))
game_btnFilterBg.sprite = CommonUISprite:GetSprite("filter1")
self.game_btnFilter_activepoint = game_btnFilter:Find("imagePoint")
self.game_btnFilter_activepoint = self.game_btnFilter_activepoint:GetComponent(typeof(UnityEngine.UI.Image))
self.game_btnFilter_activepoint.sprite = CommonUISprite:GetSprite("activepoint")
game_btnFilter = game_btnFilter:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(game_btnFilter, function()
end)
local game_btnNews = self.game:Find("btnNews")
local game_btnNewsBg = game_btnNews:GetComponent(typeof(UnityEngine.UI.Image))
game_btnNewsBg.sprite = CommonUISprite:GetSprite("new1")
self.game_btnNews_activepoint = game_btnNews:Find("imagePoint")
self.game_btnNews_activepoint = self.game_btnNews_activepoint:GetComponent(typeof(UnityEngine.UI.Image))
self.game_btnNews_activepoint.sprite = CommonUISprite:GetSprite("activepoint")
game_btnNews = game_btnNews:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(game_btnNews, function()
end)
for index, value in ipairs(self.go_arrUI) do
value.gameObject:SetActive(false)
end
self.down_selectbtn = 3
self:ShowPage(self.down_selectbtn)
end
function M:ShowPage(btnVar)
self.down_arrBtnDown[self.down_selectbtn].AnimatorMax:Play("close", -1, 0)
self.go_arrUI[self.down_selectbtn].gameObject:SetActive(false)
self.down_selectbtn = btnVar
self.down_arrBtnDown[btnVar].AnimatorCircle:Play("open", -1, 0)
self.down_arrBtnDown[btnVar].AnimatorMax:Play("open", -1, 0)
self.go_arrUI[btnVar].gameObject:SetActive(true)
self.go_arrUI[btnVar].position = self.imagePoint.position
Unit.v_join.bg.gameObject:SetActive(false)
if btnVar == 1 then
Unit.v_main.v.position = self.imagePoint.position
Unit.v_none.position = self.imagePoint.position
Unit.v_list.position = self.imagePoint.position
Unit.v_join.position = self.imagePoint.position
if self.isJoinPlay then
Unit.v_main.v.gameObject:SetActive(true)
Unit.v_none.v.gameObject:SetActive(false)
else
Unit.v_main.v.gameObject:SetActive(false)
Unit.v_none.v.gameObject:SetActive(true)
end
Unit.v_list.v.gameObject:SetActive(false)
Unit.v_join.v.gameObject:SetActive(false)
elseif btnVar == 2 then
elseif btnVar == 3 then
elseif btnVar == 4 then
elseif btnVar == 5 then
end
end
function M:SetTuoGuanState()
-- printlog("初始化设置托管状态")
if ControllerManager.enterPlayerData and #ControllerManager.enterPlayerData > 0 then
-- pt(ControllerManager.enterPlayerData)
for i = 1, #ControllerManager.enterPlayerData do
local p = self._player_info[self:GetPos(ControllerManager.enterPlayerData[i].seat)]
-- p.seat=ControllerManager.enterPlayerData[i].seat
local t = ControllerManager.enterPlayerData[i].entrust_time
-- local isShow=ControllerManager.enterPlayerData[i].entrust
-- if isShow==nil then return end
if t and t > 0 then
p:IsShowTGTips(true, t)
else
end
end
ControllerManager.enterPlayerData = nil
end
end
return M

View File

@ -0,0 +1,29 @@
MatchView = {}
local M = MatchView
function MatchView.new()
setmetatable(M, { __index = BaseView })
local self = setmetatable({}, { __index = M })
self.class = "MatchView"
self._full = true
-- self:init()
return self
end
function M:init()
-- self:InitView("base/prefab/ViewMatch.prefab", "base/prefab/ViewMatch")
local view = self._view
local bg = view.transform:Find("imageBG")
bg = bg:GetComponent(typeof(UnityEngine.UI.Image))
bg.sprite = CommonUISprite:GetSprite("bg1")
local btnBack = view.transform:Find("btnBack")
local btnBackBg = btnBack:GetComponent(typeof(UnityEngine.UI.Image))
btnBackBg.sprite = CommonUISprite:GetSprite("arrow1")
btnBack = btnBack:GetComponent(typeof(UnityEngine.UI.Button))
LuaUIHelper:AddButtonClick(btnBack, function()
UIManager.ShowUI(UIManager.LobbyView)
end)
end

View File

@ -0,0 +1,70 @@
--创建牌友圈View对象
--author--
local CreateGroupView = {}
local M = CreateGroupView
local url = {"ui://NewGroup/Win_CreateGroup","ui://NewGroup/Win_UpdateGroup"}
function CreateGroupView.new(blur_view,default_str)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "CreateGroupView"
self._close_destroy = true
self._close_zone = false
self._blur_view = blur_view
self.default_str = default_str
self:init(url[self.is_update and 2 or 1])
return self
end
function M:init(url)
BaseWindow.init(self,url)
local tex_name = self._view:GetChild("tex_name")
local ctr_agent = self._view:GetController("agent")
local user = DataManager.SelfUser
self._view:GetController("index").selectedIndex = 2
self._view:GetController("alliance").selectedIndex = 1
local btn_ok = self._view:GetChild("btn_ok")
btn_ok.onClick:Set(function()
if string.utf8len(tex_name.text) == 0 then
ViewUtil.ErrorTip(-12,"请输入圈子名称!")
return
end
if MsgParser:checkString(tex_name.text) then
ViewUtil.ErrorTip(-12,"您输入的名称存在敏感字!")
return
end
-- if not self.is_update and not self.config then
-- ViewUtil.ErrorTip(-12,"请选择玩法!")
-- return
-- end
if self.callback then
local ctr_index = self._view:GetController("index")
local index = ctr_index.selectedIndex + 1
local pay_type = index
local fg_type = 1
if index == 3 then
pay_type = 1
fg_type = 2
end
self.callback(tex_name.text, pay_type, fg_type)
end
self:Destroy()
end)
local btn_cal = self._view:GetChild("btn_cal")
btn_cal.onClick:Set(function()
self:Destroy()
end)
end
function M:SetCallback(callback)
self.callback = callback
end
return M

View File

@ -0,0 +1,79 @@
-- 被邀请界面
local FGInvitedMsgView = {}
local M = FGInvitedMsgView
setmetatable(M, {__index = BaseWindow})
function FGInvitedMsgView.new(blur_view, group_id, callback)
local self = setmetatable({}, {__index = M})
self.class = "FGInvitedMsgView"
self._blur_view = blur_view
self._animation = true
self._close_destroy = true
self._close_time = 15
self.group_id = group_id
self.callback = callback
UIPackage.AddPackage("base/newgroup/ui/FGAssist")
self:init("ui://FGAssist/panel_invited")
return self
end
function M:FillData(data)
self._view:GetChild("tex_name").text = data.nick
self._view:GetChild("tex_id").text = "ID:" .. data.uid
local btn_head = self._view:GetChild("btn_head")
ImageLoad.Load(data.portrait, btn_head._iconObject)
local group = DataManager.groups:get(self.group_id)
local play = group:getPlay(data.pid)
self._view:GetChild("tex_play_name").text = play and play.name or pid
self._view:GetChild("tex_game_name").text = data.g_name
local btn_refuse = self._view:GetChild("btn_refuse")
local id = data.invi_id
local btn_yes = self._view:GetChild("btn_yes")
btn_yes.onClick:Set(function()
local refuse = btn_refuse.selected and 1 or 0
self:SendResponse(id, refuse)
self:Destroy()
if self.callback then
self.callback(data.roomid)
end
end)
local btn_no = self._view:GetChild("btn_no")
btn_no.onClick:Set(function()
local refuse = btn_refuse.selected and 1 or 0
self:SendResponse(id, refuse)
self:Destroy()
end)
self._co = coroutine.start(function()
while self._close_time > 0 do
coroutine.wait(1)
self._close_time = self._close_time - 1
self:ShowLeftTime()
end
self:Destroy()
end)
end
function M:ShowLeftTime()
self._view:GetChild("tex_left_time").text = self._close_time .. "s"
end
function M:SendResponse(id, refuse)
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
mgr_ctr:FG_ResponseInvited(id, refuse)
end
function M:Destroy()
if self._co then
coroutine.stop(self._co)
self._co = nil
end
BaseWindow.Destroy(self)
end
return M

Some files were not shown because too many files have changed in this diff Show More