装备添加
This commit is contained in:
@@ -9,6 +9,8 @@ import { HeroModelComp } from "../hero/HeroModelComp";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroSkillList, SkillSet } from "../common/config/SkillSet";
|
||||
import { cardType, getRandomCardUUID } from "../common/config/CardSet";
|
||||
import { EquipInfo } from "../common/config/Equips";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -21,8 +23,8 @@ export class CardComp extends CCComp {
|
||||
is_used:boolean=false;
|
||||
|
||||
onLoad(){
|
||||
this.on(GameEvent.HeroSelect,this.onHeroSelect,this)
|
||||
this.on(GameEvent.HeroSkillSelect,this.onHeroSkillSelect,this)
|
||||
// this.on(GameEvent.HeroSelect,this.hero_select,this)
|
||||
// this.on(GameEvent.HeroSkillSelect,this.hero_skill_select,this)
|
||||
this.on(GameEvent.CardRefresh,this.onCardRefresh,this)
|
||||
}
|
||||
|
||||
@@ -34,11 +36,9 @@ export class CardComp extends CCComp {
|
||||
this.node.getChildByName("Button").active=false
|
||||
this.node.getChildByName("show").active=false
|
||||
}
|
||||
onHeroSelect(event: string, args: any){
|
||||
hero_select(event: string, args: any){
|
||||
this.c_type=0
|
||||
let hero_list =HeroList
|
||||
let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
|
||||
this.c_uuid=hero_list[x]
|
||||
this.c_uuid=args.uuid
|
||||
console.log("onCardRefresh c_uuid:"+this.c_uuid)
|
||||
this.show_hero(this.c_uuid)
|
||||
this.node.getChildByName("show").active=false
|
||||
@@ -48,12 +48,10 @@ export class CardComp extends CCComp {
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
onHeroSkillSelect(event: string, args: any){
|
||||
hero_skill_select(event: string, args: any){
|
||||
this.c_type=1
|
||||
console.log("card onHeroSkillSelect")
|
||||
let skill_list =HeroSkillList
|
||||
let x=RandomManager.instance.getRandomInt(0,skill_list.length,1)
|
||||
this.c_uuid=skill_list[x]
|
||||
console.log("card hero_skill_select",args)
|
||||
this.c_uuid=args.uuid
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.show_skill(this.c_uuid)
|
||||
@@ -62,20 +60,32 @@ export class CardComp extends CCComp {
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
equip_select(event: string, args: any){
|
||||
this.c_type=2
|
||||
this.c_uuid=args.uuid
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.show_equip(this.c_uuid)
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
onCardRefresh(event: string, args: any){
|
||||
this.c_type=0
|
||||
let hero_list =HeroList
|
||||
let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
|
||||
this.c_uuid=hero_list[x]
|
||||
// console.log("onCardRefresh c_uuid:"+this.c_uuid)
|
||||
this.show_hero(this.c_uuid)
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
|
||||
let card =getRandomCardUUID()
|
||||
console.log("onCardRefresh 开始请求卡牌",card)
|
||||
switch(card.type){
|
||||
case cardType.HERO:
|
||||
this.hero_select(GameEvent.HeroSelect,card)
|
||||
break
|
||||
case cardType.SKILL:
|
||||
this.hero_skill_select(GameEvent.HeroSkillSelect,card)
|
||||
break
|
||||
case cardType.EQUIP:
|
||||
this.equip_select(GameEvent.EquipSelect,card)
|
||||
break
|
||||
}
|
||||
}
|
||||
show_skill(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
@@ -83,6 +93,11 @@ export class CardComp extends CCComp {
|
||||
show.getChildByName("ap").active=false
|
||||
show.getChildByName("hp").active=false
|
||||
show.getChildByName("mask").getChildByName("skill").active=true
|
||||
show.getChildByName("mask").getChildByName("s_bg").active=true
|
||||
show.getChildByName("mask").getChildByName("equip").active=false
|
||||
show.getChildByName("mask").getChildByName("e_bg").active=false
|
||||
show.getChildByName("mask").getChildByName("hero").active=false
|
||||
show.getChildByName("mask").getChildByName("h_bg").active=false
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("skill").getComponent(Sprite);
|
||||
@@ -95,6 +110,11 @@ export class CardComp extends CCComp {
|
||||
show.getChildByName("ap").active=true
|
||||
show.getChildByName("hp").active=true
|
||||
show.getChildByName("mask").getChildByName("skill").active=false
|
||||
show.getChildByName("mask").getChildByName("s_bg").active=false
|
||||
show.getChildByName("mask").getChildByName("equip").active=false
|
||||
show.getChildByName("mask").getChildByName("e_bg").active=false
|
||||
show.getChildByName("mask").getChildByName("hero").active=true
|
||||
show.getChildByName("mask").getChildByName("h_bg").active=true
|
||||
show.getChildByName("name").getComponent(Label).string=HeroInfo[uuid].name
|
||||
show.getChildByName("ap").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].ap.toString()
|
||||
show.getChildByName("hp").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].hp.toString()
|
||||
@@ -104,11 +124,29 @@ export class CardComp extends CCComp {
|
||||
// show.getChildByName("lv").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].lv.toString()
|
||||
var icon_path = "game/heros/herois"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("icon").getComponent(Sprite);
|
||||
const sprite = show.getChildByName("mask").getChildByName("hero").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
|
||||
});
|
||||
this.node.getChildByName("Button").getChildByName("Label").getComponent(Label).string=this.check_heros()
|
||||
}
|
||||
show_equip(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("ap").active=false
|
||||
show.getChildByName("hp").active=false
|
||||
show.getChildByName("mask").getChildByName("skill").active=false
|
||||
show.getChildByName("mask").getChildByName("s_bg").active=false
|
||||
show.getChildByName("mask").getChildByName("equip").active=true
|
||||
show.getChildByName("mask").getChildByName("e_bg").active=true
|
||||
show.getChildByName("mask").getChildByName("hero").active=false
|
||||
show.getChildByName("mask").getChildByName("h_bg").active=false
|
||||
show.getChildByName("name").getComponent(Label).string=EquipInfo[uuid].name
|
||||
var icon_path = "game/heros/equips"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("equip").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(EquipInfo[uuid].uuid.toString());
|
||||
});
|
||||
this.node.getChildByName("Button").getChildByName("Label").getComponent(Label).string=this.check_heros()
|
||||
}
|
||||
check_heros(){
|
||||
// let heros=ecs.query(ecs.allOf(HeroModelComp))
|
||||
// for(let hero of heros){
|
||||
@@ -138,7 +176,8 @@ export class CardComp extends CCComp {
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
case 2:
|
||||
oops.message.dispatchEvent(GameEvent.UseCard,{uuid:this.c_uuid})
|
||||
console.log("use_card 装备卡")
|
||||
oops.message.dispatchEvent(GameEvent.EquipAdd,{uuid:this.c_uuid,type:EquipInfo[this.c_uuid].type})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ import { _decorator, 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 { GameEvent } from "../common/config/GameEvent";
|
||||
import { CardComp } from "./CardComp";
|
||||
import { cardType, getRandomCardsByType } from "../common/config/CardSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -9,26 +11,66 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('CardsCompComp')
|
||||
@ecs.register('CardsComp', false)
|
||||
export class CardsCompComp extends CCComp {
|
||||
card1:any=null
|
||||
card2:any=null
|
||||
card3:any=null
|
||||
card4:any=null
|
||||
card1c:CardComp=null
|
||||
card2c:CardComp=null
|
||||
card3c:CardComp=null
|
||||
card4c:CardComp=null
|
||||
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
this.on(GameEvent.HeroSkillSelect, this.show, this);
|
||||
this.on(GameEvent.HeroSkillSelect, this.onHeroSkillSelect, this);
|
||||
this.on(GameEvent.HeroSkillSelectEnd, this.hide, this);
|
||||
this.on(GameEvent.HeroSelect, this.show, this);
|
||||
this.on(GameEvent.HeroSelect, this.onHeroSelect, this);
|
||||
this.on(GameEvent.HeroSelectEnd, this.hide, this);
|
||||
this.on(GameEvent.CardRefresh, this.show, this);
|
||||
this.on(GameEvent.CardRefreshEnd, this.hide, this);
|
||||
this.on(GameEvent.CardsClose, this.hide, this);
|
||||
|
||||
this.card1=this.node.getChildByName("card1")
|
||||
this.card2=this.node.getChildByName("card2")
|
||||
this.card3=this.node.getChildByName("card3")
|
||||
this.card4=this.node.getChildByName("card4")
|
||||
this.card1c=this.card1.getComponent(CardComp)
|
||||
this.card2c=this.card2.getComponent(CardComp)
|
||||
this.card3c=this.card3.getComponent(CardComp)
|
||||
this.card4c=this.card4.getComponent(CardComp)
|
||||
|
||||
|
||||
}
|
||||
onHeroSelect(event: string, args: any){
|
||||
this.show(GameEvent.HeroSelect,args)
|
||||
let list=getRandomCardsByType(cardType.HERO,4)
|
||||
console.log("cards onHeroSelect",list)
|
||||
this.card1c.hero_select(GameEvent.HeroSelect,list[0])
|
||||
this.card2c.hero_select(GameEvent.HeroSelect,list[1])
|
||||
this.card3c.hero_select(GameEvent.HeroSelect,list[2])
|
||||
this.card4c.hero_select(GameEvent.HeroSelect,list[3])
|
||||
}
|
||||
|
||||
onHeroSkillSelect(event: string, args: any){
|
||||
|
||||
this.show(GameEvent.HeroSkillSelect,args)
|
||||
let list=getRandomCardsByType(cardType.SKILL,4)
|
||||
console.log("cards onHeroSkillSelect",list)
|
||||
this.card1c.hero_skill_select(GameEvent.HeroSkillSelect,list[0])
|
||||
this.card2c.hero_skill_select(GameEvent.HeroSkillSelect,list[1])
|
||||
this.card3c.hero_skill_select(GameEvent.HeroSkillSelect,list[2])
|
||||
this.card4c.hero_skill_select(GameEvent.HeroSkillSelect,list[3])
|
||||
}
|
||||
|
||||
show(e:GameEvent,data:any){
|
||||
this.node.setPosition(v3(0,640,0))
|
||||
console.log("cards show",e,this.node.position)
|
||||
// console.log("cards show",e,this.node.position)
|
||||
}
|
||||
|
||||
hide(e:GameEvent,data:any){
|
||||
this.node.setPosition(v3(0,-1000,0))
|
||||
console.log("cards hide",e,this.node.position)
|
||||
// console.log("cards hide",e,this.node.position)
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
174
assets/script/game/map/EquipSkillComp.ts
Normal file
174
assets/script/game/map/EquipSkillComp.ts
Normal file
@@ -0,0 +1,174 @@
|
||||
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";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { MissionEvent } from "../common/config/MissionEvent";
|
||||
import { EquipsComp } from "./EquipsComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('EquipSkillComp')
|
||||
@ecs.register('EquipSkill', false)
|
||||
export class EquipSkillComp extends CCComp {
|
||||
skill1:any=null
|
||||
skill2:any=null
|
||||
skill3:any=null
|
||||
boxs:Node=null
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
this.on(GameEvent.UseSkillCard, this.get_skill, this);
|
||||
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
this.boxs=this.node.getChildByName("boxs")
|
||||
}
|
||||
start(){
|
||||
this.fight_ready()
|
||||
let equips=this.node.getComponent(EquipsComp)
|
||||
}
|
||||
fight_ready(){
|
||||
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.skill1={
|
||||
uuid:0,
|
||||
name:"skill1",
|
||||
type:0, //1 被动 0 主动
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
this.skill2={
|
||||
uuid:0,
|
||||
name:"skill2",
|
||||
type:0,//
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
this.skill3={
|
||||
uuid:0,
|
||||
name:"skill3",
|
||||
type:0,//
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
}
|
||||
update(dt: number): void {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
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
|
||||
}
|
||||
}
|
||||
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)
|
||||
oops.message.dispatchEvent(GameEvent.CastHeroSkill,uuid)
|
||||
}
|
||||
|
||||
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) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "bce99fa9-0a06-4f7b-b378-77a6aa2524b0",
|
||||
"uuid": "b316181b-0323-4100-8d4d-4b68529d3c19",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
@@ -1,261 +1,212 @@
|
||||
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";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { MissionEvent } from "../common/config/MissionEvent";
|
||||
|
||||
import { _decorator, Component, Node, resources, Sprite, SpriteAtlas } from 'cc';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { EquipInfo, EquipType, EquipAttr, EquipAttrTarget } from '../common/config/Equips';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('EquipsCompComp')
|
||||
@ecs.register('EquipsComp', false)
|
||||
export class EquipsCompComp extends CCComp {
|
||||
|
||||
@ccclass('EquipsComp')
|
||||
export class EquipsComp extends Component {
|
||||
weapon:any=null
|
||||
armor:any=null
|
||||
ring:any=null
|
||||
accessory:any=null
|
||||
skill1:any=null
|
||||
skill2:any=null
|
||||
skill3:any=null
|
||||
boxs:Node=null
|
||||
attrs:any={
|
||||
hero:{
|
||||
ap:0,
|
||||
hp:0,
|
||||
atk_count:0,
|
||||
atk_speed:0,
|
||||
skill_dmg:0,
|
||||
skill_cd:0,
|
||||
},
|
||||
ally:{
|
||||
ap:0,
|
||||
hp:0,
|
||||
atk_count:0,
|
||||
atk_speed:0,
|
||||
skill_dmg:0,
|
||||
skill_cd:0,
|
||||
},
|
||||
enemy:{
|
||||
ap:0,
|
||||
hp:0,
|
||||
atk_count:0,
|
||||
atk_speed:0,
|
||||
skill_dmg:0,
|
||||
skill_cd:0,
|
||||
},
|
||||
friend:{
|
||||
ap:0,
|
||||
hp:0,
|
||||
atk_count:0,
|
||||
atk_speed:0,
|
||||
skill_dmg:0,
|
||||
skill_cd:0,
|
||||
}
|
||||
}
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
this.on(GameEvent.UseSkillCard, this.get_skill, this);
|
||||
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
oops.message.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
oops.message.on(GameEvent.EquipAdd,this.equip_add,this)
|
||||
oops.message.on(GameEvent.EquipRemove,this.equip_remove,this)
|
||||
this.boxs=this.node.getChildByName("boxs")
|
||||
}
|
||||
start(){
|
||||
this.fight_ready()
|
||||
}
|
||||
fight_ready(){
|
||||
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
|
||||
this.boxs.getChildByName("accessory").getChildByName("icon").active=false
|
||||
this.weapon={
|
||||
uuid:0,
|
||||
uuid:2001,
|
||||
name:"weapon",
|
||||
type:"weapon",
|
||||
level:0,
|
||||
quality:0,
|
||||
skill_uuid:0,
|
||||
skill_name:"skill1",
|
||||
skill_type:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
this.armor={
|
||||
uuid:0,
|
||||
uuid:2002,
|
||||
name:"armor",
|
||||
type:"armor",
|
||||
level:0,
|
||||
quality:0,
|
||||
skill_uuid:0,
|
||||
skill_name:"skill1",
|
||||
skill_type:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
this.ring={
|
||||
this.accessory={
|
||||
uuid:0,
|
||||
name:"ring",
|
||||
type:"ring",
|
||||
name:"accessory",
|
||||
type:"accessory",
|
||||
level:0,
|
||||
quality:0,
|
||||
skill_uuid:0,
|
||||
skill_name:"skill1",
|
||||
skill_type:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
}
|
||||
this.skill1={
|
||||
uuid:0,
|
||||
name:"skill1",
|
||||
type:0, //1 被动 0 主动
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
this.count_attrs()
|
||||
}
|
||||
equip_add(e:GameEvent,data:any){
|
||||
console.log("equip_add",data)
|
||||
if(data.type==EquipType.WEAPON){
|
||||
this.weapon.uuid=data.uuid
|
||||
this.weapon.name=data.name
|
||||
this.weapon.type=data.type
|
||||
this.weapon.level=data.level
|
||||
this.show_weapon(data.uuid)
|
||||
}
|
||||
this.skill2={
|
||||
uuid:0,
|
||||
name:"skill2",
|
||||
type:0,//
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
if(data.type==EquipType.ARMOR){
|
||||
this.armor.uuid=data.uuid
|
||||
this.armor.name=data.name
|
||||
this.armor.type=data.type
|
||||
this.armor.level=data.level
|
||||
this.show_armor(data.uuid)
|
||||
}
|
||||
this.skill3={
|
||||
uuid:0,
|
||||
name:"skill3",
|
||||
type:0,//
|
||||
level:0,
|
||||
quality:0,
|
||||
cd:0,
|
||||
cd_time:0,
|
||||
if(data.type==EquipType.ACCESSORY){
|
||||
this.accessory.uuid=data.uuid
|
||||
this.accessory.name=data.name
|
||||
this.accessory.type=data.type
|
||||
this.accessory.level=data.level
|
||||
this.show_accessory(data.uuid)
|
||||
}
|
||||
}
|
||||
show_weapon(uuid:number){
|
||||
let icon = this.node.getChildByName("boxs").getChildByName("weapon").getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/heros/equips"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = icon.getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(uuid.toString());
|
||||
});
|
||||
|
||||
}
|
||||
show_armor(uuid:number){
|
||||
let icon = this.node.getChildByName("boxs").getChildByName("armor").getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/heros/equips"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = icon.getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(uuid.toString());
|
||||
});
|
||||
}
|
||||
show_accessory(uuid:number){
|
||||
let icon = this.node.getChildByName("boxs").getChildByName("accessory").getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/heros/equips"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = icon.getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(uuid.toString());
|
||||
});
|
||||
}
|
||||
count_attrs(){
|
||||
// 重置所有属性
|
||||
this.reset_attrs();
|
||||
|
||||
// 获取所有装备的属性
|
||||
let weapon_attrs = this.weapon.uuid ? EquipInfo[this.weapon.uuid]?.attributes || [] : [];
|
||||
let armor_attrs = this.armor.uuid ? EquipInfo[this.armor.uuid]?.attributes || [] : [];
|
||||
let accessory_attrs = this.accessory.uuid ? EquipInfo[this.accessory.uuid]?.attributes || [] : [];
|
||||
|
||||
// 合并所有装备属性
|
||||
const allAttrs = [...weapon_attrs, ...armor_attrs, ...accessory_attrs];
|
||||
|
||||
// 计算每个目标的属性加成
|
||||
allAttrs.forEach(attr => {
|
||||
const target = attr.target || EquipAttrTarget.ALL;
|
||||
const targetKey = this.getTargetKey(target);
|
||||
|
||||
if (targetKey) {
|
||||
switch (attr.type) {
|
||||
case EquipAttr.ATK:
|
||||
this.attrs[targetKey].ap += attr.value;
|
||||
break;
|
||||
case EquipAttr.HP:
|
||||
this.attrs[targetKey].hp += attr.value;
|
||||
break;
|
||||
case EquipAttr.ATK_COUNT:
|
||||
this.attrs[targetKey].atk_count += attr.value;
|
||||
break;
|
||||
case EquipAttr.ATK_SPEED:
|
||||
this.attrs[targetKey].atk_speed += attr.value;
|
||||
break;
|
||||
case EquipAttr.SKILL_DMG:
|
||||
this.attrs[targetKey].skill_dmg += attr.value;
|
||||
break;
|
||||
case EquipAttr.SKILL_SPEED:
|
||||
this.attrs[targetKey].skill_cd += attr.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log("count_attrs",this.attrs)
|
||||
}
|
||||
|
||||
// 重置所有属性为0
|
||||
private reset_attrs() {
|
||||
Object.keys(this.attrs).forEach(key => {
|
||||
Object.keys(this.attrs[key]).forEach(attrKey => {
|
||||
this.attrs[key][attrKey] = 0;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 根据目标类型获取对应的key
|
||||
private getTargetKey(target: EquipAttrTarget): string | null {
|
||||
switch (target) {
|
||||
case EquipAttrTarget.ALL:
|
||||
return 'hero'; // 默认作用于英雄
|
||||
case EquipAttrTarget.SELF:
|
||||
return 'hero';
|
||||
case EquipAttrTarget.FRIEND:
|
||||
return 'friend';
|
||||
case EquipAttrTarget.ENEMY:
|
||||
return 'enemy';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
equip_remove(e:GameEvent,data:any){
|
||||
console.log("equip_remove",data)
|
||||
}
|
||||
update(dt: number): void {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
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)
|
||||
oops.message.dispatchEvent(GameEvent.CastHeroSkill,uuid)
|
||||
}
|
||||
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) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b316181b-0323-4100-8d4d-4b68529d3c19",
|
||||
"uuid": "a8fa7cb8-6ae9-42bd-8b54-7510b5757576",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
|
||||
70
assets/script/game/map/FightConComp.ts
Normal file
70
assets/script/game/map/FightConComp.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('FightConComp')
|
||||
export class FightConComp extends Component {
|
||||
attrs:any={
|
||||
hero:{
|
||||
ap:0,
|
||||
hp:0,
|
||||
atk_count:0,
|
||||
atk_speed:0,
|
||||
skill_dmg:0,
|
||||
skill_cd:0,
|
||||
},
|
||||
ally:{
|
||||
ap:0,
|
||||
hp:0,
|
||||
atk_count:0,
|
||||
atk_speed:0,
|
||||
skill_dmg:0,
|
||||
skill_cd:0,
|
||||
},
|
||||
enemy:{
|
||||
ap:0,
|
||||
hp:0,
|
||||
atk_count:0,
|
||||
atk_speed:0,
|
||||
skill_dmg:0,
|
||||
skill_cd:0,
|
||||
},
|
||||
friend:{
|
||||
ap:0,
|
||||
hp:0,
|
||||
atk_count:0,
|
||||
atk_speed:0,
|
||||
skill_dmg:0,
|
||||
skill_cd:0,
|
||||
}
|
||||
}
|
||||
onLoad(){
|
||||
// console.log("fight con start")
|
||||
oops.message.on(GameEvent.EquipChange,this.equip_change,this)
|
||||
oops.message.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
}
|
||||
|
||||
equip_change(e:GameEvent,equip:any){
|
||||
this.attrs.hero=equip.hero
|
||||
this.attrs.ally=equip.ally
|
||||
this.attrs.enemy=equip.enemy
|
||||
this.attrs.friend=equip.friend
|
||||
}
|
||||
fight_ready(e:GameEvent){
|
||||
this.attrs.hero=this.attrs.ally=this.attrs.enemy=this.attrs.friend={
|
||||
ap:0,
|
||||
hp:0,
|
||||
atk_count:0,
|
||||
atk_speed:0,
|
||||
skill_dmg:0,
|
||||
skill_cd:0,
|
||||
}
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
assets/script/game/map/FightConComp.ts.meta
Normal file
9
assets/script/game/map/FightConComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "7aec9f6c-509f-4b5d-9993-76ba73b5bdc8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
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 { CdType, SkillSet } from "../common/config/SkillSet";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { Skill } from "../skills/Skill";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('MSkillComp')
|
||||
@ecs.register('MSkillComp', false)
|
||||
export class MSkillComp extends CCComp {
|
||||
/** 技能队列 */
|
||||
private skillQueue: Array<{
|
||||
uuid: number,
|
||||
startPos: Vec3,
|
||||
targetPos: Vec3,
|
||||
group: number,
|
||||
count: number,
|
||||
cd: number,
|
||||
cdTimer: number // 改用累计时间计时器
|
||||
}> = [];
|
||||
/** 常驻技能 */
|
||||
MSkill:any={
|
||||
uuid:0,
|
||||
CdType:0,
|
||||
cd:0,
|
||||
count:0,
|
||||
cdTimer:0
|
||||
}
|
||||
/** 技能队列 */
|
||||
protected onLoad(): void {
|
||||
this.on(GameEvent.MissionSkill, this.skill_event, this);
|
||||
}
|
||||
start() {
|
||||
|
||||
}
|
||||
init(){
|
||||
|
||||
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if (!smc.mission.play || smc.mission.pause) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理技能队列
|
||||
this.processSkillQueue(dt);
|
||||
}
|
||||
skill_event(e: any) {
|
||||
// 技能加入队列
|
||||
const { uuid, startPos, targetPos, group, count = 1, cd = 0 } = e;
|
||||
this.skillQueue.push({
|
||||
uuid,
|
||||
startPos,
|
||||
targetPos,
|
||||
group,
|
||||
count,
|
||||
cd,
|
||||
cdTimer: 0 // 初始化计时器为0
|
||||
});
|
||||
}
|
||||
private processSkillQueue(dt: number) {
|
||||
// 遍历技能队列
|
||||
for (let i = this.skillQueue.length - 1; i >= 0; i--) {
|
||||
const skill = this.skillQueue[i];
|
||||
|
||||
// 累加计时器
|
||||
skill.cdTimer += dt;
|
||||
|
||||
// 检查CD (将cd从毫秒转换为秒进行比较)
|
||||
if (skill.cdTimer < skill.cd * 0.001) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 释放技能
|
||||
this.doSkill(
|
||||
skill.uuid,
|
||||
skill.startPos,
|
||||
skill.targetPos,
|
||||
skill.group
|
||||
);
|
||||
|
||||
// 重置CD计时器
|
||||
skill.cdTimer = 0;
|
||||
|
||||
// 减少技能次数
|
||||
skill.count--;
|
||||
|
||||
// 如果技能次数用完,从队列中移除
|
||||
if (skill.count <= 0) {
|
||||
this.skillQueue.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
private doSkill(uuid: number, start_pos: Vec3, target_pos: Vec3, group: number) {
|
||||
const skillEntity = ecs.getEntity<Skill>(Skill);
|
||||
skillEntity.load(
|
||||
start_pos, // 起始位置
|
||||
group, // 阵营
|
||||
this.node.parent, // 父节点
|
||||
uuid, // 技能ID
|
||||
target_pos, // 目标位置
|
||||
);
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
// 清空技能队列
|
||||
this.skillQueue = [];
|
||||
}
|
||||
}
|
||||
@@ -19,20 +19,6 @@ export class MissionComp extends CCComp {
|
||||
reward:number = 0;
|
||||
reward_num:number = 0;
|
||||
GlodAddTimer:Timer = new Timer(1);
|
||||
mission_data:any={
|
||||
gold:10,//金币
|
||||
refresh_gold:1,//刷新金币
|
||||
refrsh_time:1, //刷新时间
|
||||
call_gold:3,//召唤金币
|
||||
add_gold:1,//金币增加
|
||||
change_gold:1,//金币变化
|
||||
exp:0,//经验
|
||||
skp:0,//技能点
|
||||
box:0,//宝箱
|
||||
energy:0,//能量
|
||||
hp:0,//血量
|
||||
ap:0,//攻击
|
||||
}
|
||||
onLoad(){
|
||||
this.on(GameEvent.MissionStart,this.mission_start,this)
|
||||
this.on(GameEvent.FightEnd,this.fight_end,this)
|
||||
@@ -118,7 +104,7 @@ export class MissionComp extends CCComp {
|
||||
//局内数据初始化
|
||||
console.log("局内数据初始化")
|
||||
smc.mission.play = true;
|
||||
smc.vmdata.mission_data =MissionData
|
||||
smc.vmdata.mission_data = JSON.parse(JSON.stringify(MissionData));
|
||||
this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time)
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ export class MissionHeroCompComp extends CCComp {
|
||||
let hero = ecs.getEntity<Hero>(Hero);
|
||||
let scale = 1
|
||||
let pos:Vec3 = this.start_pos[fight_pos].pos;
|
||||
console.log("hero load0",pos,this.start_pos)
|
||||
// console.log("hero load0",pos,this.start_pos)
|
||||
hero.load(pos,scale,uuid,info,fight_pos);
|
||||
oops.message.dispatchEvent(GameEvent.HeroSelectEnd)
|
||||
this.current_hero_uuid=0
|
||||
|
||||
@@ -22,24 +22,13 @@ export default class SkillLayer extends Component {
|
||||
@property(Prefab)
|
||||
light: Prefab = null;
|
||||
onLoad(){
|
||||
oops.message.on("monster_load", this.doMonsterLoad, this);
|
||||
oops.message.on("hero_load", this.doHeroLoad, this);
|
||||
oops.message.on("do_use_skill", this.doSkill, this);
|
||||
// oops.message.on("do_use_skill", this.doSkill, this);
|
||||
|
||||
}
|
||||
doSkill(){
|
||||
// console.log("doSkill")
|
||||
}
|
||||
doMonsterLoad(){
|
||||
// const light = instantiate(this.light);
|
||||
// light.setPosition(300,-30,0);
|
||||
// this.node.addChild(light);
|
||||
}
|
||||
doHeroLoad(){
|
||||
// const light = instantiate(this.light);
|
||||
// light.setPosition(BoxSet.HERO_START,BoxSet.GAME_LINE,0);
|
||||
// this.node.addChild(light);
|
||||
}
|
||||
|
||||
update(dt: number) {
|
||||
// this.timer.update(dt)
|
||||
// if (this.timer.update(dt))
|
||||
|
||||
Reference in New Issue
Block a user