修改了挺多, 继续完善 战斗流程设计
This commit is contained in:
@@ -4,6 +4,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { CardComp } from "./CardComp";
|
||||
import { cardType, getRandomCardsByType } from "../common/config/CardSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -20,16 +21,22 @@ export class CardsCompComp extends CCComp {
|
||||
card3c:CardComp=null
|
||||
card4c:CardComp=null
|
||||
|
||||
/** 卡牌展示队列 */
|
||||
private cardQueue: Array<{type: GameEvent, data?: any}> = [];
|
||||
/** 是否正在展示卡牌 */
|
||||
private isShowing: boolean = false;
|
||||
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
this.on(GameEvent.HeroSkillSelect, this.onHeroSkillSelect, this);
|
||||
this.on(GameEvent.HeroSkillSelectEnd, this.hide, this);
|
||||
this.on(GameEvent.HeroSelect, this.onHeroSelect, this);
|
||||
this.on(GameEvent.HeroSelectEnd, this.hide, this);
|
||||
this.on(GameEvent.CardRefresh, this.show, this);
|
||||
this.on(GameEvent.CardRefreshEnd, this.hide, this);
|
||||
this.on(GameEvent.CardsClose, this.hide, this);
|
||||
this.on(GameEvent.HeroSkillSelect, this.addToQueue, this);
|
||||
this.on(GameEvent.HeroSelect, this.addToQueue, this);
|
||||
this.on(GameEvent.CardRefresh, this.addToQueue, this);
|
||||
|
||||
this.on(GameEvent.HeroSkillSelectEnd, this.close_cards, this);
|
||||
this.on(GameEvent.HeroSelectEnd, this.close_cards, this);
|
||||
this.on(GameEvent.CardRefreshEnd, this.close_cards, this);
|
||||
this.on(GameEvent.CardsClose, this.close_cards, this);
|
||||
|
||||
this.card1=this.node.getChildByName("card1")
|
||||
this.card2=this.node.getChildByName("card2")
|
||||
@@ -42,29 +49,99 @@ export class CardsCompComp extends CCComp {
|
||||
|
||||
|
||||
}
|
||||
onHeroSelect(event: string, args: any){
|
||||
this.show(GameEvent.HeroSelect,args)
|
||||
hero_select(){
|
||||
let list=getRandomCardsByType(cardType.HERO,4)
|
||||
console.log("cards onHeroSelect",list)
|
||||
this.card1c.hero_select(GameEvent.HeroSelect,list[0])
|
||||
this.card2c.hero_select(GameEvent.HeroSelect,list[1])
|
||||
this.card3c.hero_select(GameEvent.HeroSelect,list[2])
|
||||
this.card4c.hero_select(GameEvent.HeroSelect,list[3])
|
||||
console.log("英雄选择卡牌列表",list)
|
||||
this.card1c.hero_select(list[0])
|
||||
this.card2c.hero_select(list[1])
|
||||
this.card3c.hero_select(list[2])
|
||||
this.card4c.hero_select(list[3])
|
||||
}
|
||||
|
||||
onHeroSkillSelect(event: string, args: any){
|
||||
hero_skill_select(){
|
||||
|
||||
this.show(GameEvent.HeroSkillSelect,args)
|
||||
let list=getRandomCardsByType(cardType.SKILL,4)
|
||||
console.log("cards onHeroSkillSelect",list)
|
||||
this.card1c.hero_skill_select(GameEvent.HeroSkillSelect,list[0])
|
||||
this.card2c.hero_skill_select(GameEvent.HeroSkillSelect,list[1])
|
||||
this.card3c.hero_skill_select(GameEvent.HeroSkillSelect,list[2])
|
||||
this.card4c.hero_skill_select(GameEvent.HeroSkillSelect,list[3])
|
||||
console.log("技能选择卡牌列表",list)
|
||||
this.card1c.hero_skill_select(list[0])
|
||||
this.card2c.hero_skill_select(list[1])
|
||||
this.card3c.hero_skill_select(list[2])
|
||||
this.card4c.hero_skill_select(list[3])
|
||||
}
|
||||
equip_select(){
|
||||
let list=getRandomCardsByType(cardType.EQUIP,4)
|
||||
console.log("装备选择卡牌列表",list)
|
||||
this.card1c.equip_select(list[0])
|
||||
this.card2c.equip_select(list[1])
|
||||
this.card3c.equip_select(list[2])
|
||||
this.card4c.equip_select(list[3])
|
||||
}
|
||||
func_select(){
|
||||
console.log("功能选择卡牌")
|
||||
}
|
||||
random_select(){
|
||||
this.card1c.random_select()
|
||||
this.card2c.random_select()
|
||||
this.card3c.random_select()
|
||||
this.card4c.random_select()
|
||||
}
|
||||
|
||||
/** 添加卡牌展示到队列 */
|
||||
private addToQueue(e: GameEvent, data?: any) {
|
||||
console.log("添加卡牌到队列", e);
|
||||
this.cardQueue.push({type: e, data: data});
|
||||
this.processQueue();
|
||||
}
|
||||
|
||||
show(e:GameEvent,data:any){
|
||||
/** 处理卡牌队列 */
|
||||
private processQueue() {
|
||||
if (this.isShowing || this.cardQueue.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextCard = this.cardQueue.shift();
|
||||
this.isShowing = true;
|
||||
this.show_cards(nextCard.type, nextCard.data);
|
||||
}
|
||||
|
||||
show_cards(e:GameEvent,data:any){
|
||||
this.node.getChildByName("Button").active=false
|
||||
switch(e){
|
||||
case GameEvent.HeroSelect:
|
||||
console.log("显示英雄选择卡牌")
|
||||
this.hero_select()
|
||||
break
|
||||
case GameEvent.HeroSkillSelect:
|
||||
console.log("显示技能选择卡牌")
|
||||
this.hero_skill_select()
|
||||
break
|
||||
case GameEvent.CardRefresh:
|
||||
console.log("显示随机刷新卡牌")
|
||||
this.node.getChildByName("Button").active=true
|
||||
this.random_select()
|
||||
break
|
||||
}
|
||||
this.show()
|
||||
}
|
||||
close_cards(e:GameEvent,data:any){
|
||||
switch(e){
|
||||
case GameEvent.HeroSelect:
|
||||
console.log("关闭英雄选择卡牌")
|
||||
break
|
||||
case GameEvent.HeroSkillSelect:
|
||||
console.log("关闭技能选择卡牌")
|
||||
break
|
||||
case GameEvent.CardRefresh:
|
||||
console.log("关闭随机刷新卡牌")
|
||||
break
|
||||
case GameEvent.CardsClose:
|
||||
console.log("关闭所有卡牌")
|
||||
break
|
||||
}
|
||||
this.hide()
|
||||
}
|
||||
show(){
|
||||
// 设置初始状态
|
||||
smc.mission.pause=true
|
||||
this.node.setPosition(v3(0, 0, 0));
|
||||
this.node.setScale(v3(0, 0, 1));
|
||||
|
||||
@@ -77,7 +154,8 @@ export class CardsCompComp extends CCComp {
|
||||
.start();
|
||||
}
|
||||
|
||||
hide(e:GameEvent,data:any){
|
||||
hide(){
|
||||
smc.mission.pause=false
|
||||
tween(this.node)
|
||||
.parallel(
|
||||
tween().to(0.3, { scale: v3(0, 0, 1) }, { easing: 'backIn' }),
|
||||
@@ -85,12 +163,23 @@ export class CardsCompComp extends CCComp {
|
||||
)
|
||||
.call(()=>{
|
||||
this.node.setPosition(v3(0, -1000, 0));
|
||||
this.isShowing = false;
|
||||
this.processQueue(); // 处理队列中的下一个卡牌
|
||||
})
|
||||
.start();
|
||||
}
|
||||
|
||||
//放弃选择
|
||||
give_up_select(){
|
||||
this.hide()
|
||||
let mission_data=smc.vmdata.mission_data
|
||||
mission_data.gold+=(mission_data.back_gold+mission_data.buff_back_gold) //返还金币
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.cardQueue = [];
|
||||
this.isShowing = false;
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user