@@ -19,8 +19,7 @@ import { mLogger } from "../common/Logger";
import { _decorator , Node , Sprite , Label , RichText , NodeEventType , Vec3 , Tween , tween , UIOpacity , SpriteFrame , resources , AnimationClip } from "cc" ;
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS" ;
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp" ;
import { CardConfig , CardType } from "../common/config/Card Set" ;
import { HeroInfo } from "../common/config/heroSet" ;
import { HeroInfo , HeroCardConfig } from "../common/config/hero Set" ;
import { buildSkillDescMoreRich , ISkillDescSource } from "../common/config/HeroSkillDesc" ;
import { oops } from "db://oops-framework/core/Oops" ;
import { GameEvent } from "../common/config/GameEvent" ;
@@ -83,7 +82,7 @@ export class CHeroComp extends CCComp {
// ======================== 运行时状态 ========================
/** 当前槽位承载的卡牌配置, null 表示空槽 */
private cardData : CardConfig | null = null ;
private cardData : Hero CardConfig | null = null ;
/** 是否已购买 */
private isPurchased : boolean = false ;
/** 是否已缓存基准 Y/Z 坐标(首次 setSlotPosition 时确定) */
@@ -153,17 +152,14 @@ export class CHeroComp extends CCComp {
*
* @param data 卡牌配置,传 null 时清空显示
*/
applyCardData ( data : CardConfig | null ) : void {
applyCardData ( data : Hero CardConfig | null ) : void {
mLogger . log ( this . debugMode , "CHeroComp" , "applyCardData" , {
nodeName : this.node?.name ,
nodeUuid : this.node?.uuid ,
uuid : data?.uuid ? ? null ,
type : data ? . type ? ? null ,
name : data?.name ? ? null ,
card_lv : data?.card_lv ? ? null ,
hero_lv : data?.hero_lv ? ? null ,
cost : data?.cost ? ? null ,
icon : data?.icon ? ? null ,
nodeActiveBefore : this.node?.active
} ) ;
@@ -238,19 +234,12 @@ export class CHeroComp extends CCComp {
return ;
}
// 动态升级卡( SpecialUpgrade + target_hero_eid) 按英雄卡样式渲染:
// 通过 eid 反查场上实体得到 hero_uuid; 实体不存在时降级为本卡 uuid
const isUpgradeCard = this . cardData . type === CardType . SpecialUpgrade && ! ! this . cardData . target_hero_eid ;
const renderUuid = isUpgradeCard
? ( this . queryHeroUuidByEid ( this . cardData . target_hero_eid as number ) ? ? this . cardData . uuid )
: this . cardData . uuid ;
const renderUuid = this . cardData . uuid ;
const hero = HeroInfo [ renderUuid ] ;
mLogger . log ( this . debugMode , "CHeroComp" , "updateUI resolve" , {
nodeName : this.node?.name ,
uuid : this.cardData.uuid ,
type : this . cardData . type ,
isUpgradeCard ,
renderUuid ,
heroFound : ! ! hero ,
heroName : hero?.name ? ? null ,
@@ -272,18 +261,10 @@ export class CHeroComp extends CCComp {
} ) ;
}
// 等级标签(★ 表示卡牌等级;升级卡显示英雄目标等级;普通 英雄卡显示局外等级)
// 等级标签: 英雄卡显示局外等级( Lv.N)
if ( this . level_label ) {
if ( isUpgradeCar d) {
const heroLv = Math . max ( 1 , this . cardData . hero_lv ? ? 1 ) ;
this . level_label . string = heroLv > 1 ? ` Lv. ${ heroLv - 1 } -> Lv. ${ heroLv } ` : ` Lv. ${ heroLv } ` ;
} else if ( this . cardData . type === CardType . Hero ) {
const heroLv = smc . getHeroOuterLv ( this . cardData . uuid ) ;
this . level_label . string = heroLv > 1 ? ` Lv. ${ heroLv } ` : "" ;
} else {
const lv = this . cardData . card_lv ? ? 1 ;
this . level_label . string = lv >= 2 ? "★" . repeat ( lv - 1 ) : "" ;
}
const heroLv = smc . getHeroOuterLv ( this . cardData . uui d) ;
this . level_label . string = heroLv > 1 ? ` Lv. ${ heroLv } ` : "" ;
}
// 背景:按 card_lv 激活对应颜色子节点( 1→green 2→blue 3→purple 4→red 5→yellow)
@@ -580,32 +561,22 @@ export class CHeroComp extends CCComp {
oops . audio . playEffect ( "music/button" ) ;
// 英雄卡数量上限校验: guard 模式, MissionCardComp 可设 cancel=true 阻止使用
if ( this . cardData . type === CardType . Hero ) {
const guard = {
cancel : false ,
reason : "" ,
uuid : this. cardData. uuid ,
hero_lv : smc.getHeroOuterLv ( this . cardData . uuid ) ,
card_lv : this.cardData.base_card_lv ? ? this . cardData . card_lv ? ? 1
} ;
oops . message . dispatchEvent ( GameEvent . UseHeroCard , guard ) ;
if ( guard . cancel ) return ;
}
const guard = {
cancel : false ,
reason : "" ,
uuid : this.cardData.uuid ,
hero_lv : smc.getHeroOuterLv ( this . cardData. uuid) ,
card_lv : this.cardData.base_card_lv ? ? this . cardData . card_lv ? ? 1
} ;
oops . message . dispatchEvent ( GameEvent . UseHeroCard , guard ) ;
if ( guard . cancel ) return ;
smc . vmdata . scores . refresh_hit_count ++ ;
const used = this . cardData ;
// 按卡牌类型分发效果 事件
switch ( used . type ) {
case CardType.Hero :
oops.message.dispatchEvent ( GameEvent . CallHero , used ) ;
break ;
case CardType.SpecialUpgrade :
case CardType.SpecialRefresh :
oops.message.dispatchEvent ( GameEvent . UseSpecialCard , used ) ;
break ;
}
// 派发英雄召唤 事件
oops . message . dispatchEvent ( GameEvent . CallHero , used ) ;
// 播放购买动画(缩小淡出),刷新卡池由 CardUsed 事件触发
this . playPurchaseAnim ( ) ;
@@ -620,8 +591,7 @@ export class CHeroComp extends CCComp {
oops . message . dispatchEvent ( GameEvent . CardUsed , this ) ;
mLogger . log ( this . debugMode , "CHeroComp" , "hero card purchased" , {
uuid : used.uuid ,
type : used . type
uuid : used.uuid
} ) ;
}
@@ -638,7 +608,7 @@ export class CHeroComp extends CCComp {
* @param data 卡牌配置, null 时清空显示
* @returns 是否成功接收( true = 接收并刷新 UI)
*/
applyDrawCard ( data : CardConfig | null ) : boolean {
applyDrawCard ( data : Hero CardConfig | null ) : boolean {
this . applyCardData ( data ) ;
return ! ! data ;
}