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": {}
|
||||
}
|
Reference in New Issue
Block a user