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