mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
update 添加松鼠角色
This commit is contained in:
@@ -2,7 +2,7 @@ import { Node } from "cc";
|
||||
import { TableGRoleAttack } from "../../../../resources/config/ts/TableGRoleAttack";
|
||||
import GRoleBase from "../role/GRoleBase";
|
||||
import GAttackNormal from "./GAttackNormal";
|
||||
import GAttackParabolicRemote from "./GAttackParabolicRemote";
|
||||
import GAttackParabolicBangRemote from "./GAttackParabolicBangRemote";
|
||||
import { UITransform } from "cc";
|
||||
import GButtleBase from "../bullet/GButtleBase";
|
||||
|
||||
@@ -21,13 +21,13 @@ export class GAttackBullet{
|
||||
}
|
||||
|
||||
//攻击方式基类
|
||||
export class GAttackBase{
|
||||
attack(role:GRoleBase<{}>,info:TableGRoleAttack){};
|
||||
export interface GAttackBase{
|
||||
attack(role:GRoleBase<{}>,info:TableGRoleAttack);
|
||||
}
|
||||
|
||||
//攻击方式
|
||||
export const GAttack:{[key:string]:(new () => GAttackBase)} = {
|
||||
["Normal"]:GAttackNormal,
|
||||
["ParabolicRemote"]:GAttackParabolicRemote,
|
||||
["ParabolicBangRemote"]:GAttackParabolicBangRemote,
|
||||
}
|
||||
|
||||
|
@@ -1,12 +0,0 @@
|
||||
|
||||
|
||||
export default class GAttackBullet {
|
||||
|
||||
//创建子弹
|
||||
static create(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -8,20 +8,40 @@ import { v3 } from "cc";
|
||||
import { bezier } from "cc";
|
||||
import { v2 } from "cc";
|
||||
import { Vec2 } from "cc";
|
||||
import { sp } from "cc";
|
||||
import GEffectUtil from "../../effect/GEffectUtil";
|
||||
import { TableGRoleAttackEffect } from "../../../../resources/config/ts/TableGRoleAttackEffect";
|
||||
import GDetection from "../common/GDetection";
|
||||
import { rect } from "cc";
|
||||
import { UITransform } from "cc";
|
||||
import { BoxCollider2D } from "cc";
|
||||
/**
|
||||
* 抛物线普攻
|
||||
* 攻击子弹,子弹大小,龙骨-初始位置
|
||||
* 抛物线 爆炸普攻
|
||||
* 攻击子弹,爆炸特效,龙骨-初始位置,子弹大小
|
||||
*/
|
||||
export default class GAttackParabolicRemote implements GAttackBase{
|
||||
|
||||
attack(role: GRoleBase<{}>, info: TableGRoleAttack): void {
|
||||
|
||||
let enemy = role.fsm.enemy;
|
||||
if(!enemy) return;
|
||||
|
||||
//[子弹图片]
|
||||
let image:SpriteFrame = app.role.bullets[info.attackArgs[0]];
|
||||
let scale:number = info.attackArgs[1] as unknown as number;
|
||||
let bang = {
|
||||
ske: app.role.effects[info.attackArgs[1]],
|
||||
info: TableGRoleAttackEffect.getConfig(info.attackArgs[1])
|
||||
};
|
||||
let bone = role.spine.findBone(info.attackArgs[2]);
|
||||
let scale:number = parseFloat(info.attackArgs[3]);
|
||||
let aw = parseFloat(info.attackArgs[4]);
|
||||
let ah = parseFloat(info.attackArgs[5]);
|
||||
|
||||
if(!image || !bone || !scale || !bang|| !aw|| !ah) {
|
||||
console.warn("GAttackParabolicRemote ERROR",image,bone,scale,bang);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(role.spine,bone);
|
||||
let bullet = GAttackBullet.create(GButtleDefault,{
|
||||
image:image,
|
||||
@@ -48,8 +68,21 @@ export default class GAttackParabolicRemote implements GAttackBase{
|
||||
))
|
||||
})
|
||||
.onComplete(() => {
|
||||
enemy.onHit();
|
||||
bullet.node.removeFromParent();
|
||||
|
||||
//生成爆炸特效
|
||||
let effect = GEffectUtil.create(bang.ske);
|
||||
role.mode.addGNode(effect.node,bullet.node.worldPosition);
|
||||
//获取默认动画
|
||||
effect.setAnimation(0,bang.info.animation,false);
|
||||
//销毁
|
||||
bullet.node.destroy();
|
||||
|
||||
// enemy.getComponent(BoxCollider2D).apply();
|
||||
|
||||
// console.log(enemy.v2World,enemy.getComponent(BoxCollider2D).worldPoints,enemy.getComponent(UITransform).getBoundingBoxToWorld());
|
||||
GDetection.testAABBRole(rect(effect.node.worldPosition.x,effect.node.worldPosition.y,aw,ah)).forEach(role =>{
|
||||
role.onHit();
|
||||
});
|
||||
})
|
||||
.start();
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "13b542e0-5fa9-4b1d-bfef-8196b3b3ffd6",
|
||||
"uuid": "f4c29cde-2ca3-452d-ad3e-3d6376f2bd6c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
@@ -7,6 +7,7 @@ import { size } from "cc";
|
||||
import { Size } from "cc";
|
||||
import { v3 } from "cc";
|
||||
import { Vec2 } from "cc";
|
||||
import { GData } from "../../../GData";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export interface GButtleDefaultInfo{
|
||||
@@ -19,7 +20,7 @@ export interface GButtleDefaultInfo{
|
||||
export default class GButtleDefault extends GButtleBase<GButtleDefaultInfo>{
|
||||
|
||||
setData(info:GButtleDefaultInfo){
|
||||
this.node.layer = 1;
|
||||
this.node.layer = GData.layer.World;
|
||||
this.node.addComponent(Sprite).spriteFrame = info.image;
|
||||
this.node.scale = v3(info.scale,info.scale,0);
|
||||
}
|
||||
|
9
JisolGameCocos/assets/script/battle/base/common.meta
Normal file
9
JisolGameCocos/assets/script/battle/base/common.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "651f7991-f580-4d09-a013-54c78bf46740",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
import { math } from "cc";
|
||||
import { PhysicsSystem2D } from "cc";
|
||||
import GRoleBase from "../role/GRoleBase";
|
||||
import { Vec2 } from "cc";
|
||||
|
||||
|
||||
//检测工具类
|
||||
export default class GDetection{
|
||||
|
||||
//检测角色
|
||||
static testAABBRole(rect:math.Rect):GRoleBase<{}>[]{
|
||||
//@ts-ignore
|
||||
return PhysicsSystem2D.instance.testAABB(rect).map(item => item.getComponent(GRoleBase<any>));
|
||||
}
|
||||
//检测角色
|
||||
static testPointRole(pos:Vec2){
|
||||
//@ts-ignore
|
||||
console.log(PhysicsSystem2D.instance.testPoint(pos));
|
||||
}
|
||||
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "04262003-45a4-4d9d-a1d3-83c11146c891",
|
||||
"uuid": "a2cdfca5-479c-4e51-9245-29dd3626cbc2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
63
JisolGameCocos/assets/script/battle/base/common/GSpine.ts
Normal file
63
JisolGameCocos/assets/script/battle/base/common/GSpine.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { sp } from "cc";
|
||||
import GRoleBase from "../role/GRoleBase";
|
||||
import JNSkeleton from "../../../../../extensions/ngame/assets/ngame/sync/frame/game/spine/JNFrameSkeleton";
|
||||
import { Node } from "cc";
|
||||
import GBaseMode from "../../GBaseMode";
|
||||
import { Vec2 } from "cc";
|
||||
|
||||
|
||||
//Spine 工具
|
||||
export default class GSpine{
|
||||
|
||||
//保存当前Spine 播放新 Spine 结束后还原
|
||||
static onPlayAnotherSpine(role:GRoleBase<{}>,spine:sp.SkeletonData,play:string,fun:{
|
||||
start?:(ske:JNSkeleton) => void,
|
||||
end?:() => void,
|
||||
} = {}):JNSkeleton{
|
||||
|
||||
//关闭当前角色原本的Spine
|
||||
role.spine.enabled = false;
|
||||
//添加新的spine
|
||||
let spineNode = new Node();
|
||||
role.node.addChild(spineNode);
|
||||
let another = spineNode.addComponent(JNSkeleton);
|
||||
another.skeletonData = spine;
|
||||
fun.start && fun.start(another);
|
||||
another.setCompleteListener(() => {
|
||||
//还原
|
||||
role.spine.enabled = true;
|
||||
spineNode.destroy();
|
||||
fun.end && fun.end();
|
||||
});
|
||||
another.setAnimation(0,play,false);
|
||||
// another.setAnimation(0,play,false);
|
||||
return another;
|
||||
|
||||
}
|
||||
|
||||
//创建一个Spine
|
||||
static onCreateSpine(spine:sp.SkeletonData):JNSkeleton{
|
||||
|
||||
let spineNode = new Node();
|
||||
let another = spineNode.addComponent(JNSkeleton);
|
||||
another.premultipliedAlpha = false;
|
||||
another.skeletonData = spine;
|
||||
return another;
|
||||
|
||||
}
|
||||
|
||||
// 创建一个 Spine 并且 播放 销毁
|
||||
static onPlaySceneSpine(scene:GBaseMode<{}>,pos:Vec2,spine:sp.SkeletonData,play:string):JNSkeleton{
|
||||
|
||||
let create = this.onCreateSpine(spine);
|
||||
scene.addGNode(create.node,pos);
|
||||
create.setCompleteListener(() => {
|
||||
//销毁
|
||||
create.node.destroy();
|
||||
});
|
||||
create.setAnimation(0,play);
|
||||
return create;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "8c684f5a-84b5-4ea1-92d3-c0b70461970c",
|
||||
"uuid": "ded09977-91f1-4932-aba7-c9c5d8489859",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
@@ -14,6 +14,8 @@ enum ProcessEnum {
|
||||
AttackEnemy = 2,
|
||||
//回阵型
|
||||
MoveToTactical = 3,
|
||||
//释放技能
|
||||
ReleaseSkills = 4,
|
||||
}
|
||||
|
||||
export default abstract class GFSMBattle extends GFSMBase{
|
||||
@@ -51,13 +53,19 @@ export default abstract class GFSMBattle extends GFSMBase{
|
||||
title:"攻击敌人",
|
||||
mode:GFSMProcessMode.WaitExecute,
|
||||
execute: this.onAttackProcess.bind(this),
|
||||
to:[ProcessEnum.SeekEnemy],//移动回阵型
|
||||
to:[ProcessEnum.SeekEnemy,ProcessEnum.ReleaseSkills],//移动回阵型 释放技能
|
||||
},
|
||||
[ProcessEnum.MoveToTactical]:{
|
||||
title:"移动回阵型",
|
||||
mode:GFSMProcessMode.WaitExecute,
|
||||
execute: this.onMoveToTacticalProcess.bind(this),
|
||||
to:[ProcessEnum.SeekEnemy],//移动回阵型
|
||||
},
|
||||
[ProcessEnum.ReleaseSkills]:{
|
||||
title:"释放技能",
|
||||
mode:GFSMProcessMode.WaitExecute,
|
||||
execute: this.onReleaseSkillsProcess.bind(this),
|
||||
to:[ProcessEnum.AttackEnemy],//继续攻击
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,12 +149,24 @@ export default abstract class GFSMBattle extends GFSMBase{
|
||||
this.player.fsmAnim.isAttack = true;
|
||||
//如果有敌人则攻击 没有 则 重置
|
||||
if(this.enemy){
|
||||
// if(){
|
||||
// //如果可以释放大招
|
||||
// }else{
|
||||
// //不可以则普攻
|
||||
//朝向敌人
|
||||
this.player.onTowardsTarget(this.enemy);
|
||||
return GFSMProcessEnum.Wait;
|
||||
// }
|
||||
}else{
|
||||
return ProcessEnum.SeekEnemy;
|
||||
}
|
||||
}
|
||||
|
||||
//释放技能
|
||||
onReleaseSkillsProcess(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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",
|
||||
}
|
@@ -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