Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d5b8bb4d5 | |||
| b16e8d7820 | |||
| 2686136f72 | |||
| cfa9e279e5 | |||
| ed376a4825 | |||
| a753cf4998 | |||
|
|
a9b10b88c0 | ||
| f00a65e2f8 |
@@ -5,48 +5,68 @@
|
|||||||
文件用途:角色移动脚本
|
文件用途:角色移动脚本
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {CharacterObject} obj
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
function checkCanChangeState_Character_Move(obj) {
|
function checkCanChangeState_Character_Move(obj) {
|
||||||
//获取当前状态
|
//获取当前状态
|
||||||
local CurState = obj.GetState();
|
local CurState = obj.GetState()
|
||||||
//得到摇杆的数据 X 和 Y的范围 -1.0 ~ 1.0
|
//得到摇杆的数据 X 和 Y的范围 -1.0 ~ 1.0
|
||||||
local arr = obj.GetVars("_move_data_", "float");
|
local arr = obj.GetVars("_move_data_", "float")
|
||||||
if (fabs(arr[0]) > 0.35 || fabs(arr[1]) > 0.35) {
|
if (fabs(arr[0]) > 0.35 || fabs(arr[1]) > 0.35) {
|
||||||
return true;
|
return true
|
||||||
} else return false;
|
} else return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {CharacterObject} obj
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
function SetState_Character_Move(obj) {
|
function SetState_Character_Move(obj) {
|
||||||
//获取移动数据
|
//获取移动数据
|
||||||
local arr = obj.GetVars("_move_data_", "float");
|
local arr = obj.GetVars("_move_data_", "float")
|
||||||
|
|
||||||
//设置人物朝向 摇杆X轴大于0则朝右,小于0则朝左
|
//设置人物朝向 摇杆X轴大于0则朝右,小于0则朝左
|
||||||
local SetValue = arr[0] > 0 ? 0 : 1;
|
local SetValue = arr[0] > 0 ? 0 : 1
|
||||||
if (SetValue != obj.GetDirection()) {
|
if (SetValue != obj.GetDirection()) {
|
||||||
if (fabs(arr[0]) > 0.35) obj.SetDirection(SetValue);
|
if (fabs(arr[0]) > 0.35) obj.SetDirection(SetValue)
|
||||||
//设置动作
|
//设置动作
|
||||||
obj.SetAction("move");
|
obj.SetAction("move")
|
||||||
} else {
|
} else {
|
||||||
if (obj.GetState() != 1) obj.SetAction("move");
|
if (obj.GetState() != 1) obj.SetAction("move")
|
||||||
}
|
}
|
||||||
|
|
||||||
local Speed = 250;
|
local Speed = 250
|
||||||
local Dir = obj.GetDirection();
|
local Dir = obj.GetDirection();
|
||||||
local Pos = obj.GetPosition();
|
local Pos = obj.GetPosition();
|
||||||
local XOffset = null;
|
local XOffset
|
||||||
if (fabs(arr[0]) > 0.35) XOffset = ((arr[0] > 0 ? Speed : -Speed));
|
if (fabs(arr[0]) > 0.35) XOffset = arr[0] > 0 ? Speed : -Speed
|
||||||
else XOffset = 0;
|
else XOffset = 0
|
||||||
local YOffset = null;
|
local YOffset
|
||||||
//当摇杆Y轴大于0.35或小于-0.35时,设置Y轴偏移量
|
//当摇杆Y轴大于0.35或小于-0.35时,设置Y轴偏移量
|
||||||
if (fabs(arr[1]) > 0.35) YOffset = (arr[1] > 0 ? Speed : -Speed);
|
if (fabs(arr[1]) > 0.35) YOffset = arr[1] > 0 ? Speed : -Speed
|
||||||
else YOffset = 0;
|
else YOffset = 0
|
||||||
|
|
||||||
obj.SetSpeed(XOffset, YOffset, null);
|
obj.SetSpeed(XOffset, YOffset, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {CharacterObject} obj
|
||||||
|
* @param {integer} DeltaTime
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
function ProcState_Character_Move(obj, DeltaTime) {
|
function ProcState_Character_Move(obj, DeltaTime) {
|
||||||
//获取移动数据
|
//获取移动数据
|
||||||
local arr = obj.GetVars("_move_data_", "float");
|
local arr = obj.GetVars("_move_data_", "float")
|
||||||
if (arr[0] == 0 && arr[1] == 0) {
|
if (arr[0] == 0 && arr[1] == 0) {
|
||||||
obj.SetState(0);
|
obj.SetState(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,23 @@
|
|||||||
文件用途:角色站立状态
|
文件用途:角色站立状态
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {CharacterObject} obj
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
function checkCanChangeState_Character_Rest(obj) {
|
function checkCanChangeState_Character_Rest(obj) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {CharacterObject} obj
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
function SetState_Character_Rest(obj) {
|
function SetState_Character_Rest(obj) {
|
||||||
//设置动作
|
//设置动作
|
||||||
obj.SetAction("rest");
|
obj.SetAction("rest");
|
||||||
@@ -17,6 +29,13 @@ function SetState_Character_Rest(obj) {
|
|||||||
obj.SetSpeed(0, 0, null);
|
obj.SetSpeed(0, 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {CharacterObject} obj
|
||||||
|
* @param {integer} DeltaTime
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
function ProcState_Character_Rest(obj, DeltaTime) {
|
function ProcState_Character_Rest(obj, DeltaTime) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,25 +1,34 @@
|
|||||||
/*
|
/**
|
||||||
文件名:ActiveObject.nut
|
* Description placeholder
|
||||||
路径:Game/ObjectClass/ActiveObject.nut
|
* @param {*} Object
|
||||||
创建日期:2025-10-03 02:50
|
*/
|
||||||
文件用途:
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ActiveObject extends BaseObject {
|
class ActiveObject extends BaseObject {
|
||||||
|
constructor(Object) {
|
||||||
|
base.constructor(Object);
|
||||||
|
}
|
||||||
|
|
||||||
constructor(Object) {
|
/**
|
||||||
base.constructor(Object);
|
* 设置三轴速度
|
||||||
}
|
* @function
|
||||||
|
* @param {integer} x
|
||||||
|
* @param {integer} y
|
||||||
|
* @param {integer} z
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function SetSpeed(x, y, z) {
|
||||||
|
local CurSpeed = sq_GetSpeed(C_Object);
|
||||||
|
if (x == null) x = CurSpeed.x;
|
||||||
|
if (y == null) y = CurSpeed.y;
|
||||||
|
if (z == null) z = CurSpeed.z;
|
||||||
|
sq_SetSpeed(C_Object, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
function SetSpeed(x, y, z) {
|
/**
|
||||||
local CurSpeed = sq_GetSpeed(C_Object);
|
* 获取三轴速度
|
||||||
if (x == null) x = CurSpeed.x;
|
* @function
|
||||||
if (y == null) y = CurSpeed.y;
|
* @returns {any}
|
||||||
if (z == null) z = CurSpeed.z;
|
*/
|
||||||
sq_SetSpeed(C_Object, x, y, z);
|
function GetSpeed() {
|
||||||
}
|
return sq_GetSpeed(C_Object);
|
||||||
|
}
|
||||||
function GetSpeed() {
|
}
|
||||||
return sq_GetSpeed(C_Object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,32 +1,75 @@
|
|||||||
|
/**
|
||||||
|
* Description placeholder
|
||||||
|
* @param {*} Object
|
||||||
|
*/
|
||||||
class BaseObject {
|
class BaseObject {
|
||||||
//c++对象指针
|
//c++对象指针
|
||||||
C_Object = null;
|
C_Object = null;
|
||||||
|
|
||||||
constructor(Object) {
|
constructor(Object) {
|
||||||
C_Object = Object;
|
C_Object = Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetPosition() {
|
/**
|
||||||
return sq_GetPosition(C_Object);
|
* 获取坐标
|
||||||
}
|
* @function
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
function GetPosition() {
|
||||||
|
return sq_GetPosition(C_Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置坐标
|
||||||
|
* @function
|
||||||
|
* @param {integer} x
|
||||||
|
* @param {integer} y
|
||||||
|
* @param {integer} z
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function SetPosition(x, y, z) {
|
||||||
|
sq_SetPosition(C_Object, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
function SetPosition(x, y, z) {
|
/**
|
||||||
sq_SetPosition(C_Object, x, y, z);
|
* 获取储存器
|
||||||
}
|
* @function
|
||||||
|
* @param {string} Name
|
||||||
|
* @param {string} Type
|
||||||
|
* @returns {array}
|
||||||
|
*/
|
||||||
|
function GetVars(Name, Type) {
|
||||||
|
return sq_GetVars(C_Object, Name, Type);
|
||||||
|
}
|
||||||
|
|
||||||
function GetVars(Name, Type) {
|
/**
|
||||||
return sq_GetVars(C_Object, Name, Type);
|
* 设置储存器
|
||||||
}
|
* @function
|
||||||
|
* @param {string} Name
|
||||||
|
* @param {any} Type
|
||||||
|
* @param {array} Value
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function SetVars(Name, Type, Value) {
|
||||||
|
sq_SetVars(C_Object, Name, Type, Value);
|
||||||
|
}
|
||||||
|
|
||||||
function SetVars(Name, Type, Value) {
|
/**
|
||||||
sq_SetVars(C_Object, Name, Type, Value);
|
* 获取方向
|
||||||
}
|
* @function
|
||||||
|
* @returns {integer}
|
||||||
|
*/
|
||||||
|
function GetDirection() {
|
||||||
|
return sq_GetDirection(C_Object);
|
||||||
|
}
|
||||||
|
|
||||||
function GetDirection() {
|
/**
|
||||||
return sq_GetDirection(C_Object);
|
* 设置方向
|
||||||
}
|
* @function
|
||||||
|
* @param {integer} Dir
|
||||||
function SetDirection(Dir) {
|
* @returns {void}
|
||||||
sq_SetDirection(C_Object, Dir);
|
*/
|
||||||
}
|
function SetDirection(Dir) {
|
||||||
}
|
sq_SetDirection(C_Object, Dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,23 +1,38 @@
|
|||||||
/*
|
/**
|
||||||
文件名:CharacterObject.nut
|
* Description placeholder
|
||||||
路径:Game/ObjectClass/CharacterObject.nut
|
* @param {*} Object
|
||||||
创建日期:2025-10-03 02:50
|
*/
|
||||||
文件用途:
|
|
||||||
*/
|
|
||||||
class CharacterObject extends ActiveObject {
|
class CharacterObject extends ActiveObject {
|
||||||
constructor(Object) {
|
constructor(Object) {
|
||||||
base.constructor(Object);
|
base.constructor(Object)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态
|
||||||
|
* @function
|
||||||
|
* @returns {integer} 状态编号
|
||||||
|
*/
|
||||||
function GetState() {
|
function GetState() {
|
||||||
return sq_GetState(C_Object);
|
return sq_GetState(C_Object)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置状态
|
||||||
|
* @function
|
||||||
|
* @param {integer} State
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
function SetState(State) {
|
function SetState(State) {
|
||||||
sq_SetState(C_Object, State);
|
sq_SetState(C_Object, State)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置动作
|
||||||
|
* @function
|
||||||
|
* @param {string} key
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
function SetAction(key) {
|
function SetAction(key) {
|
||||||
sq_SetAction(C_Object, key);
|
sq_SetAction(C_Object, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,81 +5,102 @@
|
|||||||
文件用途:
|
文件用途:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** 状态机
|
||||||
|
* @global
|
||||||
|
*/
|
||||||
class StateMachine {
|
class StateMachine {
|
||||||
//状态注册表
|
//状态注册表
|
||||||
StatusRegistry = null;
|
StatusRegistry = null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
if (getroottable().rawin("__StateMachine__")) {
|
if (getroottable().rawin("__StateMachine__")) {
|
||||||
// 防止重复实例化
|
// 防止重复实例化
|
||||||
throw "StateMachine 不能重复实例化!";
|
throw "StateMachine 不能重复实例化!";
|
||||||
}
|
}
|
||||||
//初始化状态注册表
|
//初始化状态注册表
|
||||||
StatusRegistry = {};
|
StatusRegistry = {};
|
||||||
foreach(JobIndex in getconsttable().CHARACTERJOB) {
|
foreach (JobIndex in getconsttable().CHARACTERJOB) {
|
||||||
StatusRegistry[JobIndex] <- {};
|
StatusRegistry[JobIndex] <- {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 静态方法:获取唯一实例
|
/**
|
||||||
function GetInstance() {
|
* 静态方法:获取唯一实例
|
||||||
if (!getroottable().rawin("__StateMachine__")) {
|
* @function
|
||||||
// 首次调用时创建实例
|
* @returns {StateMachine}
|
||||||
getroottable()["__StateMachine__"] <- StateMachine();
|
*/
|
||||||
}
|
function GetInstance() {
|
||||||
return getroottable()["__StateMachine__"];
|
if (!getroottable().rawin("__StateMachine__")) {
|
||||||
}
|
// 首次调用时创建实例
|
||||||
|
getroottable()["__StateMachine__"] <- StateMachine();
|
||||||
|
}
|
||||||
|
return getroottable()["__StateMachine__"];
|
||||||
|
}
|
||||||
|
|
||||||
//注册状态
|
/**
|
||||||
function RegisterState(Job, StateName, StateIndex) {
|
* 注册状态
|
||||||
StatusRegistry[Job][StateIndex] <- {
|
* @function
|
||||||
StateName = StateName,
|
* @param {integer} Job
|
||||||
StateIndex = StateIndex
|
* @param {any} StateName
|
||||||
}
|
* @param {integer} StateIndex
|
||||||
print("注册了状态" + StateName + ",状态索引为" + StateIndex);
|
* @returns {void}
|
||||||
}
|
*/
|
||||||
|
function RegisterState(Job, StateName, StateIndex) {
|
||||||
|
StatusRegistry[Job][StateIndex] <- {
|
||||||
|
StateName = StateName,
|
||||||
|
StateIndex = StateIndex
|
||||||
|
};
|
||||||
|
print("注册了状态" + StateName + ",状态索引为" + StateIndex);
|
||||||
|
}
|
||||||
|
|
||||||
//获取状态信息
|
/**
|
||||||
function GetStateInfo(Job, State) {
|
* 获取状态信息
|
||||||
return StatusRegistry[Job][State];
|
* @function
|
||||||
}
|
* @param {integer} Job
|
||||||
|
* @param {integer} State
|
||||||
|
* @returns {integer}
|
||||||
|
*/
|
||||||
|
function GetStateInfo(Job, State) {
|
||||||
|
return StatusRegistry[Job][State];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function StateMachine_checkCanChangeState(C_Object, Job, State) {
|
function StateMachine_checkCanChangeState(C_Object, Job, State) {
|
||||||
//获取状态信息
|
//获取状态信息
|
||||||
local StateInfo = StateMachine.GetInstance().GetStateInfo(Job, State);
|
local StateInfo = StateMachine.GetInstance().GetStateInfo(Job, State);
|
||||||
//判断是否有 检查能否切换状态函数
|
//判断是否有 检查能否切换状态函数
|
||||||
local FuncName = "checkCanChangeState_" + StateInfo.StateName;
|
local FuncName = "checkCanChangeState_" + StateInfo.StateName;
|
||||||
if (getroottable().rawin(FuncName)) {
|
if (getroottable().rawin(FuncName)) {
|
||||||
return getroottable()[FuncName](CharacterObject(C_Object));
|
return getroottable()[FuncName](CharacterObject(C_Object));
|
||||||
} else {
|
} else {
|
||||||
error("没有找到" + FuncName + "函数");
|
error("没有找到" + FuncName + "函数");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function StateMachine_SetState(C_Object, Job, State) {
|
function StateMachine_SetState(C_Object, Job, State) {
|
||||||
//获取状态信息
|
//获取状态信息
|
||||||
local StateInfo = StateMachine.GetInstance().GetStateInfo(Job, State);
|
local StateInfo = StateMachine.GetInstance().GetStateInfo(Job, State);
|
||||||
//判断是否有 设置状态函数
|
//判断是否有 设置状态函数
|
||||||
local FuncName = "SetState_" + StateInfo.StateName;
|
local FuncName = "SetState_" + StateInfo.StateName;
|
||||||
if (getroottable().rawin(FuncName)) {
|
if (getroottable().rawin(FuncName)) {
|
||||||
getroottable()[FuncName](CharacterObject(C_Object));
|
getroottable()[FuncName](CharacterObject(C_Object));
|
||||||
} else {
|
} else {
|
||||||
error("没有找到" + FuncName + "函数");
|
error("没有找到" + FuncName + "函数");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function StateMachine_ProcState(C_Object, Job, State, DeltaTime) {
|
function StateMachine_ProcState(C_Object, Job, State, DeltaTime) {
|
||||||
//获取状态信息
|
//获取状态信息
|
||||||
local StateInfo = StateMachine.GetInstance().GetStateInfo(Job, State);
|
local StateInfo = StateMachine.GetInstance().GetStateInfo(Job, State);
|
||||||
//判断是否有 设置状态函数
|
//判断是否有 设置状态函数
|
||||||
local FuncName = "ProcState_" + StateInfo.StateName;
|
local FuncName = "ProcState_" + StateInfo.StateName;
|
||||||
if (getroottable().rawin(FuncName)) {
|
if (getroottable().rawin(FuncName)) {
|
||||||
getroottable()[FuncName](CharacterObject(C_Object), DeltaTime);
|
getroottable()[FuncName](CharacterObject(C_Object), DeltaTime);
|
||||||
} else {
|
} else {
|
||||||
error("没有找到" + FuncName + "函数");
|
error("没有找到" + FuncName + "函数");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
enum.nut
|
enum.nut
|
||||||
|
Tool/Math.nut
|
||||||
|
|
||||||
|
|
||||||
Game/StateMachine/StateMachine.nut
|
Game/StateMachine/StateMachine.nut
|
||||||
@@ -12,5 +13,17 @@ Game/CharacterScript/Common/Rest.nut
|
|||||||
Game/CharacterScript/Common/Move.nut
|
Game/CharacterScript/Common/Move.nut
|
||||||
|
|
||||||
|
|
||||||
UI/asd.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
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
UI/MainUI.nut
Normal file
28
UI/MainUI.nut
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
文件名:MainUI.nut
|
||||||
|
路径:UI/MainUI.nut
|
||||||
|
创建日期:2025-10-11 11:21
|
||||||
|
文件用途:主界面UI
|
||||||
|
*/
|
||||||
|
//主界面UI初始化回调
|
||||||
|
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_(EventType, EventData) {
|
||||||
|
_Global_Windows_Events_(EventType, EventData);
|
||||||
|
}
|
||||||
|
//主界面UI更新回调
|
||||||
|
function _MainUI_Update_(deltaTime) {
|
||||||
|
_Global_Windows_Logic_(deltaTime);
|
||||||
|
}
|
||||||
|
//主界面UI退出回调
|
||||||
|
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 {
|
enum CHARACTERJOB {
|
||||||
SWORDMAN // 男鬼剑士
|
SWORDMAN, // 男鬼剑士
|
||||||
FIGHTER // 女格斗家
|
FIGHTER, // 女格斗家
|
||||||
GUNNER // 男神枪手
|
GUNNER, // 男神枪手
|
||||||
MAGE // 女魔法师
|
MAGE, // 女魔法师
|
||||||
PRIEST // 男圣职者
|
PRIEST, // 男圣职者
|
||||||
AT_GUNNER // 女神枪手
|
AT_GUNNER, // 女神枪手
|
||||||
THIEF // 暗夜使者
|
THIEF, // 暗夜使者
|
||||||
AT_FIGHTER // 男格斗家
|
AT_FIGHTER, // 男格斗家
|
||||||
AT_MAGE // 男魔法师
|
AT_MAGE, // 男魔法师
|
||||||
DEMONIC_SWORDMAN // 黑暗武士
|
DEMONIC_SWORDMAN, // 黑暗武士
|
||||||
CREATOR_MAGE // 缔造者
|
CREATOR_MAGE, // 缔造者
|
||||||
AT_SWORDMAN // 女鬼剑士
|
AT_SWORDMAN, // 女鬼剑士
|
||||||
KNIGHT // 守护者
|
KNIGHT, // 守护者
|
||||||
DEMONIC_LANCER // 魔枪士
|
DEMONIC_LANCER, // 魔枪士
|
||||||
AT_PRIEST // 女圣职者
|
AT_PRIEST, // 女圣职者
|
||||||
GUN_BLADER // 枪剑士
|
GUN_BLADER, // 枪剑士
|
||||||
ARCHER // 弓箭手
|
ARCHER, // 弓箭手
|
||||||
MAX // 无
|
MAX // 无
|
||||||
};
|
}
|
||||||
|
|
||||||
|
enum UI_EVENT {
|
||||||
|
MOUSEMOTION, //鼠标移动
|
||||||
|
MOUSEBUTTONDOWN, //鼠标按下
|
||||||
|
MOUSEBUTTONUP, //鼠标释放
|
||||||
|
MOUSEWHEEL //鼠标滚轮
|
||||||
|
KEYDOWN //键盘按下
|
||||||
|
KEYUP //键盘释放
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,5 +28,41 @@
|
|||||||
},
|
},
|
||||||
"Game/ObjectClass/CharacterObject.nut": {
|
"Game/ObjectClass/CharacterObject.nut": {
|
||||||
"description": "角色对象"
|
"description": "角色对象"
|
||||||
|
},
|
||||||
|
"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": "鼠标"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
112
internalInterfaceDoc/func.nut
Normal file
112
internalInterfaceDoc/func.nut
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} C_Object
|
||||||
|
* @param {integer} state 状态编号
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function sq_SetState(C_Object, state) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} C_Object
|
||||||
|
* @param {string} key 动作名称
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function sq_SetAction(C_Object, key) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} C_Object
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function sq_GetSpeed(C_Object) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} C_Object
|
||||||
|
* @param {integer} x
|
||||||
|
* @param {integer} y
|
||||||
|
* @param {integer} z
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function sq_SetSpeed(C_Object, x, y, z) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} C_Object
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function sq_GetPosition(C_Object) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} C_Object
|
||||||
|
* @param {integer} x
|
||||||
|
* @param {integer} y
|
||||||
|
* @param {integer} z
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function sq_SetPosition(C_Object, x, y, z) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} C_Object
|
||||||
|
* @param {string} Name 储存器名称
|
||||||
|
* @param {string} Type 数据类型(int,float,string,bool)
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function sq_GetVars(C_Object, Name, Type) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} C_Object
|
||||||
|
* @param {string} Name 储存器名称
|
||||||
|
* @param {string} Type 数据类型(int,float,string,bool)
|
||||||
|
* @param {any} Value
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function sq_SetVars(C_Object, Name, Type, Value) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} C_Object
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function sq_GetDirection(C_Object) {}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {any} C_Object
|
||||||
|
* @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){}
|
||||||
|
|
||||||
83
internalInterfaceDoc/文档注释须知.nut
Normal file
83
internalInterfaceDoc/文档注释须知.nut
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
//Type Squirrel的类型名称与squirrel一致
|
||||||
|
|
||||||
|
//integer->整数
|
||||||
|
//float->浮点数
|
||||||
|
//array或者[]代表任意类型数组
|
||||||
|
//table->{}
|
||||||
|
//string->字符串
|
||||||
|
//boolean->布尔值
|
||||||
|
|
||||||
|
//文档注释中指定类型的数组应该这么做
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description placeholder
|
||||||
|
* @param {array(integer)} args
|
||||||
|
*/
|
||||||
|
function arrayExample(args) {}
|
||||||
|
|
||||||
|
//任意类型的数组应该这么做
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {array} args
|
||||||
|
* @returns {void} //如果不写@returns 代表返回null,{void}或{*}代表返回any
|
||||||
|
*/
|
||||||
|
function anyArrayExample(args) {}
|
||||||
|
|
||||||
|
//以下是其他类型的文档注释示例
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {integer} args
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function intExample(args) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {float} args
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function floatExample(args) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description placeholder
|
||||||
|
* @param {string} args
|
||||||
|
*/
|
||||||
|
function stringExample(args) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {boolean} args
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function boolExample(args) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @function
|
||||||
|
* @param {table} args
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function tableExample(args) {}
|
||||||
|
|
||||||
|
//以下是内联提示与hover
|
||||||
|
local a = 1;
|
||||||
|
local b = "1";
|
||||||
|
local c = 1.1;
|
||||||
|
local d = false;
|
||||||
|
local t = {};
|
||||||
|
local arr = [];
|
||||||
|
local intArr = [1];
|
||||||
|
local floatArr = [1.1];
|
||||||
|
local strArr = ["str"];
|
||||||
|
local anyArr = [];
|
||||||
|
|
||||||
|
//以下是二元表达式类型推断
|
||||||
|
local x = 1 + 1;
|
||||||
|
local x1 = 1 / 1;
|
||||||
|
local x2 = 1 * 0.1;
|
||||||
|
local x3 = (1 + 1).tofloat() + (1 / 2).tofloat();
|
||||||
Reference in New Issue
Block a user