import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,resources,Sprite,SpriteAtlas,tween,UITransform,v3, Vec3,Animation, UI } 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 { smc } from "../common/SingletonModuleComp"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager"; import { MSkillset, MSlist, SkillSet } from "../common/config/SkillSet"; import { HeroModelComp } from "../hero/HeroModelComp"; import { RewardSet } from "../common/config/RewardSet"; import { BoxSet, GameSet } from "../common/config/BoxSet"; import { GameMap } from "./GameMap"; import { MapModelComp } from "./model/MapModelComp"; import { Talent } from "../Role/Talent"; import { Talents } from "../common/config/TalentSet"; import { HeroViewComp } from "../hero/HeroViewComp"; import { BossViewComp } from "../Boss/BossViewComp"; import { Hero } from "../hero/Hero"; import { HeroInfo, HeroSet } from "../common/config/heroSet"; import { Boss } from "../Boss/Boss"; import { MonModelComp } from "../hero/MonModelComp"; import { BossList, MBSet, MissionNum, MissionSet, MonsetList } from "../common/config/MissionSet"; import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; import { HCard } from "./HCard"; import { HCardComp } from "./HCardComp"; import { VictoryComp } from "./VictoryComp"; import { ItemComp } from "./ItemComp"; import { MSkillComp } from "./MSkillComp"; import { Monster } from "../hero/Mon"; import { UIID } from "../common/config/GameUIConfig"; import { CardControllerComp } from "./CardController"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('MissionComp') @ecs.register('Mission', false) export class MissionComp extends CCComp { VictoryComp:any = null; mon_list:any = [] call_hero_timer: Timer = new Timer(0.3); target_timer: Timer = new Timer(0.1); reward:number = 0; reward_num:number = 0; game_over:boolean = false; fight_start:boolean = false; mission_buff_type:number = 1 // 1 攻击 2 防御 3 HP m_mission_buff_type:number = 1 // 1 攻击 2 防御 3 HP mission_buff_up_exp:number = 99999999 MSComp:MSkillComp=null MMSComp:MSkillComp=null onLoad(){ 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.VictoryComp=this.node.getChildByName("victory").getComponent(VictoryComp) console.log("mission_start:",this.MSComp) } protected update(dt: number): void { if(!smc.mission.play||smc.mission.pause){ return } if(this.fight_start){ this.check_mon_num() } this.count_hero_pos() this.count_mon_pos() this.check_buff() // if (this.game_timer.update(dt)) { // smc.vmdata.game.g_time += 1; // } // this.shuaxin(dt) } mission_start(){ /* todo 关卡设定完善*/ let mon_set=RandomManager.instance.getRandomByObjectList(MissionSet,1) this.mon_list=mon_set[0] console.log("mission_start:",this.mon_list,this.MSComp,this.MMSComp) this.mission_init() this.mskill_init() this.mon_refresh() this.heros_call() } mission_end(){ smc.mission.play=false smc.mission.pause=false let heros:any= this.get_heros();; let monsters:any= this.get_mons(); let hcards:any= ecs.query(ecs.allOf(HCardComp)); let rewards:any= ecs.query(ecs.allOf(ItemComp)); // let hcns=this.node.getChildByName("hcards") // for(let i=0;i(HCard) // console.log("hcard:",hcard) hcard.load(heros[i].HeroView.hero_uuid,i,node) } this.fight_start= true } /** 添加玩家 */ private addHero(uuid:number=1001,i:number=0) { let hero = ecs.getEntity(Hero); let scale = 1 let pos:Vec3 = v3(HeroSet.StartPos[HeroInfo[uuid].type]-i*15,BoxSet.GAME_LINE); // console.log("addHero:",pos) hero.load(pos,scale,uuid); } private addMonster(uuid:number=1001,i:number=0) { let mon = ecs.getEntity(Monster); let scale = -1 let pos:Vec3 = v3(-1*HeroSet.StartPos[HeroInfo[uuid].type]+i*15,BoxSet.GAME_LINE); console.log("addMonster:",pos) mon.load(pos,scale,uuid,false); } /** 视图层逻辑代码分离演示 */ /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ reset() { this.node.destroy(); } }