开箱 随机buff 初步完成
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { _decorator, Animation, Component, Node, tween, v3 } from 'cc';
|
||||
import { _decorator, Animation, Component, Label, Node, resources, Sprite, SpriteAtlas, tween, v3 } from 'cc';
|
||||
import { SuperCards, SuperCardsType } from '../common/config/CardSet';
|
||||
import { SkillSet } from '../common/config/SkillSet';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('LuckCardComp')
|
||||
@@ -18,6 +20,22 @@ export class LuckCardComp extends Component {
|
||||
this.timer=2
|
||||
}
|
||||
}
|
||||
show_card(card:any){
|
||||
var icon_path = "game/heros/cards"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = this.node.getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(SuperCards[card.uuid].path);
|
||||
});
|
||||
this.node.getChildByName("name").getComponent(Label).string=SuperCards[card.uuid].name
|
||||
switch(SuperCards[card.uuid].type){
|
||||
case SuperCardsType.BUFF:
|
||||
this.node.getChildByName("val").getComponent(Label).string="+"+SuperCards[card.uuid].value2
|
||||
break
|
||||
case SuperCardsType.AOE:
|
||||
this.node.getChildByName("val").getComponent(Label).string=SkillSet[SuperCards[card.uuid].value1].name+"X"+SuperCards[card.uuid].value2
|
||||
break
|
||||
}
|
||||
}
|
||||
do_destroy(){
|
||||
tween(this.node)
|
||||
.to(0.2, {
|
||||
|
||||
@@ -12,6 +12,8 @@ import { defaultEnhancements, EnhancementOptions } from "../common/config/LevelU
|
||||
import { MonModelComp } from "../hero/MonModelComp";
|
||||
import { TalentSlot } from "../common/config/TalentSet";
|
||||
import { RogueTalWave } from "./RogueConfig";
|
||||
import { cardType, getRandomCardsByType, SuperCards, SuperCardsList, SuperCardsType } from "../common/config/CardSet";
|
||||
import { LuckCardComp } from "./LuckCardComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
@@ -293,17 +295,30 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
|
||||
call_func_card(){
|
||||
this.show_lucky_gold()
|
||||
if(smc.vmdata.mission_data.gold < smc.vmdata.mission_data.lucky_gold){
|
||||
oops.gui.toast("金币不足", false);
|
||||
return
|
||||
}
|
||||
this.do_lucky_card()
|
||||
|
||||
}
|
||||
show_lucky_gold(){
|
||||
do_lucky_card(){
|
||||
smc.vmdata.mission_data.gold-=smc.vmdata.mission_data.lucky_gold
|
||||
let list=getRandomCardsByType(cardType.SPECIAL,1)
|
||||
let card=SuperCards[list[0].uuid]
|
||||
console.log("[MissionComp] do_lucky_card",card)
|
||||
this.show_lucky_gold(card)
|
||||
oops.message.dispatchEvent(GameEvent.LuckCardUsed,card)
|
||||
}
|
||||
show_lucky_gold(card:any){
|
||||
var path = "game/gui/lcard";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.setScale(0,0,0)
|
||||
node.getComponent(LuckCardComp).show_card(card)
|
||||
node.parent = this.node
|
||||
node.setPosition(v3(this.node.getChildByName("luckybox").position.x,this.node.getChildByName("luckybox").position.y));
|
||||
let height=this.node.getComponent(UITransform).height
|
||||
let height=this.node.getComponent(UITransform).height
|
||||
tween(node) .to(0.5, {
|
||||
scale: v3(1,1,1),
|
||||
position: v3(0, height-300),
|
||||
|
||||
Reference in New Issue
Block a user