Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d5b8bb4d5 | |||
| b16e8d7820 | |||
| 2686136f72 | |||
| cfa9e279e5 | |||
| ed376a4825 | |||
| a753cf4998 |
@@ -6,66 +6,67 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {ActiveObject} obj
|
||||
*
|
||||
* @function
|
||||
* @param {CharacterObject} obj
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkCanChangeState_Character_Move(obj) {
|
||||
//获取当前状态
|
||||
local CurState = obj.GetState();
|
||||
//得到摇杆的数据 X 和 Y的范围 -1.0 ~ 1.0
|
||||
local arr = obj.GetVars("_move_data_", "float");
|
||||
if (fabs(arr[0]) > 0.35 || fabs(arr[1]) > 0.35) {
|
||||
return true;
|
||||
} else return false;
|
||||
//获取当前状态
|
||||
local CurState = obj.GetState()
|
||||
//得到摇杆的数据 X 和 Y的范围 -1.0 ~ 1.0
|
||||
local arr = obj.GetVars("_move_data_", "float")
|
||||
if (fabs(arr[0]) > 0.35 || fabs(arr[1]) > 0.35) {
|
||||
return true
|
||||
} else return false
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {ActiveObject} obj
|
||||
*
|
||||
* @function
|
||||
* @param {CharacterObject} obj
|
||||
* @returns {void}
|
||||
*/
|
||||
function SetState_Character_Move(obj) {
|
||||
//获取移动数据
|
||||
local arr = obj.GetVars("_move_data_", "float");
|
||||
//获取移动数据
|
||||
local arr = obj.GetVars("_move_data_", "float")
|
||||
|
||||
//设置人物朝向 摇杆X轴大于0则朝右,小于0则朝左
|
||||
local SetValue = arr[0] > 0 ? 0 : 1;
|
||||
if (SetValue != obj.GetDirection()) {
|
||||
if (fabs(arr[0]) > 0.35) obj.SetDirection(SetValue);
|
||||
//设置动作
|
||||
obj.SetAction("move");
|
||||
} else {
|
||||
if (obj.GetState() != 1) obj.SetAction("move");
|
||||
}
|
||||
//设置人物朝向 摇杆X轴大于0则朝右,小于0则朝左
|
||||
local SetValue = arr[0] > 0 ? 0 : 1
|
||||
if (SetValue != obj.GetDirection()) {
|
||||
if (fabs(arr[0]) > 0.35) obj.SetDirection(SetValue)
|
||||
//设置动作
|
||||
obj.SetAction("move")
|
||||
} else {
|
||||
if (obj.GetState() != 1) obj.SetAction("move")
|
||||
}
|
||||
|
||||
local Speed = 250;
|
||||
local Dir = obj.GetDirection();
|
||||
local Pos = obj.GetPosition();
|
||||
local XOffset = null;
|
||||
if (fabs(arr[0]) > 0.35) XOffset = arr[0] > 0 ? Speed : -Speed;
|
||||
else XOffset = 0;
|
||||
local YOffset = null;
|
||||
//当摇杆Y轴大于0.35或小于-0.35时,设置Y轴偏移量
|
||||
if (fabs(arr[1]) > 0.35) YOffset = arr[1] > 0 ? Speed : -Speed;
|
||||
else YOffset = 0;
|
||||
local Speed = 250
|
||||
local Dir = obj.GetDirection();
|
||||
local Pos = obj.GetPosition();
|
||||
local XOffset
|
||||
if (fabs(arr[0]) > 0.35) XOffset = arr[0] > 0 ? Speed : -Speed
|
||||
else XOffset = 0
|
||||
local YOffset
|
||||
//当摇杆Y轴大于0.35或小于-0.35时,设置Y轴偏移量
|
||||
if (fabs(arr[1]) > 0.35) YOffset = arr[1] > 0 ? Speed : -Speed
|
||||
else YOffset = 0
|
||||
|
||||
obj.SetSpeed(XOffset, YOffset, null);
|
||||
obj.SetSpeed(XOffset, YOffset, null)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {ActiveObject} obj
|
||||
*
|
||||
* @function
|
||||
* @param {CharacterObject} obj
|
||||
* @param {integer} DeltaTime
|
||||
* @returns {void}
|
||||
*/
|
||||
function ProcState_Character_Move(obj, DeltaTime) {
|
||||
//获取移动数据
|
||||
local arr = obj.GetVars("_move_data_", "float");
|
||||
if (arr[0] == 0 && arr[1] == 0) {
|
||||
obj.SetState(0);
|
||||
}
|
||||
//获取移动数据
|
||||
local arr = obj.GetVars("_move_data_", "float")
|
||||
if (arr[0] == 0 && arr[1] == 0) {
|
||||
obj.SetState(0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,23 @@
|
||||
文件用途:角色站立状态
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {CharacterObject} obj
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function checkCanChangeState_Character_Rest(obj) {
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {CharacterObject} obj
|
||||
* @returns {void}
|
||||
*/
|
||||
function SetState_Character_Rest(obj) {
|
||||
//设置动作
|
||||
obj.SetAction("rest");
|
||||
@@ -17,6 +29,13 @@ function SetState_Character_Rest(obj) {
|
||||
obj.SetSpeed(0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {CharacterObject} obj
|
||||
* @param {integer} DeltaTime
|
||||
* @returns {void}
|
||||
*/
|
||||
function ProcState_Character_Rest(obj, DeltaTime) {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* Description placeholder
|
||||
* @global
|
||||
* @param {*} Object
|
||||
*/
|
||||
class ActiveObject extends BaseObject {
|
||||
@@ -9,7 +8,7 @@ class ActiveObject extends BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 设置三轴速度
|
||||
* @function
|
||||
* @param {integer} x
|
||||
* @param {integer} y
|
||||
@@ -25,7 +24,7 @@ class ActiveObject extends BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取三轴速度
|
||||
* @function
|
||||
* @returns {any}
|
||||
*/
|
||||
|
||||
@@ -11,16 +11,16 @@ class BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取坐标
|
||||
* @function
|
||||
* @returns {any}
|
||||
*/
|
||||
function GetPosition() {
|
||||
return sq_GetPosition(C_Object);
|
||||
}
|
||||
//
|
||||
|
||||
/**
|
||||
*
|
||||
* 设置坐标
|
||||
* @function
|
||||
* @param {integer} x
|
||||
* @param {integer} y
|
||||
@@ -32,22 +32,22 @@ class BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取储存器
|
||||
* @function
|
||||
* @param {string} Name
|
||||
* @param {any} Type
|
||||
* @returns {any}
|
||||
* @param {string} Type
|
||||
* @returns {array}
|
||||
*/
|
||||
function GetVars(Name, Type) {
|
||||
return sq_GetVars(C_Object, Name, Type);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 设置储存器
|
||||
* @function
|
||||
* @param {string} Name
|
||||
* @param {any} Type
|
||||
* @param {any} Value
|
||||
* @param {array} Value
|
||||
* @returns {void}
|
||||
*/
|
||||
function SetVars(Name, Type, Value) {
|
||||
@@ -55,7 +55,7 @@ class BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取方向
|
||||
* @function
|
||||
* @returns {integer}
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ class BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 设置方向
|
||||
* @function
|
||||
* @param {integer} Dir
|
||||
* @returns {void}
|
||||
|
||||
@@ -3,36 +3,36 @@
|
||||
* @param {*} Object
|
||||
*/
|
||||
class CharacterObject extends ActiveObject {
|
||||
constructor(Object) {
|
||||
base.constructor(Object);
|
||||
}
|
||||
constructor(Object) {
|
||||
base.constructor(Object)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @returns {*}
|
||||
*/
|
||||
function GetState() {
|
||||
return sq_GetState(C_Object);
|
||||
}
|
||||
/**
|
||||
* 获取状态
|
||||
* @function
|
||||
* @returns {integer} 状态编号
|
||||
*/
|
||||
function GetState() {
|
||||
return sq_GetState(C_Object)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {integer} State
|
||||
* @returns {void}
|
||||
*/
|
||||
function SetState(State) {
|
||||
sq_SetState(C_Object, State);
|
||||
}
|
||||
/**
|
||||
* 设置状态
|
||||
* @function
|
||||
* @param {integer} State
|
||||
* @returns {void}
|
||||
*/
|
||||
function SetState(State) {
|
||||
sq_SetState(C_Object, State)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {any} key
|
||||
* @returns {void}
|
||||
*/
|
||||
function SetAction(key) {
|
||||
sq_SetAction(C_Object, key);
|
||||
}
|
||||
/**
|
||||
* 设置动作
|
||||
* @function
|
||||
* @param {string} key
|
||||
* @returns {void}
|
||||
*/
|
||||
function SetAction(key) {
|
||||
sq_SetAction(C_Object, key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class StateMachine {
|
||||
/**
|
||||
* 静态方法:获取唯一实例
|
||||
* @function
|
||||
* @returns {table}
|
||||
* @returns {StateMachine}
|
||||
*/
|
||||
function GetInstance() {
|
||||
if (!getroottable().rawin("__StateMachine__")) {
|
||||
@@ -91,6 +91,7 @@ function StateMachine_SetState(C_Object, Job, State) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function StateMachine_ProcState(C_Object, Job, State, DeltaTime) {
|
||||
//获取状态信息
|
||||
local StateInfo = StateMachine.GetInstance().GetStateInfo(Job, State);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
enum.nut
|
||||
Tool/Math.nut
|
||||
|
||||
|
||||
Game/StateMachine/StateMachine.nut
|
||||
@@ -12,5 +13,17 @@ Game/CharacterScript/Common/Rest.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/Windows/System/Cursor.nut
|
||||
UI/Windows/HUD/Window_hud.nut
|
||||
|
||||
UI/MainUI.nut
|
||||
main.nut
|
||||
125
Tool/Math.nut
Normal file
125
Tool/Math.nut
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
文件名:Math.nut
|
||||
路径:Tool/Math.nut
|
||||
创建日期:2025-10-21 18:10
|
||||
文件用途:数学工具
|
||||
*/
|
||||
class Math {
|
||||
/**
|
||||
* 取随机值 左闭右闭
|
||||
* @function
|
||||
* @param {integer} Min
|
||||
* @param {integer} Max
|
||||
* @returns {integer}
|
||||
*/
|
||||
function Rand(Min, Max) {
|
||||
local In = rand();
|
||||
local Ret = (Min + (Max - Min + 1) * (In / (RAND_MAX + 1).tofloat())).tointeger();
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机返回数组中的任意一个数
|
||||
* @function
|
||||
* @param {array} arr
|
||||
* @returns {any}
|
||||
*/
|
||||
function GetRandomElementFromArray(arr) {
|
||||
if (arr.len() == 0) {
|
||||
return null;
|
||||
}
|
||||
// 生成一个0到数组长度-1之间的随机索引
|
||||
local randomIndex = Math.Rand(0, arr.len() - 1);
|
||||
return arr[randomIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过坐标获得两点旋转角度
|
||||
* @function
|
||||
* @param {integer} x1
|
||||
* @param {integer} y1
|
||||
* @param {integer} x2
|
||||
* @param {integer} y2
|
||||
* @returns {float}
|
||||
*/
|
||||
function GetRorateAngleByPos(x1, y1, x2, y2) {
|
||||
return (atan2((y2 - y1).tofloat(), (x2 - x1).tofloat()) * 180) / PI;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {integer} x1
|
||||
* @param {aintegerny} y1
|
||||
* @param {integer} x2
|
||||
* @param {integer} y2
|
||||
* @returns {float}
|
||||
*/
|
||||
function GetDistanceByPos(x1, y1, x2, y2) {
|
||||
return sqrt(pow((x2 - x1).tofloat(), 2) + pow((y2 - y1).tofloat(), 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得两值随时间的匀速运动值
|
||||
* @function
|
||||
* @param {any} sv
|
||||
* @param {any} ev
|
||||
* @param {float} currentRate
|
||||
* @param {float} maxRate
|
||||
* @returns {*}
|
||||
*/
|
||||
function GetUniformVelocity(sv, ev, currentRate, maxRate) {
|
||||
local rate = currentRate.tofloat() / maxRate.tofloat();
|
||||
local varyValue = ev - sv;
|
||||
return sv + varyValue * rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得两值随时间的变速运动值
|
||||
* @function
|
||||
* @param {any} sv
|
||||
* @param {any} ev
|
||||
* @param {float} currentRate
|
||||
* @param {float} maxRate
|
||||
* @param {any} increaseFeature
|
||||
* @returns {*}
|
||||
*/
|
||||
function GetAccel(sv, ev, currentRate, maxRate, increaseFeature) {
|
||||
local rate = currentRate.tofloat() / maxRate.tofloat();
|
||||
local varyValue = ev - sv;
|
||||
local increaseRate = 1.0;
|
||||
if (increaseFeature) {
|
||||
increaseRate = pow(50, rate) / 50.0; //慢->快
|
||||
} else {
|
||||
// 修正后的减速逻辑计算,例如采用线性变换结合幂次运算来实现更合理的减速效果
|
||||
// 先将rate映射到一个更合适的范围(这里从[0,1]映射到[0.1, 1],可调整)
|
||||
local mappedRate = rate * 0.9 + 0.1;
|
||||
increaseRate = pow(mappedRate, 2); // 幂次可调整,这里取2来让减速更明显,可根据实际情况修改
|
||||
}
|
||||
return sv + varyValue * increaseRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个矩形是否相交
|
||||
* @function
|
||||
* @param {any} x1
|
||||
* @param {any} y1
|
||||
* @param {any} width1
|
||||
* @param {any} height1
|
||||
* @param {any} x2
|
||||
* @param {any} y2
|
||||
* @param {any} width2
|
||||
* @param {any} height2
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function IsIntersectRect(x1, y1, width1, height1, x2, y2, width2, height2) {
|
||||
// 计算矩形1的边界
|
||||
local right1 = x1 + width1;
|
||||
local bottom1 = y1 + height1;
|
||||
// 计算矩形2的边界
|
||||
local right2 = x2 + width2;
|
||||
local bottom2 = y2 + height2;
|
||||
// 检查是否有重叠
|
||||
return !(right1 < x2 || bottom1 < y2 || x1 > right2 || y1 > bottom2);
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,24 @@
|
||||
文件用途:主界面UI
|
||||
*/
|
||||
//主界面UI初始化回调
|
||||
function _MainUI_Enter_()
|
||||
{
|
||||
function _MainUI_Enter_(UI_Scene) {
|
||||
if (!_SYS_UI_SCENE_Instance_) _SYS_UI_SCENE_Instance_ = Actor(UI_Scene);
|
||||
//初始化随机数种子
|
||||
srand(time());
|
||||
|
||||
//初始化鼠标
|
||||
Game_Cursor.GetInstance();
|
||||
|
||||
local TestWindow = sq_CreaterWindowInstance("HUD窗口", Window_hud, 0, 0, 1280, 720, 0);
|
||||
TestWindow.ResetFoucus();
|
||||
}
|
||||
//主界面UI事件回调
|
||||
function _MainUI_HandleEvents_(event)
|
||||
{
|
||||
function _MainUI_HandleEvents_(EventType, EventData) {
|
||||
_Global_Windows_Events_(EventType, EventData);
|
||||
}
|
||||
//主界面UI更新回调
|
||||
function _MainUI_Update_(deltaTime)
|
||||
{
|
||||
function _MainUI_Update_(deltaTime) {
|
||||
_Global_Windows_Logic_(deltaTime);
|
||||
}
|
||||
//主界面UI退出回调
|
||||
function _MainUI_Exit_()
|
||||
{
|
||||
}
|
||||
function _MainUI_Exit_() {}
|
||||
|
||||
46
UI/ObjectClass/Actor.nut
Normal file
46
UI/ObjectClass/Actor.nut
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
文件名: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);
|
||||
}
|
||||
|
||||
function SetScale(Value, ...) {
|
||||
if (vargv.len() == 0)
|
||||
sq_SetScale(this.C_Object, Value);
|
||||
else if (vargv.len() == 1)
|
||||
sq_SetScale(this.C_Object, Value, vargv[0]);
|
||||
}
|
||||
|
||||
function SetPos(Value, ...) {
|
||||
if (vargv.len() == 0) {
|
||||
sq_SetPos(this.C_Object, Value);
|
||||
} else if (vargv.len() == 1) {
|
||||
sq_SetPos(this.C_Object, Value, vargv[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
116
UI/ObjectClass/GameWindow.nut
Normal file
116
UI/ObjectClass/GameWindow.nut
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
文件名: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";
|
||||
//是否活动窗口Flag
|
||||
IsActiveFlag = false;
|
||||
|
||||
function _typeof() {
|
||||
return "GameWindow";
|
||||
}
|
||||
|
||||
constructor(WindowName, gX, gY, gWidth, gHeight, gTitleHeight) {
|
||||
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 OnMouseEvent(Type, Data) {
|
||||
if (!Visible) return;
|
||||
foreach (Window in Childrens) {
|
||||
if (Window instanceof WindowNode) Window.OnMouseEvent(Type, Data);
|
||||
}
|
||||
}
|
||||
|
||||
//键盘事件回调
|
||||
function OnKeyEvent(Type, Data) {
|
||||
if (!Visible) return;
|
||||
foreach (Window in Childrens) {
|
||||
if (Window instanceof WindowNode) Window.OnKeyEvent(Type, Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {any} WindowName
|
||||
* @param {GameWindow} WindowClass
|
||||
* @returns {any}
|
||||
*/
|
||||
function sq_CreaterWindowInstance(WindowName, WindowClass, gX, gY, gWidth, gHeight, gTitleHeight) {
|
||||
foreach (idx, val in _SYS_WINDOW_LIST_) {
|
||||
if (val.WindowName == WindowName) return val;
|
||||
}
|
||||
|
||||
local NewWindow = WindowClass(WindowName, gX, gY, gWidth, gHeight, gTitleHeight);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _Global_Windows_Events_(EventType, EventData) {
|
||||
//先传递鼠标事件
|
||||
Game_Cursor.GetInstance().Event(EventType, EventData);
|
||||
//事件是否被响应Flag
|
||||
local EventInteractiveFlag = false;
|
||||
for (local i = _SYS_WINDOW_LIST_.len() - 1; i > -1; i--) {
|
||||
local Window = _SYS_WINDOW_LIST_[i];
|
||||
if (Window.Visible) {
|
||||
if (EventType == UI_EVENT.MOUSEMOTION || EventType == UI_EVENT.MOUSEBUTTONDOWN || EventType == UI_EVENT.MOUSEBUTTONUP) {
|
||||
Window.OnMouseEvent(EventType, EventData);
|
||||
} else if (EventType == UI_EVENT.KEYDOWN || EventType == UI_EVENT.KEYUP) {
|
||||
Window.OnKeyEvent(EventType, EventData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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))
|
||||
}
|
||||
}
|
||||
42
UI/ObjectClass/WindowNode.nut
Normal file
42
UI/ObjectClass/WindowNode.nut
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
文件名: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) {
|
||||
if (!(Act instanceof WindowNode)) base.AddChild(Act);
|
||||
Childrens.push(Act);
|
||||
}
|
||||
}
|
||||
20
UI/Windows/HUD/Window_hud.nut
Normal file
20
UI/Windows/HUD/Window_hud.nut
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
文件名:Window_hud.nut
|
||||
路径:UI/Windows/HUD/Window_hud.nut
|
||||
创建日期:2025-10-19 20:36
|
||||
文件用途:
|
||||
*/
|
||||
|
||||
class Window_hud extends GameWindow {
|
||||
constructor(Name, gX, gY, gWidth, gHeight, gTitleHeight) {
|
||||
base.constructor(Name, gX, gY, gWidth, gHeight, gTitleHeight);
|
||||
|
||||
InitSprite();
|
||||
}
|
||||
|
||||
function InitSprite() {
|
||||
local Sp = Sprite("sprite/interface2/hud/hud.img", 0);
|
||||
Sp.SetPos((1280 - 403) / 2, 720 - 75);
|
||||
AddChild(Sp);
|
||||
}
|
||||
}
|
||||
75
UI/Windows/System/Cursor.nut
Normal file
75
UI/Windows/System/Cursor.nut
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
文件名:Cursor.nut
|
||||
路径:UI/Windows/System/Cursor.nut
|
||||
创建日期:2025-10-21 18:46
|
||||
文件用途:
|
||||
*/
|
||||
|
||||
class Game_Cursor extends GameWindow {
|
||||
//鼠标精灵数组
|
||||
MouseSprite = null;
|
||||
//当前鼠标工作ID
|
||||
CurrentMouseTaskId = 0;
|
||||
|
||||
//鼠标X坐标
|
||||
MouseX = 0;
|
||||
//鼠标Y坐标
|
||||
MouseY = 0;
|
||||
|
||||
constructor() {
|
||||
if (getroottable().rawin("__Game_Cursor__")) {
|
||||
// 防止重复实例化
|
||||
throw "Game_Cursor 不能重复实例化!";
|
||||
}
|
||||
base.constructor("系统鼠标", 0, 0, 1280, 720, 0);
|
||||
|
||||
Init();
|
||||
//设置鼠标的层级最高
|
||||
this.SetZOrder(10000000);
|
||||
_SYS_UI_SCENE_Instance_.AddChild(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态方法:获取唯一实例
|
||||
* @function
|
||||
* @returns {Game_Cursor}
|
||||
*/
|
||||
function GetInstance() {
|
||||
if (!getroottable().rawin("__Game_Cursor__")) {
|
||||
// 首次调用时创建实例
|
||||
getroottable()["__Game_Cursor__"] <- Game_Cursor();
|
||||
}
|
||||
return getroottable()["__Game_Cursor__"];
|
||||
}
|
||||
|
||||
function Init() {
|
||||
MouseSprite = [];
|
||||
for (local i = 0; i < 254; i++) {
|
||||
//初始化鼠标精灵
|
||||
local Buffer = Sprite("sprite/interface/newstyle/windows/cursor.img", i);
|
||||
MouseSprite.push(Buffer);
|
||||
}
|
||||
SetNormalTask(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置鼠标的普通任务
|
||||
* @function
|
||||
* @returns {void}
|
||||
*/
|
||||
function SetNormalTask(TaskId) {
|
||||
RemoveChild(MouseSprite[CurrentMouseTaskId]);
|
||||
CurrentMouseTaskId = TaskId;
|
||||
AddChild(MouseSprite[CurrentMouseTaskId]);
|
||||
MouseSprite[CurrentMouseTaskId].SetPos(MouseX, MouseY);
|
||||
}
|
||||
|
||||
//事件
|
||||
function Event(EventType, EventData) {
|
||||
if (EventType == UI_EVENT.MOUSEMOTION) {
|
||||
MouseX = EventData[0];
|
||||
MouseY = EventData[1];
|
||||
MouseSprite[CurrentMouseTaskId].SetPos(MouseX, MouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
enum.nut
45
enum.nut
@@ -6,22 +6,31 @@
|
||||
*/
|
||||
|
||||
enum CHARACTERJOB {
|
||||
SWORDMAN // 男鬼剑士
|
||||
FIGHTER // 女格斗家
|
||||
GUNNER // 男神枪手
|
||||
MAGE // 女魔法师
|
||||
PRIEST // 男圣职者
|
||||
AT_GUNNER // 女神枪手
|
||||
THIEF // 暗夜使者
|
||||
AT_FIGHTER // 男格斗家
|
||||
AT_MAGE // 男魔法师
|
||||
DEMONIC_SWORDMAN // 黑暗武士
|
||||
CREATOR_MAGE // 缔造者
|
||||
AT_SWORDMAN // 女鬼剑士
|
||||
KNIGHT // 守护者
|
||||
DEMONIC_LANCER // 魔枪士
|
||||
AT_PRIEST // 女圣职者
|
||||
GUN_BLADER // 枪剑士
|
||||
ARCHER // 弓箭手
|
||||
SWORDMAN, // 男鬼剑士
|
||||
FIGHTER, // 女格斗家
|
||||
GUNNER, // 男神枪手
|
||||
MAGE, // 女魔法师
|
||||
PRIEST, // 男圣职者
|
||||
AT_GUNNER, // 女神枪手
|
||||
THIEF, // 暗夜使者
|
||||
AT_FIGHTER, // 男格斗家
|
||||
AT_MAGE, // 男魔法师
|
||||
DEMONIC_SWORDMAN, // 黑暗武士
|
||||
CREATOR_MAGE, // 缔造者
|
||||
AT_SWORDMAN, // 女鬼剑士
|
||||
KNIGHT, // 守护者
|
||||
DEMONIC_LANCER, // 魔枪士
|
||||
AT_PRIEST, // 女圣职者
|
||||
GUN_BLADER, // 枪剑士
|
||||
ARCHER, // 弓箭手
|
||||
MAX // 无
|
||||
};
|
||||
}
|
||||
|
||||
enum UI_EVENT {
|
||||
MOUSEMOTION, //鼠标移动
|
||||
MOUSEBUTTONDOWN, //鼠标按下
|
||||
MOUSEBUTTONUP, //鼠标释放
|
||||
MOUSEWHEEL //鼠标滚轮
|
||||
KEYDOWN //键盘按下
|
||||
KEYUP //键盘释放
|
||||
}
|
||||
|
||||
@@ -31,5 +31,38 @@
|
||||
},
|
||||
"UI/MainUI.nut": {
|
||||
"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": "窗口节点"
|
||||
},
|
||||
"UI/Windows": {
|
||||
"description": "窗口集合"
|
||||
},
|
||||
"UI/Windows/HUD": {
|
||||
"description": "血槽"
|
||||
},
|
||||
"UI/Windows/HUD/Window_hud.nut": {
|
||||
"description": "血槽窗口"
|
||||
},
|
||||
"Tool": {
|
||||
"description": "工具类"
|
||||
},
|
||||
"UI/Windows/System": {
|
||||
"description": "系统"
|
||||
},
|
||||
"UI/Windows/System/Cursor.nut": {
|
||||
"description": "鼠标"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* @function
|
||||
* @param {any} C_Object
|
||||
* @param {integer} state
|
||||
* @param {integer} state 状态编号
|
||||
* @returns {void}
|
||||
*/
|
||||
function sq_SetState(C_Object, state) {}
|
||||
@@ -11,8 +11,7 @@ function sq_SetState(C_Object, state) {}
|
||||
*
|
||||
* @function
|
||||
* @param {any} C_Object
|
||||
* @param {any} key
|
||||
*
|
||||
* @param {string} key 动作名称
|
||||
* @returns {void}
|
||||
*/
|
||||
function sq_SetAction(C_Object, key) {}
|
||||
@@ -59,8 +58,8 @@ function sq_SetPosition(C_Object, x, y, z) {}
|
||||
*
|
||||
* @function
|
||||
* @param {any} C_Object
|
||||
* @param {string} Name
|
||||
* @param {any} Type
|
||||
* @param {string} Name 储存器名称
|
||||
* @param {string} Type 数据类型(int,float,string,bool)
|
||||
* @returns {void}
|
||||
*/
|
||||
function sq_GetVars(C_Object, Name, Type) {}
|
||||
@@ -69,8 +68,8 @@ function sq_GetVars(C_Object, Name, Type) {}
|
||||
*
|
||||
* @function
|
||||
* @param {any} C_Object
|
||||
* @param {string} Name
|
||||
* @param {any} Type
|
||||
* @param {string} Name 储存器名称
|
||||
* @param {string} Type 数据类型(int,float,string,bool)
|
||||
* @param {any} Value
|
||||
* @returns {void}
|
||||
*/
|
||||
@@ -82,14 +81,32 @@ function sq_SetVars(C_Object, Name, Type, Value) {}
|
||||
* @param {any} C_Object
|
||||
* @returns {void}
|
||||
*/
|
||||
function sq_GetDirection(C_Object) {
|
||||
|
||||
}
|
||||
function sq_GetDirection(C_Object) {}
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {any} C_Object
|
||||
* @param {integer} Dir
|
||||
* @param {integer} Dir 方向(0左 1右)
|
||||
* @returns {void}
|
||||
*/
|
||||
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){}
|
||||
|
||||
function sq_SetPos(a,...){}
|
||||
function sq_SetScale(a,...){}
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {any} a
|
||||
* @param {any} b
|
||||
* @returns {any}
|
||||
*/
|
||||
function pow(a,b){}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user