mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交捕捉
This commit is contained in:
@@ -58,7 +58,7 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
//攻击回调
|
||||
attackCallbacks:Function[] = [];
|
||||
//添加受击回调
|
||||
//添加攻击回调
|
||||
addAttackCallback(fun:Function){this.attackCallbacks.push(fun)};
|
||||
|
||||
get():this{
|
||||
@@ -147,7 +147,7 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
onHit(){
|
||||
// return;
|
||||
this.blood -= 10;
|
||||
this.hitCallbacks.forEach(fun => fun());
|
||||
this.hitCallbacks.forEach(fun => fun(this,10));
|
||||
//检测是否死亡
|
||||
if(this.blood <= 0){
|
||||
//关闭状态机
|
||||
|
@@ -0,0 +1,18 @@
|
||||
import { _decorator } from "cc";
|
||||
import GRoleExpandBase from "../GRoleExpandBase";
|
||||
import { GOnHookPet } from "../../../../../../../extensions/ngame/assets/ngame/message/proto";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
* 无限模式 野怪 扩展类
|
||||
*/
|
||||
@ccclass('GRoleOnHookCreepsExpand')
|
||||
export default class GRoleOnHookCreepsExpand extends GRoleExpandBase<{}>{
|
||||
|
||||
//野怪
|
||||
creeps:GOnHookPet;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "edf60f56-5d3e-48d1-90b4-6deef4b5635c",
|
||||
"uuid": "3a21518a-766b-4f61-a59f-3e8825cf08f0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
@@ -1,13 +1,12 @@
|
||||
import { _decorator } from "cc";
|
||||
import GRoleDefault from "../../GRoleDefault";
|
||||
import GRoleExpandBase from "../GRoleExpandBase";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
* 角色 无限模式 扩展类
|
||||
* 无限模式 玩家 扩展类
|
||||
*/
|
||||
@ccclass('GRoleDefault')
|
||||
export default class GRoleOnHookExpand extends GRoleExpandBase<{}>{
|
||||
@ccclass('GRoleOnHookPlayerExpand')
|
||||
export default class GRoleOnHookPlayerExpand extends GRoleExpandBase<{}>{
|
||||
|
||||
//角色Id
|
||||
petId:number;
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3c2ff03b-a7e4-4afb-bb3c-ceacb17300ae",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -17,11 +17,13 @@ import { v2 } from "cc";
|
||||
import GFSMOnHookMode from "./OnHook/GFSMOnHookMode";
|
||||
import { TB } from "../../../resources/config/data/schema";
|
||||
import PlayerTacticalData, { PlayerTacticalEvent } from "../../data/PlayerTacticalData";
|
||||
import GRoleOnHookExpand from "../base/role/expand/OnHook/GRoleOnHookExpand";
|
||||
import GRoleOnHookPlayerExpand from "../base/role/expand/OnHook/GRoleOnHookPlayerExpand";
|
||||
import PlayerPetData from "../../data/PlayerPetData";
|
||||
import { GUI } from "../../ui/UIConfig";
|
||||
import { GAction } from "../../consts/GAction";
|
||||
import { GActionType } from "../../consts/GActionType";
|
||||
import { GOnHookPet, GOnHookPets } from "../../../../extensions/ngame/assets/ngame/message/proto";
|
||||
import GOnHookManager from "../../manager/battle/mode/GOnHookManager";
|
||||
import GRoleOnHookCreepsExpand from "../base/role/expand/OnHook/GRoleOnHookCreepsExpand";
|
||||
import { ModeRenderEvent } from "../../ui/Consts/Game/ModeRender";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//挂机模式状态
|
||||
@@ -45,18 +47,8 @@ export interface GOnHookInfo{
|
||||
roles: TB.TbGRole[];
|
||||
}
|
||||
|
||||
//野怪
|
||||
interface GOnHookPet{
|
||||
key:string; //野怪唯一Id
|
||||
petTbId:number; //野怪配置表Id
|
||||
}
|
||||
//野怪列表
|
||||
interface GOnHookPets{
|
||||
pets:GOnHookPet[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂机模式 无限出现小怪 (不是联机模式 该模式支持使用本地数据)
|
||||
* 挂机模式 无限出现小怪 (不是联机模式 该模式支持使用本地数据 和 API)
|
||||
*/
|
||||
@ccclass('GOnHookMode')
|
||||
export default class GOnHookMode extends GBaseMode<{}>{
|
||||
@@ -115,21 +107,6 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
//是否允许攻击
|
||||
isAllowAttack:boolean = false;
|
||||
|
||||
//野怪列表
|
||||
_wildlifes:GOnHookPets;
|
||||
get wildlifes(){
|
||||
//如果没有野怪了 则 向服务器生成
|
||||
if(!this._wildlifes || !(this._wildlifes.pets.length)){
|
||||
//生成
|
||||
this.onSpawnWildlife();
|
||||
return null;
|
||||
}
|
||||
return this._wildlifes;
|
||||
}
|
||||
set wildlifes(data:GOnHookPets){
|
||||
this._wildlifes = data;
|
||||
}
|
||||
|
||||
//添加监听事件
|
||||
addEvent(){
|
||||
app.event.on(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this);
|
||||
@@ -185,18 +162,7 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
// this.onResetGenerateEnemy();
|
||||
|
||||
}
|
||||
|
||||
//生成野怪
|
||||
onSpawnWildlife(){
|
||||
//获取服务器野怪
|
||||
app.socket.SendBack(GAction.MODE_ON_HOOK_SPAWN_PET,{
|
||||
type:GActionType.GOnHookPets,
|
||||
fun:(info:GOnHookPets) => {
|
||||
this.wildlifes = info;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//更新玩家宠物
|
||||
onUpdatePlayerPet(){
|
||||
//获取玩家阵容
|
||||
@@ -205,7 +171,7 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
//移除不再阵容中的宠物
|
||||
let roles = [...this.getOnesRoleAlive(GOnHookModePlayerEnum.PLAYER)]
|
||||
roles.forEach(role => {
|
||||
let expand = role.getComponent(GRoleOnHookExpand);
|
||||
let expand = role.getComponent(GRoleOnHookPlayerExpand);
|
||||
//如果宠物不再阵容中 则 移除宠物
|
||||
if(infos.indexOf(expand.petId) < 0){
|
||||
//移除宠物
|
||||
@@ -267,7 +233,7 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
//如果场上有这个宠物则更新阵法位置
|
||||
let passRole:GRoleDefault;
|
||||
this.playerRoles.forEach(role => {
|
||||
if(role.getComponent(GRoleOnHookExpand).petId == petId)
|
||||
if(role.getComponent(GRoleOnHookPlayerExpand).petId == petId)
|
||||
passRole = role;
|
||||
})
|
||||
if(passRole){
|
||||
@@ -285,10 +251,21 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
}
|
||||
let role = this.onGenRole(GOnHookModePlayerEnum.PLAYER,index,TD.TbGRole.get(info.petTbId));
|
||||
//向宠物添加 OnHook 扩展
|
||||
let expand = role.node.addComponent(GRoleOnHookExpand);
|
||||
let expand = role.node.addComponent(GRoleOnHookPlayerExpand);
|
||||
expand.petId = petId;
|
||||
}
|
||||
|
||||
//生成野怪
|
||||
onGenCreeps(index:number,creeps:GOnHookPet){
|
||||
|
||||
let role = this.onGenRole(GOnHookModePlayerEnum.ENEMY,index,TD.TbGRole.get(creeps.petTbId));
|
||||
|
||||
//向野怪添加扩展
|
||||
let expand = role.node.addComponent(GRoleOnHookCreepsExpand);
|
||||
expand.creeps = creeps;
|
||||
|
||||
}
|
||||
|
||||
//生成宠物
|
||||
onGenRole(type: GOnHookModePlayerEnum,index:number,info:TB.TbGRole):GRoleDefault {
|
||||
|
||||
@@ -308,6 +285,8 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
|
||||
//绑定死亡回调
|
||||
entity.addKillBackEvent(this.onRoleKillBack.bind(this))
|
||||
//绑定受击回调
|
||||
entity.addHitCallback(this.onHitBack.bind(this));
|
||||
|
||||
this.addGObject(entity,tactical.getPosition(index));
|
||||
|
||||
@@ -364,11 +343,10 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
//生成敌人
|
||||
onResetGenerateEnemy(){
|
||||
this.enemyRoles = [];
|
||||
if(!this.wildlifes) return;
|
||||
|
||||
//获取敌人
|
||||
let wildlife = this.wildlifes.pets.shift();
|
||||
this.onGenRole(GOnHookModePlayerEnum.ENEMY,2,GRoleUtil.getGRole(wildlife.petTbId));
|
||||
let creeps = GOnHookManager.getIns().getNextCreeps();
|
||||
if(!creeps) return; //没有获取到野怪则返回
|
||||
this.onGenCreeps(2,creeps);
|
||||
// this.enemyInfo.roles.forEach((info,index) => this.onGenRole(GOnHookModePlayerEnum.ENEMY,index + 1,info));
|
||||
}
|
||||
|
||||
@@ -380,14 +358,22 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
role.node.destroy()
|
||||
},3000)
|
||||
|
||||
//如果死亡的是野怪则通知野怪死亡
|
||||
if(role.getComponent(GRoleOnHookCreepsExpand)){
|
||||
GOnHookManager.getIns().onKillSreeps(role.getComponent(GRoleOnHookCreepsExpand).creeps);
|
||||
}
|
||||
|
||||
//清理
|
||||
this.onClearCache();
|
||||
|
||||
// //如果没有敌人则生成敌人
|
||||
// if(this.getOnesRole(GOnHookModePlayerEnum.ENEMY).filter(role => !!role.get()).length <= 0){
|
||||
// //生成敌人
|
||||
// this.onResetGenerateEnemy();
|
||||
// }
|
||||
}
|
||||
|
||||
//角色受击回调
|
||||
onHitBack(role:GRoleDefault,hit:number){
|
||||
|
||||
//添加受击显示
|
||||
app.event.emit(ModeRenderEvent.HIT,role,hit);
|
||||
|
||||
}
|
||||
|
||||
//清理缓存
|
||||
|
Reference in New Issue
Block a user