mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
127 lines
3.6 KiB
TypeScript
127 lines
3.6 KiB
TypeScript
import { Vec2 } from "cc";
|
|
import GDefaultMode from "./default/GDefaultMode";
|
|
import { TB } from "../../config/data/schema";
|
|
import GRoleDefault from "../base/role/GRoleDefault";
|
|
import { _decorator } from "cc";
|
|
import GBaseMode from "../GBaseMode";
|
|
import { Prefab } from "cc";
|
|
import { instantiate } from "cc";
|
|
import GRoleCGCrystal from "../base/role/CampGuardian/GRoleCGCrystal";
|
|
import { TD } from "../../App";
|
|
import { GTowards } from "../base/GObject";
|
|
import GRoleBase from "../base/role/GRoleBase";
|
|
import { GTactical } from "../entity/GTactical";
|
|
import JNFrameTime from "../../../../extensions/ngame/assets/ngame/sync/frame/game/time/JNFrameTime";
|
|
import { TbGPetId } from "../../config/TbGPet";
|
|
const { ccclass, property } = _decorator;
|
|
|
|
//阵营守护 角色
|
|
export enum GCampGuardianEnum{
|
|
PLAYER, //玩家
|
|
ENEMY, //敌人
|
|
}
|
|
|
|
//阵营守护
|
|
//玩家派兵攻击对方阵营 游戏参考
|
|
@ccclass('GCampGuardianMode')
|
|
export default class GCampGuardianMode extends GBaseMode<{},{}>{
|
|
|
|
//玩家水晶位置
|
|
playerPos: Vec2 = new Vec2(-600,0);
|
|
//敌方水晶位置
|
|
enemyPos: Vec2 = new Vec2(600,0);
|
|
|
|
//我方水晶
|
|
|
|
//敌方水晶
|
|
|
|
//水晶预制体
|
|
@property(Prefab)
|
|
crystalPrefab: Prefab;
|
|
|
|
//角色预制体
|
|
@property(Prefab)
|
|
petPrefab: Prefab;
|
|
|
|
//玩家宠物
|
|
playerRoles: GRoleBase<{}>[] = [];
|
|
//敌方宠物
|
|
enemyRoles: GRoleBase<{}>[] = [];
|
|
|
|
onSyncInitSuccess(){
|
|
|
|
//生成水晶
|
|
this.onGenCrystal(GCampGuardianEnum.PLAYER);
|
|
this.onGenCrystal(GCampGuardianEnum.ENEMY);
|
|
|
|
//定时器生成
|
|
JNFrameTime.getInstance().setInterval(() => {
|
|
this.onGenRole(GCampGuardianEnum.PLAYER,TD.TbGRole.get(TbGPetId.坚强小石));
|
|
this.onGenRole(GCampGuardianEnum.PLAYER,TD.TbGRole.get(TbGPetId.坚强小石));
|
|
this.onGenRole(GCampGuardianEnum.PLAYER,TD.TbGRole.get(TbGPetId.坚强小石));
|
|
this.onGenRole(GCampGuardianEnum.ENEMY,TD.TbGRole.get(TbGPetId.雷吉艾斯));
|
|
},1000)
|
|
|
|
}
|
|
|
|
//生成水晶
|
|
onGenCrystal(type:GCampGuardianEnum){
|
|
|
|
let crystalNode = instantiate(this.crystalPrefab);
|
|
let crystal = crystalNode.getComponent(GRoleCGCrystal);
|
|
crystal.init(TD.TbGRole.get(TbGPetId.雷吉艾斯));
|
|
|
|
switch(type){
|
|
case GCampGuardianEnum.PLAYER:
|
|
this.addGObject(crystal,this.playerPos)
|
|
break;
|
|
case GCampGuardianEnum.ENEMY:
|
|
crystal.setTowards(GTowards.LEFT)
|
|
this.addGObject(crystal,this.enemyPos)
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
//生成宠物
|
|
onGenRole(type:GCampGuardianEnum,info:TB.TbGRole):GRoleDefault {
|
|
|
|
let tactical = GTactical.getTactical();
|
|
let pos:Vec2;
|
|
|
|
switch(type){
|
|
case GCampGuardianEnum.PLAYER:
|
|
pos = tactical.getPosXYPosition(1,1,this.playerPos);
|
|
break;
|
|
case GCampGuardianEnum.ENEMY:
|
|
pos = tactical.getPosXYPosition(1,1,this.enemyPos);
|
|
break;
|
|
}
|
|
|
|
|
|
if(!pos) return;
|
|
let role = instantiate(this.petPrefab);
|
|
|
|
let entity = role.getComponent(GRoleDefault);
|
|
//初始化
|
|
entity.onInit(type,info,tactical,tactical.getPosXY(1,1));
|
|
|
|
// //绑定寻敌
|
|
// entity.onQueryEunmy = () => {
|
|
// return this.getEnumy(entity,type);
|
|
// }
|
|
|
|
// //绑定死亡回调
|
|
// entity.addKillBackEvent(this.onRoleKillBack.bind(this))
|
|
// //绑定受击回调
|
|
// entity.addHitCallback(this.onHitBack.bind(this));
|
|
|
|
this.addGObject(entity,pos);
|
|
return entity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|