游戏 模式再次改变
This commit is contained in:
76
assets/script/game/map/HeroUiComp.ts
Normal file
76
assets/script/game/map/HeroUiComp.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { _decorator, resources, Sprite, SpriteAtlas ,Node, ProgressBar, tween, v3, Label, Animation, CCString, CCInteger} 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";
|
||||
import { CdType, SkillSet } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { MissionEvent } from "../common/config/MissionEvent";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('HeroUiComp')
|
||||
@ecs.register('HeroUi', false)
|
||||
export class HeroUiComp extends CCComp {
|
||||
@property(CCString)
|
||||
hero_slot:string="skill1"
|
||||
@property(CCInteger)
|
||||
hero_slot_index:number=1
|
||||
heroUi:any=null
|
||||
skill_cd_bar_progress:any=null
|
||||
max_show:boolean=false
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
this.on(GameEvent.UseHeroCard,this.get_hero,this)
|
||||
// this.node.getChildByName("icon").getChildByName("cd").active=false
|
||||
}
|
||||
start(){
|
||||
this.fight_ready()
|
||||
}
|
||||
|
||||
fight_ready(){
|
||||
console.log("[HeroUiComp]: fight_ready",this.node)
|
||||
this.heroUi={
|
||||
uuid:0,
|
||||
name:"hero",
|
||||
type:0, //1 被动 0 主动
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
active:false,
|
||||
}
|
||||
|
||||
}
|
||||
update(dt: number): void {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
get_hero(e:GameEvent,data:any){
|
||||
console.log("[HeroUiComp]: get_hero",data)
|
||||
let hero=HeroInfo[data.uuid]
|
||||
let icon=this.node.getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/heros/herois"
|
||||
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = icon.getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(hero.path);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/map/HeroUiComp.ts.meta
Normal file
9
assets/script/game/map/HeroUiComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "2b9bf809-2ad7-4169-be07-ad256ab89cb2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
143
assets/script/game/map/MSkillComp.ts
Normal file
143
assets/script/game/map/MSkillComp.ts
Normal file
@@ -0,0 +1,143 @@
|
||||
import { _decorator, resources, Sprite, SpriteAtlas ,Node, ProgressBar, tween, v3, Label, Animation, CCString, CCInteger} 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";
|
||||
import { CdType, SkillSet } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { MissionEvent } from "../common/config/MissionEvent";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('MSkillComp')
|
||||
@ecs.register('MSkill', false)
|
||||
export class MSkillComp extends CCComp {
|
||||
@property(CCString)
|
||||
skill_slot:string="skill1"
|
||||
@property(CCInteger)
|
||||
skill_slot_index:number=1
|
||||
skill:any=null
|
||||
skill_cd_bar_progress:any=null
|
||||
max_show:boolean=false
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
this.on(GameEvent.UseSkillCard, this.get_skill, this);
|
||||
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
this.on(GameEvent.MasterCalled,this.master_called,this)
|
||||
// this.node.getChildByName("icon").getChildByName("cd").active=false
|
||||
}
|
||||
start(){
|
||||
this.fight_ready()
|
||||
}
|
||||
private master_called(e:any,data:any){
|
||||
console.log("[EquipSkillComp]: master_called",data)
|
||||
let hero=HeroInfo[data.uuid]
|
||||
if(hero.skills.length>0){
|
||||
this.get_skill(null,{slot:this.skill_slot,uuid:hero.skills[this.skill_slot_index]})
|
||||
}
|
||||
}
|
||||
|
||||
fight_ready(){
|
||||
console.log("[MSkillComp]: fight_ready",this.node)
|
||||
this.node.getChildByName("icon").active=false
|
||||
this.hide_skill_get(null,"skill1")
|
||||
this.skill={
|
||||
uuid:0,
|
||||
name:"skill1",
|
||||
type:0, //1 被动 0 主动
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
active:false,
|
||||
}
|
||||
|
||||
}
|
||||
update(dt: number): void {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
if(this.skill.uuid!=0){
|
||||
let cd=this.skill.cd/((smc.vmdata.hero.skill_cd_buff)/100+1)
|
||||
if(this.skill.cd_time < cd){
|
||||
this.skill.cd_time+=dt
|
||||
}else{
|
||||
if(this.skill.type==1){
|
||||
this.spell_skill()
|
||||
}
|
||||
}
|
||||
let progress=(1-this.skill.cd_time/cd)
|
||||
this.node.getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=progress
|
||||
}
|
||||
|
||||
}
|
||||
show_max(){
|
||||
this.node.getChildByName("light").active=true
|
||||
this.node.getComponent(Animation).play()
|
||||
}
|
||||
hide_max(){
|
||||
this.max_show=false
|
||||
this.node.getChildByName("light").active=false
|
||||
this.node.setScale(1,1,1)
|
||||
this.node.getComponent(Animation).stop()
|
||||
}
|
||||
spell_skill(){
|
||||
console.log("spell_skill")
|
||||
this.skill.cd_time=0
|
||||
tween(this.node).to(0.1, {scale:v3(1.2,1.2,1)},{onComplete:()=>{
|
||||
tween(this.node).to(0.2, {scale:v3(1,1,1)}).start()
|
||||
}}).start()
|
||||
this.do_skill(this.skill.uuid)
|
||||
this.hide_max()
|
||||
}
|
||||
|
||||
do_skill(uuid:number){
|
||||
oops.message.dispatchEvent(GameEvent.CastHeroSkill,uuid)
|
||||
}
|
||||
|
||||
get_skill(e:GameEvent,data:any){
|
||||
console.log("[MSkillComp]: get_skill",data)
|
||||
if(data.slot==this.skill_slot||this.skill_slot_index==data.slot){
|
||||
this.skill.uuid=data.uuid
|
||||
this.skill.skill_name=SkillSet[data.uuid].name
|
||||
this.skill.type=1
|
||||
this.skill.cd=SkillSet[data.uuid].cd
|
||||
this.skill.cd_time=SkillSet[data.uuid].cd
|
||||
let icon1 = this.node.getChildByName("icon")
|
||||
icon1.active=true
|
||||
// if(SkillSet[data.uuid].CdType!=CdType.cd){
|
||||
// icon1.getChildByName("cd").active=false
|
||||
// }
|
||||
var icon_path = "game/heros/cards"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = icon1.getChildByName("skill").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
call_skill_card(e:any,data:any){
|
||||
oops.message.dispatchEvent(GameEvent.HeroSkillSelect,{slot:data})
|
||||
}
|
||||
|
||||
|
||||
show_info(e:any,data:any){
|
||||
console.log("[MSkillComp]: show_info",this.skill)
|
||||
|
||||
}
|
||||
|
||||
private hide_skill_get(e:any,data:string){
|
||||
this.node.getChildByName("get").active =false
|
||||
this.node.getChildByName("tip").active =false
|
||||
this.node.getChildByName("light").active=false
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
1
assets/script/game/map/MSkillComp.ts.meta
Normal file
1
assets/script/game/map/MSkillComp.ts.meta
Normal file
@@ -0,0 +1 @@
|
||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"e0acc008-a00f-4682-ba4f-c47506bddf26","files":[],"subMetas":{},"userData":{}}
|
||||
@@ -191,7 +191,7 @@ export class MissionComp extends CCComp {
|
||||
loading.active=true
|
||||
this.scheduleOnce(()=>{
|
||||
loading.active=false
|
||||
},0.5)
|
||||
},1)
|
||||
this.to_ready()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user