mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
update 添加松鼠角色
This commit is contained in:
@@ -8,11 +8,13 @@ import { v3 } from "cc";
|
||||
import { GTactical } from "../../entity/GTactical";
|
||||
import { JEasing, JTween } from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/tween/JNFrameTween";
|
||||
import { v2 } from "cc";
|
||||
import GRole from "../../entity/GRole";
|
||||
import { app } from "../../../App";
|
||||
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
|
||||
import { GAttack, GAttackBase } from "../attack/GAttack";
|
||||
import { GRoleType } from "./GRoleType";
|
||||
import { TableGRole } from "../../../../resources/config/ts/TableGRole";
|
||||
import { TableGRoleSkill } from "../../../../resources/config/ts/TableGRoleSkill";
|
||||
import { GSkill, GSkillBase } from "../../skill/GSkill";
|
||||
import JNSkeleton from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/spine/JNFrameSkeleton";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export enum GRoleAnimEvent{
|
||||
@@ -22,14 +24,17 @@ export enum GRoleAnimEvent{
|
||||
//角色基类
|
||||
export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
@property(sp.Skeleton)
|
||||
spine:sp.Skeleton;
|
||||
@property(JNSkeleton)
|
||||
spine:JNSkeleton;
|
||||
|
||||
//角色
|
||||
role:GRole
|
||||
role:TableGRole
|
||||
|
||||
//角色技能
|
||||
skills:GSkillBase[] = [];
|
||||
|
||||
//角色类型
|
||||
type:GRoleType;
|
||||
type:number;
|
||||
|
||||
//状态机
|
||||
fsm:GFSMBattle;
|
||||
@@ -61,10 +66,6 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
blood:number = 100;
|
||||
fullBlood:number = 100;
|
||||
|
||||
//能量
|
||||
energy:number = 0;
|
||||
fullEnergy:number = 100;
|
||||
|
||||
//是否死亡
|
||||
_isDie:boolean = false;
|
||||
get isDie(){ return this._isDie}
|
||||
@@ -81,14 +82,14 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
onSyncLoad(){
|
||||
|
||||
if(!this.spine) this.spine = this.node.getComponent(sp.Skeleton);
|
||||
if(!this.spine) this.spine = this.node.getComponent(JNSkeleton);
|
||||
//如果没有生成则直接销毁
|
||||
if(!this.spine) {
|
||||
this.node.removeFromParent();
|
||||
this.node.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
this.spine.debugBones = true;
|
||||
// this.spine.debugBones = true;
|
||||
|
||||
this.bind(this.role);
|
||||
|
||||
@@ -105,11 +106,18 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
}
|
||||
|
||||
//设置角色
|
||||
bind(role:GRole){
|
||||
bind(role:TableGRole){
|
||||
if(this.spine)
|
||||
this.spine.skeletonData = app.role.skData[role.id];
|
||||
this.range = role.range; //设置攻击范围
|
||||
this.role = role;
|
||||
|
||||
this.range = role.roleAttackRange; //设置攻击范围
|
||||
this.role = role; //设置角色
|
||||
|
||||
// 设置技能
|
||||
this.skills = role.roleSkillIds.map(skillId => {
|
||||
let info = TableGRoleSkill.getConfig(skillId);
|
||||
return (new GSkill[info.skillController]()).bind(this,info);
|
||||
})
|
||||
}
|
||||
|
||||
//创建一个状态机
|
||||
@@ -123,6 +131,10 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
this.fsm && this.fsm.onUpdate(dt / 1000);
|
||||
this.fsmAnim && this.fsmAnim.onUpdate(dt / 1000);
|
||||
|
||||
if(frame.index == 100){
|
||||
this.skills[0] && this.skills[0].release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//向目标点移动
|
||||
@@ -153,18 +165,55 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
}
|
||||
|
||||
//朝向目标
|
||||
onTowardsTarget(role:GRoleBase<{}>){
|
||||
//获取两个坐标差值向量
|
||||
let normal = this.v2World.subtract(role.v2World).normalize();
|
||||
//设置朝向
|
||||
if(normal.x != 0){
|
||||
if(normal.x < 0){
|
||||
this.setTowards(GTowards.RIGHT)
|
||||
}else{
|
||||
this.setTowards(GTowards.LEFT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//攻击
|
||||
onAttack(){
|
||||
//敌人扣血
|
||||
let info = TableGRoleAttack.getConfig(this.role.id);
|
||||
(new GAttack[info.attackWay]()).attack(this,info);
|
||||
}
|
||||
|
||||
//释放技能 每一次只能释放一次
|
||||
onSkill():boolean{
|
||||
|
||||
for (const item of this.skills) {
|
||||
if(item.isRelease()){
|
||||
//如果可以释放则释放
|
||||
item.release();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
//每一次攻击 则 增加能量条
|
||||
this.energy += 10;
|
||||
}
|
||||
|
||||
//受击
|
||||
onHit(){
|
||||
// return;
|
||||
this.blood -= 10;
|
||||
//检测是否死亡
|
||||
if(this.blood <= 0){
|
||||
//关闭状态机
|
||||
this.fsm.close();
|
||||
//设置死亡
|
||||
this.isDie = true;
|
||||
}
|
||||
}
|
||||
|
||||
onDebugHit(){
|
||||
this.blood -= 10;
|
||||
//检测是否死亡
|
||||
if(this.blood <= 0){
|
||||
@@ -198,6 +247,11 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
this.setTowards(this.tactical.towards);
|
||||
}
|
||||
|
||||
//过滤敌人
|
||||
filterEnemy(roles:GRoleBase<{}>[] = []){
|
||||
return roles.filter(role => role.type != this.type);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,8 +0,0 @@
|
||||
|
||||
//角色类型
|
||||
export enum GRoleType{
|
||||
PLAYER = "PLAYER",
|
||||
ENMEY = "ENMEY",
|
||||
PVP1 = "PVP1",
|
||||
PVP2 = "PVP2",
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "04262003-45a4-4d9d-a1d3-83c11146c891",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -51,7 +51,6 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
|
||||
|
||||
//更新显示
|
||||
this.bloodVolume.progress = this.blood / this.fullBlood;
|
||||
this.energyVolume.progress = this.energy / this.fullBlood;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +75,6 @@ export default class GRolePVPEntity extends GRoleBase<GDemoMessage>{
|
||||
if(this.isDie){
|
||||
//销毁数据
|
||||
this.mode.killRole(this);
|
||||
// this.node.removeFromParent();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user