Files
heros/assets/script/game/map/CardController.ts
2024-12-12 16:57:16 +08:00

133 lines
4.5 KiB
TypeScript

import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,resources,Sprite,SpriteAtlas,tween,UITransform,v3 } 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 { SkillSet } from "../common/config/SkillSet";
import { HeroModelComp } from "../hero/HeroModelComp";
import { RewardSet } from "../common/config/RewardSet";
import { 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 { Position } from "../../../../extensions/oops-plugin-framework/assets/libs/gui/badge/Badge";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('CardControllerComp')
@ecs.register('CardController', false)
export class CardControllerComp extends CCComp {
touch_time:number = 0
in_touch:boolean = false
bbg:any=null
bbg_y:number=45
bbg_x:any=[-300,-150,0,150,300]
protected onLoad(): void {
this.bbg=this.node.getChildByName("bar").getChildByName("bbg")
}
start() {
this.hero_home_hide()
this.mission_hide()
this.bbg=this.node.getChildByName("bar").getChildByName("bbg")
this.bbg.setPosition(v3(this.bbg_x[2],this.bbg_y))
}
show_info(uuid:number,type:number){
console.log("show_info",uuid)
}
protected update(dt: number): void {
if(smc.vmdata.game_over||smc.vmdata.game_pause){
return
}
}
bar_change(e:any,args:any){
switch(args){
case "hero":
break;
}
}
hero_home_show(){
let node=this.node.getChildByName("hero_home")
node.active = true
tween(node).to( 0.1,{ position: v3(0,node.position.y)}, ).start();
}
hero_home_hide(){
let node=this.node.getChildByName("hero_home")
node.active = false
// tween(node).to( 0.1,{ position: v3(2000,node.position.y)}, ).start();
}
mission_home_show(){
this.node.getChildByName("mission_home").active=true;
}
mission_home_hide(){
this.node.getChildByName("mission_home").active=false;
}
mission_show(){
this.node.getChildByName("mission").active = true;
}
mission_hide(){
this.node.getChildByName("mission").active = false;
}
mission_start(){
this.node.getChildByName("bar").active=false;
this.mission_home_hide()
this.mission_show();
smc.mission.play = true;
// oops.message.dispatchEvent("mission_start")
}
to_mission(){
this.hero_home_hide()
this.mission_home_show()
this.mission_hide()
this.node.getChildByName("bar").active=true;
// tween(this.bbg).to(0.1,{Position:v3(this.bbg_x[2],this.bbg_y)}).start()
this.bbg.setPosition(this.bbg_x[2],this.bbg_y)
}
to_shop(){
this.mission_home_hide()
this.hero_home_hide()
this.mission_hide()
// tween(this.bbg).to(0.1,{Position:v3(this.bbg_x[0],this.bbg_y)}).start()
this.bbg.setPosition(this.bbg_x[0],this.bbg_y)
}
to_hero(){
this.mission_home_hide()
this.hero_home_show()
this.mission_hide()
// tween(this.bbg).to(0.1,{Position:v3(this.bbg_x[1],this.bbg_y)}).start()
this.bbg.setPosition(this.bbg_x[1],this.bbg_y)
}
to_skills(){
this.mission_home_hide()
this.hero_home_hide()
this.mission_hide()
// tween(this.bbg).to(0.1,{Position:v3(this.bbg_x[3],this.bbg_y)}).start()
this.bbg.setPosition(this.bbg_x[3],this.bbg_y)
}
to_battle(){
this.mission_home_hide()
this.hero_home_hide()
this.mission_hide()
// tween(this.bbg).to(0.1,{Position:v3(this.bbg_x[4],this.bbg_y)}).start()
this.bbg.setPosition(this.bbg_x[4],this.bbg_y)
}
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}