增加落点显示

This commit is contained in:
King Wang 2021-12-07 01:00:39 +08:00
parent 4c95908c99
commit 8930b34e38
9 changed files with 489 additions and 208 deletions

View File

@ -18,21 +18,69 @@
"_children": [ "_children": [
{ {
"__id__": 2 "__id__": 2
},
{
"__id__": 13
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 11 "__id__": 18
} }
], ],
"_prefab": { "_prefab": {
"__id__": 13 "__id__": 20
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 1.248, "y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "arrow",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 12
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@ -62,17 +110,17 @@
"_name": "javelin", "_name": "javelin",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 1 "__id__": 2
}, },
"_children": [ "_children": [
{ {
"__id__": 3 "__id__": 4
} }
], ],
"_active": true, "_active": true,
"_components": [], "_components": [],
"_prefab": { "_prefab": {
"__id__": 10 "__id__": 11
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -107,17 +155,17 @@
"_name": "RootNode", "_name": "RootNode",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 2 "__id__": 3
}, },
"_children": [ "_children": [
{ {
"__id__": 4 "__id__": 5
} }
], ],
"_active": true, "_active": true,
"_components": [], "_components": [],
"_prefab": { "_prefab": {
"__id__": 9 "__id__": 10
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -152,17 +200,17 @@
"_name": "对象001", "_name": "对象001",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 3 "__id__": 4
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 5 "__id__": 6
} }
], ],
"_prefab": { "_prefab": {
"__id__": 8 "__id__": 9
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -197,11 +245,11 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 4 "__id__": 5
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 6 "__id__": 7
}, },
"_materials": [ "_materials": [
{ {
@ -211,7 +259,7 @@
], ],
"_visFlags": 0, "_visFlags": 0,
"lightmapSettings": { "lightmapSettings": {
"__id__": 7 "__id__": 8
}, },
"_mesh": { "_mesh": {
"__uuid__": "401c28d6-3085-4209-9f2e-3aff6da5855c@035c0", "__uuid__": "401c28d6-3085-4209-9f2e-3aff6da5855c@035c0",
@ -272,6 +320,121 @@
}, },
"fileId": "e4s27HRhlBboS6EhifyuWl" "fileId": "e4s27HRhlBboS6EhifyuWl"
}, },
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "5bf0LATlNOKYlJWbTsFq/i"
},
{
"__type__": "cc.Node",
"_name": "circle",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 14
}
],
"_prefab": {
"__id__": 17
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0.1,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": -0.7071067811865475,
"y": 0,
"z": 0,
"w": 0.7071067811865476
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 4.7,
"y": 4.7,
"z": 1
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": -90,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.MeshRenderer",
"_name": "Quad<ModelComponent>",
"_objFlags": 0,
"node": {
"__id__": 13
},
"_enabled": true,
"__prefab": {
"__id__": 15
},
"_materials": [
{
"__uuid__": "5bd9794b-bfe1-46e1-b390-6060f1f08992",
"__expectedType__": "cc.Material"
}
],
"_visFlags": 0,
"lightmapSettings": {
"__id__": 16
},
"_mesh": {
"__uuid__": "1263d74c-8167-4928-91a6-4e2672411f47@fc873",
"__expectedType__": "cc.Mesh"
},
"_shadowCastingMode": 0,
"_shadowReceivingMode": 1,
"_enableMorph": true,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "c3HynMn7RK/rmskpx1afpj"
},
{
"__type__": "cc.ModelLightmapSettings",
"texture": null,
"uvParam": {
"__type__": "cc.Vec4",
"x": 0,
"y": 0,
"z": 0,
"w": 0
},
"_bakeable": false,
"_castShadow": false,
"_receiveShadow": false,
"_recieveShadow": false,
"_lightmapSize": 64
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "51HSPesSRFgrKXr9+iQVi5"
},
{ {
"__type__": "2330evjMPtBCJhzJpbQ/Kgk", "__type__": "2330evjMPtBCJhzJpbQ/Kgk",
"_name": "", "_name": "",
@ -282,7 +445,13 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 12 "__id__": 19
},
"arrow": {
"__id__": 2
},
"circle": {
"__id__": 13
}, },
"_id": "" "_id": ""
}, },

View File

@ -1,5 +1,5 @@
import { Component, Vec3, _decorator } from 'cc'; import { Color, Component, MeshRenderer, Node, Vec3, _decorator } from 'cc';
import { MathUtil } from '../../scripts/models/MathUtil'; import { MathUtil } from '../../scripts/models/MathUtil';
import { gameConfig } from '../../scripts/shared/game/gameConfig'; import { gameConfig } from '../../scripts/shared/game/gameConfig';
import { ArrowState } from '../../scripts/shared/game/state/ArrowState'; import { ArrowState } from '../../scripts/shared/game/state/ArrowState';
@ -13,6 +13,11 @@ export class Arrow extends Component {
id!: number; id!: number;
state!: ArrowState; state!: ArrowState;
@property(Node)
arrow!: Node;
@property(Node)
circle!: Node;
// 开始位置(场景坐标) // 开始位置(场景坐标)
private _startPos = new Vec3; private _startPos = new Vec3;
// 落点位置(场景坐标) // 落点位置(场景坐标)
@ -32,6 +37,8 @@ export class Arrow extends Component {
this._endTime = this._startTime + gameConfig.arrowFlyTime; this._endTime = this._startTime + gameConfig.arrowFlyTime;
this._updatePosAndForward(0); this._updatePosAndForward(0);
this.circle.setPosition(this._endPos.x, 0.1, this._endPos.z);
this.circle.getComponent(MeshRenderer)?.material!.setProperty('mainColor', new Color(255, 255, 255, 255));
} }
update() { update() {
@ -51,6 +58,8 @@ export class Arrow extends Component {
} }
this._isRemoved = true; this._isRemoved = true;
this.circle.getComponent(MeshRenderer)?.material!.setProperty('mainColor', new Color(255, 0, 0, 255));
// 落地 1 秒后消失 // 落地 1 秒后消失
this.scheduleOnce(() => { this.scheduleOnce(() => {
this.node.removeFromParent() this.node.removeFromParent()
@ -59,11 +68,11 @@ export class Arrow extends Component {
private _updatePosAndForward(percent: number) { private _updatePosAndForward(percent: number) {
let nextPos = this._getPos(percent); let nextPos = this._getPos(percent);
this.node.position = nextPos; this.arrow.position = nextPos;
//武器朝向下一个目标位置, 形成曲线飞行的感觉 //武器朝向下一个目标位置, 形成曲线飞行的感觉
let lastPos = this._getPos(percent - 0.01) let lastPos = this._getPos(percent - 0.01)
this.node.forward = nextPos.clone().subtract(lastPos).normalize(); this.arrow.forward = nextPos.clone().subtract(lastPos).normalize();
} }
private _getPos(percent: number) { private _getPos(percent: number) {

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "92638561-9d6c-4011-ba3c-c672a78e54f1",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -0,0 +1,40 @@
{
"ver": "1.0.21",
"importer": "image",
"imported": true,
"uuid": "06fa3f81-1aae-4aad-a544-143756df67eb",
"files": [
".png",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "06fa3f81-1aae-4aad-a544-143756df67eb@6c48a",
"displayName": "circle",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
"imageUuidOrDatabaseUri": "06fa3f81-1aae-4aad-a544-143756df67eb"
},
"ver": "1.0.21",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": true,
"type": "texture",
"redirect": "06fa3f81-1aae-4aad-a544-143756df67eb@6c48a"
}
}

View File

@ -0,0 +1,35 @@
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": "1",
"_defines": [
{
"USE_TEXTURE": true
}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"mainTexture": {
"__uuid__": "06fa3f81-1aae-4aad-a544-143756df67eb@6c48a",
"__expectedType__": "cc.Texture2D"
}
}
]
}

View File

@ -0,0 +1,11 @@
{
"ver": "1.0.9",
"importer": "material",
"imported": true,
"uuid": "5bd9794b-bfe1-46e1-b390-6060f1f08992",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -27,17 +27,20 @@
"__id__": 16 "__id__": 16
}, },
{ {
"__id__": 25 "__id__": 17
},
{
"__id__": 50
} }
], ],
"_active": true, "_active": true,
"_components": [], "_components": [],
"_prefab": { "_prefab": {
"__id__": 58 "__id__": 53
}, },
"autoReleaseAssets": false, "autoReleaseAssets": false,
"_globals": { "_globals": {
"__id__": 61 "__id__": 56
}, },
"_id": "0d3889f6-dc9c-424e-b8cd-6fa78d63af15" "_id": "0d3889f6-dc9c-424e-b8cd-6fa78d63af15"
}, },
@ -320,11 +323,7 @@
"_parent": { "_parent": {
"__id__": 1 "__id__": 1
}, },
"_children": [ "_children": [],
{
"__id__": 17
}
],
"_active": true, "_active": true,
"_components": [], "_components": [],
"_prefab": null, "_prefab": null,
@ -356,113 +355,6 @@
}, },
"_id": "46+eJFPoNAd75C26ynMBuo" "_id": "46+eJFPoNAd75C26ynMBuo"
}, },
{
"__type__": "cc.Node",
"_objFlags": 0,
"_parent": {
"__id__": 16
},
"_prefab": {
"__id__": 18
}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 17
},
"asset": {
"__uuid__": "6eda806d-83a6-474f-a7b7-b75c57ba73b3",
"__expectedType__": "cc.Prefab"
},
"fileId": "ad10ECDidH979xbvqlbbgn",
"instance": {
"__id__": 19
}
},
{
"__type__": "cc.PrefabInstance",
"fileId": "f7+AxAbd1K15HySl2cJ7yx",
"mountedChildren": [],
"mountedComponents": [],
"propertyOverrides": [
{
"__id__": 20
},
{
"__id__": 22
},
{
"__id__": 23
},
{
"__id__": 24
}
],
"removedComponents": []
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 21
},
"propertyPath": [
"_name"
],
"value": "Arrow"
},
{
"__type__": "cc.TargetInfo",
"localID": [
"ad10ECDidH979xbvqlbbgn"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 21
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 1.248,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 21
},
"propertyPath": [
"_lrot"
],
"value": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 21
},
"propertyPath": [
"_euler"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Canvas", "_name": "Canvas",
@ -472,28 +364,28 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 26 "__id__": 18
}, },
{ {
"__id__": 28 "__id__": 20
}, },
{ {
"__id__": 45 "__id__": 37
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 54 "__id__": 46
}, },
{ {
"__id__": 55 "__id__": 47
}, },
{ {
"__id__": 56 "__id__": 48
}, },
{ {
"__id__": 57 "__id__": 49
} }
], ],
"_prefab": null, "_prefab": null,
@ -530,13 +422,13 @@
"_name": "Camera", "_name": "Camera",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 25 "__id__": 17
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 27 "__id__": 19
} }
], ],
"_prefab": null, "_prefab": null,
@ -573,7 +465,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 26 "__id__": 18
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -613,16 +505,16 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 25 "__id__": 17
}, },
"_prefab": { "_prefab": {
"__id__": 29 "__id__": 21
} }
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
"__id__": 28 "__id__": 20
}, },
"asset": { "asset": {
"__uuid__": "0363f7f8-204e-410e-ade0-03adca6ea835", "__uuid__": "0363f7f8-204e-410e-ade0-03adca6ea835",
@ -630,7 +522,7 @@
}, },
"fileId": "25fHuwytBN2qk6dH5oVJvO", "fileId": "25fHuwytBN2qk6dH5oVJvO",
"instance": { "instance": {
"__id__": 30 "__id__": 22
} }
}, },
{ {
@ -639,32 +531,32 @@
"mountedChildren": [], "mountedChildren": [],
"mountedComponents": [], "mountedComponents": [],
"propertyOverrides": [ "propertyOverrides": [
{
"__id__": 23
},
{
"__id__": 25
},
{
"__id__": 26
},
{
"__id__": 27
},
{
"__id__": 28
},
{
"__id__": 30
},
{ {
"__id__": 31 "__id__": 31
}, },
{ {
"__id__": 33 "__id__": 33
}, },
{
"__id__": 34
},
{ {
"__id__": 35 "__id__": 35
},
{
"__id__": 36
},
{
"__id__": 38
},
{
"__id__": 39
},
{
"__id__": 41
},
{
"__id__": 43
} }
], ],
"removedComponents": [] "removedComponents": []
@ -672,7 +564,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 32 "__id__": 24
}, },
"propertyPath": [ "propertyPath": [
"_name" "_name"
@ -688,7 +580,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 32 "__id__": 24
}, },
"propertyPath": [ "propertyPath": [
"_lpos" "_lpos"
@ -703,7 +595,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 32 "__id__": 24
}, },
"propertyPath": [ "propertyPath": [
"_lrot" "_lrot"
@ -719,7 +611,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 32 "__id__": 24
}, },
"propertyPath": [ "propertyPath": [
"_euler" "_euler"
@ -734,7 +626,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 37 "__id__": 29
}, },
"propertyPath": [ "propertyPath": [
"_contentSize" "_contentSize"
@ -754,7 +646,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 32 "__id__": 24
}, },
"propertyPath": [ "propertyPath": [
"_layer" "_layer"
@ -764,7 +656,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 40 "__id__": 32
}, },
"propertyPath": [ "propertyPath": [
"_layer" "_layer"
@ -780,7 +672,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 42 "__id__": 34
}, },
"propertyPath": [ "propertyPath": [
"_layer" "_layer"
@ -796,7 +688,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 44 "__id__": 36
}, },
"propertyPath": [ "propertyPath": [
"_layer" "_layer"
@ -814,26 +706,26 @@
"_name": "btnAttack", "_name": "btnAttack",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 25 "__id__": 17
}, },
"_children": [ "_children": [
{ {
"__id__": 46 "__id__": 38
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 49 "__id__": 41
}, },
{ {
"__id__": 50 "__id__": 42
}, },
{ {
"__id__": 51 "__id__": 43
}, },
{ {
"__id__": 53 "__id__": 45
} }
], ],
"_prefab": null, "_prefab": null,
@ -870,16 +762,16 @@
"_name": "Label", "_name": "Label",
"_objFlags": 512, "_objFlags": 512,
"_parent": { "_parent": {
"__id__": 45 "__id__": 37
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 47 "__id__": 39
}, },
{ {
"__id__": 48 "__id__": 40
} }
], ],
"_prefab": null, "_prefab": null,
@ -916,7 +808,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 46 "__id__": 38
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -937,7 +829,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 46 "__id__": 38
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -975,7 +867,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 45 "__id__": 37
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -996,7 +888,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 45 "__id__": 37
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -1035,13 +927,13 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 45 "__id__": 37
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
"clickEvents": [ "clickEvents": [
{ {
"__id__": 52 "__id__": 44
} }
], ],
"_interactable": true, "_interactable": true,
@ -1093,14 +985,14 @@
"_duration": 0.1, "_duration": 0.1,
"_zoomScale": 1.2, "_zoomScale": 1.2,
"_target": { "_target": {
"__id__": 45 "__id__": 37
}, },
"_id": "96d2z2/TpJ558pTlUMNNUO" "_id": "96d2z2/TpJ558pTlUMNNUO"
}, },
{ {
"__type__": "cc.ClickEvent", "__type__": "cc.ClickEvent",
"target": { "target": {
"__id__": 25 "__id__": 17
}, },
"component": "", "component": "",
"_componentId": "d4728cOzxlKHLMu5Xg48U8U", "_componentId": "d4728cOzxlKHLMu5Xg48U8U",
@ -1112,7 +1004,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 45 "__id__": 37
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -1124,7 +1016,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 25 "__id__": 17
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -1145,12 +1037,12 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 25 "__id__": 17
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
"_cameraComponent": { "_cameraComponent": {
"__id__": 27 "__id__": 19
}, },
"_alignCanvasWithScreen": true, "_alignCanvasWithScreen": true,
"_id": "ebX9QTnS1AlKH1eI+/bdJk" "_id": "ebX9QTnS1AlKH1eI+/bdJk"
@ -1160,7 +1052,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 25 "__id__": 17
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -1189,7 +1081,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 25 "__id__": 17
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -1212,33 +1104,123 @@
"__id__": 4 "__id__": 4
}, },
"btnAttack": { "btnAttack": {
"__id__": 45 "__id__": 37
},
"attackPosIndicator": {
"__id__": 50
}, },
"_id": "86PJf2PFRK5LGUONuKqmzS" "_id": "86PJf2PFRK5LGUONuKqmzS"
}, },
{
"__type__": "cc.Node",
"_name": "attackPosIndicator",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 51
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0.1,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": -0.7071067811865475,
"y": 0,
"z": 0,
"w": 0.7071067811865476
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 4.7,
"y": 4.7,
"z": 1
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": -90,
"y": 0,
"z": 0
},
"_id": "fdFAHYRNVNIr2aN7wVD+Nn"
},
{
"__type__": "cc.MeshRenderer",
"_name": "Quad<ModelComponent>",
"_objFlags": 0,
"node": {
"__id__": 50
},
"_enabled": true,
"__prefab": null,
"_materials": [
{
"__uuid__": "5bd9794b-bfe1-46e1-b390-6060f1f08992",
"__expectedType__": "cc.Material"
}
],
"_visFlags": 0,
"lightmapSettings": {
"__id__": 52
},
"_mesh": {
"__uuid__": "1263d74c-8167-4928-91a6-4e2672411f47@fc873",
"__expectedType__": "cc.Mesh"
},
"_shadowCastingMode": 0,
"_shadowReceivingMode": 1,
"_enableMorph": true,
"_id": "6fuuF9XfNLL4/uFd0cFyL+"
},
{
"__type__": "cc.ModelLightmapSettings",
"texture": null,
"uvParam": {
"__type__": "cc.Vec4",
"x": 0,
"y": 0,
"z": 0,
"w": 0
},
"_bakeable": false,
"_castShadow": false,
"_receiveShadow": false,
"_recieveShadow": false,
"_lightmapSize": 64
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"fileId": "", "fileId": "",
"targetOverrides": [ "targetOverrides": [
{ {
"__id__": 59 "__id__": 54
} }
] ]
}, },
{ {
"__type__": "cc.TargetOverrideInfo", "__type__": "cc.TargetOverrideInfo",
"source": { "source": {
"__id__": 57 "__id__": 49
}, },
"sourceInfo": null, "sourceInfo": null,
"propertyPath": [ "propertyPath": [
"joyStick" "joyStick"
], ],
"target": { "target": {
"__id__": 28 "__id__": 20
}, },
"targetInfo": { "targetInfo": {
"__id__": 60 "__id__": 55
} }
}, },
{ {
@ -1250,16 +1232,16 @@
{ {
"__type__": "cc.SceneGlobals", "__type__": "cc.SceneGlobals",
"ambient": { "ambient": {
"__id__": 62 "__id__": 57
}, },
"shadows": { "shadows": {
"__id__": 63 "__id__": 58
}, },
"_skybox": { "_skybox": {
"__id__": 64 "__id__": 59
}, },
"fog": { "fog": {
"__id__": 65 "__id__": 60
} }
}, },
{ {

View File

@ -1,5 +1,5 @@
import { Button, Component, instantiate, Node, Prefab, UIOpacity, Vec2, _decorator } from 'cc'; import { Button, Color, Component, instantiate, MeshRenderer, Node, Prefab, UIOpacity, Vec2, _decorator } from 'cc';
import { Arrow } from '../../prefabs/Arrow/Arrow'; import { Arrow } from '../../prefabs/Arrow/Arrow';
import { Joystick } from '../../prefabs/Joystick/Joystick'; import { Joystick } from '../../prefabs/Joystick/Joystick';
import { Player } from '../../prefabs/Player/Player'; import { Player } from '../../prefabs/Player/Player';
@ -30,6 +30,8 @@ export class GameScene extends Component {
@property(Node) @property(Node)
btnAttack: Node = null as any; btnAttack: Node = null as any;
@property(Node)
attackPosIndicator!: Node;
gameManager!: GameManager; gameManager!: GameManager;
@ -40,6 +42,8 @@ export class GameScene extends Component {
onLoad() { onLoad() {
(window as any).game = this; (window as any).game = this;
this.attackPosIndicator.getComponent(MeshRenderer)!.material!.setProperty('mainColor', Color.CYAN);
// 初始化摇杆 // 初始化摇杆
this.joyStick.options = { this.joyStick.options = {
onOperate: v => { onOperate: v => {
@ -87,6 +91,8 @@ export class GameScene extends Component {
} }
this._updatePlayers(); this._updatePlayers();
this._updateAttackIndicator();
} }
private _updatePlayers() { private _updatePlayers() {
@ -159,6 +165,7 @@ export class GameScene extends Component {
let sceneOffset = playerNode.forward.clone().normalize().multiplyScalar(gameConfig.arrowDistance); let sceneOffset = playerNode.forward.clone().normalize().multiplyScalar(gameConfig.arrowDistance);
// 攻击落点(逻辑层坐标) // 攻击落点(逻辑层坐标)
let targetPos = new Vec2(playerState.pos.x, playerState.pos.y).add2f(sceneOffset.x, -sceneOffset.z); let targetPos = new Vec2(playerState.pos.x, playerState.pos.y).add2f(sceneOffset.x, -sceneOffset.z);
// 发送输入 // 发送输入
this.gameManager.sendClientInput({ this.gameManager.sendClientInput({
type: 'PlayerAttack', type: 'PlayerAttack',
@ -175,4 +182,20 @@ export class GameScene extends Component {
this.btnAttack.getComponent(UIOpacity)!.opacity = 255; this.btnAttack.getComponent(UIOpacity)!.opacity = 255;
}, 1) }, 1)
} }
private _updateAttackIndicator() {
let playerState = this.gameManager.state.players.find(v => v.id === this.gameManager.selfPlayerId);
if (!playerState) {
return;
}
let playerNode = this._playerInstances[this.gameManager.selfPlayerId]?.node;
if (!playerNode) {
return;
}
// 攻击落点位置(表现层坐标)
let sceneTargetPos = playerNode.position.clone().add(playerNode.forward.clone().normalize().multiplyScalar(gameConfig.arrowDistance));
this.attackPosIndicator.setPosition(sceneTargetPos.x, 0.1, sceneTargetPos.z);
}
} }