dd
This commit is contained in:
@@ -11,6 +11,7 @@ import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroSkillList, SkillSet } from "../common/config/SkillSet";
|
||||
import { cardType, getRandomCardUUID, Quality, SuperCards } from "../common/config/CardSet";
|
||||
import { EquipInfo } from "../common/config/Equips";
|
||||
import { FightSet } from "../common/config/Mission";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -21,11 +22,10 @@ export class CardComp extends CCComp {
|
||||
c_uuid:number=0;
|
||||
c_type:number=0; //1英雄,2 技能.3 装备 4.功能卡牌
|
||||
is_used:boolean=false;
|
||||
|
||||
cost_gold:number=0;
|
||||
onLoad(){
|
||||
// this.on(GameEvent.HeroSelect,this.hero_select,this)
|
||||
// this.on(GameEvent.HeroSkillSelect,this.hero_skill_select,this)
|
||||
// this.on(GameEvent.CardRefresh,this.rad,this)
|
||||
}
|
||||
|
||||
start() {
|
||||
@@ -39,7 +39,7 @@ export class CardComp extends CCComp {
|
||||
hero_select(args: any){
|
||||
this.c_type=cardType.HERO
|
||||
this.c_uuid=args.uuid
|
||||
console.log("card hero_select c_uuid:"+this.c_uuid)
|
||||
console.log("[cardcomp]:card hero_select c_uuid:"+this.c_uuid)
|
||||
this.show_hero(this.c_uuid)
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
@@ -50,7 +50,7 @@ export class CardComp extends CCComp {
|
||||
}
|
||||
hero_skill_select(args: any){
|
||||
this.c_type=cardType.SKILL
|
||||
console.log("card hero_skill_select",args)
|
||||
console.log("[cardcomp]:card hero_skill_select",args)
|
||||
this.c_uuid=args.uuid
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
@@ -72,7 +72,7 @@ export class CardComp extends CCComp {
|
||||
}, 0.1);
|
||||
}
|
||||
func_select(args: any){
|
||||
console.log("card func_select",args)
|
||||
console.log("[cardcomp]:card func_select",args)
|
||||
this.c_type=cardType.SPECIAL
|
||||
this.c_uuid=args.uuid
|
||||
this.node.getChildByName("show").active=false
|
||||
@@ -86,7 +86,7 @@ export class CardComp extends CCComp {
|
||||
|
||||
random_select(){
|
||||
let card =getRandomCardUUID() //随机获取卡牌类型
|
||||
console.log("rad 开始请求卡牌",card)
|
||||
console.log("[cardcomp]:rad 开始请求卡牌",card)
|
||||
switch(card.type){
|
||||
case cardType.HERO:
|
||||
this.hero_select(card)
|
||||
@@ -106,17 +106,8 @@ export class CardComp extends CCComp {
|
||||
show_skill(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=SkillSet[uuid].name
|
||||
show.getChildByName("q1").active=SkillSet[uuid].quality==Quality.WHITE
|
||||
show.getChildByName("q2").active=SkillSet[uuid].quality==Quality.GREEN
|
||||
show.getChildByName("q3").active=SkillSet[uuid].quality==Quality.BLUE
|
||||
show.getChildByName("q4").active=SkillSet[uuid].quality==Quality.PURPLE
|
||||
show.getChildByName("q5").active=SkillSet[uuid].quality==Quality.ORANGE
|
||||
show.getChildByName("mask").getChildByName("q1").active=SkillSet[uuid].quality==Quality.WHITE
|
||||
show.getChildByName("mask").getChildByName("q2").active=SkillSet[uuid].quality==Quality.GREEN
|
||||
show.getChildByName("mask").getChildByName("q3").active=SkillSet[uuid].quality==Quality.BLUE
|
||||
show.getChildByName("mask").getChildByName("q4").active=SkillSet[uuid].quality==Quality.PURPLE
|
||||
show.getChildByName("mask").getChildByName("q5").active=SkillSet[uuid].quality==Quality.ORANGE
|
||||
this.do_card_bg_show()
|
||||
this.do_card_bg_show(SkillSet[uuid].quality)
|
||||
this.node.getChildByName("Button").getChildByName("coins").active=false
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("skill").getComponent(Sprite);
|
||||
@@ -124,28 +115,20 @@ export class CardComp extends CCComp {
|
||||
});
|
||||
show.getChildByName("info").getComponent(Label).string=SkillSet[uuid].info
|
||||
}
|
||||
|
||||
show_hero(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
this.do_card_bg_show()
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=HeroInfo[uuid].name
|
||||
this.do_card_bg_show(HeroInfo[uuid].quality)
|
||||
this.node.getChildByName("Button").getChildByName("coins").active=false
|
||||
// show.getChildByName("ap").active=true
|
||||
// show.getChildByName("hp").active=true
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=HeroInfo[uuid].name
|
||||
// show.getChildByName("ap").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].ap.toString()
|
||||
// show.getChildByName("hp").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].hp.toString()
|
||||
// show.getChildByName("type").getChildByName("war").active=HeroInfo[uuid].type==0
|
||||
// show.getChildByName("type").getChildByName("bow").active=HeroInfo[uuid].type==1
|
||||
// show.getChildByName("type").getChildByName("mag").active=HeroInfo[uuid].type==2
|
||||
// show.getChildByName("lv").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].lv.toString()
|
||||
show.getChildByName("q1").active=HeroInfo[uuid].quality==Quality.WHITE
|
||||
show.getChildByName("q2").active=HeroInfo[uuid].quality==Quality.GREEN
|
||||
show.getChildByName("q3").active=HeroInfo[uuid].quality==Quality.BLUE
|
||||
show.getChildByName("q4").active=HeroInfo[uuid].quality==Quality.PURPLE
|
||||
show.getChildByName("q5").active=HeroInfo[uuid].quality==Quality.ORANGE
|
||||
show.getChildByName("mask").getChildByName("q1").active=HeroInfo[uuid].quality==Quality.WHITE
|
||||
show.getChildByName("mask").getChildByName("q2").active=HeroInfo[uuid].quality==Quality.GREEN
|
||||
show.getChildByName("mask").getChildByName("q3").active=HeroInfo[uuid].quality==Quality.BLUE
|
||||
show.getChildByName("mask").getChildByName("q4").active=HeroInfo[uuid].quality==Quality.PURPLE
|
||||
show.getChildByName("mask").getChildByName("q5").active=HeroInfo[uuid].quality==Quality.ORANGE
|
||||
var icon_path = "game/heros/herois"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("hero").getComponent(Sprite);
|
||||
@@ -154,20 +137,11 @@ export class CardComp extends CCComp {
|
||||
show.getChildByName("info").getComponent(Label).string=HeroInfo[uuid].info
|
||||
|
||||
}
|
||||
|
||||
show_equip(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
this.do_card_bg_show()
|
||||
show.getChildByName("q1").active=EquipInfo[uuid].quality==Quality.WHITE
|
||||
show.getChildByName("q2").active=EquipInfo[uuid].quality==Quality.GREEN
|
||||
show.getChildByName("q3").active=EquipInfo[uuid].quality==Quality.BLUE
|
||||
show.getChildByName("q4").active=EquipInfo[uuid].quality==Quality.PURPLE
|
||||
show.getChildByName("q5").active=EquipInfo[uuid].quality==Quality.ORANGE
|
||||
show.getChildByName("mask").getChildByName("q1").active=EquipInfo[uuid].quality==Quality.WHITE
|
||||
show.getChildByName("mask").getChildByName("q2").active=EquipInfo[uuid].quality==Quality.GREEN
|
||||
show.getChildByName("mask").getChildByName("q3").active=EquipInfo[uuid].quality==Quality.BLUE
|
||||
show.getChildByName("mask").getChildByName("q4").active=EquipInfo[uuid].quality==Quality.PURPLE
|
||||
show.getChildByName("mask").getChildByName("q5").active=EquipInfo[uuid].quality==Quality.ORANGE
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=EquipInfo[uuid].name
|
||||
this.do_card_bg_show(EquipInfo[uuid].quality)
|
||||
var icon_path = "game/heros/equips"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("equip").getComponent(Sprite);
|
||||
@@ -175,21 +149,11 @@ export class CardComp extends CCComp {
|
||||
});
|
||||
show.getChildByName("info").getComponent(Label).string=EquipInfo[uuid].info
|
||||
}
|
||||
|
||||
show_func(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
this.do_card_bg_show()
|
||||
show.getChildByName("q1").active=SuperCards[uuid].quality==Quality.WHITE
|
||||
show.getChildByName("q2").active=SuperCards[uuid].quality==Quality.GREEN
|
||||
show.getChildByName("q3").active=SuperCards[uuid].quality==Quality.BLUE
|
||||
show.getChildByName("q4").active=SuperCards[uuid].quality==Quality.PURPLE
|
||||
show.getChildByName("q5").active=SuperCards[uuid].quality==Quality.ORANGE
|
||||
show.getChildByName("mask").getChildByName("q1").active=SuperCards[uuid].quality==Quality.WHITE
|
||||
show.getChildByName("mask").getChildByName("q2").active=SuperCards[uuid].quality==Quality.GREEN
|
||||
show.getChildByName("mask").getChildByName("q3").active=SuperCards[uuid].quality==Quality.BLUE
|
||||
show.getChildByName("mask").getChildByName("q4").active=SuperCards[uuid].quality==Quality.PURPLE
|
||||
show.getChildByName("mask").getChildByName("q5").active=SuperCards[uuid].quality==Quality.ORANGE
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=SuperCards[uuid].name
|
||||
|
||||
this.do_card_bg_show(SuperCards[uuid].quality)
|
||||
|
||||
var icon_path = "game/heros/cards"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
@@ -198,7 +162,8 @@ export class CardComp extends CCComp {
|
||||
});
|
||||
show.getChildByName("info").getComponent(Label).string=SuperCards[uuid].info
|
||||
}
|
||||
do_card_bg_show(){
|
||||
|
||||
do_card_bg_show(q:number=Quality.WHITE){
|
||||
this.node.getChildByName("Button").getChildByName("Label").getComponent(Label).string=this.check_heros()
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("ap").active=false
|
||||
@@ -225,6 +190,36 @@ export class CardComp extends CCComp {
|
||||
show.getChildByName("type").getChildByName("name").getComponent(Label).string="特效"
|
||||
break
|
||||
}
|
||||
show.getChildByName("q1").active=q==Quality.WHITE
|
||||
show.getChildByName("q2").active=q==Quality.GREEN
|
||||
show.getChildByName("q3").active=q==Quality.BLUE
|
||||
show.getChildByName("q4").active=q==Quality.PURPLE
|
||||
show.getChildByName("q5").active=q==Quality.ORANGE
|
||||
show.getChildByName("mask").getChildByName("q1").active=q==Quality.WHITE
|
||||
show.getChildByName("mask").getChildByName("q2").active=q==Quality.GREEN
|
||||
show.getChildByName("mask").getChildByName("q3").active=q==Quality.BLUE
|
||||
show.getChildByName("mask").getChildByName("q4").active=q==Quality.PURPLE
|
||||
show.getChildByName("mask").getChildByName("q5").active=q==Quality.ORANGE
|
||||
this.node.getChildByName("Button").getChildByName("coins").active=true
|
||||
this.node.getChildByName("Button").getChildByName("coins").getChildByName("num").getComponent(Label).string=this.get_cost_gold(q).toString()
|
||||
}
|
||||
|
||||
get_cost_gold(quality:number){
|
||||
switch(quality){
|
||||
case Quality.GREEN:
|
||||
return FightSet.GREEN_GOLD
|
||||
|
||||
case Quality.BLUE:
|
||||
return FightSet.BLUE_GOLD
|
||||
|
||||
case Quality.PURPLE:
|
||||
return FightSet.PURPLE_GOLD
|
||||
|
||||
case Quality.ORANGE:
|
||||
return FightSet.ORANGE_GOLD
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
check_heros(){
|
||||
// let heros=ecs.query(ecs.allOf(HeroModelComp))
|
||||
@@ -238,33 +233,45 @@ export class CardComp extends CCComp {
|
||||
// }
|
||||
return "购买"
|
||||
}
|
||||
reset_card(){
|
||||
this.cost_gold=0
|
||||
this.c_type=0
|
||||
this.c_uuid=0
|
||||
this.is_used=false
|
||||
}
|
||||
use_card(){
|
||||
switch(this.c_type){
|
||||
case cardType.HERO:
|
||||
if(smc.vmdata.mission_data.gold< smc.vmdata.mission_data.call_gold){
|
||||
oops.gui.toast("金币不足", false);
|
||||
return
|
||||
}
|
||||
oops.message.dispatchEvent(GameEvent.UseHeroCard,{uuid:this.c_uuid})
|
||||
smc.vmdata.mission_data.gold-=smc.vmdata.mission_data.call_gold
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
case cardType.SKILL:
|
||||
console.log("use_card 技能卡")
|
||||
console.log("[cardcomp]:use_card 技能卡")
|
||||
oops.message.dispatchEvent(GameEvent.UseSkillCard,{uuid:this.c_uuid})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
case cardType.EQUIP:
|
||||
console.log("use_card 装备卡")
|
||||
console.log("[cardcomp]:use_card 装备卡")
|
||||
if(!this.cost_gold_check()) return
|
||||
oops.message.dispatchEvent(GameEvent.EquipAdd,{uuid:this.c_uuid,type:EquipInfo[this.c_uuid].type})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
case cardType.SPECIAL:
|
||||
console.log("use_card 功能卡")
|
||||
console.log("[cardcomp]:use_card 功能卡")
|
||||
if(!this.cost_gold_check()) return
|
||||
oops.message.dispatchEvent(GameEvent.UseSpecialCard,{uuid:this.c_uuid})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
}
|
||||
this.reset_card()
|
||||
}
|
||||
cost_gold_check(){
|
||||
if(smc.vmdata.mission_data.gold< this.cost_gold){
|
||||
oops.gui.toast("[cardcomp]:金币不足", false);
|
||||
return false
|
||||
}
|
||||
smc.vmdata.mission_data.gold-=this.cost_gold
|
||||
return true
|
||||
}
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
|
||||
Reference in New Issue
Block a user