dd
This commit is contained in:
@@ -1465,6 +1465,7 @@
|
||||
"__prefab": {
|
||||
"__id__": 64
|
||||
},
|
||||
"boss": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
||||
@@ -41,10 +41,16 @@
|
||||
},
|
||||
{
|
||||
"__id__": 36
|
||||
},
|
||||
{
|
||||
"__id__": 38
|
||||
},
|
||||
{
|
||||
"__id__": 40
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 38
|
||||
"__id__": 42
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@@ -250,8 +256,8 @@
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -0.7,
|
||||
"y": 0.7,
|
||||
"x": -0.5,
|
||||
"y": 0.5,
|
||||
"z": 1
|
||||
},
|
||||
"_mobility": 0,
|
||||
@@ -489,7 +495,7 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 56.04296875,
|
||||
"width": 54.6953125,
|
||||
"height": 34.24
|
||||
},
|
||||
"_anchorPoint": {
|
||||
@@ -525,7 +531,7 @@
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_string": "boos",
|
||||
"_string": "boss",
|
||||
"_horizontalAlign": 1,
|
||||
"_verticalAlign": 1,
|
||||
"_actualFontSize": 24,
|
||||
@@ -773,7 +779,7 @@
|
||||
"fileId": "6cDIo6gXFNnbPNuWVAqhBD"
|
||||
},
|
||||
{
|
||||
"__type__": "dc1b7IQTVxHfIHFfWu0u4I/",
|
||||
"__type__": "28f75OvN8xORrEARFQIvFR+",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
@@ -784,11 +790,82 @@
|
||||
"__prefab": {
|
||||
"__id__": 37
|
||||
},
|
||||
"speed": 0,
|
||||
"ospeed": 0,
|
||||
"timer": 0,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "88a6VdbQBB7YwXovYCN2Sy"
|
||||
"fileId": "f62tOwBpxKm4MpLsPbCKG0"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RigidBody2D",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 39
|
||||
},
|
||||
"enabledContactListener": true,
|
||||
"bullet": true,
|
||||
"awakeOnLoad": true,
|
||||
"_group": 2,
|
||||
"_type": 1,
|
||||
"_allowSleep": false,
|
||||
"_gravityScale": 1,
|
||||
"_linearDamping": 0,
|
||||
"_angularDamping": 0,
|
||||
"_linearVelocity": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_angularVelocity": 0,
|
||||
"_fixedRotation": false,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "bdqz3JXMRNc5Yad+RGJR82"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.BoxCollider2D",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 41
|
||||
},
|
||||
"tag": 0,
|
||||
"_group": 2,
|
||||
"_density": 1,
|
||||
"_sensor": true,
|
||||
"_friction": 0.2,
|
||||
"_restitution": 0,
|
||||
"_offset": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_size": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 100,
|
||||
"height": 100
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "d1DRpMW/VNg72wJ/w04vVK"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
|
||||
192
assets/resources/gui/animation.anim
Normal file
192
assets/resources/gui/animation.anim
Normal file
@@ -0,0 +1,192 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.AnimationClip",
|
||||
"_name": "animation",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {
|
||||
"embeddedPlayerGroups": []
|
||||
},
|
||||
"_native": "",
|
||||
"sample": 60,
|
||||
"speed": 1,
|
||||
"wrapMode": 2,
|
||||
"enableTrsBlending": false,
|
||||
"_duration": 0.3333333333333333,
|
||||
"_hash": 500763545,
|
||||
"_tracks": [
|
||||
{
|
||||
"__id__": 1
|
||||
}
|
||||
],
|
||||
"_exoticAnimation": null,
|
||||
"_events": [],
|
||||
"_embeddedPlayers": [],
|
||||
"_additiveSettings": {
|
||||
"__id__": 11
|
||||
},
|
||||
"_auxiliaryCurveEntries": []
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.VectorTrack",
|
||||
"_binding": {
|
||||
"__type__": "cc.animation.TrackBinding",
|
||||
"path": {
|
||||
"__id__": 2
|
||||
},
|
||||
"proxy": null
|
||||
},
|
||||
"_channels": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
},
|
||||
{
|
||||
"__id__": 7
|
||||
},
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_nComponents": 3
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.TrackPath",
|
||||
"_paths": [
|
||||
"position"
|
||||
]
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.Channel",
|
||||
"_curve": {
|
||||
"__id__": 4
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealCurve",
|
||||
"_times": [
|
||||
0
|
||||
],
|
||||
"_values": [
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 0,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": null
|
||||
}
|
||||
],
|
||||
"preExtrapolation": 1,
|
||||
"postExtrapolation": 1
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.Channel",
|
||||
"_curve": {
|
||||
"__id__": 6
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealCurve",
|
||||
"_times": [
|
||||
0,
|
||||
0.1666666716337204,
|
||||
0.3333333432674408
|
||||
],
|
||||
"_values": [
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 0,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 30,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": {
|
||||
"tangentMode": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 0,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": {
|
||||
"tangentMode": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"preExtrapolation": 1,
|
||||
"postExtrapolation": 1
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.Channel",
|
||||
"_curve": {
|
||||
"__id__": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealCurve",
|
||||
"_times": [
|
||||
0
|
||||
],
|
||||
"_values": [
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 0,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": null
|
||||
}
|
||||
],
|
||||
"preExtrapolation": 1,
|
||||
"postExtrapolation": 1
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.Channel",
|
||||
"_curve": {
|
||||
"__id__": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealCurve",
|
||||
"_times": [],
|
||||
"_values": [],
|
||||
"preExtrapolation": 1,
|
||||
"postExtrapolation": 1
|
||||
},
|
||||
{
|
||||
"__type__": "cc.AnimationClipAdditiveSettings",
|
||||
"enabled": false,
|
||||
"refClip": null
|
||||
}
|
||||
]
|
||||
13
assets/resources/gui/animation.anim.meta
Normal file
13
assets/resources/gui/animation.anim.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"ver": "2.0.3",
|
||||
"importer": "animation-clip",
|
||||
"imported": true,
|
||||
"uuid": "9fbb4e9a-8a4f-42b0-b402-4f56823ca4af",
|
||||
"files": [
|
||||
".cconb"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"name": "animation"
|
||||
}
|
||||
}
|
||||
270
assets/resources/gui/prefab/test.prefab
Normal file
270
assets/resources/gui/prefab/test.prefab
Normal file
@@ -0,0 +1,270 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.Prefab",
|
||||
"_name": "test",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_native": "",
|
||||
"data": {
|
||||
"__id__": 1
|
||||
},
|
||||
"optimizationPolicy": 0,
|
||||
"persistent": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "test",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": null,
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 2
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 10
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 12
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 1000
|
||||
},
|
||||
"_lrot": {
|
||||
"__type__": "cc.Quat",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0.2,
|
||||
"y": 0.2,
|
||||
"z": 1
|
||||
},
|
||||
"_mobility": 0,
|
||||
"_layer": 1,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "button_play",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
},
|
||||
{
|
||||
"__id__": 7
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 9
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"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
|
||||
},
|
||||
"_mobility": 0,
|
||||
"_layer": 1,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 4
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 331,
|
||||
"height": 329
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "ed+rjPiRhN6biuG33DpnYa"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
"_dstBlendFactor": 4,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "ffdf7637-e3aa-4245-9076-52371fdea4a0@f9941",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
},
|
||||
"_type": 0,
|
||||
"_fillType": 0,
|
||||
"_sizeMode": 1,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_useGrayscale": false,
|
||||
"_atlas": null,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "68JjUi3dNAfqmwo/cOIOkH"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Animation",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 8
|
||||
},
|
||||
"playOnLoad": false,
|
||||
"_clips": [
|
||||
{
|
||||
"__uuid__": "9fbb4e9a-8a4f-42b0-b402-4f56823ca4af",
|
||||
"__expectedType__": "cc.AnimationClip"
|
||||
}
|
||||
],
|
||||
"_defaultClip": {
|
||||
"__uuid__": "9fbb4e9a-8a4f-42b0-b402-4f56823ca4af",
|
||||
"__expectedType__": "cc.AnimationClip"
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "94PhhWc6RKxIQf1IOpvNyM"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "4f2sOPyA1EZZeFBJ/GDDS1",
|
||||
"instance": null,
|
||||
"targetOverrides": null,
|
||||
"nestedPrefabInstanceRoots": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 11
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 100,
|
||||
"height": 100
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "03zhvTa1JEPaRq8Bc5S65V"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__id__": 0
|
||||
},
|
||||
"fileId": "10RCPwc6NPRJ5H55CCc70U",
|
||||
"targetOverrides": null
|
||||
}
|
||||
]
|
||||
13
assets/resources/gui/prefab/test.prefab.meta
Normal file
13
assets/resources/gui/prefab/test.prefab.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"ver": "1.1.50",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "1e119ee5-2632-4156-868d-3a10f15db5f6",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "test"
|
||||
}
|
||||
}
|
||||
@@ -31,9 +31,9 @@ export class Main extends Root {
|
||||
]
|
||||
smc.heros = [
|
||||
{profession:'war',speed:50},
|
||||
{profession:'magic',speed:50},
|
||||
{profession:'heath',speed:50},
|
||||
{profession:'war',speed:50},
|
||||
// {profession:'magic',speed:50},
|
||||
// {profession:'heath',speed:50},
|
||||
// {profession:'war',speed:50},
|
||||
]
|
||||
console.log("Game start");
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ export class MoveToSystem extends ecs.ComblockSystem<ecs.Entity> implements ecs.
|
||||
|
||||
entityEnter(e: ecs.Entity): void {
|
||||
e.add(VariableMoveToComponent);
|
||||
console.log("MoveToSystem entityEnter");
|
||||
}
|
||||
|
||||
entityRemove(e: ecs.Entity): void {
|
||||
|
||||
@@ -15,7 +15,8 @@ const { ccclass, property } = _decorator;
|
||||
@ecs.register('MapView', false)
|
||||
export class MapViewComp extends CCComp {
|
||||
scene: MapViewScene = null!;
|
||||
|
||||
@property(Prefab)
|
||||
boss: Prefab = null!;
|
||||
/** 是否正在转场 */
|
||||
|
||||
|
||||
@@ -23,7 +24,7 @@ export class MapViewComp extends CCComp {
|
||||
current_map: any;
|
||||
/** 转场碰撞点对象集合 */
|
||||
|
||||
private timer: Timer = new Timer(2);
|
||||
private timer: Timer = new Timer(3);
|
||||
onLoad(){
|
||||
// 监听全局事件
|
||||
oops.message.on("monster_load", this.onMonsterLoaded, this);
|
||||
@@ -63,18 +64,12 @@ export class MapViewComp extends CCComp {
|
||||
}
|
||||
|
||||
if (smc.monsters.length>0){
|
||||
var path = "game/monster/monster";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
var scene = smc.map.MapView.scene;
|
||||
node.parent = scene.entityLayer!.node!;
|
||||
node.setPosition(v3(360,-60))
|
||||
this.node.addChild(node);
|
||||
|
||||
// let monster = ecs.getEntity<Monster>(Monster);
|
||||
// monster.load(v3(360,-60),smc.monsters[0].speed);
|
||||
// monster.move(v3(0,-60));
|
||||
// smc.monsters.splice(0,1)
|
||||
|
||||
let monster = ecs.getEntity<Monster>(Monster);
|
||||
monster.load(v3(360,-60),smc.monsters[0].speed);
|
||||
monster.move(v3(0,-60));
|
||||
smc.monsters.splice(0,1)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export class Monster extends ecs.Entity {
|
||||
MonsterModel!: MonsterModelComp;
|
||||
// 视图层
|
||||
MonsterView!: MonsterViewComp;
|
||||
RoleMoveTo!: MoveToComp; // 移动
|
||||
MoveToComp!: MoveToComp; // 移动
|
||||
|
||||
protected init() {
|
||||
this.addComponents<ecs.Comp>(
|
||||
@@ -46,10 +46,8 @@ export class Monster extends ecs.Entity {
|
||||
node.setPosition(pos)
|
||||
|
||||
var mv = node.getComponent(MonsterViewComp)!;
|
||||
mv.speed = speed;
|
||||
mv.ospeed = speed;
|
||||
mv.Tpos = v3(0,0,0);
|
||||
// this.add(mv);
|
||||
|
||||
this.add(mv);
|
||||
smc.monsters_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0}),
|
||||
// node.setScale(-1, 1, 1);
|
||||
oops.message.dispatchEvent("monster_load",this)
|
||||
|
||||
@@ -28,37 +28,14 @@ export class MonsterViewComp extends CCComp {
|
||||
timer: number = 0;
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start () {
|
||||
// 注册单个碰撞体的回调函数
|
||||
// console.log('MonsterViewComp start');
|
||||
let collider = this.getComponent(Collider2D);
|
||||
// console.log('Monster collider',collider);
|
||||
if (collider) {
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 注册全局碰撞回调函数
|
||||
if (PhysicsSystem2D.instance) {
|
||||
// console.log('PhysicsSystem2D.instance');
|
||||
PhysicsSystem2D.instance.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
}
|
||||
}
|
||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
// 只在两个碰撞体开始接触时被调用一次
|
||||
// console.log('monster Contact,otherCollider',otherCollider);
|
||||
this.speed = 0;
|
||||
this.timer = 1;
|
||||
switch (otherCollider.group) {
|
||||
case BoxSet.HERO_SKILL:
|
||||
// console.log('monster coolider hero skill');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
this.as = this.getComponent(MonsterSpine);
|
||||
console.log('this.ospeed:',this);
|
||||
console.log('this.ent:',this);
|
||||
}
|
||||
|
||||
update(dt: number){
|
||||
@@ -72,7 +49,7 @@ export class MonsterViewComp extends CCComp {
|
||||
if(this.node.position.x > -360){
|
||||
this.move(dt);
|
||||
}
|
||||
if(this.node.position.x < -360){
|
||||
if(this.node.position.x < -300){
|
||||
smc.monsters_in = smc.monsters_in.filter(element => element.eid !== this.ent.eid);
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
62
assets/script/game/monster/bossComp.ts
Normal file
62
assets/script/game/monster/bossComp.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { _decorator, Component, Node,Collider2D ,Contact2DType,PhysicsSystem2D,IPhysics2DContact} from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('bossCom')
|
||||
export class bossCom extends Component {
|
||||
@property(Number)
|
||||
private speed: number = 100;
|
||||
@property(Number)
|
||||
private ospeed: number = 100;
|
||||
@property(Number)
|
||||
private timer: number = 0;
|
||||
|
||||
protected onLoad(): void {
|
||||
this.speed = this.ospeed = 100;
|
||||
}
|
||||
start () {
|
||||
// 注册单个碰撞体的回调函数
|
||||
// console.log('MonsterViewComp start');
|
||||
let collider = this.getComponent(Collider2D);
|
||||
// console.log('Monster collider',collider);
|
||||
if (collider) {
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
}
|
||||
|
||||
// 注册全局碰撞回调函数
|
||||
if (PhysicsSystem2D.instance) {
|
||||
// console.log('PhysicsSystem2D.instance');
|
||||
PhysicsSystem2D.instance.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
}
|
||||
}
|
||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
// 只在两个碰撞体开始接触时被调用一次
|
||||
// console.log('monster Contact,otherCollider',otherCollider);
|
||||
this.speed = 0;
|
||||
this.timer = 1;
|
||||
|
||||
}
|
||||
|
||||
update(dt: number){
|
||||
if(this.timer > 0){
|
||||
this.timer -= dt;
|
||||
if(this.timer <= 0){
|
||||
this.speed = this.ospeed;
|
||||
this.timer = 0;
|
||||
}
|
||||
}
|
||||
if(this.node.position.x > -360){
|
||||
this.move(dt);
|
||||
}
|
||||
if(this.node.position.x < -360){
|
||||
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
move(dt: number){
|
||||
this.node.setPosition(this.node.position.x-dt*this.speed, this.node.position.y, this.node.position.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
assets/script/game/monster/bossComp.ts.meta
Normal file
9
assets/script/game/monster/bossComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "28f753af-37cc-4e46-b100-445408bc547e",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user