mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { TB } from "../../../config/data/schema";
|
||||
import GRoleDefault from "../../base/role/GRoleDefault";
|
||||
import GDefaultMode from "./GDefaultMode";
|
||||
|
||||
//角色
|
||||
export enum GNormalModeEnum{
|
||||
PLAYER, //玩家
|
||||
ENEMY, //怪物
|
||||
}
|
||||
|
||||
export default class GNormalModeBase extends GDefaultMode<{},{}>{
|
||||
|
||||
//生成宠物
|
||||
onGenRole(type: GNormalModeEnum,index:number,info:TB.TbGRole):GRoleDefault {
|
||||
|
||||
let tactical = this.getInfo(type).tactical;
|
||||
let pos:Vec2 = this.getInfo(type).tactical.getPosition(index);
|
||||
if(!pos) return;
|
||||
let role = instantiate(this.rolePrefab);
|
||||
|
||||
let entity = role.getComponent(GRoleDefault);
|
||||
//初始化
|
||||
entity.onInit(type,info,tactical,index);
|
||||
|
||||
//绑定寻敌
|
||||
entity.onQueryEunmy = () => {
|
||||
return this.getEnumy(entity,type);
|
||||
}
|
||||
|
||||
//绑定死亡回调
|
||||
entity.addKillBackEvent(this.onRoleKillBack.bind(this))
|
||||
//绑定受击回调
|
||||
entity.addHitCallback(this.onHitBack.bind(this));
|
||||
|
||||
this.addGObject(entity,tactical.getPosition(index));
|
||||
|
||||
this.getOnesRole(type).push(entity);
|
||||
|
||||
return entity;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user