This commit is contained in:
2020-07-04 14:41:25 +08:00
parent 70c346d2c1
commit a8f02e4da5
3748 changed files with 587372 additions and 0 deletions

View File

@@ -0,0 +1,267 @@
-- 需要先加载的部分
require "public.CLLIncludeBase"
-------------------------------------------------------
-- 重新命名
---@type UnityEngine.Vector2
Vector2 = CS.UnityEngine.Vector2
---@type UnityEngine.Vector4
Vector4 = CS.UnityEngine.Vector4
---@type UnityEngine.Color
Color = CS.UnityEngine.Color
---@type UnityEngine.Ray
Ray = CS.UnityEngine.Ray
---@type UnityEngine.Ray2D
Ray2D = CS.UnityEngine.Ray2D
---@type UnityEngine.Bounds
Bounds = CS.UnityEngine.Bounds
Resources = CS.UnityEngine.Resources
---@type UnityEngine.TextAsset
TextAsset = CS.UnityEngine.TextAsset
---@type UnityEngine.AnimationCurve
AnimationCurve = CS.UnityEngine.AnimationCurve
---@type UnityEngine.AnimationClip
AnimationClip = CS.UnityEngine.AnimationClip
---@type UnityEngine.MonoBehaviour
MonoBehaviour = CS.UnityEngine.MonoBehaviour
---@type UnityEngine.ParticleSystem
ParticleSystem = CS.UnityEngine.ParticleSystem
---@type UnityEngine.SkinnedMeshRenderer
SkinnedMeshRenderer = CS.UnityEngine.SkinnedMeshRenderer
---@type UnityEngine.Renderer
Renderer = CS.UnityEngine.Renderer
---@type UnityEngine.WWW
WWW = CS.UnityEngine.WWW
---@type UnityEngine.Screen
Screen = CS.UnityEngine.Screen
---@type System.IO.File
File = CS.System.IO.File
---@type System.IO.Directory
Directory = CS.System.IO.Directory
---@type UnityEngine.RaycastHit
RaycastHit = CS.UnityEngine.RaycastHit
---@type UnityEngine.PlayerPrefs
PlayerPrefs = CS.UnityEngine.PlayerPrefs
---@type UnityEngine.SystemInfo
SystemInfo = CS.UnityEngine.SystemInfo
---@type UnityEngine.Shader
Shader = CS.UnityEngine.Shader
---@type System.IO.Path
Path = CS.System.IO.Path
---@type System.IO.MemoryStream
MemoryStream = CS.System.IO.MemoryStream
DateTime = CS.System.DateTime
---@type UIRoot
UIRoot = CS.UIRoot
---@type UICamera
UICamera = CS.UICamera
---@type UIRect
UIRect = CS.UIRect
---@type UIWidget
UIWidget = CS.UIWidget
---@type UIWidgetContainer
UIWidgetContainer = CS.UIWidgetContainer
---@type UILabel
UILabel = CS.UILabel
---@type UIToggle
UIToggle = CS.UIToggle
---@type UIBasicSprite
UIBasicSprite = CS.UIBasicSprite
---@type UITexture
UITexture = CS.UITexture
---@type UISprite
UISprite = CS.UISprite
---@type UIButton
UIButton = CS.UIButton
---@type UIProgressBar
UIProgressBar = CS.UIProgressBar
---@type UISlider
UISlider = CS.UISlider
---@type UIGrid
UIGrid = CS.UIGrid
---@type UITable
UITable = CS.UITable
---@type UIInput
UIInput = CS.UIInput
---@type UIScrollView
UIScrollView = CS.UIScrollView
---@type UITweener
UITweener = CS.UITweener
---@type TweenWidth
TweenWidth = CS.TweenWidth
---@type TweenRotation
TweenRotation = CS.TweenRotation
---@type TweenPosition
TweenPosition = CS.TweenPosition
---@type TweenScale
TweenScale = CS.TweenScale
---@type TweenAlpha
TweenAlpha = CS.TweenAlpha
---@type UICenterOnChild
UICenterOnChild = CS.UICenterOnChild
---@type UIAtlas
UIAtlas = CS.UIAtlas
---@type UILocalize
UILocalize = CS.UILocalize
---@type UIPlayTween
UIPlayTween = CS.UIPlayTween
---@type UIAnchor
UIAnchor = CS.UIAnchor
---@type UIPopupList
UIPopupList = CS.UIPopupList
---@type MyWWWTexture
MyWWWTexture = CS.MyWWWTexture
---@type Coolape.CLAssetsManager
CLAssetsManager = CS.Coolape.CLAssetsManager
---@type Coolape.B2InputStream
B2InputStream = CS.Coolape.B2InputStream
---@type Coolape.B2OutputStream
B2OutputStream = CS.Coolape.B2OutputStream
---@type Coolape.CLBulletBase
CLBulletBase = CS.Coolape.CLBulletBase
---@type Coolape.CLBulletPool
CLBulletPool = CS.Coolape.CLBulletPool
---@type Coolape.CLEffect
CLEffect = CS.Coolape.CLEffect
---@type Coolape.CLEffectPool
CLEffectPool = CS.Coolape.CLEffectPool
---@type Coolape.CLMaterialPool
CLMaterialPool = CS.Coolape.CLMaterialPool
---@type Coolape.CLRolePool
CLRolePool = CS.Coolape.CLRolePool
---@type Coolape.CLSoundPool
CLSoundPool = CS.Coolape.CLSoundPool
---@type Coolape.CLSharedAssets
CLSharedAssets = CS.Coolape.CLSharedAssets
---@type Coolape.CLSharedAssets.CLMaterialInfor
CLMaterialInfor = CS.Coolape.CLSharedAssets.CLMaterialInfor
---@type Coolape.CLTexturePool
CLTexturePool = CS.Coolape.CLTexturePool
---@type Coolape.CLThingsPool
CLThingsPool = CS.Coolape.CLThingsPool
---@type Coolape.CLBaseLua
CLBaseLua = CS.Coolape.CLBaseLua
---@type Coolape.CLBehaviour4Lua
CLBehaviour4Lua = CS.Coolape.CLBehaviour4Lua
---@type Coolape.CLUtlLua
CLUtlLua = CS.Coolape.CLUtlLua
---@type Coolape.CLMainBase
CLMainBase = CS.Coolape.CLMainBase
---@type Coolape.CLAssetType
CLAssetType = CS.Coolape.CLAssetType
---@type Coolape.CLRoleAction
CLRoleAction = CS.Coolape.CLRoleAction
---@type Coolape.CLRoleAvata
CLRoleAvata = CS.Coolape.CLRoleAvata
---@type Coolape.CLUnit
CLUnit = CS.Coolape.CLUnit
---@type Coolape.BlockWordsTrie
BlockWordsTrie = CS.Coolape.BlockWordsTrie
---@type Coolape.ColorEx
ColorEx = CS.Coolape.ColorEx
---@type Coolape.DateEx
DateEx = CS.Coolape.DateEx
---@type Coolape.FileEx
FileEx = CS.Coolape.FileEx
---@type Coolape.HttpEx
HttpEx = CS.Coolape.HttpEx
---@type Coolape.JSON
JSON = CS.Coolape.JSON
---@type Coolape.ListEx
ListEx = CS.Coolape.ListEx
---@type Coolape.MyMainCamera
MyMainCamera = CS.Coolape.MyMainCamera
---@type Coolape.MyTween
MyTween = CS.Coolape.MyTween
---@type Coolape.NewList
NewList = CS.Coolape.NewList
---@type Coolape.NewMap
NewMap = CS.Coolape.NewMap
---@type Coolape.SoundEx
SoundEx = CS.Coolape.SoundEx
---@type Coolape.NumEx
NumEx = CS.Coolape.NumEx
---@type Coolape.ObjPool
ObjPool = CS.Coolape.ObjPool
---@type Coolape.SScreenShakes
SScreenShakes = CS.Coolape.SScreenShakes
---@type Coolape.ZipEx
ZipEx = CS.Coolape.ZipEx
---@type Coolape.XXTEA
XXTEA = CS.Coolape.XXTEA
---@type Coolape.CLButtonMsgLua
CLButtonMsgLua = CS.Coolape.CLButtonMsgLua
---@type Coolape.CLJoystick
CLJoystick = CS.Coolape.CLJoystick
---@type Coolape.CLUIDrag4World
CLUIDrag4World = CS.Coolape.CLUIDrag4World
---@type Coolape.CLUILoopGrid
CLUILoopGrid = CS.Coolape.CLUILoopGrid
---@type Coolape.CLUILoopTable
CLUILoopTable = CS.Coolape.CLUILoopTable
---@type Coolape.TweenSpriteFill
TweenSpriteFill = CS.Coolape.TweenSpriteFill
---@type Coolape.UIDragPage4Lua
UIDragPage4Lua = CS.Coolape.UIDragPage4Lua
---@type Coolape.UIDragPageContents
UIDragPageContents = CS.Coolape.UIDragPageContents
---@type Coolape.UIGridPage
UIGridPage = CS.Coolape.UIGridPage
---@type Coolape.UIMoveToCell
UIMoveToCell = CS.Coolape.UIMoveToCell
---@type Coolape.UISlicedSprite
UISlicedSprite = CS.Coolape.UISlicedSprite
---@type Coolape.CLAlert
CLAlert = CS.Coolape.CLAlert
---@type Coolape.CLCellBase
CLCellBase = CS.Coolape.CLCellBase
---@type Coolape.CLCellLua
CLCellLua = CS.Coolape.CLCellLua
---@type Coolape.CLPanelBase
CLPanelBase = CS.Coolape.CLPanelBase
---@type Coolape.CLPanelLua
CLPanelLua = CS.Coolape.CLPanelLua
---@type Coolape.CLUIRenderQueue
CLUIRenderQueue = CS.Coolape.CLUIRenderQueue
---@type Coolape.EffectNum
EffectNum = CS.Coolape.EffectNum
---@type Coolape.EffectProgress
EffectProgress = CS.Coolape.EffectProgress
---@type Coolape.B2Int
B2Int = CS.Coolape.B2Int
---@type Coolape.AngleEx
AngleEx = CS.Coolape.AngleEx
---@type Coolape.CLMyGrid
CLMyGrid = CS.Coolape.CLMyGrid
---@type Coolape.ReporterMessageReceiver
ReporterMessageReceiver = CS.ReporterMessageReceiver
---@type Coolape.CLUIFormUtl
CLUIFormUtl = CS.Coolape.CLUIFormUtl
---@type CLUIElement
CLUIElement = CS.CLUIElement
CLUIElementDate = CS.CLUIElementDate
CLUIElementPopList = CS.CLUIElementPopList
---@type System.Uri
Uri = CS.System.Uri
-------------------------------------------------------
---@type NativeGalleryUtl
NativeGalleryUtl = CS.NativeGalleryUtl
---@type MyLocation
MyLocation = CS.MyLocation
---@type Dist.SpringWebsocket.Client
SocketClient = CS.Dist.SpringWebsocket.Client
---@type Dist.SpringWebsocket.StompFrame
StompFrame = CS.Dist.SpringWebsocket.StompFrame
---@type Dist.SpringWebsocket.StatusCodeEnum
StompStatus = CS.Dist.SpringWebsocket.StatusCodeEnum
---@type Mp3PlayerByUrl
Mp3PlayerByUrl = CS.Mp3PlayerByUrl
---@type CLUICheckbox
CLUICheckbox = CS.CLUICheckbox
---@type CLUIPopListPanel
CLUIPopListPanel = CS.CLUIPopListPanel
-------------------------------------------------------
json = require("json.json")
-------------------------------------------------------

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fefaa5d63c5004f2b84f7bef71a359ea
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,207 @@
-- 需要先加载的部分
-------------------------------------------------------
---@type UnityEngine.Application
Application = CS.UnityEngine.Application
---@type UnityEngine.SystemInfo
SystemInfo = CS.UnityEngine.SystemInfo
---@type UnityEngine.QualitySettings
QualitySettings = CS.UnityEngine.QualitySettings
---@type UnityEngine.Time
Time = CS.UnityEngine.Time
---@type UnityEngine.GameObject
GameObject = CS.UnityEngine.GameObject
---@type UnityEngine.Component
Component = CS.UnityEngine.Component
---@type UnityEngine.Behaviour
Behaviour = CS.UnityEngine.Behaviour
---@type UnityEngine.Transform
Transform = CS.UnityEngine.Transform
---@type UnityEngine.Vector3
Vector3 = CS.UnityEngine.Vector3
---@type UnityEngine.Rect
Rect = CS.UnityEngine.Rect
---@type System.Collections.Queue
Queue = CS.System.Collections.Queue
---@type System.Collections.Stack
Stack = CS.System.Collections.Stack
---@type System.Collections.Hashtable
Hashtable = CS.System.Collections.Hashtable
---@type System.Collections.ArrayList
ArrayList = CS.System.Collections.ArrayList
---@type UnityEngine.PlayerPrefs
PlayerPrefs = CS.UnityEngine.PlayerPrefs
---@type System.IO.File
File = CS.System.IO.File
---@type System.IO.Path
Path = CS.System.IO.Path
---@type System.IO.Directory
Directory = CS.System.IO.Directory
---@type System.IO.MemoryStream
MemoryStream = CS.System.IO.MemoryStream
---@type UnityEngine.Color
Color = CS.UnityEngine.Color
---@type System.GC
GC = CS.System.GC
---NGUI
---@type Localization
Localization = CS.Localization
---@type NGUITools
NGUITools = CS.NGUITools
---@type Coolape.ReporterMessageReceiver
ReporterMessageReceiver = CS.ReporterMessageReceiver
----Coolape
---@type Coolape.JSON
JSON = CS.Coolape.JSON
---@type Coolape.CLCfgBase
CLCfgBase = CS.Coolape.CLCfgBase
---@type Coolape.WWWEx
WWWEx = CS.Coolape.WWWEx
---@type Coolape.CLAssetType
CLAssetType = CS.Coolape.CLAssetType
---@type Coolape.StrEx
StrEx = CS.Coolape.StrEx
---@type Coolape.Utl
Utl = CS.Coolape.Utl
---@type Coolape.CLPanelManager
CLPanelManager = CS.Coolape.CLPanelManager
---@type Coolape.Net
Net = CS.Coolape.Net
---@type Coolape.Net.NetWorkType
NetWorkType = CS.Coolape.Net.NetWorkType
---@type Coolape.PStr
PStr = CS.Coolape.PStr
---@type Coolape.MapEx
MapEx = CS.Coolape.MapEx
---@type Coolape.CLUIOtherObjPool
CLUIOtherObjPool = CS.Coolape.CLUIOtherObjPool
---@type Coolape.CLUIInit
CLUIInit = CS.Coolape.CLUIInit
---@type Coolape.InvokeEx
InvokeEx = CS.Coolape.InvokeEx
---@type Coolape.CLPathCfg
CLPathCfg = CS.Coolape.CLPathCfg
---@type Coolape.CLVerManager
CLVerManager = CS.Coolape.CLVerManager
---@type Coolape.CLUIUtl
CLUIUtl = CS.Coolape.CLUIUtl
---@type Coolape.CLMainBase
CLMainBase = CS.Coolape.CLMainBase
---@type Coolape.SoundEx
SoundEx = CS.Coolape.SoundEx
---@type Coolape.FileEx
FileEx = CS.Coolape.FileEx
---@type Coolape.B2InputStream
B2InputStream = CS.Coolape.B2InputStream
---@type Coolape.B2OutputStream
B2OutputStream = CS.Coolape.B2OutputStream
---@type Coolape.CLAlert
CLAlert = CS.Coolape.CLAlert
---@type Coolape.AndroidStatusBar
AndroidStatusBar = CS.Coolape.AndroidStatusBar
---other
---@type MyMain
MyMain = CS.MyMain
---@type MyCfg
MyCfg = CS.MyCfg
-------------------------------------------------------
require "toolkit.CLLPrintEx"
---@public 重写require
local localReq = require
function require(path)
local ret, result = pcall(localReq, path)
--("toolkit.KKWhiteList")
if not ret then
printe("Err:" .. result)
return nil
end
return result
end
-------------------------------------------------------
-- require
require("bio.BioUtl")
require("toolkit.LuaUtl")
require("public.CLLPrefs")
require("toolkit.CLLUpdateUpgrader")
require("toolkit.CLLVerManager")
-------------------------------------------------------
-- 全局变量
__version__ = Application.version -- "1.0"
__UUID__ = ""
-------------------------------------------------------
bio2Int = BioUtl.bio2int
int2Bio = BioUtl.int2bio
bio2Long = BioUtl.bio2long
long2Bio = BioUtl.long2bio
bio2number = BioUtl.bio2number
number2bio = BioUtl.number2bio
net = Net.self
NetSuccess = 1000 -- Net.SuccessCode
LGet = Localization.Get
function LGetFmt(key, ...)
return string.format(LGet(key), ...)
end
---@public 异步加载panel
---@param panelName string 页面名
---@param callback function 取得页面的回调(panel, orgs)
---@param paras object 回调的透传参数
---@param luaClass ClassBase lua类可为空
function getPanelAsy(panelName, callback, paras, luaClass)
if luaTable then
CLPanelManager.getPanelAsy(
panelName,
---@param p Coolape.CLPanelLua
function(p, orgs)
if p.luaTable == nil then
p.luaTable = luaClass.new()
end
callback(p, orgs)
end,
paras
)
else
CLPanelManager.getPanelAsy(panelName, callback, paras)
end
end
-------------------------------------------------------
-- 模式
GameMode = {
none = 0,
city = 1,
map = 2,
battle = 3
}
-------------------------------------------------------
local chnCfg -- 安装包配置
function getChlCfg()
if chnCfg ~= nil then
return chnCfg
end
if not CLCfgBase.self.isEditMode then
local fpath = "chnCfg.json" -- 该文在打包时会自动放在streamingAssetsPath目录下详细参见打包工具
local content = FileEx.readNewAllText(fpath)
if (content ~= nil) then
chnCfg = JSON.DecodeMap(content)
end
end
return chnCfg
end
-- 取得渠道代码
function getChlCode()
if chnCfg ~= nil then
return MapEx.getString(chnCfg, "SubChannel")
end
local chlCode = "0000"
chnCfg = getChlCfg()
if (chnCfg ~= nil) then
chlCode = MapEx.getString(chnCfg, "SubChannel")
end
return chlCode
end
-------------------------------------------------------

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8025640677eda4b369c7de3d35027774
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
require("public.class")
require("public.CLLQueue")
---@class CLLPool
CLLPool = class("CLLPool")
--local queue;
--local cloneClass;
function CLLPool:ctor(classObj)
self.queue = CLLQueue.new(100)
self.cloneClass = classObj
end
function CLLPool:createObj()
return self.cloneClass.new()
end
function CLLPool:borrow()
if self.queue:isEmpty() then
return self:createObj()
end
return self.queue:deQueue();
end
function CLLPool:retObj(obj)
self.queue:enQueue(obj);
end
return CLLPool;

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f84e347bcb9454bddb9cb06f1cc7c9ca
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,116 @@
-- 本地存储
do
local UserName = "UserName"
local UserPsd = "UserPsd"
local AutoFight = "AutoFight"
local TestMode = "isTestMode"
local TestModeUrl = "TestModeUrl"
local soundEffSwitch = "soundEffSwitch"
local musicSwitch = "musicSwitch"
local userInfor = "userInfor"
local currServer = "currServer"
local lastLoginBtn = "lastLoginBtn"
local token = "token"
local currGroup = "currGroup"
Prefs = {}
function Prefs.setUserName(v)
PlayerPrefs.SetString(UserName, v)
end
function Prefs.getUserName()
return PlayerPrefs.GetString(UserName, "")
end
function Prefs.setUserPsd(v)
PlayerPrefs.SetString(UserPsd, v)
end
function Prefs.getUserPsd(...)
return PlayerPrefs.GetString(UserPsd, "")
end
function Prefs.setAutoFight(v)
PlayerPrefs.SetInt(AutoFight, v and 0 or 1)
end
function Prefs.getAutoFight(...)
return (PlayerPrefs.GetInt(AutoFight, 0) == 0) and true or false
end
function Prefs.setTestMode(v)
PlayerPrefs.SetInt(TestMode, v and 0 or 1)
end
function Prefs.getTestMode(v)
return (PlayerPrefs.GetInt(TestMode, 0) == 0) and true or false
end
function Prefs.setTestModeUrl(v)
PlayerPrefs.SetString(TestModeUrl, v)
end
function Prefs.getTestModeUrl()
return PlayerPrefs.GetString(TestModeUrl, "")
end
function Prefs.setUserInfor(v)
PlayerPrefs.SetString(userInfor, v)
end
function Prefs.getUserInfor()
return PlayerPrefs.GetString(userInfor, "")
end
function Prefs.setCurrServer(v)
PlayerPrefs.SetString(currServer, v)
end
function Prefs.getCurrServer()
return PlayerPrefs.GetString(currServer, "")
end
function Prefs.getSoundEffSwitch()
local f = PlayerPrefs.GetInt(soundEffSwitch, 0)
return (f == 0 and true or false)
end
function Prefs.setSoundEffSwitch(v)
local f = v and 0 or 1
PlayerPrefs.SetInt("soundEffSwitch", f)
end
function Prefs.getMusicSwitch()
local f = PlayerPrefs.GetInt(musicSwitch, 0)
return (f == 0 and true or false)
end
function Prefs.setMusicSwitch(v)
local f = v and 0 or 1
PlayerPrefs.SetInt("musicSwitch", f)
end
function Prefs.setLastLoginBtn(v)
return PlayerPrefs.SetString(lastLoginBtn, v)
end
function Prefs.getLastLoginBtn()
return PlayerPrefs.GetString(lastLoginBtn, "")
end
function Prefs.getToken()
return PlayerPrefs.GetString(token, "")
end
function Prefs.setToken(val)
PlayerPrefs.SetString(token, val)
end
function Prefs.getCurrGroup(phone)
return PlayerPrefs.GetString(phone .. "_" .. currGroup, "")
end
function Prefs.setCurrGroup(phone, val)
PlayerPrefs.SetString(phone .. "_" .. currGroup, val)
end
end

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9c62b7b1602d04ce4bb8b528598accdd
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,115 @@
--
-- Date: 2014-11-19 16:51:19
--
require("public.class")
---@class CLLQueue
CLLQueue = class("CLLQueue")
local insert = table.insert;
local remove = table.remove
function CLLQueue:ctor()
--self.capacity = capacity
self.queue = {}
--self.size_ = 0
--self.head = -1
--self.rear = -1
end
function CLLQueue:enQueue(element)
insert(self.queue, 1, 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
-- if temp == self.head then
-- print("Error: capacity is full.")
-- return
-- else
-- self.rear = temp
-- end
--
-- self.queue[self.rear] = element
-- self.size_ = self.size_ + 1
--end
end
function CLLQueue:deQueue()
if self:isEmpty() then
return nil;
end
return remove(self.queue, #(self.queue))
--if self:isEmpty() then
-- print("Error: The CLLQueue 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 CLLQueue:contains(obj)
if self:isEmpty() then
return false
end
for i, v in ipairs(self.queue) do
if v == obj then
return true
end
end
return false
end
function CLLQueue:clear()
self.queue = nil
self.queue = {}
--self.size_ = 0
--self.head = -1
--self.rear = -1
end
function CLLQueue:isEmpty()
if #(self.queue) == 0 then
return true
end
return false
--if self:size() == 0 then
-- return true
--end
--return false
end
function CLLQueue:size()
return #(self.queue)
end
function CLLQueue:printElement()
local str = ""
for i = self.size(), 1 do
str = str .. self.queue[i] .. ","
end
print(str)
--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].."}"
--print(str)
end
return CLLQueue

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8415343360d3948cd98502c5b7d57614
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
--
-- Date: 2014-11-19 15:29:02
--
require("public.class")
---@class CLLStack
CLLStack = class("CLLStack")
local remove = table.remove
function CLLStack:ctor()
self.stack_table = {}
end
function CLLStack:push(element)
local size = self:size()
self.stack_table[size + 1] = element
end
function CLLStack:pop()
local size = self:size()
if self:isEmpty() then
print("Error: CLLStack is empty!")
return
end
return remove(self.stack_table,size)
end
function CLLStack:top()
local size = self:size()
if self:isEmpty() then
print("Error: CLLStack is empty!")
return
end
return self.stack_table[size]
end
function CLLStack:contains(obj)
if self:isEmpty() then
return false
end
for i, v in pairs(self.stack_table) do
if v == obj then
return true
end
end
return false
end
function CLLStack:isEmpty()
local size = self:size()
if size == 0 then
return true
end
return false
end
function CLLStack:size()
return #(self.stack_table) or 0
end
function CLLStack:clear()
-- body
self.stack_table = nil
self.stack_table = {}
end
function CLLStack:printElement()
local size = self:size()
if self:isEmpty() then
print("Error: CLLStack is empty!")
return
end
local str = "{"..self.stack_table[size]
size = size - 1
while size > 0 do
str = str..", "..self.stack_table[size]
size = size - 1
end
str = str.."}"
print(str)
end
return CLLStack

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 893873b6ba53a4032a0fa9bbb295329d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,148 @@
---@class ClassBase
---@field public super ClassBase
local m = {}
function m.new()
end
function m:ctor(...)
end
---public 包装函数给c#用
function m:wrapFunc(func)
end
function m:wrapFunction4CS(func)
end
---public 创建类
---使用例:
--[[
A = class("A") -- 创建类A
function A:func1()
print("I'm A call func1")
end
function A:func2()
print("I'm A call func2")
end
------------------------------
B = class("B", A) -- 创建类B,继承A
function B:func1() -- 重载func1并且调用父类的func1注意使用方式
B.super.func1(self)
print("I'm B call func1")
end
function B:func3()
print("I'm B call func3")
end
------------------------------
C = class("C", B) -- 创建类C,继承B
function C:func1() -- 重载func1并且调用父类的func1注意使用方式
C.super.func1(self)
print("I'm C call func1")
end
------------------------------
-- 测试
local obj = C.new()
obj:func1()
obj:func2()
obj:func3()
-- 运行结果
LUA: [debug]:I'm A call func1
LUA: [debug]:I'm B call func1
LUA: [debug]:I'm C call func1
LUA: [debug]:I'm A call func2
LUA: [debug]:I'm B call func3
--]]
---@param classname string 类名
---@param super table 基类也是用class方法创建的类可以不传
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
end
cls.ctor = function()
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 = clone(super)
cls = {}
setmetatable(cls, {__index = super})
cls.super = super
else
cls = {
ctor = function()
end
}
end
cls.__cname = classname
cls.__ctype = 2 -- lua
cls.__index = cls
---public 包装函数给c#用
function cls:wrapFunc(func)
return self:wrapFunction4CS(func)
end
---public 包装函数给c#用
function cls:wrapFunction4CS(func)
if func == nil then
return nil
end
if self.__wrapFuncMap == nil then
self.__wrapFuncMap = {}
end
local infor = self.__wrapFuncMap[func]
if infor == nil then
infor = {instance = self, func = func}
self.__wrapFuncMap[func] = infor
end
return infor
end
function cls.new(...)
local instance = setmetatable({}, cls)
instance.class = cls
instance.__wrapFuncMap = {}, -- 包装函数缓存
instance:ctor(...)
return instance
end
end
return cls
end

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 820b39eaff2ad4dc5ab644539eed41d4
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: