游戏开始 初始技能功能 继续完善
This commit is contained in:
@@ -8,6 +8,7 @@ import { oops } from "db://oops-framework/core/Oops";
|
||||
import { HeroModelComp } from "../hero/HeroModelComp";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroSkillList, SkillSet } from "../common/config/SkillSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -16,35 +17,58 @@ const { ccclass, property } = _decorator;
|
||||
@ecs.register('Card', false)
|
||||
export class CardComp extends CCComp {
|
||||
c_uuid:number=0;
|
||||
c_type:number=0;
|
||||
c_type:number=0; //0英雄,1 技能.2 装备
|
||||
is_used:boolean=false;
|
||||
|
||||
onLoad(){
|
||||
this.on(GameEvent.HeroSelect,this.onCardRefresh,this)
|
||||
this.on(GameEvent.HeroSkillSelect,this.onCardRefresh,this)
|
||||
this.on(GameEvent.HeroSelect,this.onHeroSelect,this)
|
||||
this.on(GameEvent.HeroSkillSelect,this.onHeroSkillSelect,this)
|
||||
this.on(GameEvent.CardRefresh,this.onCardRefresh,this)
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
init_card(){
|
||||
this.node.getChildByName("Button").active=false
|
||||
this.node.getChildByName("show").active=false
|
||||
}
|
||||
onHeroSelect(event: string, args: any){
|
||||
|
||||
}
|
||||
onHeroSkillSelect(event: string, args: any){
|
||||
|
||||
}
|
||||
onCardRefresh(event: string, args: any){
|
||||
this.c_type=0
|
||||
let hero_list =HeroList
|
||||
let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
|
||||
this.c_uuid=hero_list[x]
|
||||
console.log("onCardRefresh c_uuid:"+this.c_uuid)
|
||||
this.update_card(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')
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
onHeroSkillSelect(event: string, args: any){
|
||||
this.c_type=1
|
||||
console.log("card onHeroSkillSelect")
|
||||
let skill_list =HeroSkillList
|
||||
let x=RandomManager.instance.getRandomInt(0,skill_list.length,1)
|
||||
this.c_uuid=skill_list[x]
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.show_skill(this.c_uuid)
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
onCardRefresh(event: string, args: any){
|
||||
this.c_type=0
|
||||
let hero_list =HeroList
|
||||
let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
|
||||
this.c_uuid=hero_list[x]
|
||||
// console.log("onCardRefresh 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')
|
||||
this.scheduleOnce(() => {
|
||||
@@ -53,15 +77,31 @@ export class CardComp extends CCComp {
|
||||
}, 0.1);
|
||||
|
||||
}
|
||||
update_card(uuid:number){
|
||||
show_skill(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("name").getComponent(Label).string=SkillSet[uuid].name
|
||||
show.getChildByName("ap").active=false
|
||||
show.getChildByName("hp").active=false
|
||||
show.getChildByName("mask").getChildByName("skill").active=true
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("skill").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[uuid].path);
|
||||
});
|
||||
this.node.getChildByName("Button").getChildByName("Label").getComponent(Label).string=this.check_heros()
|
||||
}
|
||||
show_hero(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("ap").active=true
|
||||
show.getChildByName("hp").active=true
|
||||
show.getChildByName("mask").getChildByName("skill").active=false
|
||||
show.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("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()
|
||||
var icon_path = "game/heros/herois"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("icon").getComponent(Sprite);
|
||||
@@ -90,12 +130,16 @@ export class CardComp extends CCComp {
|
||||
}
|
||||
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 1:
|
||||
console.log("use_card 技能卡")
|
||||
oops.message.dispatchEvent(GameEvent.UseSkillCard,{uuid:this.c_uuid})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
case 2:
|
||||
oops.message.dispatchEvent(GameEvent.UseCard,{uuid:this.c_uuid})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ const { ccclass, property } = _decorator;
|
||||
@ecs.register('CardsComp', false)
|
||||
export class CardsCompComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
onLoad() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
this.on(GameEvent.HeroSkillSelect, this.show, this);
|
||||
this.on(GameEvent.HeroSkillSelectEnd, this.hide, this);
|
||||
@@ -18,14 +18,17 @@ export class CardsCompComp extends CCComp {
|
||||
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);
|
||||
}
|
||||
|
||||
show(){
|
||||
show(e:GameEvent,data:any){
|
||||
this.node.setPosition(v3(0,640,0))
|
||||
console.log("cards show",e,this.node.position)
|
||||
}
|
||||
|
||||
hide(){
|
||||
hide(e:GameEvent,data:any){
|
||||
this.node.setPosition(v3(0,-1000,0))
|
||||
console.log("cards hide",e,this.node.position)
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
29
assets/script/game/map/EquipsComp.ts
Normal file
29
assets/script/game/map/EquipsComp.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { _decorator } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('EquipsCompComp')
|
||||
@ecs.register('EquipsComp', false)
|
||||
export class EquipsCompComp extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
this.on(GameEvent.UseSkillCard, this.get_skill, this);
|
||||
}
|
||||
|
||||
update(dt: number): void {
|
||||
|
||||
}
|
||||
|
||||
get_skill(){
|
||||
console.log("get_skill")
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/map/EquipsComp.ts.meta
Normal file
9
assets/script/game/map/EquipsComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b316181b-0323-4100-8d4d-4b68529d3c19",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -61,10 +61,16 @@ export class MissionComp extends CCComp {
|
||||
this.node.active=true
|
||||
this.data_init()
|
||||
this.hart_hero_load()
|
||||
this.to_hero_skill_select()
|
||||
let loading=this.node.parent.getChildByName("loading")
|
||||
loading.active=true
|
||||
this.scheduleOnce(()=>{
|
||||
this.to_hero_skill_select()
|
||||
loading.active=false
|
||||
},0.5)
|
||||
}
|
||||
|
||||
to_hero_skill_select(){
|
||||
console.log("英雄技能选择")
|
||||
oops.message.dispatchEvent(GameEvent.HeroSkillSelect)
|
||||
}
|
||||
|
||||
@@ -94,6 +100,7 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
data_init(){
|
||||
//局内数据初始化
|
||||
console.log("局内数据初始化")
|
||||
this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time)
|
||||
smc.mission.status=1
|
||||
smc.mission.play = true;
|
||||
|
||||
Reference in New Issue
Block a user