1111
This commit is contained in:
@@ -27,7 +27,7 @@ class StateMachine {
|
|||||||
/**
|
/**
|
||||||
* 静态方法:获取唯一实例
|
* 静态方法:获取唯一实例
|
||||||
* @function
|
* @function
|
||||||
* @returns {table}
|
* @returns {StateMachine}
|
||||||
*/
|
*/
|
||||||
function GetInstance() {
|
function GetInstance() {
|
||||||
if (!getroottable().rawin("__StateMachine__")) {
|
if (!getroottable().rawin("__StateMachine__")) {
|
||||||
|
|||||||
@@ -12,5 +12,10 @@ Game/CharacterScript/Common/Rest.nut
|
|||||||
Game/CharacterScript/Common/Move.nut
|
Game/CharacterScript/Common/Move.nut
|
||||||
|
|
||||||
|
|
||||||
|
UI/ObjectClass/BaseNode.nut
|
||||||
|
UI/ObjectClass/Actor.nut
|
||||||
|
UI/ObjectClass/WindowNode.nut
|
||||||
|
UI/ObjectClass/GameWindow.nut
|
||||||
|
UI/ObjectClass/Sprite.nut
|
||||||
UI/MainUI.nut
|
UI/MainUI.nut
|
||||||
main.nut
|
main.nut
|
||||||
@@ -5,18 +5,23 @@
|
|||||||
文件用途:主界面UI
|
文件用途:主界面UI
|
||||||
*/
|
*/
|
||||||
//主界面UI初始化回调
|
//主界面UI初始化回调
|
||||||
function _MainUI_Enter_()
|
function _MainUI_Enter_(UI_Scene) {
|
||||||
{
|
if (!_SYS_UI_SCENE_Instance_) _SYS_UI_SCENE_Instance_ = Actor(UI_Scene)
|
||||||
|
|
||||||
|
local TestWindow = sq_CreaterWindow("测试窗口", GameWindow)
|
||||||
|
TestWindow.ResetFoucus()
|
||||||
|
|
||||||
|
local Sp = Sprite(
|
||||||
|
"sprite/interface2/worldmap/step_2(area)/step_2(area)_bg.img",
|
||||||
|
12
|
||||||
|
)
|
||||||
|
TestWindow.AddChild(Sp)
|
||||||
}
|
}
|
||||||
//主界面UI事件回调
|
//主界面UI事件回调
|
||||||
function _MainUI_HandleEvents_(event)
|
function _MainUI_HandleEvents_(event) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
//主界面UI更新回调
|
//主界面UI更新回调
|
||||||
function _MainUI_Update_(deltaTime)
|
function _MainUI_Update_(deltaTime) {
|
||||||
{
|
_Global_Windows_Logic_(deltaTime)
|
||||||
}
|
}
|
||||||
//主界面UI退出回调
|
//主界面UI退出回调
|
||||||
function _MainUI_Exit_()
|
function _MainUI_Exit_() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
31
UI/ObjectClass/Actor.nut
Normal file
31
UI/ObjectClass/Actor.nut
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
文件名:Actor.nut
|
||||||
|
路径:UI/ObjectClass/Actor.nut
|
||||||
|
创建日期:2025-10-18 16:33
|
||||||
|
文件用途:
|
||||||
|
*/
|
||||||
|
class Actor extends BaseNode {
|
||||||
|
function _typeof() {
|
||||||
|
return "Actor"
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(obj = null) {
|
||||||
|
if (obj) {
|
||||||
|
base.constructor(obj, false)
|
||||||
|
} else {
|
||||||
|
base.constructor(sq_CreateActor())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function AddChild(Act) {
|
||||||
|
sq_AddChild(this.C_Object, Act.C_Object)
|
||||||
|
}
|
||||||
|
|
||||||
|
function RemoveChild(Act) {
|
||||||
|
sq_RemoveChild(this.C_Object, Act.C_Object)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetZOrder(Order){
|
||||||
|
sq_SetZOrder(this.C_Object, Order);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
UI/ObjectClass/BaseNode.nut
Normal file
16
UI/ObjectClass/BaseNode.nut
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
文件名:BaseNode.nut
|
||||||
|
路径:UI/ObjectClass/BaseNode.nut
|
||||||
|
创建日期:2025-10-18 20:43
|
||||||
|
文件用途:
|
||||||
|
*/
|
||||||
|
class BaseNode {
|
||||||
|
/** @private */
|
||||||
|
C_Object = null
|
||||||
|
|
||||||
|
constructor(CObject, DestructFlag = true) {
|
||||||
|
this.C_Object = CObject
|
||||||
|
//析构对象
|
||||||
|
if (DestructFlag) sq_RegisterDestruction(C_Object, this)
|
||||||
|
}
|
||||||
|
}
|
||||||
87
UI/ObjectClass/GameWindow.nut
Normal file
87
UI/ObjectClass/GameWindow.nut
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
文件名:GameWindow.nut
|
||||||
|
路径:UI/ObjectClass/GameWindow.nut
|
||||||
|
创建日期:2025-10-18 20:58
|
||||||
|
文件用途:游戏窗口类
|
||||||
|
*/
|
||||||
|
_SYS_UI_SCENE_Instance_ <- null
|
||||||
|
_SYS_WINDOW_LIST_ <- []
|
||||||
|
|
||||||
|
class GameWindow extends WindowNode {
|
||||||
|
//窗口名称
|
||||||
|
WindowName = "undefined"
|
||||||
|
|
||||||
|
function _typeof() {
|
||||||
|
return "GameWindow"
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(WindowName) {
|
||||||
|
base.constructor()
|
||||||
|
}
|
||||||
|
|
||||||
|
function ResetFoucus() {
|
||||||
|
SetVisible(true)
|
||||||
|
//遍历全局窗口数组将自己移除重新添加在末尾
|
||||||
|
foreach (Index, WindowObj in _SYS_WINDOW_LIST_) {
|
||||||
|
if (WindowObj.WindowName == this.WindowName) {
|
||||||
|
_SYS_WINDOW_LIST_.remove(Index)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_SYS_WINDOW_LIST_.append(this)
|
||||||
|
SetZOrder(_SYS_WINDOW_LIST_.len())
|
||||||
|
}
|
||||||
|
|
||||||
|
function Proc(Dt) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} WindowName
|
||||||
|
* @param {GameWindow} WindowClass
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
function sq_CreaterWindow(WindowName, WindowClass) {
|
||||||
|
foreach (idx, val in _SYS_WINDOW_LIST_) {
|
||||||
|
if (val.WindowName == WindowName) return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
local NewWindow = WindowClass(WindowName);
|
||||||
|
getroottable()._SYS_WINDOW_LIST_.push(NewWindow);
|
||||||
|
return NewWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {float} Dt
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function _Global_Windows_Logic_(Dt) {
|
||||||
|
if (_SYS_UI_SCENE_Instance_) {
|
||||||
|
for (local i = 0; i < _SYS_WINDOW_LIST_.len(); i++) {
|
||||||
|
local Window = _SYS_WINDOW_LIST_[i]
|
||||||
|
//如果窗口不可见并且 处于演出状态
|
||||||
|
if (!Window.Visible && Window.PerformanceState) {
|
||||||
|
Window.PerformanceState = false
|
||||||
|
_SYS_UI_SCENE_Instance_.RemoveChild(Window)
|
||||||
|
if (Window.DestroyFlag) {
|
||||||
|
_SYS_WINDOW_LIST_.remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
} else if (Window.Visible && !Window.PerformanceState) {
|
||||||
|
_SYS_UI_SCENE_Instance_.AddChild(Window)
|
||||||
|
Window.PerformanceState = true;
|
||||||
|
}
|
||||||
|
//无论窗口是否显示都需要调用Proc
|
||||||
|
Window.Proc(Dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
15
UI/ObjectClass/Sprite.nut
Normal file
15
UI/ObjectClass/Sprite.nut
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
文件名:Sprite.nut
|
||||||
|
路径:UI/ObjectClass/Sprite.nut
|
||||||
|
创建日期:2025-10-18 19:51
|
||||||
|
文件用途:精灵类
|
||||||
|
*/
|
||||||
|
class Sprite extends Actor {
|
||||||
|
function _typeof() {
|
||||||
|
return "Sprite"
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(ImgPath, Idx) {
|
||||||
|
base.constructor(sq_CreateSprite(ImgPath, Idx))
|
||||||
|
}
|
||||||
|
}
|
||||||
43
UI/ObjectClass/WindowNode.nut
Normal file
43
UI/ObjectClass/WindowNode.nut
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
文件名:WindowNode.nut
|
||||||
|
路径:UI/ObjectClass/WindowNode.nut
|
||||||
|
创建日期:2025-10-18 20:54
|
||||||
|
文件用途:窗口节点类
|
||||||
|
*/
|
||||||
|
class WindowNode extends Actor {
|
||||||
|
//演出状态
|
||||||
|
PerformanceState = false;
|
||||||
|
//子控件
|
||||||
|
Childrens = null;
|
||||||
|
//刷新函数
|
||||||
|
UpdateFunc = null;
|
||||||
|
//是否可见
|
||||||
|
Visible = true;
|
||||||
|
//宽度
|
||||||
|
Width = null;
|
||||||
|
//高度
|
||||||
|
Height = null;
|
||||||
|
//销毁Flag
|
||||||
|
DestroyFlag = false;
|
||||||
|
|
||||||
|
|
||||||
|
function _typeof() {
|
||||||
|
return "WindowNode"
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
base.constructor()
|
||||||
|
|
||||||
|
//子控件list初始化
|
||||||
|
Childrens = []
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetVisible(Flag) {
|
||||||
|
Visible = Flag
|
||||||
|
}
|
||||||
|
|
||||||
|
function AddChild(Act) {
|
||||||
|
base.AddChild(Act)
|
||||||
|
Childrens.push(Act)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,5 +31,20 @@
|
|||||||
},
|
},
|
||||||
"UI/MainUI.nut": {
|
"UI/MainUI.nut": {
|
||||||
"description": "UI入口"
|
"description": "UI入口"
|
||||||
|
},
|
||||||
|
"UI/ObjectClass": {
|
||||||
|
"description": "对象类"
|
||||||
|
},
|
||||||
|
"UI/ObjectClass/Actor.nut": {
|
||||||
|
"description": "演员类"
|
||||||
|
},
|
||||||
|
"UI/ObjectClass/Sprite.nut": {
|
||||||
|
"description": "精灵类"
|
||||||
|
},
|
||||||
|
"UI/ObjectClass/BaseNode.nut": {
|
||||||
|
"description": "基础节点"
|
||||||
|
},
|
||||||
|
"UI/ObjectClass/WindowNode.nut": {
|
||||||
|
"description": "窗口节点"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,9 +81,7 @@ function sq_SetVars(C_Object, Name, Type, Value) {}
|
|||||||
* @param {any} C_Object
|
* @param {any} C_Object
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function sq_GetDirection(C_Object) {
|
function sq_GetDirection(C_Object) {}
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @function
|
* @function
|
||||||
@@ -92,3 +90,10 @@ function sq_GetDirection(C_Object) {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function sq_SetDirection(C_Object, Dir) {}
|
function sq_SetDirection(C_Object, Dir) {}
|
||||||
|
|
||||||
|
function sq_CreateActor() {}
|
||||||
|
function sq_RegisterDestruction(a,b) {}
|
||||||
|
function sq_CreateSprite(a,b) {}
|
||||||
|
function sq_AddChild(a,b){}
|
||||||
|
function sq_RemoveChild(a,b){}
|
||||||
|
function sq_SetZOrder(a,b){}
|
||||||
Reference in New Issue
Block a user