diff --git a/assets/resources/game/map/map_rpg.prefab b/assets/resources/game/map/map_rpg.prefab index 5c6c7dfd..ab83e7a5 100644 --- a/assets/resources/game/map/map_rpg.prefab +++ b/assets/resources/game/map/map_rpg.prefab @@ -1465,6 +1465,7 @@ "__prefab": { "__id__": 64 }, + "boss": null, "_id": "" }, { diff --git a/assets/resources/game/monster/boss.prefab b/assets/resources/game/monster/boss.prefab index 90598360..aeea9c38 100644 --- a/assets/resources/game/monster/boss.prefab +++ b/assets/resources/game/monster/boss.prefab @@ -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", diff --git a/assets/resources/gui/animation.anim b/assets/resources/gui/animation.anim new file mode 100644 index 00000000..61bb4bf3 --- /dev/null +++ b/assets/resources/gui/animation.anim @@ -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 + } +] \ No newline at end of file diff --git a/assets/resources/gui/animation.anim.meta b/assets/resources/gui/animation.anim.meta new file mode 100644 index 00000000..39c9e9a4 --- /dev/null +++ b/assets/resources/gui/animation.anim.meta @@ -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" + } +} diff --git a/assets/resources/gui/prefab/test.prefab b/assets/resources/gui/prefab/test.prefab new file mode 100644 index 00000000..332f488a --- /dev/null +++ b/assets/resources/gui/prefab/test.prefab @@ -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 + } +] \ No newline at end of file diff --git a/assets/resources/gui/prefab/test.prefab.meta b/assets/resources/gui/prefab/test.prefab.meta new file mode 100644 index 00000000..4daaa47d --- /dev/null +++ b/assets/resources/gui/prefab/test.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.50", + "importer": "prefab", + "imported": true, + "uuid": "1e119ee5-2632-4156-868d-3a10f15db5f6", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "test" + } +} diff --git a/assets/script/Main.ts b/assets/script/Main.ts index ef825604..fca6b1a2 100644 --- a/assets/script/Main.ts +++ b/assets/script/Main.ts @@ -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"); } diff --git a/assets/script/game/common/MoveTo.ts b/assets/script/game/common/MoveTo.ts index d93c65ee..730f0633 100644 --- a/assets/script/game/common/MoveTo.ts +++ b/assets/script/game/common/MoveTo.ts @@ -65,6 +65,7 @@ export class MoveToSystem extends ecs.ComblockSystem implements ecs. entityEnter(e: ecs.Entity): void { e.add(VariableMoveToComponent); + console.log("MoveToSystem entityEnter"); } entityRemove(e: ecs.Entity): void { diff --git a/assets/script/game/map/view/MapViewComp.ts b/assets/script/game/map/view/MapViewComp.ts index 60b1b8b0..5be89c63 100644 --- a/assets/script/game/map/view/MapViewComp.ts +++ b/assets/script/game/map/view/MapViewComp.ts @@ -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.load(v3(360,-60),smc.monsters[0].speed); - // monster.move(v3(0,-60)); - // smc.monsters.splice(0,1) + let monster = ecs.getEntity(Monster); + monster.load(v3(360,-60),smc.monsters[0].speed); + monster.move(v3(0,-60)); + smc.monsters.splice(0,1) } } diff --git a/assets/script/game/monster/Monster.ts b/assets/script/game/monster/Monster.ts index d3447b68..eb247ee2 100644 --- a/assets/script/game/monster/Monster.ts +++ b/assets/script/game/monster/Monster.ts @@ -22,7 +22,7 @@ export class Monster extends ecs.Entity { MonsterModel!: MonsterModelComp; // 视图层 MonsterView!: MonsterViewComp; - RoleMoveTo!: MoveToComp; // 移动 + MoveToComp!: MoveToComp; // 移动 protected init() { this.addComponents( @@ -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) diff --git a/assets/script/game/monster/MonsterViewComp.ts b/assets/script/game/monster/MonsterViewComp.ts index 789186de..a44509f7 100644 --- a/assets/script/game/monster/MonsterViewComp.ts +++ b/assets/script/game/monster/MonsterViewComp.ts @@ -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(); } diff --git a/assets/script/game/monster/bossComp.ts b/assets/script/game/monster/bossComp.ts new file mode 100644 index 00000000..a5fcf26f --- /dev/null +++ b/assets/script/game/monster/bossComp.ts @@ -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); + } +} + + diff --git a/assets/script/game/monster/bossComp.ts.meta b/assets/script/game/monster/bossComp.ts.meta new file mode 100644 index 00000000..9c96295a --- /dev/null +++ b/assets/script/game/monster/bossComp.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "28f753af-37cc-4e46-b100-445408bc547e", + "files": [], + "subMetas": {}, + "userData": {} +}