mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
108 lines
2.8 KiB
TypeScript
108 lines
2.8 KiB
TypeScript
import { Vec2 } from "cc";
|
|
import GDefaultMode from "./default/GDefaultMode";
|
|
import { TB } from "../../../resources/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";
|
|
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);
|
|
|
|
}
|
|
|
|
//生成水晶
|
|
onGenCrystal(type:GCampGuardianEnum){
|
|
|
|
let crystalNode = instantiate(this.crystalPrefab);
|
|
let crystal = crystalNode.getComponent(GRoleCGCrystal);
|
|
crystal.init(TD.TbGRole.get(10005));
|
|
|
|
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 = 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;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|