修复 buff 逻辑处理 bug : 预制体不能设置全局监听oops.message.on,会一直执行

This commit is contained in:
2024-08-28 00:09:55 +08:00
parent 5b1991c90f
commit 4096a17330
15 changed files with 195 additions and 143 deletions

View File

@@ -1737,7 +1737,7 @@
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "5fIwQdqmtEi7HN7Oz8K15G" "fileId": "68LK1h7fRIYahCdzqUvVcV"
}, },
{ {
"__type__": "sp.Skeleton", "__type__": "sp.Skeleton",

View File

@@ -98,9 +98,9 @@ export class RoleViewComp extends CCComp {
let skill = ecs.getEntity<Skill>(Skill); let skill = ecs.getEntity<Skill>(Skill);
let pos = v3(35,55) let pos = v3(35,55)
let scale = 1 let scale = 1
let speed =SkillSet[skill_uuid].speed; let speed =smc.skills[skill_uuid].speed;
let dis = SkillSet[skill_uuid].dis; let dis = smc.skills[skill_uuid].dis;
let atk = SkillSet[skill_uuid].atk+this.atk; let atk = smc.skills[skill_uuid].atk+this.atk;
let uuid = skill_uuid; let uuid = skill_uuid;
skill.load(pos,speed,dis,scale,this.node,uuid,atk,2); skill.load(pos,speed,dis,scale,this.node,uuid,atk,2);
} }

View File

@@ -95,9 +95,9 @@ export class Role2ViewComp extends CCComp {
let skill = ecs.getEntity<Skill>(Skill); let skill = ecs.getEntity<Skill>(Skill);
let pos = v3(60,50) let pos = v3(60,50)
let scale = 1 let scale = 1
let speed =SkillSet[skill_uuid].speed; let speed =smc.skills[skill_uuid].speed;
let dis = SkillSet[skill_uuid].dis; let dis = smc.skills[skill_uuid].dis;
let atk = SkillSet[skill_uuid].atk+this.atk; let atk = smc.skills[skill_uuid].atk+this.atk;
let uuid = skill_uuid; let uuid = skill_uuid;
skill.load(pos,speed,dis,scale,this.node,uuid,atk,2); skill.load(pos,speed,dis,scale,this.node,uuid,atk,2);
} }

View File

@@ -39,6 +39,7 @@ export class SingletonModuleComp extends ecs.Comp {
/**怪物数据 数组 */ /**怪物数据 数组 */
/**heros 数据 */ /**heros 数据 */
heros:any = []; heros:any = [];
skills:any = []
monsters_dead:any = [] monsters_dead:any = []
heros_dead:any = [] heros_dead:any = []

View File

@@ -18,56 +18,56 @@ path: 图片地址
*/ */
export const SkillSet={ export const SkillSet={
1001:{uuid: 1001,path: "1001",type: 1,level: 1,name: "火球术-初级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1001:{uuid: 1001,path: "1001",type: 1,level: 1,name: "火球术-初级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1002:{uuid: 1002,path: "1002",type: 1,level: 1,name: "寒冰箭-初级",sp_name:"ice",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1002:{uuid: 1002,path: "1002",type: 1,level: 1,name: "寒冰箭-初级",sp_name:"ice",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1003:{uuid: 1003,path: "1003",type: 9,level: 1,name: "狂暴-初级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1003:{uuid: 1003,path: "1003",type: 9,level: 1,name: "狂暴-初级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1004:{uuid: 1004,path: "1004",type: 9,level: 1,name: "守护-初级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1004:{uuid: 1004,path: "1004",type: 9,level: 1,name: "守护-初级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:100,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1005:{uuid: 1005,path: "1005",type: 9,level: 1,name: "雷霆-初级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1005:{uuid: 1005,path: "1005",type: 9,level: 1,name: "雷霆-初级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1006:{uuid: 1006,path: "1006",type: 9,level: 1,name: "再生-初级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1006:{uuid: 1006,path: "1006",type: 9,level: 1,name: "再生-初级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1007:{uuid: 1007,path: "1007",type: 5,level: 1,name: "复生-初级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1007:{uuid: 1007,path: "1007",type: 5,level: 1,name: "复生-初级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1008:{uuid: 1008,path: "1008",type: 9,level: 1,name: "灵巧-初级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1008:{uuid: 1008,path: "1008",type: 9,level: 1,name: "灵巧-初级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1009:{uuid: 1009,path: "1009",type: 9,level: 1,name: "盾守-初级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1009:{uuid: 1009,path: "1009",type: 9,level: 1,name: "坚硬-初级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1010:{uuid: 1010,path: "1010",type: 9,level: 1,name: "治愈-初级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1010:{uuid: 1010,path: "1010",type: 9,level: 1,name: "治愈-初级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1011:{uuid: 1011,path: "1011",type: 1,level: 3,name: "火焰风暴-初级",sp_name:"fire",dis:720,count:3,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1011:{uuid: 1011,path: "1011",type: 1,level: 3,name: "火焰风暴-初级",sp_name:"fire",dis:720,count:3,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
1012:{uuid: 1012,path: "1012",type: 1,level: 3,name: "冰晶风暴-初级",sp_name:"ice",dis:720,count:3,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 1012:{uuid: 1012,path: "1012",type: 1,level: 3,name: "冰晶风暴-初级",sp_name:"ice",dis:720,count:3,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2001:{uuid: 2001,path: "1001",type: 1,level: 2,name: "火球术-中级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2001:{uuid: 2001,path: "1001",type: 1,level: 2,name: "火球术-中级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2002:{uuid: 2002,path: "1002",type: 1,level: 2,name: "寒冰箭-中级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2002:{uuid: 2002,path: "1002",type: 1,level: 2,name: "寒冰箭-中级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2003:{uuid: 2003,path: "1003",type: 9,level: 2,name: "狂暴-中级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2003:{uuid: 2003,path: "1003",type: 9,level: 2,name: "狂暴-中级",sp_name:"fire",dis:720,count:1,atk:20,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2004:{uuid: 2004,path: "1004",type: 9,level: 2,name: "守护-中级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2004:{uuid: 2004,path: "1004",type: 9,level: 2,name: "守护-中级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:200,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2005:{uuid: 2005,path: "1005",type: 9,level: 2,name: "雷霆-中级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2005:{uuid: 2005,path: "1005",type: 9,level: 2,name: "雷霆-中级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2006:{uuid: 2006,path: "1006",type: 9,level: 2,name: "再生-中级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2006:{uuid: 2006,path: "1006",type: 9,level: 2,name: "再生-中级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2007:{uuid: 2007,path: "1007",type: 5,level: 2,name: "复生-中级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2007:{uuid: 2007,path: "1007",type: 5,level: 2,name: "复生-中级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2008:{uuid: 2008,path: "1008",type: 9,level: 2,name: "灵巧-中级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2008:{uuid: 2008,path: "1008",type: 9,level: 2,name: "灵巧-中级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2009:{uuid: 2009,path: "1009",type: 9,level: 2,name: "盾守-中级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2009:{uuid: 2009,path: "1009",type: 9,level: 2,name: "坚硬-中级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2010:{uuid: 2010,path: "1010",type: 9,level: 2,name: "治愈-中级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2010:{uuid: 2010,path: "1010",type: 9,level: 2,name: "治愈-中级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2011:{uuid: 2011,path: "1011",type: 1,level: 4,name: "火焰风暴-中级",sp_name:"fire",dis:720,count:3,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2011:{uuid: 2011,path: "1011",type: 1,level: 4,name: "火焰风暴-中级",sp_name:"fire",dis:720,count:3,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
2012:{uuid: 2012,path: "1012",type: 1,level: 4,name: "冰晶风暴-中级",sp_name:"ice",dis:720,count:3,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 2012:{uuid: 2012,path: "1012",type: 1,level: 4,name: "冰晶风暴-中级",sp_name:"ice",dis:720,count:3,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3001:{uuid: 3001,path: "1001",type: 1,level: 3,name: "火球术-高级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3001:{uuid: 3001,path: "1001",type: 1,level: 3,name: "火球术-高级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3002:{uuid: 3002,path: "1002",type: 1,level: 3,name: "寒冰箭-高级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3002:{uuid: 3002,path: "1002",type: 1,level: 3,name: "寒冰箭-高级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3003:{uuid: 3003,path: "1003",type: 9,level: 3,name: "狂暴-高级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3003:{uuid: 3003,path: "1003",type: 9,level: 3,name: "狂暴-高级",sp_name:"fire",dis:720,count:1,atk:40,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3004:{uuid: 3004,path: "1004",type: 9,level: 3,name: "守护-高级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3004:{uuid: 3004,path: "1004",type: 9,level: 3,name: "守护-高级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:400,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3005:{uuid: 3005,path: "1005",type: 9,level: 3,name: "雷霆-高级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3005:{uuid: 3005,path: "1005",type: 9,level: 3,name: "雷霆-高级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3006:{uuid: 3006,path: "1006",type: 9,level: 3,name: "再生-高级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3006:{uuid: 3006,path: "1006",type: 9,level: 3,name: "再生-高级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3007:{uuid: 3007,path: "1007",type: 5,level: 3,name: "复生-高级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3007:{uuid: 3007,path: "1007",type: 5,level: 3,name: "复生-高级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3008:{uuid: 3008,path: "1008",type: 9,level: 3,name: "灵巧-高级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3008:{uuid: 3008,path: "1008",type: 9,level: 3,name: "灵巧-高级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3009:{uuid: 3009,path: "1009",type: 9,level: 3,name: "盾守-高级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3009:{uuid: 3009,path: "1009",type: 9,level: 3,name: "坚硬-高级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3010:{uuid: 3010,path: "1010",type: 9,level: 3,name: "治愈-高级",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3010:{uuid: 3010,path: "1010",type: 9,level: 3,name: "治愈-高级",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3011:{uuid: 3011,path: "1011",type: 1,level: 5,name: "火焰风暴-高级",sp_name:"fire",dis:720,count:5,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3011:{uuid: 3011,path: "1011",type: 1,level: 5,name: "火焰风暴-高级",sp_name:"fire",dis:720,count:5,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
3012:{uuid: 3012,path: "1012",type: 1,level: 5,name: "冰晶风暴-高级",sp_name:"ice",dis:720,count:5,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 3012:{uuid: 3012,path: "1012",type: 1,level: 5,name: "冰晶风暴-高级",sp_name:"ice",dis:720,count:5,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4001:{uuid: 4001,path: "1001",type: 1,level: 4,name: "火球术-终极",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4001:{uuid: 4001,path: "1001",type: 1,level: 4,name: "火球术-终极",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4002:{uuid: 4002,path: "1002",type: 1,level: 4,name: "寒冰箭-终极",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4002:{uuid: 4002,path: "1002",type: 1,level: 4,name: "寒冰箭-终极",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4003:{uuid: 4003,path: "1003",type: 9,level: 4,name: "狂暴-终极",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4003:{uuid: 4003,path: "1003",type: 9,level: 4,name: "狂暴-终极",sp_name:"fire",dis:720,count:1,atk:80,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4004:{uuid: 4004,path: "1004",type: 9,level: 4,name: "守护-终极",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4004:{uuid: 4004,path: "1004",type: 9,level: 4,name: "守护-终极",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:800,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4005:{uuid: 4005,path: "1005",type: 9,level: 4,name: "雷霆-终极",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4005:{uuid: 4005,path: "1005",type: 9,level: 4,name: "雷霆-终极",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4006:{uuid: 4006,path: "1006",type: 9,level: 4,name: "再生-终极",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4006:{uuid: 4006,path: "1006",type: 9,level: 4,name: "再生-终极",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4007:{uuid: 4007,path: "1007",type: 5,level: 4,name: "复生-终极",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4007:{uuid: 4007,path: "1007",type: 5,level: 4,name: "复生-终极",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4008:{uuid: 4008,path: "1008",type: 9,level: 4,name: "灵巧-终极",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4008:{uuid: 4008,path: "1008",type: 9,level: 4,name: "灵巧-终极",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4009:{uuid: 4009,path: "1009",type: 9,level: 4,name: "盾守-终极",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4009:{uuid: 4009,path: "1009",type: 9,level: 4,name: "坚硬-终极",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4010:{uuid: 4010,path: "1010",type: 9,level: 4,name: "治愈-终极",sp_name:"fire",dis:720,count:1,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4010:{uuid: 4010,path: "1010",type: 9,level: 4,name: "治愈-终极",sp_name:"fire",dis:720,count:1,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4011:{uuid: 4011,path: "1011",type: 1,level: 6,name: "火焰风暴-终极",sp_name:"fire",dis:720,count:5,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4011:{uuid: 4011,path: "1011",type: 1,level: 6,name: "火焰风暴-终极",sp_name:"fire",dis:720,count:5,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
4012:{uuid: 4012,path: "1012",type: 1,level: 6,name: "冰晶风暴-终极",sp_name:"ice",dis:720,count:5,atk:10,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,}, 4012:{uuid: 4012,path: "1012",type: 1,level: 6,name: "冰晶风暴-终极",sp_name:"ice",dis:720,count:5,atk:10,hp:0,shield:0,sd:100,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
9001:{uuid: 9001,path: "1001",type: 1,level: 1,name: "基础攻击1",sp_name:"base",dis:70,count:1,atk:0,sd:10,cd:3,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:450,}, 9001:{uuid: 9001,path: "1001",type: 1,level: 1,name: "基础攻击1",sp_name:"base",dis:70,count:1,atk:0,hp:0,shield:0,sd:100,cd:3,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:450,},
9002:{uuid: 9002,path: "1001",type: 1,level: 1,name: "基础攻击2",sp_name:"base2",dis:70,count:1,atk:0,sd:10,cd:3,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:450,}, 9002:{uuid: 9002,path: "1001",type: 1,level: 1,name: "基础攻击2",sp_name:"base2",dis:70,count:1,atk:0,hp:0,shield:0,sd:100,cd:3,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:450,},
9003:{uuid: 9003,path: "1001",type: 2,level: 1,name: "基础攻击3",sp_name:"base3",dis:720,count:1,atk:0,sd:10,cd:3,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:450,}, 9003:{uuid: 9003,path: "1001",type: 2,level: 1,name: "基础攻击3",sp_name:"base3",dis:720,count:1,atk:0,hp:0,shield:0,sd:100,cd:3,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:450,},
} }

View File

@@ -13,6 +13,7 @@ import { UIID } from "../common/config/GameUIConfig";
import { LoadingViewComp } from "./view/LoadingViewComp"; import { LoadingViewComp } from "./view/LoadingViewComp";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import { HeroList } from "../map/HeroList"; import { HeroList } from "../map/HeroList";
import { SkillSet } from "../common/config/SkillSet";
// import {data} from "../data/data"; // import {data} from "../data/data";
/** /**
@@ -87,6 +88,7 @@ export class Initialize extends ecs.Entity {
this.HeroList = new HeroList(); this.HeroList = new HeroList();
this.HeroList.init(); // 等待数据加载完成 this.HeroList.init(); // 等待数据加载完成
smc.heros = this.HeroList.list; smc.heros = this.HeroList.list;
smc.skills=SkillSet;
var uic: UICallbacks = { var uic: UICallbacks = {
onAdded: (node: Node, params: any) => { onAdded: (node: Node, params: any) => {
var comp = node.getComponent(LoadingViewComp) as ecs.Comp; var comp = node.getComponent(LoadingViewComp) as ecs.Comp;

View File

@@ -44,7 +44,7 @@ export class CSkill extends ecs.Entity {
const url = 'game/heros/skill'; const url = 'game/heros/skill';
resources.load(url, SpriteAtlas, (err: any, atlas) => { resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("skill").getComponent(Sprite); const sprite = node.getChildByName("skill").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[uuid].path); sprite.spriteFrame = atlas.getSpriteFrame(smc.skills[uuid].path);
}); });
this.skill_init(uuid,node,pos) this.skill_init(uuid,node,pos)
oops.message.dispatchEvent("cskill_load",this) oops.message.dispatchEvent("cskill_load",this)
@@ -67,7 +67,7 @@ export class CSkill extends ecs.Entity {
var mv = node.getComponent(CSkillComp) var mv = node.getComponent(CSkillComp)
mv.scale = 1; mv.scale = 1;
mv.skill_uuid = uuid; mv.skill_uuid = uuid;
mv.atk=SkillSet[uuid].atk; mv.atk=smc.skills[uuid].atk;
this.add(mv); this.add(mv);
} }

View File

@@ -9,6 +9,8 @@ import { MonsterModelComp } from "./MonsterModelComp";
import { MonsterViewComp } from "./MonsterViewComp"; import { MonsterViewComp } from "./MonsterViewComp";
import { BoxSet } from "../common/config/BoxSet"; import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { HeroModelComp } from "./HeroModelComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
/** 视图层对象 */ /** 视图层对象 */
@@ -29,9 +31,9 @@ export class CSkillComp extends CCComp {
/** 视图层逻辑代码分离演示 */ /** 视图层逻辑代码分离演示 */
start() { start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象 // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
this.sd =new Timer(SkillSet[this.skill_uuid].sd) this.sd =new Timer(smc.skills[this.skill_uuid].sd)
this.cd = new Timer(SkillSet[this.skill_uuid].cd) this.cd = new Timer(smc.skills[this.skill_uuid].cd)
this.time =SkillSet[this.skill_uuid].sd this.time =smc.skills[this.skill_uuid].sd
this.node.getChildByName("time").getComponent(Label).string = this.time.toString() this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
} }
@@ -45,7 +47,13 @@ export class CSkillComp extends CCComp {
if (this.cd.update(dt)) { if (this.cd.update(dt)) {
this.time -=1 this.time -=1
this.node.getChildByName("time").getComponent(Label).string = this.time.toString() this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
this.shoot() if(smc.skills[this.skill_uuid].type == 1){
this.shoot()
}
if(smc.skills[this.skill_uuid].type == 9){
this.add_buff()
}
} }
} }
shoot() { shoot() {
@@ -72,11 +80,24 @@ export class CSkillComp extends CCComp {
angle = randian * (180 / Math.PI); angle = randian * (180 / Math.PI);
// console.log("angle",angle); // console.log("angle",angle);
let scale = this.scale let scale = this.scale
let dis = SkillSet[this.skill_uuid].dis+this.dis; let dis = smc.skills[this.skill_uuid].dis+this.dis;
let atk = SkillSet[this.skill_uuid].atk+this.atk; let atk = smc.skills[this.skill_uuid].atk+this.atk;
let speed = SkillSet[this.skill_uuid].speed+this.speed; let speed = smc.skills[this.skill_uuid].speed+this.speed;
skill.load(pos,speed,dis,scale,this.node,this.skill_uuid,atk,angle,t_pos); skill.load(pos,speed,dis,scale,this.node,this.skill_uuid,atk,angle,t_pos);
} }
add_buff(){
let uuid= this.skill_uuid;
let eid = 0
let group = BoxSet.HERO;
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
if (heros.length > 0) {
for (let i = 0; i < heros.length; i++) {
let hero = heros[i];
hero.MonsterBuff.add_buff(uuid,eid,group);
}
}
// oops.message.dispatchEvent("add_buff",{uuid:this.skill_uuid,eid:0,group:BoxSet.HERO})
}
/** 全局消息逻辑处理 */ /** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) { // private onHandler(event: string, args: any) {
// switch (event) { // switch (event) {
@@ -106,7 +127,6 @@ export class CSkillComp extends CCComp {
reset() { reset() {
this.sd.reset() this.sd.reset()
this.cd.reset() this.cd.reset()
this.node.destroy(); this.node.destroy();
} }
} }

View File

@@ -17,6 +17,7 @@ import { MonsterViewComp } from "./MonsterViewComp";
import {HeroModelComp} from "./HeroModelComp"; import {HeroModelComp} from "./HeroModelComp";
import { CardSet } from "../common/config/CardSet"; import { CardSet } from "../common/config/CardSet";
import { BoxSet } from "../common/config/BoxSet"; import { BoxSet } from "../common/config/BoxSet";
import { MonsterBuffComp } from "./MonsterBuffComp";
/** 角色实体 */ /** 角色实体 */
@ecs.register(`Hero`) @ecs.register(`Hero`)
export class Hero extends ecs.Entity { export class Hero extends ecs.Entity {
@@ -31,7 +32,8 @@ export class Hero extends ecs.Entity {
destroy(): void { destroy(): void {
this.remove(MonsterViewComp); this.remove(MonsterViewComp);
this.remove(MonsterModelComp); this.remove(HeroModelComp);
this.remove(MonsterBuffComp);
super.destroy(); super.destroy();
} }
@@ -83,10 +85,11 @@ export class Hero extends ecs.Entity {
} }
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){ hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!; var mv = node.getComponent(MonsterViewComp)!;
var buff =node.getComponent(MonsterBuffComp)!;
mv.hero_uuid=uuid; mv.hero_uuid=uuid;
mv.speed =mv.ospeed = smc.heros[uuid].speed; mv.speed =mv.ospeed = smc.heros[uuid].speed;
mv.hero_name= smc.heros[uuid].name; mv.hero_name= smc.heros[uuid].name;
mv.box_group= BoxSet.HERO; buff.group= mv.box_group= BoxSet.HERO;
mv.hp= mv.hp_max = smc.heros[uuid].hp; mv.hp= mv.hp_max = smc.heros[uuid].hp;
mv.level = smc.heros[uuid].level; mv.level = smc.heros[uuid].level;
mv.atk = smc.heros[uuid].atk; mv.atk = smc.heros[uuid].atk;
@@ -99,6 +102,7 @@ export class Hero extends ecs.Entity {
mv.scale = 1; mv.scale = 1;
// mv.change_name(smc.heros[uuid].name,1) // mv.change_name(smc.heros[uuid].name,1)
this.add(mv); this.add(mv);
this.add(buff);
} }

View File

@@ -48,7 +48,7 @@ export class HeroCard extends ecs.Entity {
case 2: case 2:
path = "game/heros/skill_card"; path = "game/heros/skill_card";
url = "game/heros/skill"; url = "game/heros/skill";
({ path: pathName, name, level } = SkillSet[uuid]); ({ path: pathName, name, level } = smc.skills[uuid]);
break; break;
case 3: case 3:
default: default:
@@ -74,7 +74,6 @@ export class HeroCard extends ecs.Entity {
hcv.card_type=type hcv.card_type=type
hcv.card_level=level hcv.card_level=level
this.add(hcv); this.add(hcv);
} }
} }

View File

@@ -28,13 +28,11 @@ export class Monster extends ecs.Entity {
MonsterBuff!: MonsterBuffComp; // 移动 MonsterBuff!: MonsterBuffComp; // 移动
protected init() { protected init() {
this.addComponents<ecs.Comp>( this.addComponents<ecs.Comp>( MonsterModelComp);
MonsterModelComp);
} }
destroy(): void { destroy(): void {
this.remove(MonsterViewComp); this.remove(MonsterViewComp);
this.remove(MonsterBuffComp); this.remove(MonsterBuffComp);
super.destroy(); super.destroy();
@@ -84,10 +82,10 @@ export class Monster extends ecs.Entity {
} }
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){ hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!; var mv = node.getComponent(MonsterViewComp)!;
var buff = node.getComponent(MonsterBuffComp)!; var buff =node.getComponent(MonsterBuffComp)!;
mv.speed =mv.ospeed = smc.heros[uuid].speed; mv.speed =mv.ospeed = smc.heros[uuid].speed;
mv.hero_name= smc.heros[uuid].name; mv.hero_name= smc.heros[uuid].name;
mv.box_group= BoxSet.MONSTER; buff.group=mv.box_group= BoxSet.MONSTER;
mv.hp= mv.hp_max = smc.heros[uuid].hp; mv.hp= mv.hp_max = smc.heros[uuid].hp;
mv.level = smc.heros[uuid].level; mv.level = smc.heros[uuid].level;
mv.atk = smc.heros[uuid].atk; mv.atk = smc.heros[uuid].atk;
@@ -99,7 +97,6 @@ export class Monster extends ecs.Entity {
mv.scale = -1; mv.scale = -1;
mv.Tpos = v3(0,0,0); mv.Tpos = v3(0,0,0);
this.add(mv); this.add(mv);
this.add(buff) this.add(buff);
} }
} }

View File

@@ -5,7 +5,7 @@
* @LastEditTime: 2022-08-17 12:36:18 * @LastEditTime: 2022-08-17 12:36:18
*/ */
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite} from "cc"; import { _decorator} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { MonsterSpine } from "./MonsterSpine"; import { MonsterSpine } from "./MonsterSpine";
@@ -18,9 +18,8 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
import { Skill } from "../skills/Skill"; import { Skill } from "../skills/Skill";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { SkillCom } from "../skills/SkillCom"; import { SkillCom } from "../skills/SkillCom";
import { SkillSet } from "../common/config/SkillSet";
import { BoxRangComp } from "./BoxRangComp"; import { BoxRangComp } from "./BoxRangComp";
import { Tooltip } from "../skills/Tooltip"; import { Tooltip } from "../skills/Tooltip";
import { MonsterViewComp } from "./MonsterViewComp"; import { MonsterViewComp } from "./MonsterViewComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -33,64 +32,49 @@ export class MonsterBuffComp extends CCComp {
mv!: MonsterViewComp; mv!: MonsterViewComp;
timer:Timer = new Timer(0.1); timer:Timer = new Timer(0.1);
buffs:Array<number>=[]; buffs:any=[];
buffs_arr:any=[]; group:number=0;
/** /**
skill_uuid:number=0; skill_uuid:number=0;
atk:number=0; atk:number=0;
hp:number=0; hp:number=0;
shield:number=0; shield:number=0;
time:number=0; time:number=0;
**/ **/
onLoad() { onLoad() {
this.as = this.node.getComponent(MonsterSpine); this.as = this.node.getComponent(MonsterSpine);
this.mv= this.getComponent(MonsterViewComp); this.mv= this.getComponent(MonsterViewComp);
} /** 视图层逻辑代码分离演示 */ } /** 视图层逻辑代码分离演示 */
start () { start () {
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
if (collider) {
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
}
// this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = this.level.toString();
} }
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D) { add_buff(uuid:number=0,eid:number=0,group:number=0){
if(otherCollider.tag==BoxSet.SKILL_TAG &&selfCollider.tag!=BoxSet.SKILL_TAG){ // console.log("add_buff",event,args,smc.skills[uuid]);
if(selfCollider.group != otherCollider.group){
let new_buff={
skill_uuid:uuid,
skill_name:smc.skills[uuid].name,
atk:smc.skills[uuid].atk,
hp:smc.skills[uuid].hp,
shield:smc.skills[uuid].shield,
time:smc.skills[uuid].bsd,
bcd:smc.skills[uuid].bcd,
sk_uuid:smc.skills[uuid].uuid,
}
if(eid !=0 && group ==0 ){
if(this.mv.ent.eid == eid){
this.buff_add(new_buff);
} }
} }
} if(eid ==0 && group == this.group){
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { } this.buff_add(new_buff);
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group == otherCollider.group&&otherCollider.tag == 0&&selfCollider.tag == 0){
let self_pos=selfCollider.node.getPosition();
let other_pos=otherCollider.node.getPosition();
// console.log('monster view group 相同');
switch (selfCollider.group) {
case BoxSet.HERO:
break;
case BoxSet.MONSTER:
break
}
} }
} }
update(dt: number){ update(dt: number){
if (this.timer.update(dt)) { if (this.timer.update(dt)) {
this.buff_update() this.buff_update()
@@ -102,21 +86,45 @@ export class MonsterBuffComp extends CCComp {
this.node.destroy(); this.node.destroy();
} }
buff_add(time:number,atk:number){ buff_add(buff:any){
// console.log("buff add:",this.buffs);
if(!this.node.isValid){ return }
let i = 0
if(this.buffs.length >=0){
this.buffs.forEach((b:any,index:number)=>{
if(b.skill_uuid==buff.skill_uuid){
b.time=buff.time;
this.mv.atk+=(buff.atk-b.atk);
this.mv.hp+=(buff.hp-b.hp);
this.mv.hp_max+=(buff.hp-b.hp);
this.mv.shield=buff.shield-b.shield;
i=index
}
})
}
if (i==0||this.buffs.length==0) {
this.buffs.push(buff);
this.mv.atk+=buff.atk;
this.mv.hp+=buff.hp;
this.mv.hp_max+=buff.hp;
this.mv.shield+=buff.shield;
}
// console.log("buff add:"+this.mv.ent.eid,this.node);
} }
buff_remove(index:number){ buff_remove(index:number){
this.mv.atk=this.mv.atk-this.buffs_arr[index].atk; this.mv.atk=this.mv.atk-this.buffs[index].atk;
this.mv.hp=this.mv.hp-this.buffs_arr[index].hp; this.mv.hp_max=this.mv.hp_max-this.buffs[index].hp;
this.mv.shield=this.mv.shield-this.buffs_arr[index].shield; this.mv.shield=this.mv.shield-this.buffs[index].shield;
// console.log("buff remove:"+this.mv.ent.eid,this.node)
} }
buff_update(){ buff_update(){
this.buffs_arr.forEach((buff:any,index:number)=>{ this.buffs.forEach((buff:any,index:number)=>{
buff.time -= 0.1; buff.time -= 0.1;
if(buff.time <= 0){ if(buff.time <= 0){
this.buff_remove(index); this.buff_remove(index);
} }
}) })
this.buffs_arr = this.buffs_arr.filter((buff:any) => buff.time > 0); this.buffs = this.buffs.filter((buff:any) => buff.time > 0);
// console.log(this.buffs,this.buffs);
} }
} }

View File

@@ -21,6 +21,7 @@ import { SkillCom } from "../skills/SkillCom";
import { SkillSet } from "../common/config/SkillSet"; import { SkillSet } from "../common/config/SkillSet";
import { BoxRangComp } from "./BoxRangComp"; import { BoxRangComp } from "./BoxRangComp";
import { Tooltip } from "../skills/Tooltip"; import { Tooltip } from "../skills/Tooltip";
import { MonsterBuffComp } from "./MonsterBuffComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
/** 角色显示组件 */ /** 角色显示组件 */
@@ -34,6 +35,9 @@ export class MonsterViewComp extends CCComp {
@property(Node) @property(Node)
BoxRang:Node =null! BoxRang:Node =null!
buff:MonsterBuffComp =null!
/** 角色动画 */ /** 角色动画 */
as: MonsterSpine = null!; as: MonsterSpine = null!;
hero_uuid:number = 1001; hero_uuid:number = 1001;
@@ -66,6 +70,7 @@ export class MonsterViewComp extends CCComp {
stop_cd: number = 0.5; /*停止倒计时*/ stop_cd: number = 0.5; /*停止倒计时*/
shield:number = 0; //护盾量 shield:number = 0; //护盾量
shield_max:number = 0;
shield_time:number = 0; //护盾持续时间 shield_time:number = 0; //护盾持续时间
box_group:number = 2; box_group:number = 2;
@@ -77,18 +82,18 @@ export class MonsterViewComp extends CCComp {
onLoad() { onLoad() {
this.as = this.getComponent(MonsterSpine); this.as = this.getComponent(MonsterSpine);
this.buff=this.node.getComponent(MonsterBuffComp);
this.BoxRang = this.node.getChildByName("range_box");
} /** 视图层逻辑代码分离演示 */ } /** 视图层逻辑代码分离演示 */
start () { start () {
this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite); this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0); this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
this.BoxRang = this.node.getChildByName("range_box");
this.BoxRang.getComponent(BoxRangComp).box_group = this.box_group; this.BoxRang.getComponent(BoxRangComp).box_group = this.box_group;
this.BoxRang.getComponent(BoxRangComp).offset_x = this.scale*SkillSet[this.skill_uuid].dis; this.BoxRang.getComponent(BoxRangComp).offset_x = this.scale*smc.skills[this.skill_uuid].dis;
// console.log("monseter ",this.BoxRang); // console.log("monseter ",this.BoxRang);
this.buff.group=this.box_group
// 注册单个碰撞体的回调函数 // 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D); let collider = this.getComponent(Collider2D);
collider.group = this.box_group; collider.group = this.box_group;
@@ -182,11 +187,11 @@ export class MonsterViewComp extends CCComp {
let x=32 let x=32
let pos = v3(35*this.scale,40) let pos = v3(35*this.scale,40)
let scale = this.scale let scale = this.scale
let speed =SkillSet[skill_uuid].speed; let speed =smc.skills[skill_uuid].speed;
let dis = SkillSet[skill_uuid].dis; let dis = smc.skills[skill_uuid].dis;
let atk = SkillSet[skill_uuid].atk+this.atk; let atk = smc.skills[skill_uuid].atk+this.atk;
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk); skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk);
// this.tooltip(3,SkillSet[skill_uuid].name,this.skill_uuid); // this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
} }
//使用max_skill //使用max_skill
do_max_skill(){ do_max_skill(){
@@ -194,11 +199,11 @@ export class MonsterViewComp extends CCComp {
let x=32 let x=32
let pos = v3(35*this.scale,40) let pos = v3(35*this.scale,40)
let scale = this.scale let scale = this.scale
let speed =SkillSet[this.max_skill_uuid].speed; let speed =smc.skills[this.max_skill_uuid].speed;
let dis = SkillSet[this.max_skill_uuid].dis; let dis = smc.skills[this.max_skill_uuid].dis;
let atk = SkillSet[this.max_skill_uuid].atk+this.atk; let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk); skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
this.tooltip(3,SkillSet[this.max_skill_uuid].name,this.max_skill_uuid); this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
} }
in_act(dt: number) { in_act(dt: number) {
@@ -219,7 +224,11 @@ export class MonsterViewComp extends CCComp {
if(this.is_dead){ if(this.is_dead){
return; return;
} }
this.hp -= hp; let lhp=this.shield_change(hp);
if(lhp == 0){
return;
}
this.hp += lhp;
this.tooltip(1,hp.toString()); this.tooltip(1,hp.toString());
if(this.hp > this.hp_max){ if(this.hp > this.hp_max){
this.hp = this.hp_max; this.hp = this.hp_max;
@@ -234,6 +243,18 @@ export class MonsterViewComp extends CCComp {
}, 15); }, 15);
} }
} }
shield_change(hp: number){
let ls=this.shield - hp;
if(ls <= 0){
this.shield = 0;
return ls;
}else{
this.shield = ls;
return 0;
}
// let shield_progress= this.shield/this.shield_max;
// this.node.getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
}
tooltip(type:number=1,value:string="",s_uuid:number=1001){ tooltip(type:number=1,value:string="",s_uuid:number=1001){
// console.log("tooltip",type); // console.log("tooltip",type);
let tip =ecs.getEntity<Tooltip>(Tooltip); let tip =ecs.getEntity<Tooltip>(Tooltip);

View File

@@ -30,7 +30,7 @@ export class Skill extends ecs.Entity {
super.destroy(); super.destroy();
} }
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,dis:number = 50,scale:number = 1,parent:Node,uuid:number=1001,atk:number =10,angle = 0,t_pos:Vec3 = null) { load(pos: Vec3 = Vec3.ZERO,speed:number = 100,dis:number = 50,scale:number = 1,parent:Node,uuid:number=1001,atk:number =10,angle = 0,t_pos:Vec3 = null) {
var path = "game/skills/"+SkillSet[uuid].sp_name; var path = "game/skills/"+smc.skills[uuid].sp_name;
var prefab: Prefab = oops.res.get(path, Prefab)!; var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab); var node = instantiate(prefab);
// console.log("load skill parent.position :",parent.position) // console.log("load skill parent.position :",parent.position)
@@ -46,7 +46,7 @@ export class Skill extends ecs.Entity {
sv.atk = atk; sv.atk = atk;
sv.angle = angle; sv.angle = angle;
sv.t_pos = t_pos; // 目标增量 sv.t_pos = t_pos; // 目标增量
sv.type = SkillSet[uuid].type; sv.type = smc.skills[uuid].type;
sv.box_tag= BoxSet.SKILL_TAG; sv.box_tag= BoxSet.SKILL_TAG;
if(scale == 1){ if(scale == 1){
sv.box_group=BoxSet.HERO sv.box_group=BoxSet.HERO

View File

@@ -37,10 +37,10 @@ export class TooltipCom extends CCComp {
this.node.getChildByName("add_life").active=true; this.node.getChildByName("add_life").active=true;
break break
case 3: case 3:
// resources.load("game/heros/skill/"+SkillSet[this.s_uuid].path, SpriteFrame, (err, spriteFrame) => { // resources.load("game/heros/skill/"+smc.skills[this.s_uuid].path, SpriteFrame, (err, spriteFrame) => {
// this.node.getChildByName("skill").getChildByName("icon").getComponent(Sprite).spriteFrame = spriteFrame; // this.node.getChildByName("skill").getChildByName("icon").getComponent(Sprite).spriteFrame = spriteFrame;
// }); // });
this.node.getChildByName("skill").getChildByName("name").getComponent(Label).string = SkillSet[this.s_uuid].name; this.node.getChildByName("skill").getChildByName("name").getComponent(Label).string = smc.skills[this.s_uuid].name;
this.node.getChildByName("skill").active=true; this.node.getChildByName("skill").active=true;
// this.alive_time = 2 // this.alive_time = 2
this.node.setPosition(v3(this.node.position.x,this.node.position.y+50)) this.node.setPosition(v3(this.node.position.x,this.node.position.y+50))