卡片召唤英雄
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -16,4 +16,8 @@ export enum GameEvent {
|
||||
MissionEnd = "MissionEnd",
|
||||
CastSkill = "CastSkill",
|
||||
CardRefresh = "CardRefresh",
|
||||
UseCard = "UseCard",
|
||||
UserHeroCard = "UserHeroCard",
|
||||
UserSkillCard = "UserSkillCard",
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroInfo, HeroList } from "../common/config/heroSet";
|
||||
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -13,14 +14,20 @@ const { ccclass, property } = _decorator;
|
||||
export class CardComp extends CCComp {
|
||||
c_uuid:number=0;
|
||||
c_type:number=0;
|
||||
is_used:boolean=false;
|
||||
onLoad(){
|
||||
this.on(GameEvent.CardRefresh,this.onCardRefresh,this)
|
||||
}
|
||||
start() {
|
||||
|
||||
this.init_card()
|
||||
}
|
||||
init_card(){
|
||||
this.is_used=true
|
||||
this.node.getChildByName("Button").active=false
|
||||
this.node.getChildByName("show").active=false
|
||||
}
|
||||
onCardRefresh(event: string, args: any){
|
||||
|
||||
this.is_used=false
|
||||
let hero_list =HeroList
|
||||
let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
|
||||
this.c_uuid=hero_list[x]
|
||||
@@ -30,6 +37,7 @@ export class CardComp extends CCComp {
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
|
||||
}
|
||||
@@ -45,6 +53,23 @@ export class CardComp extends CCComp {
|
||||
});
|
||||
|
||||
}
|
||||
use_card(){
|
||||
if(this.is_used) return
|
||||
switch(this.c_type){
|
||||
case 0:
|
||||
oops.message.dispatchEvent(GameEvent.UserHeroCard,{uuid:this.c_uuid})
|
||||
break
|
||||
case 1:
|
||||
oops.message.dispatchEvent(GameEvent.UserSkillCard,{uuid:this.c_uuid})
|
||||
break
|
||||
case 2:
|
||||
oops.message.dispatchEvent(GameEvent.UseCard,{uuid:this.c_uuid})
|
||||
break
|
||||
}
|
||||
this.node.getChildByName("show").active=false
|
||||
this.is_used=true
|
||||
this.node.getChildByName("Button").active=false
|
||||
}
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Hero } from "../hero/Hero";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -15,21 +16,21 @@ const { ccclass, property } = _decorator;
|
||||
@ecs.register('MissionHeroComp', false)
|
||||
export class MissionHeroCompComp extends CCComp {
|
||||
timer:Timer=new Timer(2)
|
||||
|
||||
onLoad(){
|
||||
this.on(GameEvent.UserHeroCard,this.call_hero,this)
|
||||
}
|
||||
start() {
|
||||
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if(smc.mission.status != 1) return
|
||||
if(this.timer.update(dt)){
|
||||
this.call_hero()
|
||||
}
|
||||
|
||||
}
|
||||
call_hero(){
|
||||
call_hero(event: string, args: any){
|
||||
this.timer.reset()
|
||||
let hero_list =HeroList
|
||||
let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
|
||||
let uuid=hero_list[x]
|
||||
let uuid=args.uuid
|
||||
console.log("call_hero",uuid)
|
||||
this.addHero(uuid)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user