英雄技能的加载 继续
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { _decorator } from "cc";
|
||||
import { _decorator, resources, Sprite, SpriteAtlas ,Node, ProgressBar} 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 { SkillSet } from "../common/config/SkillSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -9,17 +10,235 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('EquipsCompComp')
|
||||
@ecs.register('EquipsComp', false)
|
||||
export class EquipsCompComp extends CCComp {
|
||||
|
||||
weapon:any={
|
||||
uuid:0,
|
||||
name:"weapon",
|
||||
type:"weapon",
|
||||
level:0,
|
||||
quality:0,
|
||||
|
||||
skill_uuid:0,
|
||||
skill_name:"skill1",
|
||||
skill_type:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
armor:any={
|
||||
uuid:0,
|
||||
name:"armor",
|
||||
type:"armor",
|
||||
level:0,
|
||||
quality:0,
|
||||
skill_uuid:0,
|
||||
skill_name:"skill1",
|
||||
skill_type:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
ring:any={
|
||||
uuid:0,
|
||||
name:"ring",
|
||||
type:"ring",
|
||||
level:0,
|
||||
quality:0,
|
||||
skill_uuid:0,
|
||||
skill_name:"skill1",
|
||||
skill_type:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
skill1:any={
|
||||
uuid:0,
|
||||
name:"skill1",
|
||||
type:0, //1 被动 0 主动
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
skill2:any={
|
||||
uuid:0,
|
||||
name:"skill2",
|
||||
type:0,//
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
skill3:any={
|
||||
uuid:0,
|
||||
name:"skill3",
|
||||
type:0,//
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
boxs:Node=null
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
this.on(GameEvent.UseSkillCard, this.get_skill, this);
|
||||
}
|
||||
|
||||
start(){
|
||||
this.boxs=this.node.getChildByName("boxs")
|
||||
this.boxs.getChildByName("skill1").getChildByName("icon").active=false
|
||||
this.boxs.getChildByName("skill2").getChildByName("icon").active=false
|
||||
this.boxs.getChildByName("skill3").getChildByName("icon").active=false
|
||||
this.boxs.getChildByName("weapon").getChildByName("icon").active=false
|
||||
this.boxs.getChildByName("armor").getChildByName("icon").active=false
|
||||
this.boxs.getChildByName("ring").getChildByName("icon").active=false
|
||||
}
|
||||
update(dt: number): void {
|
||||
if(this.skill1.uuid!=0){
|
||||
if(this.skill1.cd_time>0){
|
||||
this.skill1.cd_time-=dt
|
||||
}else{
|
||||
this.skill1.cd_time=0
|
||||
if(this.skill1.type==1){
|
||||
this.do_skill1()
|
||||
}
|
||||
}
|
||||
this.boxs.getChildByName("skill1").getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=this.skill1.cd_time/this.skill1.cd
|
||||
}
|
||||
if(this.skill2.uuid!=0){
|
||||
if(this.skill2.cd_time>0){
|
||||
this.skill2.cd_time-=dt
|
||||
}else{
|
||||
this.skill2.cd_time=0
|
||||
if(this.skill2.type==1){
|
||||
this.do_skill2()
|
||||
}
|
||||
}
|
||||
this.boxs.getChildByName("skill2").getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=this.skill2.cd_time/this.skill2.cd
|
||||
}
|
||||
if(this.skill3.uuid!=0){
|
||||
if(this.skill3.cd_time>0){
|
||||
this.skill3.cd_time-=dt
|
||||
}else{
|
||||
this.skill3.cd_time=0
|
||||
if(this.skill3.type==1){
|
||||
this.do_skill3()
|
||||
}
|
||||
}
|
||||
this.boxs.getChildByName("skill3").getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=this.skill3.cd_time/this.skill3.cd
|
||||
}
|
||||
if(this.weapon.skill_uuid!=0){
|
||||
if(this.weapon.cd_time>0){
|
||||
this.weapon.cd_time-=dt
|
||||
}else{
|
||||
this.weapon.cd_time=0
|
||||
if(this.weapon.skill_type==1){
|
||||
this.do_weapon()
|
||||
}
|
||||
}
|
||||
this.boxs.getChildByName("weapon").getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=this.weapon.cd_time/this.weapon.cd
|
||||
}
|
||||
if(this.armor.skill_uuid!=0){
|
||||
if(this.armor.cd_time>0){
|
||||
this.armor.cd_time-=dt
|
||||
}else{
|
||||
this.armor.cd_time=0
|
||||
if(this.armor.skill_type==1){
|
||||
this.do_armor()
|
||||
}
|
||||
}
|
||||
this.boxs.getChildByName("armor").getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=this.armor.cd_time/this.armor.cd
|
||||
}
|
||||
if(this.ring.skill_uuid!=0){
|
||||
if(this.ring.cd_time>0){
|
||||
this.ring.cd_time-=dt
|
||||
}else{
|
||||
this.ring.cd_time=0
|
||||
if(this.ring.skill_type==1){
|
||||
this.do_ring()
|
||||
}
|
||||
}
|
||||
this.boxs.getChildByName("ring").getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=this.ring.cd_time/this.ring.cd
|
||||
}
|
||||
}
|
||||
do_weapon(){
|
||||
console.log("do_weapon")
|
||||
this.weapon.cd_time=this.weapon.cd
|
||||
this.do_skill(this.weapon.skill_uuid)
|
||||
}
|
||||
do_armor(){
|
||||
console.log("do_armor")
|
||||
this.armor.cd_time=this.armor.cd
|
||||
this.do_skill(this.armor.skill_uuid)
|
||||
}
|
||||
do_ring(){
|
||||
console.log("do_ring")
|
||||
this.ring.cd_time=this.ring.cd
|
||||
this.do_skill(this.ring.skill_uuid)
|
||||
}
|
||||
do_skill1(){
|
||||
console.log("do_skill1")
|
||||
this.skill1.cd_time=this.skill1.cd
|
||||
this.do_skill(this.skill1.uuid)
|
||||
}
|
||||
do_skill2(){
|
||||
console.log("do_skill2")
|
||||
this.skill2.cd_time=this.skill2.cd
|
||||
this.do_skill(this.skill2.uuid)
|
||||
}
|
||||
do_skill3(){
|
||||
console.log("do_skill3")
|
||||
this.skill3.cd_time=this.skill3.cd
|
||||
this.do_skill(this.skill3.uuid)
|
||||
}
|
||||
do_skill(uuid:number){
|
||||
console.log("出发技能:",uuid)
|
||||
|
||||
}
|
||||
|
||||
get_skill(){
|
||||
get_skill(e:GameEvent,data:any){
|
||||
console.log("get_skill")
|
||||
if(this.skill1.uuid==0){
|
||||
this.skill1.uuid=data.uuid
|
||||
this.skill1.skill_name=SkillSet[data.uuid].name
|
||||
this.skill1.type=1
|
||||
this.skill1.cd=SkillSet[data.uuid].cd
|
||||
this.skill1.cd_time=SkillSet[data.uuid].cd
|
||||
let icon = this.node.getChildByName("boxs").getChildByName("skill1").getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = icon.getChildByName("skill").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path);
|
||||
});
|
||||
return
|
||||
}
|
||||
if(this.skill2.uuid==0){
|
||||
this.skill2.uuid=data.uuid
|
||||
this.skill2.skill_name=SkillSet[data.uuid].name
|
||||
this.skill2.type=1
|
||||
this.skill2.cd=SkillSet[data.uuid].cd
|
||||
this.skill2.cd_time=SkillSet[data.uuid].cd
|
||||
let icon = this.node.getChildByName("boxs").getChildByName("skill2").getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = icon.getChildByName("skill").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path);
|
||||
});
|
||||
return
|
||||
}
|
||||
if(this.skill3.uuid==0){
|
||||
this.skill3.uuid=data.uuid
|
||||
this.skill3.skill_name=SkillSet[data.uuid].name
|
||||
this.skill3.type=1
|
||||
this.skill3.cd=SkillSet[data.uuid].cd
|
||||
this.skill3.cd_time=SkillSet[data.uuid].cd
|
||||
let icon = this.node.getChildByName("boxs").getChildByName("skill3").getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = icon.getChildByName("skill").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path);
|
||||
});
|
||||
return
|
||||
}
|
||||
console.log("技能栏满了")
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
Reference in New Issue
Block a user