dd
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { _decorator, Label, ProgressBar, resources, Sprite, SpriteAtlas } from "cc";
|
||||
import { _decorator, Label, ProgressBar, resources, Sprite, SpriteAtlas, v3, Vec3 } 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 { SkillSet } from "../common/config/SkillSet";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { Skill } from "../skills/Skill";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -11,53 +12,35 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('MSkillComp')
|
||||
@ecs.register('MSkillComp', false)
|
||||
export class MSkillComp extends CCComp {
|
||||
s_uuid: number = 0;
|
||||
group: number = 0;
|
||||
lv:number = 0;
|
||||
skill_on:boolean = false;
|
||||
cd:number = 0;
|
||||
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
}
|
||||
init(){
|
||||
this.lv=0
|
||||
console.log("MSkillComp init s_uuid:",this.s_uuid,this.group);
|
||||
this.node.getChildByName("lv").getComponent(Label).string=this.lv.toString()
|
||||
if(SkillSet[this.s_uuid]==undefined){this.skill_on=false; return}
|
||||
this.cd=SkillSet[this.s_uuid].cd;
|
||||
this.s_uuid=smc.mission.mskill
|
||||
|
||||
if(this.group == BoxSet.MONSTER){
|
||||
this.s_uuid=smc.mission.mmskill
|
||||
}
|
||||
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = this.node.getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[this.s_uuid].path);
|
||||
});
|
||||
this.skill_on=true
|
||||
|
||||
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if(!this.skill_on) return
|
||||
this.doing_cd(dt)
|
||||
}
|
||||
doing_cd(dt: number){
|
||||
this.cd-=dt
|
||||
this.node.getChildByName("cd").getComponent(ProgressBar).progress=this.cd/SkillSet[this.s_uuid].cd
|
||||
if(this.cd<=0){
|
||||
console.log("cd<=0")
|
||||
this.cd=SkillSet[this.s_uuid].cd
|
||||
if(!smc.mission.play||smc.mission.pause){
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
lvup(){
|
||||
this.lv++
|
||||
this.node.getChildByName("lv").getComponent(Label).string=this.lv.toString()
|
||||
private doSkill(config: typeof SkillSet[keyof typeof SkillSet]) {
|
||||
const skillEntity = ecs.getEntity<Skill>(Skill);
|
||||
const start_pos=v3(0,0)
|
||||
const target_pos=v3(0,0)
|
||||
skillEntity.load(
|
||||
start_pos, // 起始位置
|
||||
BoxSet.HERO, // 阵营
|
||||
this.node.parent, // 父节点
|
||||
config.uuid, // 技能ID
|
||||
target_pos, // 目标位置
|
||||
);
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,54 +38,26 @@ export class MissionComp extends CCComp {
|
||||
herosc_node:any=null
|
||||
hero_args:any=null
|
||||
onLoad(){
|
||||
// this.on(GameEvent.UserHeroCard,this.show_herosc,this)
|
||||
// this.MSComp=this.node.getChildByName("msk").getComponent(MSkillComp)
|
||||
// this.MMSComp=this.node.getChildByName("mmsk").getComponent(MSkillComp)
|
||||
// this.MSComp.group=BoxSet.HERO
|
||||
// this.MSComp.s_uuid=smc.mission.mskill
|
||||
// this.MMSComp.group=BoxSet.MONSTER
|
||||
// this.MMSComp.s_uuid=smc.mission.mmskill
|
||||
}
|
||||
start() {
|
||||
// this.heros_node=this.node.getChildByName("heros")
|
||||
// this.herosc_node=this.node.getChildByName("herosc")
|
||||
// this.herosc_node.active=false
|
||||
// this.node.getChildByName('hbg').active=false
|
||||
// this.heros_node_pos=v3(this.heros_node.position.x,this.heros_node.position.y,this.heros_node.position.z)
|
||||
// this.VictoryComp=this.node.getChildByName("victory").getComponent(VictoryComp)
|
||||
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
if(!smc.mission.play||smc.mission.pause){
|
||||
return
|
||||
}
|
||||
|
||||
// if (this.game_timer.update(dt)) {
|
||||
// smc.vmdata.game.g_time += 1;
|
||||
// }
|
||||
}
|
||||
show_herosc(event: string, args: any){
|
||||
// this.node.getChildByName('hbg').active=true
|
||||
const screenSize = this.node.getComponent(UITransform).contentSize;
|
||||
const centerY = screenSize.height / 2;
|
||||
// tween(this.heros_node).to(0.1,{position:v3(this.heros_node.position.x,centerY,0)}, // 这里以node的位置信息坐标缓动的目标
|
||||
// { // ITweenOption 的接口实现:
|
||||
// onComplete:()=>{
|
||||
|
||||
// this.herosc_node.active=true
|
||||
// this.heros_node.active=false
|
||||
// this.hero_args=args
|
||||
// }
|
||||
// }).start()
|
||||
}
|
||||
|
||||
call_hero(event: string, args: any){
|
||||
console.log("call_hero",args)
|
||||
oops.message.dispatchEvent(GameEvent.CallHero,{uuid:this.hero_args.uuid,pos:args})
|
||||
// this.herosc_node.active=false
|
||||
// this.heros_node.active=true
|
||||
// this.heros_node.position=this.heros_node_pos
|
||||
this.hero_args=null
|
||||
// this.node.getChildByName('hbg').active=false
|
||||
}
|
||||
mission_start(){
|
||||
/* todo 关卡设定完善*/
|
||||
@@ -93,7 +65,6 @@ export class MissionComp extends CCComp {
|
||||
smc.mission.status=1
|
||||
this.colose_victory()
|
||||
this.mission_init()
|
||||
// this.mskill_init()
|
||||
}
|
||||
|
||||
mission_end(){
|
||||
@@ -121,6 +92,7 @@ export class MissionComp extends CCComp {
|
||||
let home =this.node.parent.getComponent(CardControllerComp);
|
||||
home.mission_to_mission_home()
|
||||
}
|
||||
|
||||
mission_init(){
|
||||
//局内数据初始化
|
||||
this.fight_start=false
|
||||
@@ -129,20 +101,7 @@ export class MissionComp extends CCComp {
|
||||
|
||||
}
|
||||
|
||||
mskill_init(){
|
||||
this.MSComp.group=BoxSet.HERO
|
||||
this.MMSComp.group=BoxSet.MONSTER
|
||||
this.MSComp.init()
|
||||
this.MMSComp.init()
|
||||
}
|
||||
|
||||
get_mons(){
|
||||
return ecs.query(ecs.allOf(MonModelComp));
|
||||
}
|
||||
get_heros(){
|
||||
return ecs.query(ecs.allOf(HeroModelComp))
|
||||
}
|
||||
|
||||
|
||||
card_refresh(){
|
||||
oops.message.dispatchEvent(GameEvent.CardRefresh)
|
||||
}
|
||||
|
||||
@@ -90,6 +90,6 @@ export class MissionHeroCompComp extends CCComp {
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
// this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,6 @@ export class MissionMonCompComp extends CCComp {
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
// this.node.destroy();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user