增加文档

This commit is contained in:
2025-10-18 15:49:45 +08:00
parent a9b10b88c0
commit a753cf4998
7 changed files with 106 additions and 88 deletions

View File

@@ -8,64 +8,64 @@
/**
*
* @function
* @param {ActiveObject} obj
* @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
* @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
* @param {IRDSQRCharacter} 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)
}
}

View File

@@ -5,11 +5,23 @@
文件用途:角色站立状态
*/
/**
*
* @function
* @param {IRDSQRCharacter} obj
* @returns {boolean}
*/
function checkCanChangeState_Character_Rest(obj) {
return true;
}
/**
*
* @function
* @param {IRDSQRCharacter} 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 {IRDSQRCharacter} obj
* @param {integer} DeltaTime
* @returns {void}
*/
function ProcState_Character_Rest(obj, DeltaTime) {
}

View File

@@ -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}
*/

View File

@@ -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}

View File

@@ -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)
}
}

View File

@@ -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);

View File

@@ -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}
*/
@@ -89,7 +88,7 @@ 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) {}