mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
@@ -6,20 +6,18 @@ import { Node } from "cc";
|
||||
import { instantiate } from "cc";
|
||||
import { TD, app } from "../App";
|
||||
import { JNFrameInfo, JNSyncFrameEvent } from "../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
|
||||
import { CCObject } from "cc";
|
||||
import { Env, EnvCurrent } from "../Env";
|
||||
import { TB } from "../config/data/schema";
|
||||
import BattleResource from "../tools/BattleResource";
|
||||
import { director } from "cc";
|
||||
import { game } from "cc";
|
||||
|
||||
export enum BattleMode{
|
||||
//无尽模式
|
||||
OnHook = 0,
|
||||
OnHook = "OnHook",
|
||||
//PVP 模式
|
||||
PVP = 1,
|
||||
PVP = "PVP",
|
||||
//阵营守护
|
||||
CampGuardian = 2,
|
||||
CampGuardian = "CampGuardian",
|
||||
//副本
|
||||
GDungeonMode = "GDungeonMode",
|
||||
}
|
||||
|
||||
export interface GBattleModeInfo{
|
||||
|
@@ -41,7 +41,7 @@ export default class GPetAttribute extends GAttributeBase{
|
||||
if(!baseAttribute[attr.sign] || !grow[attr.sign]) return;
|
||||
|
||||
//计算 累加 ((base * value) * level)
|
||||
this.attributes[attr.id] += (baseAttribute[attr.sign] * grow[attr.sign]) * level;
|
||||
this.attributes[attr.id] = (baseAttribute[attr.sign] * grow[attr.sign]) * level;
|
||||
|
||||
})
|
||||
|
||||
|
@@ -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,
|
||||
|
105
JisolGameCocos/assets/script/battle/modes/GDungeonMode.ts
Normal file
105
JisolGameCocos/assets/script/battle/modes/GDungeonMode.ts
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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