mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交开宝箱
This commit is contained in:
@@ -15,6 +15,7 @@ import NOV2DSimple from "../../../../../extensions/ngame/assets/ngame/util/colli
|
||||
import NOVBase from "../../../../../extensions/ngame/assets/ngame/util/collide/OV/NOVBase";
|
||||
import { BoxCollider2D } from "cc";
|
||||
import { Vec3 } from "cc";
|
||||
import GAttribute from "../values/attribute/GAttribute";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export enum GRoleAnimEvent{
|
||||
@@ -204,7 +205,7 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
}
|
||||
|
||||
//生效数值
|
||||
onEffectiveValue(...values:GAttributeBase[]){
|
||||
onEffectiveValues(...values:GAttributeBase[]){
|
||||
|
||||
this.values.reset();
|
||||
values.forEach(value => {
|
||||
@@ -217,6 +218,17 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
|
||||
}
|
||||
|
||||
//生效属性
|
||||
onEffectiveValue(data:GAttribute){
|
||||
|
||||
this.values.reset(data);
|
||||
this.values.update();
|
||||
|
||||
//赋值血量
|
||||
this.blood = this.fullBlood = this.values.onBlood();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,87 @@
|
||||
import { TD, app } from "../../../App";
|
||||
import { PetEquip, PlayerPetOV } from "../../../consts/API";
|
||||
import GRoleValues from "./GRoleValues";
|
||||
import GAttribute from "./attribute/GAttribute";
|
||||
import GPetAttribute from "./attribute/role/GPetAttribute";
|
||||
import GPetEquipAttribute from "./attribute/role/GPetEquipAttribute";
|
||||
|
||||
//战斗传入数据
|
||||
export interface GBattleDataInfo{
|
||||
//宠物
|
||||
pets?:PlayerPetOV[],
|
||||
//宠物装备
|
||||
petEquips?:PetEquip[]
|
||||
}
|
||||
|
||||
export enum GBattleDataEnum{
|
||||
UPDATE = "GBattleData_UPDATE"
|
||||
}
|
||||
|
||||
//战斗数据类
|
||||
export default class GAttributeData{
|
||||
|
||||
info:GBattleDataInfo;
|
||||
isEmit:boolean;
|
||||
|
||||
constructor(info:GBattleDataInfo = {},isEmit:boolean = false){
|
||||
this.isEmit = isEmit;
|
||||
this.update(info);
|
||||
}
|
||||
|
||||
update(info:GBattleDataInfo){
|
||||
//初始化数据
|
||||
info.pets = info.pets || [];
|
||||
info.petEquips = info.petEquips || [];
|
||||
this.info = info;
|
||||
if(this.isEmit)
|
||||
app.event.emit(GBattleDataEnum.UPDATE)
|
||||
}
|
||||
|
||||
assets(info:GBattleDataInfo){
|
||||
Object.assign(this.info,info);
|
||||
if(this.isEmit)
|
||||
app.event.emit(GBattleDataEnum.UPDATE)
|
||||
}
|
||||
|
||||
//计算总战力数值
|
||||
getAllFC(){
|
||||
let fc = 0;
|
||||
Object.values(this.info.pets).forEach(pet => {
|
||||
let attribute = this.getPetAttribute(pet.petId);
|
||||
//计算战力
|
||||
fc += GAttributeData.FC(attribute);
|
||||
})
|
||||
return fc;
|
||||
}
|
||||
|
||||
//获取共享属性
|
||||
|
||||
//获取指定宠物的属性
|
||||
getPetAttribute(petId:number){
|
||||
let pet = this.info.pets.filter(item => item.petId == petId)[0];
|
||||
if(!pet) return new GAttribute();
|
||||
|
||||
let value = new GAttribute();
|
||||
value.add(new GPetAttribute(pet));
|
||||
value.add(new GPetEquipAttribute(this.info.petEquips.filter(item => item.equipPetId == petId)));
|
||||
value.update();
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
//根据属性计算战力
|
||||
static FC(info:GAttribute){
|
||||
|
||||
let fc = 0;
|
||||
|
||||
TD.TbGAttribute.getDataList().forEach(item => {
|
||||
let value = info.info[item.id] || 0;
|
||||
fc += TD.TbGAttributeFC.get(item.id).value * value;
|
||||
})
|
||||
|
||||
return fc;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "8bc8ee57-3c3f-4e5c-8a0b-9e553ec4cd17",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -25,9 +25,9 @@ export default class GRoleValues {
|
||||
}
|
||||
|
||||
//重置
|
||||
reset(){
|
||||
reset(attribute:GAttribute = new GAttribute()){
|
||||
//初始化属性
|
||||
this.attribute = new GAttribute();
|
||||
this.attribute = attribute;
|
||||
this.update();
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,49 @@
|
||||
import { TD } from "../../../../../App";
|
||||
import { PetEquip, PlayerPetOV } from "../../../../../consts/API";
|
||||
import GAttributeBase from "../GAttributeBase";
|
||||
|
||||
//宠物装备属性
|
||||
export default class GPetEquipAttribute extends GAttributeBase{
|
||||
|
||||
//宠物信息
|
||||
equips:PetEquip[];
|
||||
|
||||
constructor(equips:PetEquip[]){
|
||||
|
||||
super();
|
||||
this.equips = equips;
|
||||
|
||||
//固定属性直接计算
|
||||
this.compute();
|
||||
|
||||
}
|
||||
|
||||
//计算属性
|
||||
compute(){
|
||||
|
||||
this.attributes = {};
|
||||
|
||||
//获取全部属性信息
|
||||
TD.TbGAttribute.getDataList().forEach(attr => {
|
||||
//默认 0
|
||||
this.attributes[attr.id] = 0;
|
||||
});
|
||||
|
||||
//*************** 宠物初始属性 **************************
|
||||
this.equips.forEach(equip => {
|
||||
equip.equipBaseAttributes.forEach(attr => {
|
||||
this.attributes[attr.id] += attr.value
|
||||
})
|
||||
equip.equipHighAttributes.forEach(attr => {
|
||||
this.attributes[attr.id] += attr.value
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//刷新属性
|
||||
update(): void { }
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "e519d154-ce31-4752-8b3f-d28b3b9628f4",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -27,6 +27,8 @@ import GPetAttribute from "../base/values/attribute/role/GPetAttribute";
|
||||
import GDefaultMode from "./default/GDefaultMode";
|
||||
import GOnHookData from "../../data/GOnHookData";
|
||||
import { GModeEvent, GModeHitInfo } from "./GMode";
|
||||
import GAttributeData from "../base/values/GAttributeData";
|
||||
import GBattleData, { GBattleDataEnum } from "../../data/GBattleData";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//挂机模式状态
|
||||
@@ -103,12 +105,14 @@ export default class GOnHookMode extends GDefaultMode<{},{}>{
|
||||
//添加监听事件
|
||||
addEvent(){
|
||||
app.event.on(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this);
|
||||
app.event.on(GBattleDataEnum.UPDARE_ATTRIBUTE_SUCCESS,this.onUpdateAttribute,this);
|
||||
// app.event.on(GOnHookManagerEvent.UPDATE_MAP,this.onUpdateWorld,this);
|
||||
}
|
||||
//移除监听事件
|
||||
onDestroy(){
|
||||
super.onDestroy();
|
||||
app.event.off(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this);
|
||||
app.event.off(GBattleDataEnum.UPDARE_ATTRIBUTE_SUCCESS,this.onUpdateAttribute,this);
|
||||
// app.event.off(GOnHookManagerEvent.UPDATE_MAP,this.onUpdateWorld,this);
|
||||
}
|
||||
|
||||
@@ -188,6 +192,15 @@ export default class GOnHookMode extends GDefaultMode<{},{}>{
|
||||
|
||||
}
|
||||
|
||||
//更新属性
|
||||
onUpdateAttribute(){
|
||||
|
||||
this.getOnesRole(GOnHookModePlayerEnum.PLAYER).forEach(pet => {
|
||||
pet.onEffectiveValue(GBattleData.getIns().data.getPetAttribute(pet.getComponent(GRoleOnHookPlayerExpand).petId));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//更新帧
|
||||
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: {}){
|
||||
super.onSyncUpdate(dt,frame,input);
|
||||
@@ -247,7 +260,7 @@ export default class GOnHookMode extends GDefaultMode<{},{}>{
|
||||
expand.petId = petId;
|
||||
|
||||
//添加宠物属性
|
||||
role.onEffectiveValue(new GPetAttribute(info));
|
||||
role.onEffectiveValue(GBattleData.getIns().data.getPetAttribute(petId));
|
||||
|
||||
}
|
||||
|
||||
@@ -261,7 +274,7 @@ export default class GOnHookMode extends GDefaultMode<{},{}>{
|
||||
expand.creeps = creeps;
|
||||
|
||||
//添加野怪属性
|
||||
role.onEffectiveValue(new GPetAttribute({
|
||||
role.onEffectiveValues(new GPetAttribute({
|
||||
petId:0,
|
||||
petPlayerId:0,
|
||||
petTbId:creeps.petTbId,
|
||||
@@ -381,6 +394,7 @@ export default class GOnHookMode extends GDefaultMode<{},{}>{
|
||||
JNFrameTime.getInstance().setTimeout(() => {
|
||||
if(role.isValid)
|
||||
role.node.destroy()
|
||||
else console.log(role,"无法销毁");
|
||||
},3000)
|
||||
|
||||
//清理
|
||||
|
@@ -145,7 +145,7 @@ export default class GPVPMode extends GBaseMode<{},GPVPStart>{
|
||||
entity.addKillBackEvent(this.onRoleKillBack.bind(this))
|
||||
|
||||
//添加宠物属性
|
||||
entity.onEffectiveValue(new GPetAttribute(info));
|
||||
entity.onEffectiveValues(new GPetAttribute(info));
|
||||
|
||||
this.addGObject(entity,tactical.getPosition(index));
|
||||
this.getOnesRole(type).push(entity);
|
||||
|
Reference in New Issue
Block a user