diff --git a/assets/resources/game/heros/skill.prefab b/assets/resources/game/heros/cskill.prefab similarity index 99% rename from assets/resources/game/heros/skill.prefab rename to assets/resources/game/heros/cskill.prefab index 565dc633..a225e4ef 100644 --- a/assets/resources/game/heros/skill.prefab +++ b/assets/resources/game/heros/cskill.prefab @@ -1,7 +1,7 @@ [ { "__type__": "cc.Prefab", - "_name": "skill", + "_name": "cskill", "_objFlags": 0, "__editorExtras__": {}, "_native": "", @@ -13,7 +13,7 @@ }, { "__type__": "cc.Node", - "_name": "skill", + "_name": "cskill", "_objFlags": 0, "__editorExtras__": {}, "_parent": null, diff --git a/assets/resources/game/heros/skill.prefab.meta b/assets/resources/game/heros/cskill.prefab.meta similarity index 86% rename from assets/resources/game/heros/skill.prefab.meta rename to assets/resources/game/heros/cskill.prefab.meta index d709d494..163cd77d 100644 --- a/assets/resources/game/heros/skill.prefab.meta +++ b/assets/resources/game/heros/cskill.prefab.meta @@ -8,6 +8,6 @@ ], "subMetas": {}, "userData": { - "syncNodeName": "skill" + "syncNodeName": "cskill" } } diff --git a/assets/resources/game/heros/hero.prefab b/assets/resources/game/heros/hero.prefab index 6a941560..fc567dfd 100644 --- a/assets/resources/game/heros/hero.prefab +++ b/assets/resources/game/heros/hero.prefab @@ -34,38 +34,35 @@ "__id__": 55 }, { - "__id__": 63 + "__id__": 67 }, { - "__id__": 75 - }, - { - "__id__": 79 + "__id__": 71 } ], "_active": true, "_components": [ + { + "__id__": 81 + }, + { + "__id__": 83 + }, + { + "__id__": 85 + }, + { + "__id__": 87 + }, { "__id__": 89 }, { "__id__": 91 - }, - { - "__id__": 93 - }, - { - "__id__": 95 - }, - { - "__id__": 97 - }, - { - "__id__": 99 } ], "_prefab": { - "__id__": 101 + "__id__": 93 }, "_lpos": { "__type__": "cc.Vec3", @@ -120,7 +117,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": 3, + "y": 0, "z": 0 }, "_lrot": { @@ -160,13 +157,13 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 54, + "width": 72, "height": 12 }, "_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, - "y": 0.5 + "y": 0 }, "_id": "" }, @@ -263,7 +260,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": 0, + "y": -20, "z": 0 }, "_lrot": { @@ -364,7 +361,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": -23.028, + "y": 0, "z": 0 }, "_lrot": { @@ -496,7 +493,7 @@ "_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, - "y": 0.5 + "y": 0 }, "_id": "" }, @@ -536,8 +533,8 @@ }, "_anchorPoint": { "__type__": "cc.Vec2", - "x": 0.05283504952715698, - "y": 2.541666525933483 + "x": 0.5, + "y": 0 }, "_id": "" }, @@ -1240,186 +1237,6 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": null }, - { - "__type__": "cc.Node", - "_name": "lab_name", - "_objFlags": 0, - "__editorExtras__": {}, - "_parent": { - "__id__": 1 - }, - "_children": [], - "_active": false, - "_components": [ - { - "__id__": 56 - }, - { - "__id__": 58 - }, - { - "__id__": 60 - } - ], - "_prefab": { - "__id__": 62 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": 84.999, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 0, - "z": 0, - "w": 1 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_mobility": 0, - "_layer": 1, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.UITransform", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 55 - }, - "_enabled": true, - "__prefab": { - "__id__": 57 - }, - "_contentSize": { - "__type__": "cc.Size", - "width": 70.84750248055802, - "height": 27.2 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "c68UOAlNhN171Umca6yVvF" - }, - { - "__type__": "cc.Label", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 55 - }, - "_enabled": true, - "__prefab": { - "__id__": 59 - }, - "_customMaterial": null, - "_srcBlendFactor": 2, - "_dstBlendFactor": 4, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_string": "monster", - "_horizontalAlign": 1, - "_verticalAlign": 1, - "_actualFontSize": 18, - "_fontSize": 18, - "_fontFamily": "Arial", - "_lineHeight": 20, - "_overflow": 0, - "_enableWrapText": true, - "_font": null, - "_isSystemFontUsed": true, - "_spacingX": 0, - "_isItalic": true, - "_isBold": false, - "_isUnderline": false, - "_underlineHeight": 2, - "_cacheMode": 0, - "_enableOutline": false, - "_outlineColor": { - "__type__": "cc.Color", - "r": 24, - "g": 25, - "b": 27, - "a": 255 - }, - "_outlineWidth": 1, - "_enableShadow": false, - "_shadowColor": { - "__type__": "cc.Color", - "r": 0, - "g": 0, - "b": 0, - "a": 255 - }, - "_shadowOffset": { - "__type__": "cc.Vec2", - "x": 2, - "y": 2 - }, - "_shadowBlur": 2, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "2frm37uaJHQr0AEEaYyM82" - }, - { - "__type__": "cc.LabelOutline", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 55 - }, - "_enabled": true, - "__prefab": { - "__id__": 61 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "aeeDsd9JVLMK0M/n2WTVl7" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "31uZ7ewvdKoKWqTJ+narWR", - "instance": null, - "targetOverrides": null, - "nestedPrefabInstanceRoots": null - }, { "__type__": "cc.Node", "_name": "level", @@ -1430,20 +1247,20 @@ }, "_children": [ { - "__id__": 64 + "__id__": 56 } ], "_active": false, "_components": [ { - "__id__": 70 + "__id__": 62 }, { - "__id__": 72 + "__id__": 64 } ], "_prefab": { - "__id__": 74 + "__id__": 66 }, "_lpos": { "__type__": "cc.Vec3", @@ -1480,20 +1297,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 63 + "__id__": 55 }, "_children": [], "_active": true, "_components": [ { - "__id__": 65 + "__id__": 57 }, { - "__id__": 67 + "__id__": 59 } ], "_prefab": { - "__id__": 69 + "__id__": 61 }, "_lpos": { "__type__": "cc.Vec3", @@ -1530,11 +1347,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 64 + "__id__": 56 }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 58 }, "_contentSize": { "__type__": "cc.Size", @@ -1558,11 +1375,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 64 + "__id__": 56 }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 60 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1639,11 +1456,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 63 + "__id__": 55 }, "_enabled": true, "__prefab": { - "__id__": 71 + "__id__": 63 }, "_contentSize": { "__type__": "cc.Size", @@ -1667,11 +1484,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 63 + "__id__": 55 }, "_enabled": true, "__prefab": { - "__id__": 73 + "__id__": 65 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1731,11 +1548,11 @@ "_active": true, "_components": [ { - "__id__": 76 + "__id__": 68 } ], "_prefab": { - "__id__": 78 + "__id__": 70 }, "_lpos": { "__type__": "cc.Vec3", @@ -1772,11 +1589,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 75 + "__id__": 67 }, "_enabled": true, "__prefab": { - "__id__": 77 + "__id__": 69 }, "_contentSize": { "__type__": "cc.Size", @@ -1819,20 +1636,20 @@ "_active": true, "_components": [ { - "__id__": 80 + "__id__": 72 }, { - "__id__": 82 + "__id__": 74 }, { - "__id__": 84 + "__id__": 76 }, { - "__id__": 86 + "__id__": 78 } ], "_prefab": { - "__id__": 88 + "__id__": 80 }, "_lpos": { "__type__": "cc.Vec3", @@ -1869,11 +1686,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 79 + "__id__": 71 }, "_enabled": true, "__prefab": { - "__id__": 81 + "__id__": 73 }, "_contentSize": { "__type__": "cc.Size", @@ -1897,11 +1714,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 79 + "__id__": 71 }, "_enabled": true, "__prefab": { - "__id__": 83 + "__id__": 75 }, "enabledContactListener": true, "bullet": true, @@ -1931,11 +1748,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 79 + "__id__": 71 }, "_enabled": true, "__prefab": { - "__id__": 85 + "__id__": 77 }, "tag": 4, "_group": 2, @@ -1946,7 +1763,7 @@ "_offset": { "__type__": "cc.Vec2", "x": 0, - "y": 45 + "y": 50 }, "_size": { "__type__": "cc.Size", @@ -1965,11 +1782,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 79 + "__id__": 71 }, "_enabled": true, "__prefab": { - "__id__": 87 + "__id__": 79 }, "_id": "" }, @@ -1998,9 +1815,9 @@ "node": { "__id__": 1 }, - "_enabled": false, + "_enabled": true, "__prefab": { - "__id__": 90 + "__id__": 82 }, "_contentSize": { "__type__": "cc.Size", @@ -2028,7 +1845,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 92 + "__id__": 84 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2070,7 +1887,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 94 + "__id__": 86 }, "animator": { "__id__": 24 @@ -2091,14 +1908,14 @@ }, "_enabled": true, "__prefab": { - "__id__": 96 + "__id__": 88 }, "hitFlashMaterial": { "__uuid__": "a8f34051-ccff-4050-b9d9-234f62977264", "__expectedType__": "cc.Material" }, "BoxRang": { - "__id__": 79 + "__id__": 71 }, "_id": "" }, @@ -2116,7 +1933,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 98 + "__id__": 90 }, "enabledContactListener": true, "bullet": true, @@ -2150,7 +1967,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 100 + "__id__": 92 }, "tag": 0, "_group": 2, @@ -2161,7 +1978,7 @@ "_offset": { "__type__": "cc.Vec2", "x": 0, - "y": 34.8 + "y": 40 }, "_size": { "__type__": "cc.Size", diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index 02b00100..6db405ec 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -21,16 +21,16 @@ export class SingletonModuleComp extends ecs.Comp { initialize: Initialize = null!; /** 游戏地图 */ map: GameMap = null!; - player_buffs: any = { - 1:{x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y,eid:0}, - 2:{x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y,eid:0}, - 3:{x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y,eid:0}, - 4:{x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y,eid:0}, - 5:{x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y-70,eid:0}, - 6:{x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y-70,eid:0}, - 7:{x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y-70,eid:0}, - 8:{x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y-70,eid:0}, - }; + player_buffs: any = [ + {x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y,eid:0}, + {x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y,eid:0}, + {x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y,eid:0}, + {x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y,eid:0}, + {x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y-70,eid:0}, + {x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y-70,eid:0}, + {x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y-70,eid:0}, + {x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y-70,eid:0}, + ]; monster_buffs: any = []; /** 游戏主角 */ Role: Role = null; diff --git a/assets/script/game/common/config/BoxSet.ts b/assets/script/game/common/config/BoxSet.ts index 3646e241..326a5610 100644 --- a/assets/script/game/common/config/BoxSet.ts +++ b/assets/script/game/common/config/BoxSet.ts @@ -31,6 +31,6 @@ export enum BoxSet { CSKILL_X = 280, CSKILL_Y = 420, //攻击距离 - ATK_RANGE_X = 35, + ATK_RANGE_X = 40, MOVE_RANGE_X = 15, } \ No newline at end of file diff --git a/assets/script/game/map/MapSkillComp.ts b/assets/script/game/map/MapSkillComp.ts index 95099aec..efba94b2 100644 --- a/assets/script/game/map/MapSkillComp.ts +++ b/assets/script/game/map/MapSkillComp.ts @@ -20,12 +20,19 @@ export class MapSkillComp extends CCComp { oops.message.on("do_use_skill", this.doSkill, this); } doSkill(event: string, args: any){ - this.addSkill(args.uuid); + this.addCSkill(args.uuid); } - addSkill(uuid:number=1001){ + addSkill(){ + + } + addCSkill(uuid:number=1001,args:any=null){ let csk =ecs.getEntity(CSkill); let scale = 1 let pos = v3(BoxSet.CSKILL_X*-scale,BoxSet.CSKILL_Y) + if(args){ + pos = v3(args.x,args.y) + scale = args.scale + } csk.load(pos,scale,uuid); } doMonsterLoad(){ diff --git a/assets/script/game/monster/BoxRangComp.ts b/assets/script/game/monster/BoxRangComp.ts index 66e4ccd8..b0de5c73 100644 --- a/assets/script/game/monster/BoxRangComp.ts +++ b/assets/script/game/monster/BoxRangComp.ts @@ -20,7 +20,7 @@ export class BoxRangComp extends CCComp { let collider = this.getComponent(Collider2D); collider.group = this.box_group; collider.tag = this.box_tag; - // collider.offset = v2(this.offset_x,45); + collider.offset = v2(this.offset_x,0); this.Hero_node = this.node.parent; this.MonsterViewComp=this.Hero_node.getComponent(MonsterViewComp); // console.log("range box",this.MonsterViewComp); diff --git a/assets/script/game/monster/CSkill.ts b/assets/script/game/monster/CSkill.ts index 1e8dde4d..4f511de9 100644 --- a/assets/script/game/monster/CSkill.ts +++ b/assets/script/game/monster/CSkill.ts @@ -4,11 +4,13 @@ import { CSkillComp } from "./CSkillComp"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { smc } from "../common/SingletonModuleComp"; import { SkillSet } from "../common/config/SkillSet"; +import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; /** CSkill 模块 */ @ecs.register(`CSkill`) export class CSkill extends ecs.Entity { CSkillView!: CSkillComp; + /** 实始添加的数据层组件 */ protected init() { @@ -28,22 +30,14 @@ export class CSkill extends ecs.Entity { load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001) { // var path = "game/monster/"+prefab_path; // console.log("load skill",this) - var path = "game/heros/skill"; + var path = "game/heros/cskill"; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); var scene = smc.map.MapView.scene; node.parent = scene.entityLayer!.node!; node.getChildByName("skill").setScale(node.getChildByName("skill").scale.x*scale, node.getChildByName("skill").scale.y, node.getChildByName("skill").scale.z); // let cskills = ecs.query(ecs.allOf(CSkillComp)) - for (let index = 1; index <= 8; index++) { - if(smc.player_buffs[index].eid == 0){ - pos.x=smc.player_buffs[index].x - pos.y=smc.player_buffs[index].y - smc.player_buffs[index].eid=this.eid - break - } - - } + pos = this.add_buff() // console.log("load skill",pos,smc.player_buffs) node.setPosition(pos.x*scale,pos.y,pos.z) // console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite)) @@ -56,7 +50,19 @@ export class CSkill extends ecs.Entity { oops.message.dispatchEvent("cskill_load",this) } - + add_buff(){ + let pos = v3(0,0,0) + for (let index = 0; index < 8; index++) { + if(smc.player_buffs[index].eid == 0){ + pos.x=smc.player_buffs[index].x + pos.y=smc.player_buffs[index].y + smc.player_buffs[index].eid=this.eid + break + } + + } + return pos + } skill_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){ var mv = node.getComponent(CSkillComp) mv.scale = 1; diff --git a/assets/script/game/monster/CSkillComp.ts b/assets/script/game/monster/CSkillComp.ts index 5fb55555..6923249f 100644 --- a/assets/script/game/monster/CSkillComp.ts +++ b/assets/script/game/monster/CSkillComp.ts @@ -1,4 +1,4 @@ -import { _decorator,v3,Vec3 } from "cc"; +import { _decorator,v3,Vec3 ,Label} 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 { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; @@ -8,6 +8,7 @@ import { Monster } from "./Monster"; import { MonsterModelComp } from "./MonsterModelComp"; import { MonsterViewComp } from "./MonsterViewComp"; import { BoxSet } from "../common/config/BoxSet"; +import { smc } from "../common/SingletonModuleComp"; const { ccclass, property } = _decorator; /** 视图层对象 */ @@ -18,6 +19,7 @@ export class CSkillComp extends CCComp { private sd:Timer = new Timer(5) private cd:Timer = new Timer(1) private is_destroy:boolean = false; + time:number = 0; scale:number = 1; speed:number = 0; dis:number = 0; @@ -29,6 +31,8 @@ export class CSkillComp extends CCComp { // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象 this.sd =new Timer(SkillSet[this.skill_uuid].sd) this.cd = new Timer(SkillSet[this.skill_uuid].cd) + this.time =SkillSet[this.skill_uuid].sd + this.node.getChildByName("time").getComponent(Label).string = this.time.toString() } protected update(dt: number): void { @@ -39,6 +43,8 @@ export class CSkillComp extends CCComp { this.to_destroy() } if (this.cd.update(dt)) { + this.time -=1 + this.node.getChildByName("time").getComponent(Label).string = this.time.toString() this.shoot() } } @@ -78,6 +84,7 @@ export class CSkillComp extends CCComp { // } to_destroy() { this.is_destroy = true + this.remove_buff() // console.log("CSkillComp toDestroy"); if (this.node.isValid) { // console.log("CSkillComp.node.isValid"); @@ -85,6 +92,14 @@ export class CSkillComp extends CCComp { this.ent.destroy() } } + remove_buff(){ + for (let index = 0; index < 8; index++) { + if(smc.player_buffs[index].eid == this.ent.eid){ + smc.player_buffs[index].eid=0 + break + } + } + } /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ reset() { this.sd.reset() diff --git a/assets/script/game/monster/Hero.ts b/assets/script/game/monster/Hero.ts index 5318d245..4a92e514 100644 --- a/assets/script/game/monster/Hero.ts +++ b/assets/script/game/monster/Hero.ts @@ -45,7 +45,10 @@ export class Hero extends ecs.Entity { var scene = smc.map.MapView.scene; node.parent = scene.entityLayer!.node!; // var as = node.getComponent(MonsterSpine); - + + let ratio=this.set_ratio(uuid); + node.setScale(ratio*node.scale.x, ratio*node.scale.y, node.scale.z); + node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z); node.setPosition(pos) // console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite)) @@ -58,7 +61,26 @@ export class Hero extends ecs.Entity { this.hero_init(uuid,node) oops.message.dispatchEvent("hero_load",this) } - + set_ratio(uuid:number){ + let ratio=1; + switch (smc.heros[uuid].level) { + case 2: + ratio=1.1 + break; + case 3: + ratio=1.2 + break; + case 4: + ratio=1.3 + break; + case 5: + ratio=1.4 + break; + default: + ratio=1 + } + return ratio; + } hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){ var mv = node.getComponent(MonsterViewComp)!; mv.hero_uuid=uuid; diff --git a/assets/script/game/monster/Monster.ts b/assets/script/game/monster/Monster.ts index 90b96450..c007dbd8 100644 --- a/assets/script/game/monster/Monster.ts +++ b/assets/script/game/monster/Monster.ts @@ -45,7 +45,10 @@ export class Monster extends ecs.Entity { var node = instantiate(prefab); node.parent=layer // var as = node.getComponent(MonsterSpine); - node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z); + let ratio=this.set_ratio(uuid); + node.setScale(ratio*node.scale.x*scale, ratio*node.scale.y, node.scale.z); + + // node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z); node.setPosition(pos) // console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite)) const url = 'game/heros/heros'; @@ -56,6 +59,26 @@ export class Monster extends ecs.Entity { this.hero_init(uuid,node) oops.message.dispatchEvent("monster_load",this) } + set_ratio(uuid:number){ + let ratio=1; + switch (smc.heros[uuid].level) { + case 2: + ratio=1.1 + break; + case 3: + ratio=1.2 + break; + case 4: + ratio=1.3 + break; + case 5: + ratio=1.4 + break; + default: + ratio=1 + } + return ratio; + } hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){ var mv = node.getComponent(MonsterViewComp)!; mv.speed =mv.ospeed = smc.heros[uuid].speed; diff --git a/assets/script/game/monster/MonsterViewComp.ts b/assets/script/game/monster/MonsterViewComp.ts index f8369492..d6313606 100644 --- a/assets/script/game/monster/MonsterViewComp.ts +++ b/assets/script/game/monster/MonsterViewComp.ts @@ -76,7 +76,7 @@ export class MonsterViewComp extends CCComp { onLoad() { this.as = this.getComponent(MonsterSpine); - // PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb + PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb // | EPhysics2DDrawFlags.Pair // |EPhysics2DDrawFlags.CenterOfMass // |EPhysics2DDrawFlags.Joint @@ -156,8 +156,8 @@ export class MonsterViewComp extends CCComp { change_name(hero_name:string='hero',scale:number=1){ this.name=hero_name; - let label:any =this.node.getChildByName("lab_name") - label.getComponent(Label)!.string = hero_name; + // let label:any =this.node.getChildByName("lab_name") + // label.getComponent(Label)!.string = hero_name; let collider = this.getComponent(Collider2D); if(scale==1){ collider.group=BoxSet.HERO; @@ -208,7 +208,7 @@ export class MonsterViewComp extends CCComp { // console.log("monster shoot"); let skill = ecs.getEntity(Skill); let x=32 - let pos = v3(this.scale*32,30) + let pos = v3(32,30) let scale = this.scale let speed =SkillSet[skill_uuid].speed; let dis = SkillSet[skill_uuid].dis; diff --git a/assets/script/game/skills/Skill.ts b/assets/script/game/skills/Skill.ts index dc51280c..709fcaf3 100644 --- a/assets/script/game/skills/Skill.ts +++ b/assets/script/game/skills/Skill.ts @@ -34,7 +34,7 @@ export class Skill extends ecs.Entity { var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); node.parent = parent; - node.setScale(scale,1) + // node.setScale(scale,1) //转换pos为世界坐标 node.setPosition(pos) var sv = node.getComponent(SkillCom)!;