Lua向C#逻辑迁移 一期
创建了若干C#文件,替代对应lua文件
This commit is contained in:
Binary file not shown.
Binary file not shown.
@ -1,38 +0,0 @@
|
|||||||
---@enum EBusyRoleState
|
|
||||||
local EBusyRoleState = {
|
|
||||||
BonfireIdle = 0,
|
|
||||||
Searching = 1,
|
|
||||||
Picking = 2,
|
|
||||||
PickFinished = 3,
|
|
||||||
BackBonfire = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
---@enum ERoleMoveDirection
|
|
||||||
local ERoleMoveDirection = {
|
|
||||||
Move_Right = 0,
|
|
||||||
Move_Left = 1,
|
|
||||||
Move_All_Cnt = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
---@enum EBusyItemEffectType
|
|
||||||
local EBusyItemEffectType = {
|
|
||||||
Health = 0,
|
|
||||||
Hunger = 1,
|
|
||||||
Speed = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
---@enum EBusyAnimationPhase
|
|
||||||
local EBusyAnimationPhase = {
|
|
||||||
PrepareCast = 0,
|
|
||||||
Casting = 1,
|
|
||||||
PostCast = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
---@enum EWidgetLayoutType
|
|
||||||
local EWidgetLayoutType = {
|
|
||||||
MainLayer = 0,
|
|
||||||
PopupLayer = 1,
|
|
||||||
FloatLayer = 2,
|
|
||||||
TopLayer = 3,
|
|
||||||
LayerTypeMax = 4
|
|
||||||
};
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
--- @class BusyGameplayLibrary
|
|
||||||
--- @field K2_GetWorld fun(obj:table):table
|
|
||||||
--- @field RequestGameplayTag fun(TagName:string):GameplayTag
|
|
||||||
local BusyGameplayLibrary = {}
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
-- 这个返回值固定返回的是string,我希望当我使用import("ERoleState")时,它返回的是ERoleState的注解,或者是ERoleState.lua这个文件返回值的注解
|
|
||||||
-- ---自定义导入函数,功能类似require但支持额外特性
|
|
||||||
-- ---@generic T
|
|
||||||
-- ---@param modulePath T 模块路径或预加载的模块
|
|
||||||
-- ---@param hotReload? boolean 是否启用热重载
|
|
||||||
-- ---@return T 返回加载的模块
|
|
||||||
-- function import(modulePath, hotReload) end
|
|
||||||
|
|
||||||
|
|
||||||
---自定义模块导入函数,支持类型感知的模块加载
|
|
||||||
---@generic T : string -- 限定modulePath为字符串类型
|
|
||||||
---@param modulePath `T` 模块路径(如"ERoleState")
|
|
||||||
---@param hotReload? boolean 是否启用热重载
|
|
||||||
---@return T 返回对应模块的类型
|
|
||||||
---@error 当模块加载失败时抛出错误
|
|
||||||
function import(modulePath, hotReload) end
|
|
||||||
|
|
||||||
|
|
||||||
function Class(a, b, c) end
|
|
||||||
|
|
||||||
---@class slua
|
|
||||||
slua = {
|
|
||||||
createDelegate = function(func) end
|
|
||||||
}
|
|
||||||
|
|
||||||
--- @class KismetSystemLibrary
|
|
||||||
KismetSystemLibrary = {
|
|
||||||
K2_ClearTimerHandle = function() end
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
--- @class GameplayTag
|
|
||||||
local GameplayTag
|
|
||||||
|
|
||||||
--- @class GameplayStatics
|
|
||||||
--- @field GetPlayerController fun(uobj:table,idx:number):table
|
|
||||||
--- @field GetGameState fun(uobj:table):table
|
|
||||||
local GameplayStatics
|
|
||||||
|
|
||||||
--- @class AbilitySystemBlueprintLibrary
|
|
||||||
--- @field AssignTagSetByCallerMagnitude fun(SpecHandle:table, DataTag:GameplayTag, Magnitude:number)
|
|
||||||
local AbilitySystemBlueprintLibrary
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
---@enum ESlateVisibility
|
|
||||||
local ESlateVisibility = {
|
|
||||||
Visible = 0,
|
|
||||||
Collapsed = 1,
|
|
||||||
Hidden = 2,
|
|
||||||
HitTestInvisible = 3,
|
|
||||||
SelfHitTestInvisible = 4
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,222 +0,0 @@
|
|||||||
#ifndef LIBPDEBUG_H
|
|
||||||
#define LIBPDEBUG_H
|
|
||||||
|
|
||||||
//1.使用源码编译,要打开宏USE_SOURCE_CODE. win下要设置LUA_INTEGER和lua版本号
|
|
||||||
#define LUA_DEBUGGER_NAME "LuaPanda" //debugger's name in LuaDebug.lua
|
|
||||||
#define HOOK_LIB_VERSION "3.2.0" //lib version
|
|
||||||
//#define USE_SOURCE_CODE //using source code to build
|
|
||||||
#if !defined(USE_SOURCE_CODE) && defined(_WIN32)
|
|
||||||
#define LUA_INTEGER long long //set LUA_INTEGER. In 501 is ptrdiff_t. 503 can set longlong(64bit) or int(32bit)
|
|
||||||
#define LUA_VERSION_NUM 503 //lua version used by WIN32 build lib. eg. 501,503
|
|
||||||
#endif
|
|
||||||
//setting end
|
|
||||||
|
|
||||||
#if !defined(USE_SOURCE_CODE) && defined(_WIN32)
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <Tlhelp32.h>
|
|
||||||
#else
|
|
||||||
//2.如果lua源码是C++形式,注释掉下面extern "C"
|
|
||||||
extern "C"{
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lualib.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "luaconf.h"
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//3.如果lua代码在命名空间中,要设置用户命名空间. 防止找不到lua方法
|
|
||||||
//using namespace slua;
|
|
||||||
|
|
||||||
#ifdef USE_SOURCE_CODE
|
|
||||||
extern "C" void pdebug_init(lua_State* L);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(USE_SOURCE_CODE) && defined(_WIN32)
|
|
||||||
/*
|
|
||||||
** Lua - An Extensible Extension Language
|
|
||||||
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
|
||||||
** See Copyright Notice at the end of this file
|
|
||||||
*/
|
|
||||||
#if LUA_VERSION_NUM == 501
|
|
||||||
#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LUA_TNONE (-1)
|
|
||||||
#define LUA_TNIL 0
|
|
||||||
#define LUA_TBOOLEAN 1
|
|
||||||
#define LUA_TLIGHTUSERDATA 2
|
|
||||||
#define LUA_TNUMBER 3
|
|
||||||
#define LUA_TSTRING 4
|
|
||||||
#define LUA_TTABLE 5
|
|
||||||
#define LUA_TFUNCTION 6
|
|
||||||
#define LUA_TUSERDATA 7
|
|
||||||
#define LUA_TTHREAD 8
|
|
||||||
#define LUA_NUMBER double
|
|
||||||
#define LUA_REGISTRYINDEX (-10000)
|
|
||||||
#define LUA_ENVIRONINDEX (-10001)
|
|
||||||
#define LUA_GLOBALSINDEX (-10002)
|
|
||||||
#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
|
|
||||||
#define LUA_IDSIZE 60
|
|
||||||
#define LUA_HOOKCALL 0
|
|
||||||
#define LUA_HOOKRET 1
|
|
||||||
#define LUA_HOOKLINE 2
|
|
||||||
#define LUA_HOOKCOUNT 3
|
|
||||||
#define LUA_HOOKTAILRET 4
|
|
||||||
#define LUA_MASKCALL (1 << LUA_HOOKCALL)
|
|
||||||
#define LUA_MASKRET (1 << LUA_HOOKRET)
|
|
||||||
#define LUA_MASKLINE (1 << LUA_HOOKLINE)
|
|
||||||
#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
|
|
||||||
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
|
|
||||||
#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
|
|
||||||
#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
|
|
||||||
#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
|
|
||||||
#define lua_pop(L,n) lua_settop(L, -(n)-1)
|
|
||||||
#define lua_newtable(L) lua_createtable(L, 0, 0)
|
|
||||||
|
|
||||||
struct lua_State;
|
|
||||||
struct lua_Debug {
|
|
||||||
int event;
|
|
||||||
const char *name; /* (n) */
|
|
||||||
const char *namewhat; /* (n) `global', `local', `field', `method' */
|
|
||||||
const char *what; /* (S) `Lua', `C', `main', `tail' */
|
|
||||||
const char *source; /* (S) */
|
|
||||||
int currentline; /* (l) */
|
|
||||||
int nups; /* (u) number of upvalues */
|
|
||||||
int linedefined; /* (S) */
|
|
||||||
int lastlinedefined; /* (S) */
|
|
||||||
char short_src[LUA_IDSIZE]; /* (S) */
|
|
||||||
/* private part */
|
|
||||||
int i_ci; /* active function */
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef LUA_INTEGER lua_Integer;
|
|
||||||
typedef LUA_NUMBER lua_Number;
|
|
||||||
typedef int (*lua_CFunction) (lua_State *L);
|
|
||||||
typedef struct luaL_Reg {
|
|
||||||
const char *name;
|
|
||||||
lua_CFunction func;
|
|
||||||
} luaL_Reg;
|
|
||||||
|
|
||||||
#define LUA_KCONTEXT ptrdiff_t
|
|
||||||
typedef LUA_KCONTEXT lua_KContext;
|
|
||||||
|
|
||||||
//lua function
|
|
||||||
typedef lua_Integer(*luaDLL_checkinteger) (lua_State *L, int numArg);
|
|
||||||
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
|
|
||||||
typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);
|
|
||||||
typedef const lua_Number *(*luaDLL_version)(lua_State *L);
|
|
||||||
typedef void (*luaLDLL_register)(lua_State *L, const char *libname, const luaL_Reg *l);
|
|
||||||
typedef int (*luaDLL_gettop)(lua_State *L);
|
|
||||||
typedef const char *(*luaDLL_pushstring)(lua_State *L, const char *s);
|
|
||||||
typedef int (*luaDLL_settop)(lua_State *L, int idx);
|
|
||||||
typedef int (*luaDLL_tointeger)(lua_State *L, int idx);
|
|
||||||
typedef int (*luaDLL_next)(lua_State *L, int idx);
|
|
||||||
typedef int (*luaDLL_pcall)(lua_State *L, int nargs, int nresults, int errfunc);
|
|
||||||
typedef void (*luaDLL_pushnil)(lua_State *L);
|
|
||||||
typedef void (*luaDLL_getfield)(lua_State *L, int idx, const char *k);
|
|
||||||
typedef int (*luaDLL_getinfo)(lua_State *L, const char *what, void *ar);
|
|
||||||
typedef void (*luaDLL_pushinteger) (lua_State *L, lua_Integer n);
|
|
||||||
#if LUA_VERSION_NUM == 501
|
|
||||||
typedef int(*luaDLL_sethook)(lua_State *L, void* func, int mask, int count);
|
|
||||||
#else
|
|
||||||
typedef void (*luaDLL_sethook)(lua_State *L, lua_Hook f, int mask, int count);
|
|
||||||
#endif
|
|
||||||
typedef void (*luaDLL_pushnumber)(lua_State *L, lua_Number n);
|
|
||||||
typedef lua_Number (*luaDLL_checknumber)(lua_State *L, int narg);
|
|
||||||
typedef const char *(*luaDLL_checklstring)(lua_State *L, int narg, size_t *len);
|
|
||||||
typedef const char *(*luaDLL_tolstring)(lua_State *L, int idx, size_t *len);
|
|
||||||
typedef int (*luaDLL_type)(lua_State *L, int idx);
|
|
||||||
//5.3
|
|
||||||
typedef void (*luaDLL_createtable)(lua_State *L, int narray, int nrec);
|
|
||||||
typedef void (*luaDLL_setfuncs)(lua_State *L, const luaL_Reg *l, int nup);
|
|
||||||
typedef lua_Integer(*luaDLL_tointegerx)(lua_State *L, int idx, int *pisnum);
|
|
||||||
typedef int (*luaDLL_getglobal)(lua_State *L, const char *name);
|
|
||||||
typedef int (*luaDLL_pcallk)(lua_State *L, int nargs, int nresults, int msgh, lua_KContext ctx, lua_KFunction k);
|
|
||||||
typedef int (*luaDLL_toboolean)(lua_State *L, int index);
|
|
||||||
|
|
||||||
luaDLL_checkinteger luaL_checkinteger;
|
|
||||||
luaDLL_version lua_version;
|
|
||||||
luaDLL_gettop lua_gettop;
|
|
||||||
luaDLL_pushstring lua_pushstring;
|
|
||||||
luaLDLL_register luaL_register;
|
|
||||||
luaDLL_settop lua_settop;
|
|
||||||
luaDLL_pcall lua_pcall;
|
|
||||||
luaDLL_pushnumber lua_pushnumber;
|
|
||||||
luaDLL_checklstring luaL_checklstring;
|
|
||||||
luaDLL_tointeger lua_tointeger;
|
|
||||||
luaDLL_pushnil lua_pushnil;
|
|
||||||
luaDLL_getfield lua_getfield;
|
|
||||||
luaDLL_next lua_next;
|
|
||||||
luaDLL_getinfo lua_getinfo;
|
|
||||||
luaDLL_sethook lua_sethook;
|
|
||||||
luaDLL_checknumber luaL_checknumber;
|
|
||||||
luaDLL_type lua_type;
|
|
||||||
luaDLL_tolstring lua_tolstring;
|
|
||||||
luaDLL_pushinteger lua_pushinteger;
|
|
||||||
luaDLL_toboolean lua_toboolean;
|
|
||||||
//
|
|
||||||
HMODULE hInstLibrary;
|
|
||||||
|
|
||||||
//slua-ue header
|
|
||||||
#if LUA_VERSION_NUM > 501
|
|
||||||
//5.3
|
|
||||||
luaDLL_createtable lua_createtable;
|
|
||||||
luaDLL_setfuncs luaL_setfuncs;
|
|
||||||
luaDLL_tointegerx lua_tointegerx;
|
|
||||||
luaDLL_getglobal lua_getglobal;
|
|
||||||
luaDLL_pcallk lua_pcallk;
|
|
||||||
#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL)
|
|
||||||
#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL);
|
|
||||||
|
|
||||||
#define PURE_API =0
|
|
||||||
namespace slua {
|
|
||||||
struct LuaInterface {
|
|
||||||
virtual const lua_Number *lua_version(lua_State *L) PURE_API;
|
|
||||||
virtual const char *lua_pushstring(lua_State *L, const char *s) PURE_API;
|
|
||||||
virtual int lua_gettop(lua_State *L) PURE_API;
|
|
||||||
virtual void lua_settop(lua_State *L, int index) PURE_API;
|
|
||||||
virtual int lua_pcallk(lua_State *L, int nargs, int nresults, int msgh, lua_KContext ctx, lua_KFunction k) PURE_API;
|
|
||||||
virtual void lua_pushnumber(lua_State *L, lua_Number n) PURE_API;
|
|
||||||
virtual const char *luaL_checklstring(lua_State *L, int arg, size_t *l) PURE_API;
|
|
||||||
virtual const char *lua_tolstring(lua_State *L, int index, size_t *len) PURE_API;
|
|
||||||
virtual int lua_type(lua_State *L, int index) PURE_API;
|
|
||||||
virtual lua_Integer lua_tointegerx(lua_State *L, int index, int *isnum) PURE_API;
|
|
||||||
virtual void lua_pushnil(lua_State *L) PURE_API;
|
|
||||||
virtual int lua_getfield(lua_State *L, int index, const char *k) PURE_API;
|
|
||||||
virtual int lua_next(lua_State *L, int index) PURE_API;
|
|
||||||
virtual int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar) PURE_API;
|
|
||||||
virtual void lua_sethook(lua_State *L, lua_Hook f, int mask, int count) PURE_API;
|
|
||||||
virtual lua_Number luaL_checknumber(lua_State *L, int arg) PURE_API;
|
|
||||||
virtual void lua_createtable(lua_State *L, int narr, int nrec) PURE_API;
|
|
||||||
virtual void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) PURE_API;
|
|
||||||
virtual int lua_getglobal(lua_State *L, const char *name) PURE_API;
|
|
||||||
virtual int lua_toboolean(lua_State *L, int index) PURE_API;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
typedef slua::LuaInterface* (*dll_GetLuaInterface)();
|
|
||||||
dll_GetLuaInterface getInter;
|
|
||||||
#endif //LUA_VERSION_NUM > 501
|
|
||||||
#endif //_WIN32
|
|
||||||
#endif //LIBPDEBUG_H
|
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
******************************************************************************/
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
local MoveAbility = {}
|
|
||||||
|
|
||||||
|
|
||||||
return Class(nil, nil, MoveAbility)
|
|
||||||
@ -1,196 +0,0 @@
|
|||||||
local GameplayStatics = import("GameplayStatics")
|
|
||||||
local AbilitySystemBlueprintLibrary = import("AbilitySystemBlueprintLibrary")
|
|
||||||
local BusyGameplayLibrary = import("BusyGameplayLibrary")
|
|
||||||
|
|
||||||
--- @class FoxUltimate
|
|
||||||
--- @field RecastWindow number
|
|
||||||
local FoxUltimate = {}
|
|
||||||
|
|
||||||
|
|
||||||
function FoxUltimate:ctor()
|
|
||||||
self.ultimate_phase = 1 -- 大招阶段
|
|
||||||
self.active_recast_handle = nil
|
|
||||||
self.active_accelerate_handle = nil
|
|
||||||
|
|
||||||
self.overlap_delegate_handle = nil
|
|
||||||
self.tag_add_or_remove_delegate = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function FoxUltimate:K2_ActivateAbilityFromEvent(EventData)
|
|
||||||
print("FoxUltimate:K2_ActivateAbilityFromEvent", self.ultimate_phase)
|
|
||||||
|
|
||||||
if not self:K2_CommitAbilityCost(false) then
|
|
||||||
return self:K2_EndAbility()
|
|
||||||
end
|
|
||||||
|
|
||||||
local owner = self:GetOwningActorFromActorInfo()
|
|
||||||
self.movement = owner.MovementComponent
|
|
||||||
self.animation = owner.SpineAnimationComponent
|
|
||||||
self.asc = AbilitySystemBlueprintLibrary.GetAbilitySystemComponent(owner)
|
|
||||||
self.recast_tag = BusyGameplayLibrary.RequestGameplayTag("Ability.Flags.Recast")
|
|
||||||
self.owner = owner
|
|
||||||
|
|
||||||
|
|
||||||
local asc = self.asc
|
|
||||||
|
|
||||||
if self.tag_add_or_remove_delegate == nil then
|
|
||||||
self.tag_add_or_remove_delegate = slua.createDelegate(function(tag, is_add)
|
|
||||||
if is_add == 0 and not self.bIsActive then
|
|
||||||
self.ultimate_phase = 1
|
|
||||||
self:K2_CommitAbilityCooldown(false, false)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
owner:BindGameplayTagAddOrRemove(self.recast_tag, self.tag_add_or_remove_delegate)
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.ultimate_phase == 1 or asc:HasMatchingGameplayTag(self.recast_tag) then
|
|
||||||
self:TriggerUltimate(asc)
|
|
||||||
else
|
|
||||||
self:K2_EndAbility()
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function FoxUltimate:TriggerUltimate(asc)
|
|
||||||
if self.ultimate_phase == 1 then
|
|
||||||
-- 第一次释放大招,添加一个可以再次释放的Tag
|
|
||||||
local _, recast_effect = self:GetAbilityEffectSpecHandle("Recast", asc, 1, nil)
|
|
||||||
self.active_recast_handle = asc:BP_ApplyGameplayEffectSpecToSelf(recast_effect)
|
|
||||||
elseif self.ultimate_phase == 2 then
|
|
||||||
-- 第二次激活,移除可重复释放的tag
|
|
||||||
self.asc:RemoveActiveGameplayEffect(self.active_recast_handle, -1)
|
|
||||||
elseif self.ultimate_phase == 3 then
|
|
||||||
self.asc:RemoveActiveGameplayEffect(self.active_recast_handle, -1)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 播放动画,并监听动画完成的事件
|
|
||||||
self:PlayAnimation()
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function FoxUltimate:GetAnimationName(direction)
|
|
||||||
local animation_name_prefix
|
|
||||||
if direction.X >= 0 then
|
|
||||||
animation_name_prefix = "Ultimate/Right/"
|
|
||||||
else
|
|
||||||
animation_name_prefix = "Ultimate/Left/"
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.ultimate_phase == 1 then
|
|
||||||
return animation_name_prefix .. "UltimateStage1"
|
|
||||||
elseif self.ultimate_phase == 2 then
|
|
||||||
return animation_name_prefix .. "UltimateStage2"
|
|
||||||
elseif self.ultimate_phase == 3 then
|
|
||||||
return animation_name_prefix .. "UltimateStage3"
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function FoxUltimate:K2_OnEndAbility(bWasCancelled)
|
|
||||||
print("FoxUltimate:K2_OnEndAbility")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function FoxUltimate:GetSprintSpeedFactor()
|
|
||||||
if self.ultimate_phase == 1 then
|
|
||||||
return 2.5
|
|
||||||
elseif self.ultimate_phase == 2 then
|
|
||||||
return 2.8
|
|
||||||
elseif self.ultimate_phase == 3 then
|
|
||||||
return 3.0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function FoxUltimate:PlayAnimation()
|
|
||||||
|
|
||||||
local animation = self.animation
|
|
||||||
local PC = GameplayStatics.GetPlayerController(self, 0)
|
|
||||||
|
|
||||||
local result, ability_direction = PC:GetCursorDirection(nil) -- 获取技能的朝向
|
|
||||||
if not result then
|
|
||||||
print("FoxUltimate:TriggerPrimaryPhase can't find direction")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local anim_name = self:GetAnimationName(ability_direction) -- 获取技能动画名称
|
|
||||||
if not anim_name then
|
|
||||||
print("FoxUltimate:TriggerPrimaryPhase can't get animation", self.ultimate_phase)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local anim_entry = animation:SetAnimation(0, anim_name, false)
|
|
||||||
anim_entry.AnimationComplete:Add(function(entry) self:OnAnimationComplete(entry) end)
|
|
||||||
anim_entry.AnimationEvent:Add(function(entry, event) self:OnAnimationEvent(entry, event) end)
|
|
||||||
|
|
||||||
local anim_total_time = anim_entry:GetAnimationEnd() -- 获取技能动画时长
|
|
||||||
|
|
||||||
-- 附加加速buff
|
|
||||||
self:MakeAccelerate(self:GetSprintSpeedFactor(), anim_total_time)
|
|
||||||
self.movement:ActivateSprint(ability_direction, anim_total_time)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function FoxUltimate:MakeAccelerate(speed_factor, total_time)
|
|
||||||
local _, accelerate_effect = self:GetAbilityEffectSpecHandle("Accelerate", self.asc, 1, nil)
|
|
||||||
AbilitySystemBlueprintLibrary.AssignTagSetByCallerMagnitude(
|
|
||||||
accelerate_effect,
|
|
||||||
BusyGameplayLibrary.RequestGameplayTag("Effect.Factor"),
|
|
||||||
speed_factor
|
|
||||||
)
|
|
||||||
|
|
||||||
AbilitySystemBlueprintLibrary.AssignTagSetByCallerMagnitude(
|
|
||||||
accelerate_effect,
|
|
||||||
BusyGameplayLibrary.RequestGameplayTag("Effect.Duration"),
|
|
||||||
total_time
|
|
||||||
)
|
|
||||||
return self.asc:BP_ApplyGameplayEffectSpecToSelf(accelerate_effect)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function FoxUltimate:OnAnimationComplete(entry)
|
|
||||||
local new_phase = self.ultimate_phase + 1
|
|
||||||
if new_phase > 3 then
|
|
||||||
self.ultimate_phase = 1
|
|
||||||
else
|
|
||||||
self.ultimate_phase = new_phase
|
|
||||||
end
|
|
||||||
print("FoxUltimate:OnAnimationComplete", self.ultimate_phase)
|
|
||||||
|
|
||||||
if not self.asc:HasMatchingGameplayTag(self.recast_tag) then
|
|
||||||
self.ultimate_phase = 1
|
|
||||||
self:K2_CommitAbilityCooldown(false, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
entry.AnimationComplete:Clear()
|
|
||||||
entry.AnimationEvent:Clear()
|
|
||||||
self:K2_EndAbility()
|
|
||||||
end
|
|
||||||
|
|
||||||
function FoxUltimate:OnAnimationEvent(entry, event)
|
|
||||||
if event.Name == "OnSpeedChange" then
|
|
||||||
self.active_accelerate_handle = self:MakeAccelerate(8.0, 0.5)
|
|
||||||
elseif event.Name == "OnSpeedReset" then
|
|
||||||
self.asc:RemoveActiveGameplayEffect(self.active_accelerate_handle, -1)
|
|
||||||
elseif event.Name == "OnDamageBegin" then
|
|
||||||
local collision = self.owner["TailCollision"]
|
|
||||||
collision:SetCollisionEnabled(1)
|
|
||||||
self.overlap_delegate_handle = collision.OnComponentBeginOverlap:Add(function()
|
|
||||||
if not self.asc:HasMatchingGameplayTag(self.recast_tag) then
|
|
||||||
local _, recast_effect = self:GetAbilityEffectSpecHandle("Recast", self.asc, 1, nil)
|
|
||||||
self.active_recast_handle = self.asc:BP_ApplyGameplayEffectSpecToSelf(recast_effect)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
elseif event.Name == "OnDamageEnd" then
|
|
||||||
self.owner["TailCollision"]:SetCollisionEnabled(0)
|
|
||||||
if self.overlap_delegate_handle ~= nil then
|
|
||||||
self.owner["TailCollision"].OnComponentBeginOverlap:Remove(self.overlap_delegate_handle)
|
|
||||||
self.overlap_delegate_handle = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Class(nil, nil, FoxUltimate)
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
local RabbitUltimate = {}
|
|
||||||
|
|
||||||
|
|
||||||
return Class(nil, nil, RabbitUltimate)
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
local LevelFoxRole = {}
|
|
||||||
local Vector2D = require("Utils.Vector2D")
|
|
||||||
|
|
||||||
function LevelFoxRole:ctor()
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function LevelFoxRole:ReceiveBeginPlay()
|
|
||||||
self["SpineAnimationComponent"]:SetAnimation(0, "Idle/Front", true)
|
|
||||||
self.last_animation = "Idle/Front"
|
|
||||||
|
|
||||||
self["SpineBoneFollower"].Target = self
|
|
||||||
self["SpineBoneFollower"].BoneName = "tail"
|
|
||||||
self["SpineBoneFollower"].UseComponentTransform = true
|
|
||||||
self["SpineBoneFollower"].UseScale = true
|
|
||||||
|
|
||||||
self["TailCollision"]:SetCollisionEnabled(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function LevelFoxRole:OnMoveDirectionChanged(InDirection)
|
|
||||||
-- 运动组件更新方向响应函数
|
|
||||||
local cur_animation
|
|
||||||
if Vector2D.Equals(InDirection, Vector2D.Zero) then -- Idle的情况
|
|
||||||
local forward_direction = self["MovementComponent"]:GetForwardDirection()
|
|
||||||
if(forward_direction.Y >= 0) then
|
|
||||||
cur_animation = "Idle/Front"
|
|
||||||
else
|
|
||||||
cur_animation = "Idle/Back"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if(InDirection.Y >= 0) then
|
|
||||||
cur_animation = "Move/Front"
|
|
||||||
else
|
|
||||||
cur_animation = "Move/Back"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if cur_animation ~= self.last_animation then
|
|
||||||
self["SpineAnimationComponent"]:SetAnimation(0, cur_animation, true)
|
|
||||||
self.last_animation = cur_animation
|
|
||||||
end
|
|
||||||
|
|
||||||
self["SpineAnimationComponent"]:SetTimeScale(1.0)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function LevelFoxRole:OnMove(location)
|
|
||||||
-- 控制器移动相应函数
|
|
||||||
self["MovementComponent"]:MoveTo(location)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Class(nil, nil, LevelFoxRole)
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
local LevelRabbitRole = {}
|
|
||||||
|
|
||||||
function LevelRabbitRole:ctor()
|
|
||||||
self.last_animation = "back/move"
|
|
||||||
end
|
|
||||||
|
|
||||||
function LevelRabbitRole:ReceiveBeginPlay()
|
|
||||||
self["SpineAnimationComponent"]:SetSkin("back/move")
|
|
||||||
self["SpineAnimationComponent"]:SetAnimation(0, "animation", true)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function LevelRabbitRole:OnMove(location)
|
|
||||||
-- 控制器移动相应函数
|
|
||||||
self["MovementComponent"]:MoveTo(location)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function LevelRabbitRole:OnMoveDirectionChanged(InDirection)
|
|
||||||
-- 运动组件更新方向响应函数
|
|
||||||
local cur_animation
|
|
||||||
if(InDirection.Y >= 0) then
|
|
||||||
cur_animation = "front/move"
|
|
||||||
else
|
|
||||||
cur_animation = "back/move"
|
|
||||||
end
|
|
||||||
print("LevelRabbitRole:OnMoveDirectionChanged", cur_animation)
|
|
||||||
if cur_animation ~= self.last_animation then
|
|
||||||
self["SpineAnimationComponent"]:SetSkin(cur_animation)
|
|
||||||
self["SpineAnimationComponent"]:SetSlotsToSetupPose()
|
|
||||||
self.last_animation = cur_animation
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return Class(nil, nil, LevelRabbitRole)
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
local Campsite = {}
|
|
||||||
|
|
||||||
|
|
||||||
return Class(nil, nil, Campsite)
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
local Vector = import("Vector")
|
|
||||||
local GameplayStatics = import("GameplayStatics")
|
|
||||||
local BusyGameplayLibrary = import("BusyGameplayLibrary")
|
|
||||||
|
|
||||||
|
|
||||||
--[[****************************私有函数区域******************************]]--
|
|
||||||
|
|
||||||
--- 生成资源点
|
|
||||||
local function GenerateResourcePoint()
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- 保留到以后做联机内容时拓展
|
|
||||||
--- @class LevelGameMode
|
|
||||||
--- @field GameMapActorClass table
|
|
||||||
local LevelGameMode = {}
|
|
||||||
|
|
||||||
function LevelGameMode:ctor()
|
|
||||||
self.map_actor = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function LevelGameMode:ReceiveBeginPlay()
|
|
||||||
print("LevelGameMode:ReceiveBeginPlay", self.GameMapActorClass)
|
|
||||||
local world = BusyGameplayLibrary.K2_GetWorld(self)
|
|
||||||
local game_state = GameplayStatics.GetGameState(self) --- @type LevelGameState
|
|
||||||
|
|
||||||
if self.GameMapActorClass then
|
|
||||||
local map_actor = world:SpawnActor(self.GameMapActorClass, Vector(), nil, nil)
|
|
||||||
game_state:SetGameMapActor(map_actor)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- function LevelGameMode:K2_PostLogin(new_player_controller)
|
|
||||||
-- local new_player_state = new_player_controller.PlayerState
|
|
||||||
-- local role = new_player_state:CreateRoleRoster(new_player_controller)
|
|
||||||
-- local new_pos = FVector()
|
|
||||||
-- new_pos.X = 500
|
|
||||||
-- new_pos.Y = 500
|
|
||||||
-- new_pos.Z = 50
|
|
||||||
-- role:K2_SetActorLocation(new_pos, true, nil, false)
|
|
||||||
-- new_player_controller:Possess(role)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
return Class(nil, nil, LevelGameMode)
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
--- @class LevelGameState
|
|
||||||
local LevelGameState = {}
|
|
||||||
|
|
||||||
function LevelGameState:SetGameMapActor(game_map_actor)
|
|
||||||
self.GameMapActor = game_map_actor
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return Class(nil, nil, LevelGameState)
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
local GameplayStatics = import("GameplayStatics")
|
|
||||||
|
|
||||||
local LevelPlayerState = {}
|
|
||||||
|
|
||||||
function LevelPlayerState:ReceiveBeginPlay()
|
|
||||||
local pc = GameplayStatics.GetPlayerController(self, 0)
|
|
||||||
local role = self:CreateRoleRoster(pc)
|
|
||||||
print("LevelPlayerState:ReceiveBeginPlay", role, self:HasAuthority())
|
|
||||||
pc:Possess(role)
|
|
||||||
end
|
|
||||||
|
|
||||||
return Class(nil, nil, LevelPlayerState)
|
|
||||||
@ -0,0 +1 @@
|
|||||||
|
// 角色移动
|
||||||
@ -0,0 +1,196 @@
|
|||||||
|
// local GameplayStatics = import("GameplayStatics")
|
||||||
|
// local AbilitySystemBlueprintLibrary = import("AbilitySystemBlueprintLibrary")
|
||||||
|
// local BusyGameplayLibrary = import("BusyGameplayLibrary")
|
||||||
|
|
||||||
|
// --- @class FoxUltimate
|
||||||
|
// --- @field RecastWindow number
|
||||||
|
// local FoxUltimate = {}
|
||||||
|
|
||||||
|
|
||||||
|
// function FoxUltimate:ctor()
|
||||||
|
// self.ultimate_phase = 1 -- 大招阶段
|
||||||
|
// self.active_recast_handle = nil
|
||||||
|
// self.active_accelerate_handle = nil
|
||||||
|
|
||||||
|
// self.overlap_delegate_handle = nil
|
||||||
|
// self.tag_add_or_remove_delegate = nil
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// function FoxUltimate:K2_ActivateAbilityFromEvent(EventData)
|
||||||
|
// print("FoxUltimate:K2_ActivateAbilityFromEvent", self.ultimate_phase)
|
||||||
|
|
||||||
|
// if not self:K2_CommitAbilityCost(false) then
|
||||||
|
// return self:K2_EndAbility()
|
||||||
|
// end
|
||||||
|
|
||||||
|
// local owner = self:GetOwningActorFromActorInfo()
|
||||||
|
// self.movement = owner.MovementComponent
|
||||||
|
// self.animation = owner.SpineAnimationComponent
|
||||||
|
// self.asc = AbilitySystemBlueprintLibrary.GetAbilitySystemComponent(owner)
|
||||||
|
// self.recast_tag = BusyGameplayLibrary.RequestGameplayTag("Ability.Flags.Recast")
|
||||||
|
// self.owner = owner
|
||||||
|
|
||||||
|
|
||||||
|
// local asc = self.asc
|
||||||
|
|
||||||
|
// if self.tag_add_or_remove_delegate == nil then
|
||||||
|
// self.tag_add_or_remove_delegate = slua.createDelegate(function(tag, is_add)
|
||||||
|
// if is_add == 0 and not self.bIsActive then
|
||||||
|
// self.ultimate_phase = 1
|
||||||
|
// self:K2_CommitAbilityCooldown(false, false)
|
||||||
|
// end
|
||||||
|
// end)
|
||||||
|
// owner:BindGameplayTagAddOrRemove(self.recast_tag, self.tag_add_or_remove_delegate)
|
||||||
|
// end
|
||||||
|
|
||||||
|
// if self.ultimate_phase == 1 or asc:HasMatchingGameplayTag(self.recast_tag) then
|
||||||
|
// self:TriggerUltimate(asc)
|
||||||
|
// else
|
||||||
|
// self:K2_EndAbility()
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// end
|
||||||
|
|
||||||
|
// function FoxUltimate:TriggerUltimate(asc)
|
||||||
|
// if self.ultimate_phase == 1 then
|
||||||
|
// -- 第一次释放大招,添加一个可以再次释放的Tag
|
||||||
|
// local _, recast_effect = self:GetAbilityEffectSpecHandle("Recast", asc, 1, nil)
|
||||||
|
// self.active_recast_handle = asc:BP_ApplyGameplayEffectSpecToSelf(recast_effect)
|
||||||
|
// elseif self.ultimate_phase == 2 then
|
||||||
|
// -- 第二次激活,移除可重复释放的tag
|
||||||
|
// self.asc:RemoveActiveGameplayEffect(self.active_recast_handle, -1)
|
||||||
|
// elseif self.ultimate_phase == 3 then
|
||||||
|
// self.asc:RemoveActiveGameplayEffect(self.active_recast_handle, -1)
|
||||||
|
// end
|
||||||
|
|
||||||
|
// -- 播放动画,并监听动画完成的事件
|
||||||
|
// self:PlayAnimation()
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// function FoxUltimate:GetAnimationName(direction)
|
||||||
|
// local animation_name_prefix
|
||||||
|
// if direction.X >= 0 then
|
||||||
|
// animation_name_prefix = "Ultimate/Right/"
|
||||||
|
// else
|
||||||
|
// animation_name_prefix = "Ultimate/Left/"
|
||||||
|
// end
|
||||||
|
|
||||||
|
// if self.ultimate_phase == 1 then
|
||||||
|
// return animation_name_prefix .. "UltimateStage1"
|
||||||
|
// elseif self.ultimate_phase == 2 then
|
||||||
|
// return animation_name_prefix .. "UltimateStage2"
|
||||||
|
// elseif self.ultimate_phase == 3 then
|
||||||
|
// return animation_name_prefix .. "UltimateStage3"
|
||||||
|
// end
|
||||||
|
// return nil
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// function FoxUltimate:K2_OnEndAbility(bWasCancelled)
|
||||||
|
// print("FoxUltimate:K2_OnEndAbility")
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// function FoxUltimate:GetSprintSpeedFactor()
|
||||||
|
// if self.ultimate_phase == 1 then
|
||||||
|
// return 2.5
|
||||||
|
// elseif self.ultimate_phase == 2 then
|
||||||
|
// return 2.8
|
||||||
|
// elseif self.ultimate_phase == 3 then
|
||||||
|
// return 3.0
|
||||||
|
// end
|
||||||
|
// end
|
||||||
|
|
||||||
|
// function FoxUltimate:PlayAnimation()
|
||||||
|
|
||||||
|
// local animation = self.animation
|
||||||
|
// local PC = GameplayStatics.GetPlayerController(self, 0)
|
||||||
|
|
||||||
|
// local result, ability_direction = PC:GetCursorDirection(nil) -- 获取技能的朝向
|
||||||
|
// if not result then
|
||||||
|
// print("FoxUltimate:TriggerPrimaryPhase can't find direction")
|
||||||
|
// return
|
||||||
|
// end
|
||||||
|
// local anim_name = self:GetAnimationName(ability_direction) -- 获取技能动画名称
|
||||||
|
// if not anim_name then
|
||||||
|
// print("FoxUltimate:TriggerPrimaryPhase can't get animation", self.ultimate_phase)
|
||||||
|
// return
|
||||||
|
// end
|
||||||
|
|
||||||
|
// local anim_entry = animation:SetAnimation(0, anim_name, false)
|
||||||
|
// anim_entry.AnimationComplete:Add(function(entry) self:OnAnimationComplete(entry) end)
|
||||||
|
// anim_entry.AnimationEvent:Add(function(entry, event) self:OnAnimationEvent(entry, event) end)
|
||||||
|
|
||||||
|
// local anim_total_time = anim_entry:GetAnimationEnd() -- 获取技能动画时长
|
||||||
|
|
||||||
|
// -- 附加加速buff
|
||||||
|
// self:MakeAccelerate(self:GetSprintSpeedFactor(), anim_total_time)
|
||||||
|
// self.movement:ActivateSprint(ability_direction, anim_total_time)
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// function FoxUltimate:MakeAccelerate(speed_factor, total_time)
|
||||||
|
// local _, accelerate_effect = self:GetAbilityEffectSpecHandle("Accelerate", self.asc, 1, nil)
|
||||||
|
// AbilitySystemBlueprintLibrary.AssignTagSetByCallerMagnitude(
|
||||||
|
// accelerate_effect,
|
||||||
|
// BusyGameplayLibrary.RequestGameplayTag("Effect.Factor"),
|
||||||
|
// speed_factor
|
||||||
|
// )
|
||||||
|
|
||||||
|
// AbilitySystemBlueprintLibrary.AssignTagSetByCallerMagnitude(
|
||||||
|
// accelerate_effect,
|
||||||
|
// BusyGameplayLibrary.RequestGameplayTag("Effect.Duration"),
|
||||||
|
// total_time
|
||||||
|
// )
|
||||||
|
// return self.asc:BP_ApplyGameplayEffectSpecToSelf(accelerate_effect)
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// function FoxUltimate:OnAnimationComplete(entry)
|
||||||
|
// local new_phase = self.ultimate_phase + 1
|
||||||
|
// if new_phase > 3 then
|
||||||
|
// self.ultimate_phase = 1
|
||||||
|
// else
|
||||||
|
// self.ultimate_phase = new_phase
|
||||||
|
// end
|
||||||
|
// print("FoxUltimate:OnAnimationComplete", self.ultimate_phase)
|
||||||
|
|
||||||
|
// if not self.asc:HasMatchingGameplayTag(self.recast_tag) then
|
||||||
|
// self.ultimate_phase = 1
|
||||||
|
// self:K2_CommitAbilityCooldown(false, false)
|
||||||
|
// end
|
||||||
|
|
||||||
|
// entry.AnimationComplete:Clear()
|
||||||
|
// entry.AnimationEvent:Clear()
|
||||||
|
// self:K2_EndAbility()
|
||||||
|
// end
|
||||||
|
|
||||||
|
// function FoxUltimate:OnAnimationEvent(entry, event)
|
||||||
|
// if event.Name == "OnSpeedChange" then
|
||||||
|
// self.active_accelerate_handle = self:MakeAccelerate(8.0, 0.5)
|
||||||
|
// elseif event.Name == "OnSpeedReset" then
|
||||||
|
// self.asc:RemoveActiveGameplayEffect(self.active_accelerate_handle, -1)
|
||||||
|
// elseif event.Name == "OnDamageBegin" then
|
||||||
|
// local collision = self.owner["TailCollision"]
|
||||||
|
// collision:SetCollisionEnabled(1)
|
||||||
|
// self.overlap_delegate_handle = collision.OnComponentBeginOverlap:Add(function()
|
||||||
|
// if not self.asc:HasMatchingGameplayTag(self.recast_tag) then
|
||||||
|
// local _, recast_effect = self:GetAbilityEffectSpecHandle("Recast", self.asc, 1, nil)
|
||||||
|
// self.active_recast_handle = self.asc:BP_ApplyGameplayEffectSpecToSelf(recast_effect)
|
||||||
|
// end
|
||||||
|
// end)
|
||||||
|
// elseif event.Name == "OnDamageEnd" then
|
||||||
|
// self.owner["TailCollision"]:SetCollisionEnabled(0)
|
||||||
|
// if self.overlap_delegate_handle ~= nil then
|
||||||
|
// self.owner["TailCollision"].OnComponentBeginOverlap:Remove(self.overlap_delegate_handle)
|
||||||
|
// self.overlap_delegate_handle = nil
|
||||||
|
// end
|
||||||
|
// end
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// return Class(nil, nil, FoxUltimate)
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
using UnrealSharp.Attributes;
|
||||||
|
using UnrealSharp.Engine;
|
||||||
|
|
||||||
|
namespace Level.GameSettings;
|
||||||
|
|
||||||
|
[UClass]
|
||||||
|
public class ABusyLevelGameMode : AGameMode
|
||||||
|
{
|
||||||
|
[UProperty(PropertyFlags.EditDefaultsOnly)]
|
||||||
|
public UnrealSharp.TSubclassOf<AActor> GameMapActorClass { get; set; }
|
||||||
|
|
||||||
|
protected override void BeginPlay()
|
||||||
|
{
|
||||||
|
base.BeginPlay();
|
||||||
|
if (GameMapActorClass.Valid)
|
||||||
|
{
|
||||||
|
SpawnActor(GameMapActorClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- function LevelGameMode:K2_PostLogin(new_player_controller)
|
||||||
|
// -- local new_player_state = new_player_controller.PlayerState
|
||||||
|
// -- local role = new_player_state:CreateRoleRoster(new_player_controller)
|
||||||
|
// -- local new_pos = FVector()
|
||||||
|
// -- new_pos.X = 500
|
||||||
|
// -- new_pos.Y = 500
|
||||||
|
// -- new_pos.Z = 50
|
||||||
|
// -- role:K2_SetActorLocation(new_pos, true, nil, false)
|
||||||
|
// -- new_player_controller:Possess(role)
|
||||||
|
// -- end
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
using UnrealSharp.Attributes;
|
||||||
|
using UnrealSharp.BusyRabbit;
|
||||||
|
using UnrealSharp.Engine;
|
||||||
|
|
||||||
|
namespace Level.GameSettings;
|
||||||
|
|
||||||
|
[UClass]
|
||||||
|
public class ABusyLevelPlayerState : ALevelPlayerState
|
||||||
|
{
|
||||||
|
protected override void BeginPlay()
|
||||||
|
{
|
||||||
|
base.BeginPlay();
|
||||||
|
APlayerController pc = UGameplayStatics.GetPlayerController(0);
|
||||||
|
var role = CreateRoleRoster(pc) as APawn;
|
||||||
|
pc.Possess(role);
|
||||||
|
}
|
||||||
|
}
|
||||||
54
Script/ManagedBusyRabbit/Level/Role/BusyFoxRole.cs
Normal file
54
Script/ManagedBusyRabbit/Level/Role/BusyFoxRole.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
// local LevelFoxRole = {}
|
||||||
|
// local Vector2D = require("Utils.Vector2D")
|
||||||
|
|
||||||
|
// function LevelFoxRole:ctor()
|
||||||
|
|
||||||
|
// end
|
||||||
|
|
||||||
|
// function LevelFoxRole:ReceiveBeginPlay()
|
||||||
|
// self["SpineAnimationComponent"]:SetAnimation(0, "Idle/Front", true)
|
||||||
|
// self.last_animation = "Idle/Front"
|
||||||
|
|
||||||
|
// self["SpineBoneFollower"].Target = self
|
||||||
|
// self["SpineBoneFollower"].BoneName = "tail"
|
||||||
|
// self["SpineBoneFollower"].UseComponentTransform = true
|
||||||
|
// self["SpineBoneFollower"].UseScale = true
|
||||||
|
|
||||||
|
// self["TailCollision"]:SetCollisionEnabled(0)
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// function LevelFoxRole:OnMoveDirectionChanged(InDirection)
|
||||||
|
// -- 运动组件更新方向响应函数
|
||||||
|
// local cur_animation
|
||||||
|
// if Vector2D.Equals(InDirection, Vector2D.Zero) then -- Idle的情况
|
||||||
|
// local forward_direction = self["MovementComponent"]:GetForwardDirection()
|
||||||
|
// if(forward_direction.Y >= 0) then
|
||||||
|
// cur_animation = "Idle/Front"
|
||||||
|
// else
|
||||||
|
// cur_animation = "Idle/Back"
|
||||||
|
// end
|
||||||
|
// else
|
||||||
|
// if(InDirection.Y >= 0) then
|
||||||
|
// cur_animation = "Move/Front"
|
||||||
|
// else
|
||||||
|
// cur_animation = "Move/Back"
|
||||||
|
// end
|
||||||
|
// end
|
||||||
|
// if cur_animation ~= self.last_animation then
|
||||||
|
// self["SpineAnimationComponent"]:SetAnimation(0, cur_animation, true)
|
||||||
|
// self.last_animation = cur_animation
|
||||||
|
// end
|
||||||
|
|
||||||
|
// self["SpineAnimationComponent"]:SetTimeScale(1.0)
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// function LevelFoxRole:OnMove(location)
|
||||||
|
// -- 控制器移动相应函数
|
||||||
|
// self["MovementComponent"]:MoveTo(location)
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// return Class(nil, nil, LevelFoxRole)
|
||||||
36
Script/ManagedBusyRabbit/Level/Role/BusyRabbitRole.cs
Normal file
36
Script/ManagedBusyRabbit/Level/Role/BusyRabbitRole.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// local LevelRabbitRole = {}
|
||||||
|
|
||||||
|
// function LevelRabbitRole:ctor()
|
||||||
|
// self.last_animation = "back/move"
|
||||||
|
// end
|
||||||
|
|
||||||
|
// function LevelRabbitRole:ReceiveBeginPlay()
|
||||||
|
// self["SpineAnimationComponent"]:SetSkin("back/move")
|
||||||
|
// self["SpineAnimationComponent"]:SetAnimation(0, "animation", true)
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// function LevelRabbitRole:OnMove(location)
|
||||||
|
// -- 控制器移动相应函数
|
||||||
|
// self["MovementComponent"]:MoveTo(location)
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// function LevelRabbitRole:OnMoveDirectionChanged(InDirection)
|
||||||
|
// -- 运动组件更新方向响应函数
|
||||||
|
// local cur_animation
|
||||||
|
// if(InDirection.Y >= 0) then
|
||||||
|
// cur_animation = "front/move"
|
||||||
|
// else
|
||||||
|
// cur_animation = "back/move"
|
||||||
|
// end
|
||||||
|
// print("LevelRabbitRole:OnMoveDirectionChanged", cur_animation)
|
||||||
|
// if cur_animation ~= self.last_animation then
|
||||||
|
// self["SpineAnimationComponent"]:SetSkin(cur_animation)
|
||||||
|
// self["SpineAnimationComponent"]:SetSlotsToSetupPose()
|
||||||
|
// self.last_animation = cur_animation
|
||||||
|
// end
|
||||||
|
// end
|
||||||
|
|
||||||
|
|
||||||
|
// return Class(nil, nil, LevelRabbitRole)
|
||||||
Reference in New Issue
Block a user