This commit is contained in:
2024-09-18 13:59:54 +08:00
parent cd0dc9fe7c
commit 839ccba3de
4 changed files with 111 additions and 277 deletions

View File

@@ -31,38 +31,35 @@
"__id__": 32
},
{
"__id__": 42
"__id__": 43
},
{
"__id__": 53
},
{
"__id__": 64
"__id__": 54
}
],
"_active": true,
"_components": [
{
"__id__": 62
},
{
"__id__": 64
},
{
"__id__": 66
},
{
"__id__": 68
},
{
"__id__": 70
},
{
"__id__": 72
},
{
"__id__": 74
},
{
"__id__": 76
},
{
"__id__": 78
},
{
"__id__": 80
},
{
"__id__": 82
}
],
"_prefab": {
"__id__": 84
"__id__": 74
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -624,189 +621,6 @@
"b4sNQPJWFKha7x75SWXmRj"
]
},
{
"__type__": "cc.Node",
"_name": "range_box",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 33
},
{
"__id__": 35
},
{
"__id__": 37
},
{
"__id__": 39
}
],
"_prefab": {
"__id__": 41
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 50,
"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__": 32
},
"_enabled": true,
"__prefab": {
"__id__": 34
},
"_contentSize": {
"__type__": "cc.Size",
"width": 20,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "a7v65R9FlK35rDSodMKBaf"
},
{
"__type__": "cc.RigidBody2D",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 32
},
"_enabled": true,
"__prefab": {
"__id__": 36
},
"enabledContactListener": true,
"bullet": true,
"awakeOnLoad": true,
"_group": 4,
"_type": 1,
"_allowSleep": false,
"_gravityScale": 0,
"_linearDamping": 0,
"_angularDamping": 0,
"_linearVelocity": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_angularVelocity": 0,
"_fixedRotation": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "1dGvLlJTxIyqWs7tv5eOjk"
},
{
"__type__": "cc.BoxCollider2D",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 32
},
"_enabled": true,
"__prefab": {
"__id__": 38
},
"tag": 4,
"_group": 4,
"_density": 0,
"_sensor": false,
"_friction": 0.2,
"_restitution": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 400,
"y": 40
},
"_size": {
"__type__": "cc.Size",
"width": 800,
"height": 400
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "c1dqgNlJdOJJzLITAnZIRf"
},
{
"__type__": "d67dcRiKwhP4pIsUCUJ9o/0",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 32
},
"_enabled": true,
"__prefab": {
"__id__": 40
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "19lOItKThPfoEWLYvlEf0V"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "efBGnhxpVAs6aCGcg6inWm",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_objFlags": 0,
@@ -814,14 +628,14 @@
"__id__": 1
},
"_prefab": {
"__id__": 43
"__id__": 33
},
"__editorExtras__": {}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 42
"__id__": 32
},
"asset": {
"__uuid__": "50c3d5e4-49f8-4bd7-a15b-cda359a0ae5c",
@@ -829,7 +643,7 @@
},
"fileId": "5fqU0L3/FOhKaco5UkHuWT",
"instance": {
"__id__": 44
"__id__": 34
},
"targetOverrides": null
},
@@ -843,22 +657,22 @@
"mountedComponents": [],
"propertyOverrides": [
{
"__id__": 45
"__id__": 35
},
{
"__id__": 47
"__id__": 37
},
{
"__id__": 48
"__id__": 38
},
{
"__id__": 49
"__id__": 39
},
{
"__id__": 50
"__id__": 40
},
{
"__id__": 51
"__id__": 41
}
],
"removedComponents": []
@@ -866,7 +680,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 46
"__id__": 36
},
"propertyPath": [
"_name"
@@ -882,7 +696,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 46
"__id__": 36
},
"propertyPath": [
"_lpos"
@@ -897,7 +711,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 46
"__id__": 36
},
"propertyPath": [
"_lrot"
@@ -913,7 +727,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 46
"__id__": 36
},
"propertyPath": [
"_euler"
@@ -928,7 +742,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 46
"__id__": 36
},
"propertyPath": [
"_lscale"
@@ -943,7 +757,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 52
"__id__": 42
},
"propertyPath": [
"_active"
@@ -963,14 +777,14 @@
"__id__": 1
},
"_prefab": {
"__id__": 54
"__id__": 44
},
"__editorExtras__": {}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 53
"__id__": 43
},
"asset": {
"__uuid__": "5b4ca49e-0f12-4478-b56d-bf8198b36b90",
@@ -978,7 +792,7 @@
},
"fileId": "0d6ZXmA5dHkZxoGONDL2sE",
"instance": {
"__id__": 55
"__id__": 45
},
"targetOverrides": null
},
@@ -992,22 +806,22 @@
"mountedComponents": [],
"propertyOverrides": [
{
"__id__": 56
"__id__": 46
},
{
"__id__": 58
"__id__": 48
},
{
"__id__": 59
"__id__": 49
},
{
"__id__": 60
"__id__": 50
},
{
"__id__": 61
"__id__": 51
},
{
"__id__": 63
"__id__": 53
}
],
"removedComponents": []
@@ -1015,7 +829,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 57
"__id__": 47
},
"propertyPath": [
"_name"
@@ -1031,7 +845,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 57
"__id__": 47
},
"propertyPath": [
"_lpos"
@@ -1046,7 +860,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 57
"__id__": 47
},
"propertyPath": [
"_lrot"
@@ -1062,7 +876,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 57
"__id__": 47
},
"propertyPath": [
"_euler"
@@ -1077,7 +891,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 62
"__id__": 52
},
"propertyPath": [
"_active"
@@ -1093,7 +907,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 57
"__id__": 47
},
"propertyPath": [
"_active"
@@ -1107,14 +921,14 @@
"__id__": 1
},
"_prefab": {
"__id__": 65
"__id__": 55
},
"__editorExtras__": {}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 64
"__id__": 54
},
"asset": {
"__uuid__": "3e8ca50b-1db9-4996-affc-9d57af3a12d7",
@@ -1122,7 +936,7 @@
},
"fileId": "c46/YsCPVOJYA4mWEpNYRx",
"instance": {
"__id__": 66
"__id__": 56
},
"targetOverrides": null
},
@@ -1136,16 +950,16 @@
"mountedComponents": [],
"propertyOverrides": [
{
"__id__": 67
"__id__": 57
},
{
"__id__": 69
"__id__": 59
},
{
"__id__": 70
"__id__": 60
},
{
"__id__": 71
"__id__": 61
}
],
"removedComponents": []
@@ -1153,7 +967,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 68
"__id__": 58
},
"propertyPath": [
"_name"
@@ -1169,7 +983,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 68
"__id__": 58
},
"propertyPath": [
"_lpos"
@@ -1184,7 +998,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 68
"__id__": 58
},
"propertyPath": [
"_lrot"
@@ -1200,7 +1014,7 @@
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 68
"__id__": 58
},
"propertyPath": [
"_euler"
@@ -1222,7 +1036,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 73
"__id__": 63
},
"_contentSize": {
"__type__": "cc.Size",
@@ -1250,7 +1064,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 75
"__id__": 65
},
"enabledContactListener": true,
"bullet": true,
@@ -1284,7 +1098,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 77
"__id__": 67
},
"tag": 0,
"_group": 4,
@@ -1318,7 +1132,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 79
"__id__": 69
},
"hitFlashMaterial": {
"__uuid__": "a8f34051-ccff-4050-b9d9-234f62977264",
@@ -1328,9 +1142,7 @@
"__uuid__": "adc4e674-6203-42dd-8224-dffb471648a2",
"__expectedType__": "cc.Material"
},
"BoxRang": {
"__id__": 32
},
"BoxRang": null,
"_id": ""
},
{
@@ -1347,7 +1159,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 81
"__id__": 71
},
"_id": ""
},
@@ -1365,7 +1177,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 83
"__id__": 73
},
"_id": ""
},
@@ -1386,13 +1198,13 @@
"targetOverrides": null,
"nestedPrefabInstanceRoots": [
{
"__id__": 64
"__id__": 54
},
{
"__id__": 53
"__id__": 43
},
{
"__id__": 42
"__id__": 32
},
{
"__id__": 16

View File

@@ -21,6 +21,7 @@ import { MoveToComp } from "../common/ecs/position/MoveTo";
import { RoleRangComp } from "./RoleRangComp";
import { Tooltip } from "../skills/Tooltip";
import { MonViewComp } from "../mon/MonViewComp";
import { MonModelComp } from "../mon/MonModelComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -41,6 +42,8 @@ export class RoleViewComp extends CCComp {
is_role:boolean = false;
enemy_pos:Vec3=null!;
enemy:any=null!;
atk_enemy:any=null!;
neraster_enemy:any=null!;
/** 角色动画 */
hero_uuid:number = 1001;
hero_name : string = "role";
@@ -180,10 +183,28 @@ export class RoleViewComp extends CCComp {
this.in_shield(dt);
this.in_stop(dt);
this.in_atk(dt);
this.move();
// this.move();
this.check_enemys()
}
check_enemys(){
let enemys=ecs.query(ecs.allOf(MonViewComp));
if(enemys.length > 0){
let x= 720
for (let i = 0; i < enemys.length; i++) {
let enemy:any = enemys[i];
if(!enemy.MonView) continue
let node=enemy.MonView.node
if(node.isValid){
if(node.position.x < x){
x=node.position.x
this.enemy = node.position;
}
}
}
}else{
this.enemy = v3(720,this.node.position.y);
}
}
move(){
if(this.stop_cd > 0){
return
@@ -222,13 +243,9 @@ export class RoleViewComp extends CCComp {
let pos = v3(0,50)
let t_pos:Vec3 = v3(0,0)
if(this.enemy){
if(!this.enemy.isValid){
console.log("move_to",this.enemy.isValid);
return
}
t_pos = v3(this.enemy.position.x-(this.node.position.x),this.enemy.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)
t_pos = v3(this.enemy.x-this.node.position.x,this.enemy.y-this.node.position.y)
}else{
t_pos=v3(720,BoxSet.GAME_LINE)
t_pos=v3(720,0)
}
return {pos,t_pos}
}
@@ -244,14 +261,19 @@ export class RoleViewComp extends CCComp {
}
in_atk(dt: number) {
if(this.atk_time >= this.atk_cd){
if(this.is_atking&&this.check_enemy_alive()){
this.atk_time = 0;
// console.log("atk_cd:"+this.atk_cd);
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill,-30);
},0.4)
}
// if(this.is_atking&&this.check_enemy_alive()){
// this.atk_time = 0;
// // console.log("atk_cd:"+this.atk_cd);
// this.as.atk();
// this.scheduleOnce(()=>{
// this.shoot(this.skill,-30);
// },0.4)
// }
this.atk_time = 0;
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill,-30);
},0.4)
}else{
this.atk_time += dt;
}

View File

@@ -98,7 +98,7 @@ export class SingletonModuleComp extends ecs.Comp {
role:{
hp:3000,
hp_max:3000,
speed:30,
speed:0,
atk:10,
buff_atk:0,
mission_atk:0,

View File

@@ -174,8 +174,8 @@ export class HeroViewComp extends CCComp {
this.in_atk(dt);
this.hp_show()
// this.in_speek(dt);
// this.move(dt);
this.move_to()
this.move(dt);
// this.move_to()
// if(this.m_timer.update(dt)){
// this.move_to()
// }