天赋触发和 ui制作完成

This commit is contained in:
2025-07-29 17:08:42 +08:00
parent 3fe8edf88a
commit 16195f4cb4
9 changed files with 16800 additions and 20478 deletions

View File

@@ -0,0 +1,147 @@
import { _decorator, Component, Label, Node, resources, Sprite, SpriteAtlas } from 'cc';
import { oops } from 'db://oops-framework/core/Oops';
import { GameEvent } from '../common/config/GameEvent';
import { smc } from '../common/SingletonModuleComp';
import { EquipInfo, EquipType, EquipAttrTarget, EquipSpecialAttr} from '../common/config/Equips';
import { BuffAttr, DebuffAttr, geDebuffNum, getBuffNum } from '../common/config/SkillSet';
import { FightSet } from '../common/config/Mission';
import { Quality } from '../common/config/CardSet';
import { TalentList, TalentSlot } from '../common/config/TalentSet';
const { ccclass, property } = _decorator;
@ccclass('TalsComp')
export class TalsComp extends Component {
tal1:any=null
tal2:any=null
tal3:any=null
tal4:any=null
tal5:any=null
tal6:any=null
boxs:Node=null
// attrs:any={
// hero_buff:getBuffNum(),
// enemy_buff:getBuffNum(),
// }
/** 视图层逻辑代码分离演示 */
onLoad() {
oops.message.on(GameEvent.FightReady,this.fight_ready,this)
oops.message.on(GameEvent.UseTalentCard,this.tal_add,this)
this.boxs=this.node.getChildByName("boxs")
}
start(){
this.fight_ready()
}
fight_ready(){
this.boxs.getChildByName("tal1").getChildByName("icon").active=false
this.boxs.getChildByName("tal2").getChildByName("icon").active=false
this.boxs.getChildByName("tal3").getChildByName("icon").active=false
this.boxs.getChildByName("tal4").getChildByName("icon").active=false
this.boxs.getChildByName("tal5").getChildByName("icon").active=false
this.boxs.getChildByName("tal6").getChildByName("icon").active=false
this.boxs.getChildByName("tal1").getChildByName("light").active=false
this.boxs.getChildByName("tal2").getChildByName("light").active=false
this.boxs.getChildByName("tal3").getChildByName("light").active=false
this.boxs.getChildByName("tal4").getChildByName("light").active=false
this.boxs.getChildByName("tal5").getChildByName("light").active=false
this.boxs.getChildByName("tal6").getChildByName("light").active=false
this.reset_attrs()
}
tal_add(e:GameEvent,data:any){
console.log("[TalsComp]:tal_add",data)
switch(data.slot){
case TalentSlot[0]:
this.tal1.uuid=data.uuid
this.tal1.name=data.name
this.show_tal(data.uuid,TalentSlot[0])
break
case TalentSlot[1]:
this.tal2.uuid=data.uuid
this.tal2.name=data.name
this.show_tal(data.uuid,TalentSlot[1])
break
case TalentSlot[2]:
this.tal3.uuid=data.uuid
this.tal3.name=data.name
this.show_tal(data.uuid,TalentSlot[2])
break
case TalentSlot[3]:
this.tal4.uuid=data.uuid
this.tal4.name=data.name
this.show_tal(data.uuid,TalentSlot[3])
break
case TalentSlot[4]:
this.tal5.uuid=data.uuid
this.tal5.name=data.name
this.show_tal(data.uuid,TalentSlot[4])
break
case TalentSlot[5]:
this.tal6.uuid=data.uuid
this.tal6.name=data.name
this.show_tal(data.uuid,TalentSlot[5])
break
}
}
show_tal(uuid:number,slot:string="tal1"){
let icon = this.boxs.getChildByName(slot).getChildByName("icon")
icon.active=true
var icon_path = "game/heros/cards"
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = icon.getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(TalentList[uuid].path);
});
icon.getChildByName("q1").active=TalentList[uuid].quality==Quality.WHITE
icon.getChildByName("q2").active=TalentList[uuid].quality==Quality.GREEN
icon.getChildByName("q3").active=TalentList[uuid].quality==Quality.BLUE
icon.getChildByName("q4").active=TalentList[uuid].quality==Quality.PURPLE
icon.getChildByName("q5").active=TalentList[uuid].quality==Quality.ORANGE
}
// 重置所有属性为0
private reset_attrs() {
this.tal1={
uuid:0,
name:"tal1",
slot:TalentSlot[0],
}
this.tal2={
uuid:0,
name:"tal2",
slot:TalentSlot[1],
}
this.tal3={
uuid:0,
name:"tal3",
slot:TalentSlot[2],
}
this.tal4={
uuid:0,
name:"tal4",
slot:TalentSlot[3],
}
this.tal5={
uuid:0,
name:"tal5",
slot:TalentSlot[4],
}
this.tal6={
uuid:0,
name:"tal6",
slot:TalentSlot[5],
}
}
update(dt: number): void {
if(!smc.mission.play||smc.mission.pause) return
}
}