This commit is contained in:
2024-08-26 10:14:53 +08:00
parent 4f96558d36
commit 4f64af7848
13 changed files with 176 additions and 286 deletions

View File

@@ -1,7 +1,7 @@
[ [
{ {
"__type__": "cc.Prefab", "__type__": "cc.Prefab",
"_name": "skill", "_name": "cskill",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_native": "", "_native": "",
@@ -13,7 +13,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "skill", "_name": "cskill",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": null, "_parent": null,

View File

@@ -8,6 +8,6 @@
], ],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {
"syncNodeName": "skill" "syncNodeName": "cskill"
} }
} }

View File

@@ -34,38 +34,35 @@
"__id__": 55 "__id__": 55
}, },
{ {
"__id__": 63 "__id__": 67
}, },
{ {
"__id__": 75 "__id__": 71
},
{
"__id__": 79
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{
"__id__": 81
},
{
"__id__": 83
},
{
"__id__": 85
},
{
"__id__": 87
},
{ {
"__id__": 89 "__id__": 89
}, },
{ {
"__id__": 91 "__id__": 91
},
{
"__id__": 93
},
{
"__id__": 95
},
{
"__id__": 97
},
{
"__id__": 99
} }
], ],
"_prefab": { "_prefab": {
"__id__": 101 "__id__": 93
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -120,7 +117,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 3, "y": 0,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -160,13 +157,13 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 54, "width": 72,
"height": 12 "height": 12
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.5, "x": 0.5,
"y": 0.5 "y": 0
}, },
"_id": "" "_id": ""
}, },
@@ -263,7 +260,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": -20,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -364,7 +361,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -23.028, "y": 0,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -496,7 +493,7 @@
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.5, "x": 0.5,
"y": 0.5 "y": 0
}, },
"_id": "" "_id": ""
}, },
@@ -536,8 +533,8 @@
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.05283504952715698, "x": 0.5,
"y": 2.541666525933483 "y": 0
}, },
"_id": "" "_id": ""
}, },
@@ -1240,186 +1237,6 @@
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": 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", "__type__": "cc.Node",
"_name": "level", "_name": "level",
@@ -1430,20 +1247,20 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 64 "__id__": 56
} }
], ],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 70 "__id__": 62
}, },
{ {
"__id__": 72 "__id__": 64
} }
], ],
"_prefab": { "_prefab": {
"__id__": 74 "__id__": 66
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -1480,20 +1297,20 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 63 "__id__": 55
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 65 "__id__": 57
}, },
{ {
"__id__": 67 "__id__": 59
} }
], ],
"_prefab": { "_prefab": {
"__id__": 69 "__id__": 61
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -1530,11 +1347,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 64 "__id__": 56
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 66 "__id__": 58
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1558,11 +1375,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 64 "__id__": 56
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 68 "__id__": 60
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@@ -1639,11 +1456,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 63 "__id__": 55
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 71 "__id__": 63
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1667,11 +1484,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 63 "__id__": 55
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 73 "__id__": 65
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@@ -1731,11 +1548,11 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 76 "__id__": 68
} }
], ],
"_prefab": { "_prefab": {
"__id__": 78 "__id__": 70
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -1772,11 +1589,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 75 "__id__": 67
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 77 "__id__": 69
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1819,20 +1636,20 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 80 "__id__": 72
}, },
{ {
"__id__": 82 "__id__": 74
}, },
{ {
"__id__": 84 "__id__": 76
}, },
{ {
"__id__": 86 "__id__": 78
} }
], ],
"_prefab": { "_prefab": {
"__id__": 88 "__id__": 80
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -1869,11 +1686,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 79 "__id__": 71
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 81 "__id__": 73
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1897,11 +1714,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 79 "__id__": 71
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 83 "__id__": 75
}, },
"enabledContactListener": true, "enabledContactListener": true,
"bullet": true, "bullet": true,
@@ -1931,11 +1748,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 79 "__id__": 71
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 85 "__id__": 77
}, },
"tag": 4, "tag": 4,
"_group": 2, "_group": 2,
@@ -1946,7 +1763,7 @@
"_offset": { "_offset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 0,
"y": 45 "y": 50
}, },
"_size": { "_size": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1965,11 +1782,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 79 "__id__": 71
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 87 "__id__": 79
}, },
"_id": "" "_id": ""
}, },
@@ -1998,9 +1815,9 @@
"node": { "node": {
"__id__": 1 "__id__": 1
}, },
"_enabled": false, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 90 "__id__": 82
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -2028,7 +1845,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 92 "__id__": 84
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@@ -2070,7 +1887,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 94 "__id__": 86
}, },
"animator": { "animator": {
"__id__": 24 "__id__": 24
@@ -2091,14 +1908,14 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 96 "__id__": 88
}, },
"hitFlashMaterial": { "hitFlashMaterial": {
"__uuid__": "a8f34051-ccff-4050-b9d9-234f62977264", "__uuid__": "a8f34051-ccff-4050-b9d9-234f62977264",
"__expectedType__": "cc.Material" "__expectedType__": "cc.Material"
}, },
"BoxRang": { "BoxRang": {
"__id__": 79 "__id__": 71
}, },
"_id": "" "_id": ""
}, },
@@ -2116,7 +1933,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 98 "__id__": 90
}, },
"enabledContactListener": true, "enabledContactListener": true,
"bullet": true, "bullet": true,
@@ -2150,7 +1967,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 100 "__id__": 92
}, },
"tag": 0, "tag": 0,
"_group": 2, "_group": 2,
@@ -2161,7 +1978,7 @@
"_offset": { "_offset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 0,
"y": 34.8 "y": 40
}, },
"_size": { "_size": {
"__type__": "cc.Size", "__type__": "cc.Size",

View File

@@ -21,16 +21,16 @@ export class SingletonModuleComp extends ecs.Comp {
initialize: Initialize = null!; initialize: Initialize = null!;
/** 游戏地图 */ /** 游戏地图 */
map: GameMap = null!; map: GameMap = null!;
player_buffs: any = { player_buffs: any = [
1:{x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y,eid:0}, {x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y,eid:0},
2:{x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y,eid:0}, {x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y,eid:0},
3:{x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y,eid:0}, {x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y,eid:0},
4:{x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y,eid:0}, {x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y,eid:0},
5:{x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y-70,eid:0}, {x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y-70,eid:0},
6:{x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y-70,eid:0}, {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}, {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}, {x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y-70,eid:0},
}; ];
monster_buffs: any = []; monster_buffs: any = [];
/** 游戏主角 */ /** 游戏主角 */
Role: Role = null; Role: Role = null;

View File

@@ -31,6 +31,6 @@ export enum BoxSet {
CSKILL_X = 280, CSKILL_X = 280,
CSKILL_Y = 420, CSKILL_Y = 420,
//攻击距离 //攻击距离
ATK_RANGE_X = 35, ATK_RANGE_X = 40,
MOVE_RANGE_X = 15, MOVE_RANGE_X = 15,
} }

View File

@@ -20,12 +20,19 @@ export class MapSkillComp extends CCComp {
oops.message.on("do_use_skill", this.doSkill, this); oops.message.on("do_use_skill", this.doSkill, this);
} }
doSkill(event: string, args: any){ 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>(CSkill); let csk =ecs.getEntity<CSkill>(CSkill);
let scale = 1 let scale = 1
let pos = v3(BoxSet.CSKILL_X*-scale,BoxSet.CSKILL_Y) 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); csk.load(pos,scale,uuid);
} }
doMonsterLoad(){ doMonsterLoad(){

View File

@@ -20,7 +20,7 @@ export class BoxRangComp extends CCComp {
let collider = this.getComponent(Collider2D); let collider = this.getComponent(Collider2D);
collider.group = this.box_group; collider.group = this.box_group;
collider.tag = this.box_tag; 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.Hero_node = this.node.parent;
this.MonsterViewComp=this.Hero_node.getComponent(MonsterViewComp); this.MonsterViewComp=this.Hero_node.getComponent(MonsterViewComp);
// console.log("range box",this.MonsterViewComp); // console.log("range box",this.MonsterViewComp);

View File

@@ -4,11 +4,13 @@ import { CSkillComp } from "./CSkillComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import { SkillSet } from "../common/config/SkillSet"; import { SkillSet } from "../common/config/SkillSet";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
/** CSkill 模块 */ /** CSkill 模块 */
@ecs.register(`CSkill`) @ecs.register(`CSkill`)
export class CSkill extends ecs.Entity { export class CSkill extends ecs.Entity {
CSkillView!: CSkillComp; CSkillView!: CSkillComp;
/** 实始添加的数据层组件 */ /** 实始添加的数据层组件 */
protected init() { protected init() {
@@ -28,22 +30,14 @@ export class CSkill extends ecs.Entity {
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001) { load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001) {
// var path = "game/monster/"+prefab_path; // var path = "game/monster/"+prefab_path;
// console.log("load skill",this) // console.log("load skill",this)
var path = "game/heros/skill"; var path = "game/heros/cskill";
var prefab: Prefab = oops.res.get(path, Prefab)!; var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab); var node = instantiate(prefab);
var scene = smc.map.MapView.scene; var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!; 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); 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)) // let cskills = ecs.query(ecs.allOf(CSkillComp))
for (let index = 1; index <= 8; index++) { pos = this.add_buff()
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
}
}
// console.log("load skill",pos,smc.player_buffs) // console.log("load skill",pos,smc.player_buffs)
node.setPosition(pos.x*scale,pos.y,pos.z) node.setPosition(pos.x*scale,pos.y,pos.z)
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite)) // 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) 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)){ skill_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(CSkillComp) var mv = node.getComponent(CSkillComp)
mv.scale = 1; mv.scale = 1;

View File

@@ -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 { 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 { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; 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 { 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";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
/** 视图层对象 */ /** 视图层对象 */
@@ -18,6 +19,7 @@ export class CSkillComp extends CCComp {
private sd:Timer = new Timer(5) private sd:Timer = new Timer(5)
private cd:Timer = new Timer(1) private cd:Timer = new Timer(1)
private is_destroy:boolean = false; private is_destroy:boolean = false;
time:number = 0;
scale:number = 1; scale:number = 1;
speed:number = 0; speed:number = 0;
dis:number = 0; dis:number = 0;
@@ -29,6 +31,8 @@ export class CSkillComp extends CCComp {
// 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(SkillSet[this.skill_uuid].sd)
this.cd = new Timer(SkillSet[this.skill_uuid].cd) 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 { protected update(dt: number): void {
@@ -39,6 +43,8 @@ export class CSkillComp extends CCComp {
this.to_destroy() this.to_destroy()
} }
if (this.cd.update(dt)) { if (this.cd.update(dt)) {
this.time -=1
this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
this.shoot() this.shoot()
} }
} }
@@ -78,6 +84,7 @@ export class CSkillComp extends CCComp {
// } // }
to_destroy() { to_destroy() {
this.is_destroy = true this.is_destroy = true
this.remove_buff()
// console.log("CSkillComp toDestroy"); // console.log("CSkillComp toDestroy");
if (this.node.isValid) { if (this.node.isValid) {
// console.log("CSkillComp.node.isValid"); // console.log("CSkillComp.node.isValid");
@@ -85,6 +92,14 @@ export class CSkillComp extends CCComp {
this.ent.destroy() 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) 删除组件是触发组件处理自定义释放逻辑 */ /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() { reset() {
this.sd.reset() this.sd.reset()

View File

@@ -45,7 +45,10 @@ export class Hero extends ecs.Entity {
var scene = smc.map.MapView.scene; var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!; node.parent = scene.entityLayer!.node!;
// var as = node.getComponent(MonsterSpine); // 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.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
node.setPosition(pos) node.setPosition(pos)
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite)) // 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) this.hero_init(uuid,node)
oops.message.dispatchEvent("hero_load",this) 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)){ hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!; var mv = node.getComponent(MonsterViewComp)!;
mv.hero_uuid=uuid; mv.hero_uuid=uuid;

View File

@@ -45,7 +45,10 @@ export class Monster extends ecs.Entity {
var node = instantiate(prefab); var node = instantiate(prefab);
node.parent=layer node.parent=layer
// var as = node.getComponent(MonsterSpine); // 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) node.setPosition(pos)
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite)) // console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
const url = 'game/heros/heros'; const url = 'game/heros/heros';
@@ -56,6 +59,26 @@ export class Monster extends ecs.Entity {
this.hero_init(uuid,node) this.hero_init(uuid,node)
oops.message.dispatchEvent("monster_load",this) 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)){ hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!; var mv = node.getComponent(MonsterViewComp)!;
mv.speed =mv.ospeed = smc.heros[uuid].speed; mv.speed =mv.ospeed = smc.heros[uuid].speed;

View File

@@ -76,7 +76,7 @@ export class MonsterViewComp extends CCComp {
onLoad() { onLoad() {
this.as = this.getComponent(MonsterSpine); this.as = this.getComponent(MonsterSpine);
// PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
// | EPhysics2DDrawFlags.Pair // | EPhysics2DDrawFlags.Pair
// |EPhysics2DDrawFlags.CenterOfMass // |EPhysics2DDrawFlags.CenterOfMass
// |EPhysics2DDrawFlags.Joint // |EPhysics2DDrawFlags.Joint
@@ -156,8 +156,8 @@ export class MonsterViewComp extends CCComp {
change_name(hero_name:string='hero',scale:number=1){ change_name(hero_name:string='hero',scale:number=1){
this.name=hero_name; this.name=hero_name;
let label:any =this.node.getChildByName("lab_name") // let label:any =this.node.getChildByName("lab_name")
label.getComponent(Label)!.string = hero_name; // label.getComponent(Label)!.string = hero_name;
let collider = this.getComponent(Collider2D); let collider = this.getComponent(Collider2D);
if(scale==1){ if(scale==1){
collider.group=BoxSet.HERO; collider.group=BoxSet.HERO;
@@ -208,7 +208,7 @@ export class MonsterViewComp extends CCComp {
// console.log("monster shoot"); // console.log("monster shoot");
let skill = ecs.getEntity<Skill>(Skill); let skill = ecs.getEntity<Skill>(Skill);
let x=32 let x=32
let pos = v3(this.scale*32,30) let pos = v3(32,30)
let scale = this.scale let scale = this.scale
let speed =SkillSet[skill_uuid].speed; let speed =SkillSet[skill_uuid].speed;
let dis = SkillSet[skill_uuid].dis; let dis = SkillSet[skill_uuid].dis;

View File

@@ -34,7 +34,7 @@ export class Skill extends ecs.Entity {
var prefab: Prefab = oops.res.get(path, Prefab)!; var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab); var node = instantiate(prefab);
node.parent = parent; node.parent = parent;
node.setScale(scale,1) // node.setScale(scale,1)
//转换pos为世界坐标 //转换pos为世界坐标
node.setPosition(pos) node.setPosition(pos)
var sv = node.getComponent(SkillCom)!; var sv = node.getComponent(SkillCom)!;