This commit is contained in:
PC-20230316NUNE\Administrator
2024-01-17 00:05:44 +08:00
parent 68e0f81616
commit 8ad2313502
57 changed files with 12231 additions and 2286 deletions

View File

@@ -125,7 +125,7 @@ export default class GCampGuardianMode extends GBaseMode<{},{}>{
entity.addKillBackEvent(this.onRoleKillBack.bind(this))
//添加宠物属性
entity.onEffectiveValue(new GPetAttribute({
entity.onEffectiveValues(new GPetAttribute({
petId:info.id,
petPlayerId:0,
petTbId:info.id,

View File

@@ -0,0 +1,105 @@
import { _decorator } from "cc";
import GBaseMode from "../GBaseMode";
import { TB, TbGEntity } from "../../config/data/schema";
import PlayerTacticalData from "../../data/PlayerTacticalData";
import PlayerPetData from "../../data/PlayerPetData";
import { TD, app } from "../../App";
import { GUI } from "../../ui/UIConfig";
import { GOnHookModePlayerEnum } from "./GOnHookMode";
import GRoleDefault from "../base/role/GRoleDefault";
const { ccclass, property } = _decorator;
//角色
export enum GDungeonModeEnum{
PLAYER, //玩家
ENEMY, //怪物
}
/**
* 副本(默认) 模式
*/
@ccclass('GDungeonMode')
export default class GDungeonMode extends GBaseMode<{},TbGEntity.TDungeon>{
//生成玩家宠物
onGenPlayerPet(index:number,petId:number){
//获取玩家阵容
let infos = PlayerTacticalData.getIns().getTacticalInfo();
infos.forEach(petId => {
//获取要生成的宠物
let info = PlayerPetData.getIns().petIdQueryPetInfo(petId);
if(!info){
app.layer.Open(GUI.Tips,{text:"未拥有当前上阵的宠物"});
return;
}
let role = this.onGenRole(GOnHookModePlayerEnum.PLAYER,index,TD.TbGRole.get(info.petTbId));
})
//如果场上有这个宠物则更新阵法位置
let passRole:GRoleDefault;
this.playerRoles.forEach(role => {
if(role.getComponent(GRoleOnHookPlayerExpand).petId == petId)
passRole = role;
})
if(passRole){
//更新宠物阵法位置
passRole.tacticalIndex = index;
return;
}
if(!info){
app.layer.Open(GUI.Tips,{text:"未拥有当前上阵的宠物"});
return;
}
let role = this.onGenRole(GOnHookModePlayerEnum.PLAYER,index,TD.TbGRole.get(info.petTbId));
//向宠物添加 OnHook 扩展
let expand = role.node.addComponent(GRoleOnHookPlayerExpand);
expand.petId = petId;
//添加宠物属性
role.onEffectiveValue(GBattleData.getIns().data.getPetAttribute(petId));
}
//生成宠物
onGenRole(type: GOnHookModePlayerEnum,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;
}
}

View File

@@ -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;
}
}