伤害技能添加,技能还需完善

This commit is contained in:
2024-08-26 23:42:38 +08:00
parent 8a44a15153
commit ede4ffd4ca
20 changed files with 1439 additions and 330 deletions

File diff suppressed because one or more lines are too long

View File

@@ -528,13 +528,13 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 15.520000457763672,
"height": 9.600000381469727
"width": 83.13999938964844,
"height": 51.709999084472656
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0
"x": 0.00986288187235107,
"y": 0.3422935810543142
},
"_id": ""
},
@@ -569,7 +569,7 @@
"__expectedType__": "sp.SkeletonData"
},
"defaultSkin": "default",
"defaultAnimation": "move",
"defaultAnimation": "",
"_premultipliedAlpha": false,
"_timeScale": 1,
"_preCacheMode": 1,

View File

@@ -1,6 +1,6 @@
{
"skeleton": {
"hash": "sMfmFw/FfW4",
"hash": "jMvRjm/pTv0",
"spine": "4.2.35",
"x": -0.82,
"y": 24.4,
@@ -64,14 +64,24 @@
}
},
"magic": {
"bones": {
"bone": {
"rotate": [
{},
{ "time": 0.5, "value": 25.28 },
{ "time": 0.6667 }
]
}
}
},
"max": {
"bones": {
"bone": {
"scale": [
{ "x": 0.986, "y": 0.986 },
{ "time": 0.2, "x": 1.153, "y": 0.896 },
{ "time": 0.4, "x": 0.789, "y": 1.085, "curve": "stepped" },
{ "time": 0.5333, "x": 0.789, "y": 1.085 },
{ "time": 0.6667, "x": 0.986, "y": 0.986 }
{},
{ "time": 0.5, "x": 0.789, "y": 0.789 },
{ "time": 0.6667, "x": 1.233, "y": 1.233 },
{ "time": 0.8333, "x": 0.986, "y": 0.986 }
]
}
}
@@ -81,7 +91,8 @@
"bone": {
"scale": [
{},
{ "time": 0.5, "x": 0.937, "y": 0.937 },
{ "time": 0.3333, "x": 1.085, "y": 0.993 },
{ "time": 0.6667, "x": 0.888, "y": 0.986 },
{ "time": 1 }
]
}

View File

@@ -34,35 +34,32 @@
"__id__": 44
},
{
"__id__": 52
},
{
"__id__": 64
"__id__": 56
}
],
"_active": true,
"_components": [
{
"__id__": 60
},
{
"__id__": 62
},
{
"__id__": 64
},
{
"__id__": 66
},
{
"__id__": 68
},
{
"__id__": 70
},
{
"__id__": 72
},
{
"__id__": 74
},
{
"__id__": 76
},
{
"__id__": 78
}
],
"_prefab": {
"__id__": 80
"__id__": 72
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -994,186 +991,6 @@
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "lab_name",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 45
},
{
"__id__": 47
},
{
"__id__": 49
}
],
"_prefab": {
"__id__": 51
},
"_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__": 44
},
"_enabled": true,
"__prefab": {
"__id__": 46
},
"_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__": 44
},
"_enabled": true,
"__prefab": {
"__id__": 48
},
"_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__": 44
},
"_enabled": true,
"__prefab": {
"__id__": 50
},
"_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",
@@ -1184,20 +1001,20 @@
},
"_children": [
{
"__id__": 53
"__id__": 45
}
],
"_active": false,
"_components": [
{
"__id__": 59
"__id__": 51
},
{
"__id__": 61
"__id__": 53
}
],
"_prefab": {
"__id__": 63
"__id__": 55
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -1234,20 +1051,20 @@
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 52
"__id__": 44
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 54
"__id__": 46
},
{
"__id__": 56
"__id__": 48
}
],
"_prefab": {
"__id__": 58
"__id__": 50
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -1284,11 +1101,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 53
"__id__": 45
},
"_enabled": true,
"__prefab": {
"__id__": 55
"__id__": 47
},
"_contentSize": {
"__type__": "cc.Size",
@@ -1312,11 +1129,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 53
"__id__": 45
},
"_enabled": true,
"__prefab": {
"__id__": 57
"__id__": 49
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -1393,11 +1210,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 52
"__id__": 44
},
"_enabled": true,
"__prefab": {
"__id__": 60
"__id__": 52
},
"_contentSize": {
"__type__": "cc.Size",
@@ -1421,11 +1238,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 52
"__id__": 44
},
"_enabled": true,
"__prefab": {
"__id__": 62
"__id__": 54
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -1485,11 +1302,11 @@
"_active": true,
"_components": [
{
"__id__": 65
"__id__": 57
}
],
"_prefab": {
"__id__": 67
"__id__": 59
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -1526,11 +1343,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 64
"__id__": 56
},
"_enabled": true,
"__prefab": {
"__id__": 66
"__id__": 58
},
"_contentSize": {
"__type__": "cc.Size",
@@ -1571,7 +1388,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 69
"__id__": 61
},
"_contentSize": {
"__type__": "cc.Size",
@@ -1599,7 +1416,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 71
"__id__": 63
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -1641,7 +1458,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 73
"__id__": 65
},
"enabledContactListener": true,
"bullet": true,
@@ -1675,7 +1492,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 75
"__id__": 67
},
"tag": 0,
"_group": 4,
@@ -1709,7 +1526,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 77
"__id__": 69
},
"hitFlashMaterial": {
"__uuid__": "a8f34051-ccff-4050-b9d9-234f62977264",
@@ -1731,7 +1548,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 79
"__id__": 71
},
"animator": {
"__id__": 13

View File

@@ -105,8 +105,8 @@
},
"_lscale": {
"__type__": "cc.Vec3",
"x": -1,
"y": 1,
"x": -0.6,
"y": 0.6,
"z": 1
},
"_mobility": 0,
@@ -219,8 +219,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 286,
"height": 90
"width": 120,
"height": 80
},
"_anchorPoint": {
"__type__": "cc.Vec2",

View File

@@ -31,11 +31,14 @@
"_active": true,
"_components": [
{
"__id__": 44
"__id__": 50
},
{
"__id__": 52
}
],
"_prefab": {
"__id__": 46
"__id__": 54
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -903,16 +906,19 @@
"_children": [
{
"__id__": 35
}
],
"_active": false,
"_components": [
},
{
"__id__": 41
}
],
"_active": true,
"_components": [
{
"__id__": 47
}
],
"_prefab": {
"__id__": 43
"__id__": 49
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -1079,6 +1085,165 @@
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "name",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 34
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 42
},
{
"__id__": 44
}
],
"_prefab": {
"__id__": 46
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -37.462,
"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": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 41
},
"_enabled": true,
"__prefab": {
"__id__": 43
},
"_contentSize": {
"__type__": "cc.Size",
"width": 70.68701171875,
"height": 24.16
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "6a3nixJ2FDmLkwcHiNiBIJ"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 41
},
"_enabled": true,
"__prefab": {
"__id__": 45
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_string": "skill name",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 15,
"_fontSize": 15,
"_fontFamily": "Arial",
"_lineHeight": 16,
"_overflow": 0,
"_enableWrapText": true,
"_font": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_enableOutline": true,
"_outlineColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_outlineWidth": 2,
"_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": "4eAxZ8G69HlaWyQeyhIMZ9"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "8cqDZ2t3hCnq/3xIhHn7bG",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
@@ -1089,7 +1254,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 42
"__id__": 48
},
"_contentSize": {
"__type__": "cc.Size",
@@ -1130,7 +1295,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 45
"__id__": 51
},
"_contentSize": {
"__type__": "cc.Size",
@@ -1148,6 +1313,24 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "2fHdG8eeBH07DW0tmYrhH9"
},
{
"__type__": "49ffddtcGlJR7FwYs1yYZ7e",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 53
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "99T6VfhxpBi77UjUnNlL0n"
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@@ -4,7 +4,7 @@
* @LastEditors: dgflash
* @LastEditTime: 2022-08-17 13:43:02
*/
import { profiler, _decorator ,PhysicsSystem2D,RigidBody} from 'cc';
import { profiler, _decorator ,PhysicsSystem2D,EPhysics2DDrawFlags} from 'cc';
import { DEBUG } from 'cc/env';
import { oops } from '../../extensions/oops-plugin-framework/assets/core/Oops';
import { Root } from '../../extensions/oops-plugin-framework/assets/core/Root';
@@ -19,9 +19,12 @@ const { ccclass, property } = _decorator;
export class Main extends Root {
start() {
if (DEBUG) profiler.showStats();
PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
// | EPhysics2DDrawFlags.Pair
// |EPhysics2DDrawFlags.CenterOfMass
// |EPhysics2DDrawFlags.Joint
// |EPhysics2DDrawFlags.Shape;
}
protected async run() {
console.log("Game start");
smc.initialize = ecs.getEntity<Initialize>(Initialize);

View File

@@ -18,7 +18,7 @@ path: 图片地址
*/
export const SkillSet={
1001:{uuid: 1001,path: "1001",type: 1,level: 1,name: "火球术-初级",sp_name:"fire",dis:1720,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,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,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,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,sd:10,cd:1,bsd:10,bcd:1,sk_uuid:1001,sk_count:0,speed:350,},
@@ -66,8 +66,8 @@ export const SkillSet={
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,},
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,},
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,},
9001:{uuid: 9001,path: "9001",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,},
9002:{uuid: 9002,path: "9002",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,},
9003:{uuid: 9003,path: "9003",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,},
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,},
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,},
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,},
}

View File

@@ -29,7 +29,7 @@ export class MapMonsterComp extends CCComp {
cur_mission:number = 1; //当前关卡方案
mission_list:any = []
setp_timer: Timer = new Timer(0.5);
setp_num:number = 1;
setp_num:number = 3;
onLoad(){
// 监听全局事件
oops.message.on("other_add_monster", this.on_other_add_monster, this);

View File

@@ -24,7 +24,6 @@ export class MapViewComp extends CCComp {
async onLoad(){
// 监听全局事件
oops.message.on("do_add_hero", this.on_do_add_hero, this);
}
/**监听do_add_hero 添加hero,通过uuid */

View File

@@ -66,6 +66,8 @@ export class CSkill extends ecs.Entity {
skill_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(CSkillComp)
mv.scale = 1;
mv.skill_uuid = uuid;
mv.atk=SkillSet[uuid].atk;
this.add(mv);
}

View File

@@ -97,10 +97,10 @@ export class Hero extends ecs.Entity {
mv.max_skill_uuid = smc.heros[uuid].max_skill_uuid;
mv.Tpos = v3(0,0,0);
mv.scale = 1;
mv.change_name(smc.heros[uuid].name,1)
// mv.change_name(smc.heros[uuid].name,1)
this.add(mv);
}
}

View File

@@ -94,7 +94,6 @@ export class Monster extends ecs.Entity {
mv.max_skill_uuid = smc.heros[uuid].max_skill_uuid;
mv.scale = -1;
mv.Tpos = v3(0,0,0);
mv.change_name(smc.heros[uuid].name,-1)
this.add(mv);
}

View File

@@ -51,6 +51,9 @@ export class MonsterSpine extends Component {
atk() {
this.spine.setAnimation(0, "atk2", false);
}
maxSkill () {
this.spine.setAnimation(0, "max", false);
}
setAlpha(value: number): void {
var color: Color = this.spine.color;
color.a = 255 * (value / 1);

View File

@@ -32,7 +32,7 @@ export default class MonsterSpineAnimator extends Component {
this.spine.setEndListener(trackEntry => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
// console.log("[track %s][animation %s] end.", trackEntry.trackIndex, animationName);
if (animationName == "atk") {
if (animationName == "atk" ||animationName == "magic"||animationName=="max") {
this.spine.setAnimation(0, "move", true);
}
});

View File

@@ -5,7 +5,7 @@
* @LastEditTime: 2022-08-17 12:36:18
*/
import { Vec3, _decorator , v3,Collider2D,Contact2DType,IPhysics2DContact,PhysicsSystem2D,EPhysics2DDrawFlags,Label,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite} from "cc";
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite} 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 { MonsterSpine } from "./MonsterSpine";
@@ -20,6 +20,7 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
import { SkillCom } from "../skills/SkillCom";
import { SkillSet } from "../common/config/SkillSet";
import { BoxRangComp } from "./BoxRangComp";
import { Tooltip } from "../skills/Tooltip";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -47,7 +48,7 @@ export class MonsterViewComp extends CCComp {
hp_speed: number = 0; //每秒回复量
power: number = 0; /**能量**/
power_max: number = 600*3; /** 能量最大值 */
power_max: number = 60; /** 能量最大值 */
power_speed: number = 1; //能量回复速度每0.1秒回复量
skill_name: string = "base"; //技能名称
@@ -76,11 +77,7 @@ export class MonsterViewComp extends CCComp {
onLoad() {
this.as = this.getComponent(MonsterSpine);
PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
// | EPhysics2DDrawFlags.Pair
// |EPhysics2DDrawFlags.CenterOfMass
// |EPhysics2DDrawFlags.Joint
// |EPhysics2DDrawFlags.Shape;
} /** 视图层逻辑代码分离演示 */
start () {
this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
@@ -105,7 +102,7 @@ export class MonsterViewComp extends CCComp {
}
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D) {
if(otherCollider.tag==BoxSet.SKILL_TAG &&selfCollider.tag!=BoxSet.SKILL_TAG){
if(selfCollider.group != otherCollider.group){
let skill = otherCollider.node.getComponent(SkillCom)!;
@@ -118,20 +115,15 @@ export class MonsterViewComp extends CCComp {
}
}
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
}
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
this.is_atking = true;
this.stop_cd = 0.1;
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
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();
@@ -148,24 +140,9 @@ 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 collider = this.getComponent(Collider2D);
if(scale==1){
collider.group=BoxSet.HERO;
}else{
collider.group=BoxSet.MONSTER;
}
}
update(dt: number){
if (this.timer.update(dt)) {
this.power_change(this.power_speed)
@@ -174,7 +151,6 @@ export class MonsterViewComp extends CCComp {
this.in_stop(dt);
this.in_act(dt);
this.move(dt);
}
@@ -182,23 +158,18 @@ export class MonsterViewComp extends CCComp {
if(this.stop_cd > 0){
return
}
/**
* 根据角色的阵营检查角色的 x 轴位置是否满足特定条件。
* 如果角色属于正向阵营 (scale == 1) 且 x 轴位置大于等于 0则直接返回。
* 如果角色属于反向阵营 (scale != 1) 且 x 轴位置小于等于 0则直接返回。
*/
if (this.scale === 1 && this.node.position.x >= 120) {
return;
}
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y, this.node.position.z);
}
get_monster_pos(){
return this.node.getPosition()
}
power_change(power: number){
this.power += power;
if(this.power >= this.power_max){
this.shoot(this.max_skill_uuid);
this.as.maxSkill()
this.scheduleOnce(()=>{
this.do_max_skill();
},0.5)
this.power = 0
}
let power_progress= this.power/this.power_max;
@@ -208,12 +179,25 @@ export class MonsterViewComp extends CCComp {
// console.log("monster shoot");
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(35,40)
let pos = v3(35*this.scale,40)
let scale = this.scale
let speed =SkillSet[skill_uuid].speed;
let dis = SkillSet[skill_uuid].dis;
let atk = SkillSet[skill_uuid].atk+this.atk;
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk);
// this.tooltip(3,SkillSet[skill_uuid].name,this.skill_uuid);
}
//使用max_skill
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(35*this.scale,40)
let scale = this.scale
let speed =SkillSet[this.max_skill_uuid].speed;
let dis = SkillSet[this.max_skill_uuid].dis;
let atk = SkillSet[this.max_skill_uuid].atk+this.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);
}
in_act(dt: number) {
@@ -235,6 +219,7 @@ export class MonsterViewComp extends CCComp {
return;
}
this.hp -= hp;
this.tooltip(1,hp.toString());
if(this.hp > this.hp_max){
this.hp = this.hp_max;
}
@@ -246,9 +231,19 @@ export class MonsterViewComp extends CCComp {
setTimeout(() => {
this.ent.destroy();
}, 15);
}
}
tooltip(type:number=1,value:string="",s_uuid:number=1001){
// console.log("tooltip",type);
let tip =ecs.getEntity<Tooltip>(Tooltip);
let pos = this.node.getPosition();
let node =this.node.parent
pos.y=pos.y+60;
tip.load(pos,type,value,s_uuid,node);
}
get_monster_pos(){
return this.node.getPosition()
}
/** 静止时间 */
in_stop (dt: number) {
if(this.stop_cd > 0){

View File

@@ -36,7 +36,7 @@ export class Skill extends ecs.Entity {
// console.log("load skill parent.position :",parent.position)
pos=v3(parent.position.x+pos.x,parent.position.y+pos.y)
node.parent = parent.parent;
// node.setScale(scale,1)
node.setScale(scale,1)
//转换pos为世界坐标
node.setPosition(pos)
var sv = node.getComponent(SkillCom)!;

View File

@@ -45,9 +45,9 @@ export class SkillCom extends CCComp {
}
if(this.t_pos){
//通过欧拉角 延长 目标点 增量
this.t_pos.x=Math.cos(this.angle * Math.PI / 180) * this.dis;
this.t_pos.y=Math.sin(this.angle * Math.PI / 180) * this.dis;
tween(this.node).to( 1,{ angle:this.angle,position: this.t_pos},
// this.t_pos.x=Math.cos(this.angle * Math.PI / 180) * this.dis;
// this.t_pos.y=Math.sin(this.angle * Math.PI / 180) * this.dis;
tween(this.node).to( 0.5,{ angle:this.angle,position: this.t_pos},
{
onUpdate: (target: Vec3, ratio: number) => { // onUpdate 接受当前缓动的进度
// 将缓动系统计算出的结果赋予 node 的位置

View File

@@ -29,12 +29,19 @@ export class Tooltip extends ecs.Entity {
this.remove(TooltipCom);
super.destroy();
}
load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",icon:string="") {
load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",s_uuid:number=1001,parent:any=null,cd:number=0.3) {
var path = "game/skills/tooltip";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.parent = parent;
node.setPosition(pos)
var sv = node.getComponent(TooltipCom)!;
// console.log("load tooltip type",type,vaule,s_uuid);
sv.stype = type;
sv.value = vaule;
sv.s_uuid = s_uuid;
sv.alive_time = cd;
this.add(sv)
}
}

View File

@@ -4,6 +4,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { SkillSet } from "../common/config/SkillSet";
const { ccclass, property } = _decorator;
@@ -16,26 +17,35 @@ export class TooltipCom extends CCComp {
// // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// // this.on(ModuleEvent.Cmd, this.onHandler, this);
// }
type:number = 1;
stype:number = 1; // 1:减少生命值2增加生命值3技能图标
value:string = "";
icon:string = "";
alive_time:number = 0.3;
s_uuid:number = 1001;
alive_time:number = 1;
skill_name_time=1;
start() {
switch(this.type){
case 1:
this.node.getChildByName("loss_life").getChildByName("hp").getComponent(Label).string = this.value;
this.node.getChildByName("loss_life").active=true;
case 2:
this.node.getChildByName("add_life").getChildByName("hp").getComponent(Label).string = this.value;
this.node.getChildByName("add_life").active=true;
break
case 3:
resources.load("game/heros/skill/"+this.icon, SpriteFrame, (err, spriteFrame) => {
this.node.getChildByName("skill").getChildByName("icon").getComponent(Sprite).spriteFrame = spriteFrame;
});
this.node.getChildByName("skill").active=true;
break
}
this.node.getChildByName("loss_life").active=false;
this.node.getChildByName("add_life").active=false
this.node.getChildByName("skill").active=false;
// console.log("TooltipView start",this.node);
switch(this.stype){
case 1:
this.node.getChildByName("loss_life").getChildByName("hp").getComponent(Label).string = this.value;
this.node.getChildByName("loss_life").active=true;
break
case 2:
this.node.getChildByName("add_life").getChildByName("hp").getComponent(Label).string = this.value;
this.node.getChildByName("add_life").active=true;
break
case 3:
// resources.load("game/heros/skill/"+SkillSet[this.s_uuid].path, SpriteFrame, (err, 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").active=true;
// this.alive_time = 2
this.node.setPosition(v3(this.node.position.x,this.node.position.y+50))
break
}
}
update(deltaTime: number) {
@@ -44,13 +54,23 @@ export class TooltipCom extends CCComp {
this.alive_time -= deltaTime;
}else{
this.ent.destroy();
}
}
// if(this.skill_name_time >=0){
// this.skill_name_time -= deltaTime;
// }else{
// if(this.node.getChildByName("skill").active== true){
// this.node.getChildByName("skill").getChildByName("name").active=false;
// }
// }
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.getChildByName("loss_life").active=false;
this.node.getChildByName("add_life").active=false;
this.node.getChildByName("skill").active=false;
this.node.destroy();
}
}