涨能量需要再处理下, 怪物被攻击算命中 如何涨

This commit is contained in:
2025-07-24 00:05:11 +08:00
parent 690f0547cd
commit af89bb7707
8 changed files with 8602 additions and 7557 deletions

View File

@@ -11,6 +11,7 @@ import { FriendModelComp } from "./FriendModel";
import { MasterModelComp } from "./MasterModel";
import { GameEvent } from "../common/config/GameEvent";
import { BuffAttr } from "../common/config/SkillSet";
import { FightSet } from "../common/config/Mission";
/** 角色实体 */
@ecs.register(`Hero`)
@@ -51,6 +52,7 @@ export class Hero extends ecs.Entity {
hv.scale = 1;
hv.is_master=true;
hv.lv=1
console.log("hero load",hv.ATK_TO_POWER,hv.ATKED_TO_POWER,hv.CRIT_TO_POWER,hv.DODGE_TO_POWER)
this.add(hv);
this.addComponents<ecs.Comp>(MasterModelComp)
oops.message.dispatchEvent(GameEvent.MasterCalled,{uuid:uuid})
@@ -92,6 +94,10 @@ export class Hero extends ecs.Entity {
hv.hp= hv.hp_max = hv.hp_base=hero.hp+info.hp
hv.ap = hero.ap+info.ap;
hv.ap_base=hero.ap+info.ap;
hv.ATK_TO_POWER=FightSet.ATK_TO_POWER
hv.ATKED_TO_POWER=FightSet.ATKED_TO_POWER
hv.CRIT_TO_POWER=FightSet.CRIT_TO_POWER
hv.DODGE_TO_POWER=FightSet.DODGE_TO_POWER
hero.buff.forEach((buff:any)=>{
switch(buff.buff_type){
case BuffAttr.CRITICAL:
@@ -148,6 +154,18 @@ export class Hero extends ecs.Entity {
case BuffAttr.FROST_TIME:
hv.frost_time=buff.value
break
case BuffAttr.ATK_TO_POWER:
hv.ATK_TO_POWER+=buff.value
break
case BuffAttr.ATKED_TO_POWER:
hv.ATKED_TO_POWER+=buff.value
break
case BuffAttr.CRIT_TO_POWER:
hv.CRIT_TO_POWER+=buff.value
break
case BuffAttr.DODGE_TO_POWER:
hv.DODGE_TO_POWER+=buff.value
break
}
})
hv.atk_skill=hero.skills[0]

View File

@@ -1,7 +1,6 @@
import { _decorator, CCClass, Component, sp,Animation} from "cc";
import { FightSet } from "../common/config/Mission";
import { FacSet } from "../common/config/BoxSet";
import { _decorator, CCClass, Component, sp } from "cc";
import { HeroViewComp } from "./HeroViewComp";
import { FacSet } from "../common/config/BoxSet";
const { ccclass, property } = _decorator;
@ccclass('HeroAnmComp')
@@ -9,72 +8,63 @@ export default class HeroAnmComp extends Component{
mixTime:number= 0.2;
private spine: sp.Skeleton;
private spine?: sp.Skeleton;
private _hasStop = true;
private anm:Animation
private is_spine:boolean=false
onLoad () {
if(this.getComponent('sp.Skeleton')){
this.is_spine=true
this.spine=this.getComponent('sp.Skeleton') as sp.Skeleton;
var spine = this.spine = this.getComponent('sp.Skeleton') as sp.Skeleton;
// if(this.node.parent.getComponent(HeroViewComp).fac==FacSet.HERO){
// console.log('hero parent',this.node.parent.getComponent(HeroViewComp))
// this._setMix('Walking', 'Idle');
// this._setMix('Walking', 'Attacking');
// this._setMix('Walking', 'Taunt');
// this._setMix('Idle', 'Attacking');
// this._setMix('Idle', 'Taunt');
// this._setMix('Idle', 'Walking');
// this._setMix('Attacking', 'Idle');
// this._setMix('Attacking', 'Walking');
// this._setMix('Taunt', 'Walking');
// this._setMix('Taunt', 'Idle');
// }
spine.setCompleteListener((trackEntry) => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
if (animationName === 'Attacking'||animationName==='Taunt'||animationName==='Hurt') {
this.idle()
var spine = this.spine = this.getComponent('sp.Skeleton') as sp.Skeleton;
this._setMix('Walking', 'Idle');
this._setMix('Walking', 'Attacking');
this._setMix('Walking', 'Taunt');
this._setMix('Idle', 'Attacking');
this._setMix('Idle', 'Taunt');
this._setMix('Idle', 'Walking');
this._setMix('Attacking', 'Idle');
this._setMix('Attacking', 'Walking');
this._setMix('Attacking', 'Hurt');
this._setMix('Taunt', 'Walking');
this._setMix('Taunt', 'Idle');
this._setMix('Hurt', 'Idle');
this._setMix('Hurt', 'Attacking');
this._setMix('Hurt', 'Taunt');
spine.setCompleteListener((trackEntry) => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
if (animationName === 'Attacking'||animationName==='Taunt'||animationName==='Hurt') {
this.spine!.clearTrack(1);
if(this.node.parent.getComponent(HeroViewComp).fac==FacSet.HERO){
this.spine?.setAnimation(0, 'Idle', false);
}
var loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd);
// console.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex, animationName, loopCount);
});
spine.setEventListener(((trackEntry:any, event:any) => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
// console.log("[track %s][animation %s] event: %s, %s, %s, %s", trackEntry.trackIndex, animationName, event.data.name, event.intValue, event.floatValue, event.stringValue);
}) as any);
}else{
this.is_spine=false
this.anm=this.getComponent(Animation)
}
}
var loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd);
// console.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex, animationName, loopCount);
});
spine.setEventListener(((trackEntry:any, event:any) => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
// console.log("[track %s][animation %s] event: %s, %s, %s, %s", trackEntry.trackIndex, animationName, event.data.name, event.intValue, event.floatValue, event.stringValue);
}) as any);
this._hasStop = false;
}
// OPTIONS
toggleDebugSlots () {
if(!this.is_spine) return
this.spine!.debugSlots = !this.spine?.debugSlots;
}
toggleDebugBones () {
if(!this.is_spine) return
this.spine!.debugBones = !this.spine?.debugBones;
}
toggleDebugMesh () {
if(!this.is_spine) return
this.spine!.debugMesh = !this.spine?.debugMesh;
}
toggleUseTint () {
if(!this.is_spine) return
this.spine!.useTint = !this.spine?.useTint;
}
toggleTimeScale () {
if(!this.is_spine) return
if (this.spine!.timeScale === 1.0) {
this.spine!.timeScale = 0.3;
}
@@ -91,49 +81,25 @@ export default class HeroAnmComp extends Component{
}
move () {
if(!this.is_spine) {
this.anm?.play('move')
}else{
if (this._hasStop) {
this.spine?.setToSetupPose();
}
this.spine?.setAnimation(0, 'Walking', true);
this._hasStop = false;
if (this._hasStop) {
this.spine?.setToSetupPose();
}
this.spine?.setAnimation(0, 'Walking', true);
this._hasStop = false;
}
atk () {
if(!this.is_spine) {
this.anm?.play('atk')
}else{
this.spine?.setAnimation(0, 'Attacking', false);
}
this.spine?.setAnimation(1, 'Attacking', false);
}
max () {
if(!this.is_spine) {
this.anm?.play('atk')
}else{
this.spine?.setAnimation(0, 'Taunt', false);
}
this.spine?.setAnimation(1, 'Taunt', false);
}
atked () {
if(!this.is_spine) {
this.anm?.play('move')
}else{
this.spine?.setAnimation(0, 'Hurt', false);
}
if(this.spine.animation==='Hurt') return
this.spine?.setAnimation(1, 'Hurt', false);
}
idle () {
if(!this.is_spine) {
this.anm?.play('move')
}else{
this.spine?.setToSetupPose();
if(this.node.parent.getComponent(HeroViewComp).fac==FacSet.HERO){
this.spine?.setAnimation(0, 'Idle', true);
}else{
this.spine?.setAnimation(0, 'Walking', true);
}
}
this.spine?.setToSetupPose();
this.spine?.setAnimation(0, 'Idle', true);
}
_setMix (anim1: string, anim2: string) {

View File

@@ -111,7 +111,12 @@ export class HeroViewComp extends CCComp {
DEBUFF_COUNT:number=0; //debuff 持续次数
DEBUFF_UP:number=0; //debuff 概率提升
ATK_TO_POWER:number=0;
ATKED_TO_POWER:number=0;
CRIT_TO_POWER:number=0;
DODGE_TO_POWER:number=0;
private damageQueue: Array<{
damage: number,
isCrit: boolean,
@@ -461,8 +466,12 @@ export class HeroViewComp extends CCComp {
let damage = this.count_damage(remainingDamage)
if(is_crit) {
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE+crit_d)/100))
if(this.fac==FacSet.MON) smc.vmdata.hero.power+=this.CRIT_TO_POWER //暴击涨能量 怪物被暴击,因为只有一个英雄 直接处理
}
this.hp -= damage;
if(this.fac==FacSet.HERO) {smc.vmdata.hero.power+=this.ATKED_TO_POWER;console.log("被攻击涨能量",this)} //被攻击涨能量
if(this.fac==FacSet.MON) {smc.vmdata.hero.power+=this.ATK_TO_POWER;console.log("攻击命中涨能量",this)} //攻击命中涨能量 因为是只有1个英雄 直接处理
if(this.hp <= 0) {
if(this == null) return;
this.is_dead=true
@@ -527,6 +536,7 @@ export class HeroViewComp extends CCComp {
}
check_dodge(){
if(this.fac==FacSet.HERO) smc.vmdata.hero.power+=this.DODGE_TO_POWER //闪避涨能量
if(this.dod > 0){
let random = Math.random()*100
if(random < this.dod) {
@@ -538,6 +548,7 @@ export class HeroViewComp extends CCComp {
}
check_crit(crit:number=0){
if(this.crit_no) return false
if(crit > 0){
let random = Math.random()*100
@@ -574,10 +585,9 @@ export class HeroViewComp extends CCComp {
to_grave(){
tween(this.node).to(0.5, { position:v3(-900,this.node.position.y+300,0)},{
onComplete: (target?: object) => {
this.node.setPosition(-900,this.node.position.y-300,0)
}
}
).start()
this.node.setPosition(-900,this.node.position.y-300,0)
}
}).start()
}
// to_alive(){
// this.is_dead=false
@@ -681,7 +691,8 @@ export class HeroViewComp extends CCComp {
/** 立即显示伤害效果 */
private showDamageImmediate(damage: number, isCrit: boolean) {
this.BUFFCOMP.in_atked();
this.as.atked()
// this.BUFFCOMP.in_atked()
this.atked_count++;
if (isCrit) {
this.BUFFCOMP.tooltip(TooltipTypes.crit, damage.toFixed(0), damage);