dd
This commit is contained in:
@@ -732,7 +732,7 @@
|
|||||||
"a": 255
|
"a": 255
|
||||||
},
|
},
|
||||||
"_spriteFrame": {
|
"_spriteFrame": {
|
||||||
"__uuid__": "475189e3-a159-45bc-90f5-57864087d290@1b1f2",
|
"__uuid__": "f87f53f9-2fba-4a5b-968a-79a593311ab2@1b1f2",
|
||||||
"__expectedType__": "cc.SpriteFrame"
|
"__expectedType__": "cc.SpriteFrame"
|
||||||
},
|
},
|
||||||
"_type": 1,
|
"_type": 1,
|
||||||
@@ -1168,7 +1168,7 @@
|
|||||||
"a": 255
|
"a": 255
|
||||||
},
|
},
|
||||||
"_spriteFrame": {
|
"_spriteFrame": {
|
||||||
"__uuid__": "475189e3-a159-45bc-90f5-57864087d290@5d1ce",
|
"__uuid__": "f87f53f9-2fba-4a5b-968a-79a593311ab2@5d1ce",
|
||||||
"__expectedType__": "cc.SpriteFrame"
|
"__expectedType__": "cc.SpriteFrame"
|
||||||
},
|
},
|
||||||
"_type": 1,
|
"_type": 1,
|
||||||
|
|||||||
@@ -1473,7 +1473,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.Node",
|
"__type__": "cc.Node",
|
||||||
"_name": "Label",
|
"_name": "level",
|
||||||
"_objFlags": 0,
|
"_objFlags": 0,
|
||||||
"__editorExtras__": {},
|
"__editorExtras__": {},
|
||||||
"_parent": {
|
"_parent": {
|
||||||
@@ -1626,6 +1626,8 @@
|
|||||||
"__id__": 0
|
"__id__": 0
|
||||||
},
|
},
|
||||||
"fileId": "f8+NJtzJRC/ZYoN9vBdj6F",
|
"fileId": "f8+NJtzJRC/ZYoN9vBdj6F",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
"nestedPrefabInstanceRoots": null
|
"nestedPrefabInstanceRoots": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -142,8 +142,8 @@
|
|||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 93,
|
"width": 113,
|
||||||
"height": 93
|
"height": 113
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
@@ -240,8 +240,8 @@
|
|||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 47.5,
|
"x": 57.5,
|
||||||
"y": 47.5,
|
"y": 57.5,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -253,8 +253,8 @@
|
|||||||
},
|
},
|
||||||
"_lscale": {
|
"_lscale": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0.7,
|
"x": 1,
|
||||||
"y": 0.7,
|
"y": 1,
|
||||||
"z": 1
|
"z": 1
|
||||||
},
|
},
|
||||||
"_mobility": 0,
|
"_mobility": 0,
|
||||||
@@ -447,8 +447,8 @@
|
|||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 47.5,
|
"x": 57.5,
|
||||||
"y": 47.5,
|
"y": 57.5,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -538,8 +538,8 @@
|
|||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 127,
|
"width": 147,
|
||||||
"height": 127
|
"height": 147
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
@@ -679,7 +679,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 10,
|
"x": 10,
|
||||||
"y": 85,
|
"y": 105,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -980,8 +980,8 @@
|
|||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 10,
|
"x": 5,
|
||||||
"y": 120,
|
"y": 140,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -1180,8 +1180,8 @@
|
|||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 70,
|
"width": 80,
|
||||||
"height": 40
|
"height": 60
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
@@ -1290,18 +1290,9 @@
|
|||||||
"__uuid__": "f87f53f9-2fba-4a5b-968a-79a593311ab2@1b1f2",
|
"__uuid__": "f87f53f9-2fba-4a5b-968a-79a593311ab2@1b1f2",
|
||||||
"__expectedType__": "cc.SpriteFrame"
|
"__expectedType__": "cc.SpriteFrame"
|
||||||
},
|
},
|
||||||
"_hoverSprite": {
|
"_hoverSprite": null,
|
||||||
"__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941",
|
"_pressedSprite": null,
|
||||||
"__expectedType__": "cc.SpriteFrame"
|
"_disabledSprite": null,
|
||||||
},
|
|
||||||
"_pressedSprite": {
|
|
||||||
"__uuid__": "544e49d6-3f05-4fa8-9a9e-091f98fc2ce8@f9941",
|
|
||||||
"__expectedType__": "cc.SpriteFrame"
|
|
||||||
},
|
|
||||||
"_disabledSprite": {
|
|
||||||
"__uuid__": "951249e0-9f16-456d-8b85-a6ca954da16b@f9941",
|
|
||||||
"__expectedType__": "cc.SpriteFrame"
|
|
||||||
},
|
|
||||||
"_duration": 0.1,
|
"_duration": 0.1,
|
||||||
"_zoomScale": 1.2,
|
"_zoomScale": 1.2,
|
||||||
"_target": {
|
"_target": {
|
||||||
@@ -1366,8 +1357,8 @@
|
|||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 80,
|
"x": 85,
|
||||||
"y": 120,
|
"y": 140,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -1566,8 +1557,8 @@
|
|||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 70,
|
"width": 80,
|
||||||
"height": 40
|
"height": 60
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
@@ -1713,8 +1704,8 @@
|
|||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 95,
|
"width": 115,
|
||||||
"height": 95
|
"height": 115
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
|
|||||||
@@ -347,10 +347,10 @@
|
|||||||
"height": 108,
|
"height": 108,
|
||||||
"rawWidth": 109,
|
"rawWidth": 109,
|
||||||
"rawHeight": 108,
|
"rawHeight": 108,
|
||||||
"borderTop": 0,
|
"borderTop": 25,
|
||||||
"borderBottom": 0,
|
"borderBottom": 29,
|
||||||
"borderLeft": 0,
|
"borderLeft": 26,
|
||||||
"borderRight": 0,
|
"borderRight": 24,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"pixelsToUnit": 100,
|
"pixelsToUnit": 100,
|
||||||
"pivotX": 0.5,
|
"pivotX": 0.5,
|
||||||
@@ -1313,10 +1313,10 @@
|
|||||||
"height": 168,
|
"height": 168,
|
||||||
"rawWidth": 466,
|
"rawWidth": 466,
|
||||||
"rawHeight": 216,
|
"rawHeight": 216,
|
||||||
"borderTop": 0,
|
"borderTop": 48,
|
||||||
"borderBottom": 0,
|
"borderBottom": 48,
|
||||||
"borderLeft": 0,
|
"borderLeft": 43,
|
||||||
"borderRight": 0,
|
"borderRight": 43,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"pixelsToUnit": 100,
|
"pixelsToUnit": 100,
|
||||||
"pivotX": 0.5,
|
"pivotX": 0.5,
|
||||||
@@ -1405,10 +1405,10 @@
|
|||||||
"height": 168,
|
"height": 168,
|
||||||
"rawWidth": 466,
|
"rawWidth": 466,
|
||||||
"rawHeight": 216,
|
"rawHeight": 216,
|
||||||
"borderTop": 0,
|
"borderTop": 41,
|
||||||
"borderBottom": 0,
|
"borderBottom": 36,
|
||||||
"borderLeft": 0,
|
"borderLeft": 44,
|
||||||
"borderRight": 0,
|
"borderRight": 47,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"pixelsToUnit": 100,
|
"pixelsToUnit": 100,
|
||||||
"pivotX": 0.5,
|
"pivotX": 0.5,
|
||||||
@@ -1635,10 +1635,10 @@
|
|||||||
"height": 79,
|
"height": 79,
|
||||||
"rawWidth": 93,
|
"rawWidth": 93,
|
||||||
"rawHeight": 95,
|
"rawHeight": 95,
|
||||||
"borderTop": 0,
|
"borderTop": 21,
|
||||||
"borderBottom": 0,
|
"borderBottom": 22,
|
||||||
"borderLeft": 0,
|
"borderLeft": 17,
|
||||||
"borderRight": 0,
|
"borderRight": 16,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"pixelsToUnit": 100,
|
"pixelsToUnit": 100,
|
||||||
"pivotX": 0.5,
|
"pivotX": 0.5,
|
||||||
@@ -2417,10 +2417,10 @@
|
|||||||
"height": 97,
|
"height": 97,
|
||||||
"rawWidth": 97,
|
"rawWidth": 97,
|
||||||
"rawHeight": 97,
|
"rawHeight": 97,
|
||||||
"borderTop": 0,
|
"borderTop": 23,
|
||||||
"borderBottom": 0,
|
"borderBottom": 20,
|
||||||
"borderLeft": 0,
|
"borderLeft": 20,
|
||||||
"borderRight": 0,
|
"borderRight": 22,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"pixelsToUnit": 100,
|
"pixelsToUnit": 100,
|
||||||
"pivotX": 0.5,
|
"pivotX": 0.5,
|
||||||
@@ -2969,10 +2969,10 @@
|
|||||||
"height": 109,
|
"height": 109,
|
||||||
"rawWidth": 111,
|
"rawWidth": 111,
|
||||||
"rawHeight": 109,
|
"rawHeight": 109,
|
||||||
"borderTop": 0,
|
"borderTop": 23,
|
||||||
"borderBottom": 0,
|
"borderBottom": 24,
|
||||||
"borderLeft": 0,
|
"borderLeft": 24,
|
||||||
"borderRight": 0,
|
"borderRight": 26,
|
||||||
"packable": true,
|
"packable": true,
|
||||||
"pixelsToUnit": 100,
|
"pixelsToUnit": 100,
|
||||||
"pivotX": 0.5,
|
"pivotX": 0.5,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2022-03-29 17:08:08
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-09-02 09:45:41
|
|
||||||
*/
|
|
||||||
import { ccenum, Collider, Component, ICollisionEvent, ITriggerEvent, _decorator } from "cc";
|
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
/** 碰撞物体类型 */
|
|
||||||
export enum CollisionType {
|
|
||||||
/** 角色类 */
|
|
||||||
Hero,
|
|
||||||
/** 飞弹类体*/
|
|
||||||
Ballistic,
|
|
||||||
/** 墙体类 */
|
|
||||||
Wall
|
|
||||||
}
|
|
||||||
ccenum(CollisionType);
|
|
||||||
|
|
||||||
/** 碰撞器与触发器 */
|
|
||||||
@ccclass('GameCollision')
|
|
||||||
export class GameCollision extends Component {
|
|
||||||
private Event_TriggerEnter: any = "onTriggerEnter";
|
|
||||||
private Event_TriggerStay: any = "onTriggerStay";
|
|
||||||
private Event_TriggerExit: any = "onTriggerExit";
|
|
||||||
private Event_CollisionEnter: any = "onCollisionEnter";
|
|
||||||
private Event_CollisionStay: any = "onCollisionStay";
|
|
||||||
private Event_CollisionExit: any = "onCollisionExit";
|
|
||||||
|
|
||||||
protected collider: Collider = null!;
|
|
||||||
|
|
||||||
@property({ type: CollisionType, tooltip: '碰撞物体类型' })
|
|
||||||
type: CollisionType = CollisionType.Ballistic;
|
|
||||||
|
|
||||||
onLoad() {
|
|
||||||
this.collider = this.getComponent(Collider)!;
|
|
||||||
if (this.collider.isTrigger) {
|
|
||||||
this.collider.on(this.Event_TriggerEnter, this.onTrigger, this);
|
|
||||||
this.collider.on(this.Event_TriggerStay, this.onTrigger, this);
|
|
||||||
this.collider.on(this.Event_TriggerExit, this.onTrigger, this);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.collider.on(this.Event_CollisionEnter, this.onCollision, this);
|
|
||||||
this.collider.on(this.Event_CollisionStay, this.onCollision, this);
|
|
||||||
this.collider.on(this.Event_CollisionExit, this.onCollision, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private onTrigger(event: ITriggerEvent) {
|
|
||||||
switch (event.type) {
|
|
||||||
case this.Event_TriggerEnter:
|
|
||||||
this.onTriggerEnter(event);
|
|
||||||
break;
|
|
||||||
case this.Event_TriggerStay:
|
|
||||||
this.onTriggerStay(event);
|
|
||||||
break;
|
|
||||||
case this.Event_TriggerExit:
|
|
||||||
this.onTriggerExit(event);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected onTriggerEnter(event: ITriggerEvent) { }
|
|
||||||
protected onTriggerStay(event: ITriggerEvent) { }
|
|
||||||
protected onTriggerExit(event: ITriggerEvent) { }
|
|
||||||
|
|
||||||
private onCollision(event: ICollisionEvent) {
|
|
||||||
switch (event.type) {
|
|
||||||
case this.Event_CollisionEnter:
|
|
||||||
this.onCollisionEnter(event);
|
|
||||||
break;
|
|
||||||
case this.Event_CollisionStay:
|
|
||||||
this.onCollisionStay(event);
|
|
||||||
break;
|
|
||||||
case this.Event_CollisionExit:
|
|
||||||
this.onCollisionExit(event);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected onCollisionEnter(event: ICollisionEvent) { }
|
|
||||||
protected onCollisionStay(event: ICollisionEvent) { }
|
|
||||||
protected onCollisionExit(event: ICollisionEvent) { }
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "d331c466-f23e-4f9a-bce4-ae002d8d7871",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2021-08-11 16:41:12
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2023-01-19 15:27:24
|
|
||||||
*/
|
|
||||||
import { Node, Vec3 } from "cc";
|
|
||||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
|
||||||
import { Vec3Util } from "../../../../extensions/oops-plugin-framework/assets/core/utils/Vec3Util";
|
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
||||||
|
|
||||||
/** 向目标移动,移动过程中目标位置变化会自动修正移动目标点,直到未修正前移动到目标点停止 */
|
|
||||||
@ecs.register('MoveTo')
|
|
||||||
export class MoveToComp extends ecs.Comp {
|
|
||||||
/** 移动节点 */
|
|
||||||
node: Node = null!;
|
|
||||||
/** 移动方向 */
|
|
||||||
velocity: Vec3 = Vec3Util.zero;
|
|
||||||
/** 移动速度(每秒移动的像素距离) */
|
|
||||||
speed: number = 0;
|
|
||||||
/** 目标实体ECS编号、目标位置 */
|
|
||||||
target: Vec3 | Node | null = null;
|
|
||||||
|
|
||||||
/** 坐标标(默认本地坐标) */
|
|
||||||
ns: number = Node.NodeSpace.LOCAL;
|
|
||||||
/** 偏移距离 */
|
|
||||||
offset: number = 0;
|
|
||||||
/** 偏移向量 */
|
|
||||||
offsetVector: Vec3 | null = null;
|
|
||||||
/** 移动完成回调 */
|
|
||||||
onComplete: Function | null = null;
|
|
||||||
/** 距离变化时 */
|
|
||||||
onChange: Function | null = null;
|
|
||||||
|
|
||||||
reset() {
|
|
||||||
this.ns = Node.NodeSpace.LOCAL;
|
|
||||||
this.offset = 0;
|
|
||||||
this.target = null;
|
|
||||||
this.offsetVector = null;
|
|
||||||
this.onComplete = null;
|
|
||||||
this.onChange = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ecs.register('VariableMoveTo')
|
|
||||||
class VariableMoveToComponent extends ecs.Comp {
|
|
||||||
/** 延时触发器 */
|
|
||||||
timer: Timer = new Timer();
|
|
||||||
/** 终点备份 */
|
|
||||||
end: Vec3 | null = null;
|
|
||||||
/** 目标位置 */
|
|
||||||
target!: Vec3;
|
|
||||||
|
|
||||||
reset() {
|
|
||||||
this.end = null;
|
|
||||||
this.timer.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 跟踪移动到目标位置 */
|
|
||||||
export class MoveToSystem extends ecs.ComblockSystem<ecs.Entity> implements ecs.IEntityEnterSystem, ecs.IEntityRemoveSystem, ecs.ISystemUpdate {
|
|
||||||
filter(): ecs.IMatcher {
|
|
||||||
return ecs.allOf(MoveToComp);
|
|
||||||
}
|
|
||||||
|
|
||||||
entityEnter(e: ecs.Entity): void {
|
|
||||||
e.add(VariableMoveToComponent);
|
|
||||||
console.log("MoveToSystem entityEnter");
|
|
||||||
}
|
|
||||||
|
|
||||||
entityRemove(e: ecs.Entity): void {
|
|
||||||
e.remove(VariableMoveToComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
update(e: ecs.Entity) {
|
|
||||||
let move = e.get(MoveToComp);
|
|
||||||
let mtv = e.get(VariableMoveToComponent);
|
|
||||||
let end: Vec3;
|
|
||||||
|
|
||||||
console.assert(move.speed > 0, "移动速度必须要大于零");
|
|
||||||
|
|
||||||
if (move.target instanceof Node) {
|
|
||||||
end = move.ns == Node.NodeSpace.WORLD ? move.target.worldPosition : move.target.position;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
end = move.target as Vec3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 目标移动后,重计算移动方向与移动到目标点的速度
|
|
||||||
if (mtv.end == null || !mtv.end.strictEquals(end)) {
|
|
||||||
let target = end.clone();
|
|
||||||
if (move.offsetVector) {
|
|
||||||
target = target.add(move.offsetVector); // 这里的问题
|
|
||||||
}
|
|
||||||
|
|
||||||
// 移动方向与移动数度
|
|
||||||
let start = move.ns == Node.NodeSpace.WORLD ? move.node.worldPosition : move.node.position;
|
|
||||||
move.velocity = Vec3Util.sub(target, start).normalize();
|
|
||||||
|
|
||||||
// 移动时间与目标偏位置计算
|
|
||||||
let distance = Vec3.distance(start, target) - move.offset;
|
|
||||||
|
|
||||||
move.onChange?.call(this);
|
|
||||||
|
|
||||||
if (distance - move.offset <= 0) {
|
|
||||||
this.exit(e);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mtv.timer.step = distance / move.speed;
|
|
||||||
mtv.end = end.clone();
|
|
||||||
mtv.target = move.velocity.clone().multiplyScalar(distance).add(start);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (move.speed > 0) {
|
|
||||||
let trans = Vec3Util.mul(move.velocity, move.speed * this.dt);
|
|
||||||
move.node.translate(trans, Node.NodeSpace.LOCAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 移动完成事件
|
|
||||||
if (mtv.timer.update(this.dt)) {
|
|
||||||
if (move.ns == Node.NodeSpace.WORLD)
|
|
||||||
move.node.worldPosition = mtv.target;
|
|
||||||
else
|
|
||||||
move.node.position = mtv.target;
|
|
||||||
|
|
||||||
this.exit(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private exit(e: ecs.Entity) {
|
|
||||||
let move = e.get(MoveToComp);
|
|
||||||
move.onComplete?.call(this);
|
|
||||||
e.remove(VariableMoveToComponent);
|
|
||||||
e.remove(MoveToComp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "d233722c-c438-4eb3-ad17-6b407ef7bad0",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -62,6 +62,7 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
time:0,
|
time:0,
|
||||||
cd:10,
|
cd:10,
|
||||||
ref_cost:0,
|
ref_cost:0,
|
||||||
|
up_cost:6,
|
||||||
},
|
},
|
||||||
shuaxin: {
|
shuaxin: {
|
||||||
min: 0,
|
min: 0,
|
||||||
|
|||||||
@@ -10,48 +10,41 @@ export const CardType = {
|
|||||||
}
|
}
|
||||||
export const CardList={
|
export const CardList={
|
||||||
1:[1001,1002,1003,1004,1005,1006],
|
1:[1001,1002,1003,1004,1005,1006],
|
||||||
2:[1011,1021,1031,1041,2021,2022,2031,2032],
|
2:[1001,1002,1003,1004,1005,1006],
|
||||||
3:[1011,1021,1031,1041,2021,2022,2031,2032],
|
3:[1001,1002,1003,1004,1005,1006],
|
||||||
4:[1011,1021,1031,1041,2021,2022,2031,2032],
|
4:[1001,1002,1003,1004,1005,1006],
|
||||||
5:[1011,1021,1031,1041,2021,2022,2031,2032],
|
5:[1001,1002,1003,1004,1005,1006],
|
||||||
6:[1011,1021,1031,1041,2021,2022,2031,2032],
|
6:[1001,1002,1003,1004,1005,1006],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const CardSet = {
|
export const CardSet = {
|
||||||
1001:{
|
1001:{
|
||||||
uuid:1001, name:'叽叽', type:1, level:1,prefab_path:1001,atk:1,atk_cd:0.5, hp:15, power:45, speed:80,
|
uuid:1001, name:'叽叽', type:1, level:1,path:1001,atk:1,atk_cd:0.5, hp:15, power:45, speed:80,
|
||||||
skill:{ }
|
skill:{ }
|
||||||
},
|
},
|
||||||
1002:{
|
1002:{
|
||||||
uuid:1002, name:'汪汪', type:1, level:1,prefab_path:1002,atk:2,atk_cd:1, hp:15, power:50, speed:50,
|
uuid:1002, name:'汪汪', type:1, level:1,path:1002,atk:2,atk_cd:1, hp:15, power:50, speed:50,
|
||||||
skill:{ }
|
skill:{ }
|
||||||
},
|
},
|
||||||
1003:{
|
1003:{
|
||||||
uuid:1003, name:'喵喵', type:1, level:1,prefab_path:1003,atk:1, atk_cd:0.5, hp:20, power:50, speed:50,
|
uuid:1003, name:'喵喵', type:1, level:1,path:1003,atk:1, atk_cd:0.5, hp:20, power:50, speed:50,
|
||||||
skill:{ }
|
skill:{ }
|
||||||
},
|
},
|
||||||
1004:{
|
1004:{
|
||||||
uuid:1004, name:'胖大', type:2, level:1,prefab_path:1004,atk:4,atk_cd:1.5, hp:15, power:50, speed:50,
|
uuid:1004, name:'胖大', type:2, level:1,path:1004,atk:4,atk_cd:1.5, hp:15, power:50, speed:50,
|
||||||
skill:{ }
|
skill:{ }
|
||||||
},
|
},
|
||||||
1005:{
|
1005:{
|
||||||
uuid:1005, name:'汪汪[强]', type:1, level:2,prefab_path:1005,atk:6,atk_cd:1, hp:25, power:50, speed:50,
|
uuid:1005, name:'汪汪[强]', type:1, level:2,path:1005,atk:6,atk_cd:1, hp:25, power:50, speed:50,
|
||||||
skill:{ }
|
skill:{ }
|
||||||
},
|
},
|
||||||
1006:{
|
1006:{
|
||||||
uuid:1006, name:'沃夫', type:1, level:2,prefab_path:1006,atk:6,atk_cd:1, hp:30, power:50, speed:50,
|
uuid:1006, name:'沃夫', type:1, level:2,path:1006,atk:6,atk_cd:1, hp:30, power:50, speed:50,
|
||||||
skill:{ }
|
|
||||||
},
|
|
||||||
2031:{
|
|
||||||
uuid:2031, name:'泰哥', type:1, level:2,prefab_path:2031,atk:4,atk_cd:0.5, hp:25, power:50, speed:50,
|
|
||||||
skill:{ }
|
|
||||||
},
|
|
||||||
2032:{
|
|
||||||
uuid:2032, name:'喵喵[厚]', type:1, level:2,prefab_path:2032,atk:2.5,atk_cd:0.5, hp:40, power:50, speed:50,
|
|
||||||
skill:{ }
|
skill:{ }
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: dgflash
|
|
||||||
* @Date: 2022-07-21 17:30:59
|
|
||||||
* @LastEditors: dgflash
|
|
||||||
* @LastEditTime: 2022-09-02 14:40:28
|
|
||||||
*/
|
|
||||||
import { Node } from "cc";
|
|
||||||
|
|
||||||
/** 物理分组数据 */
|
|
||||||
export class GroupItem {
|
|
||||||
private _value: number;
|
|
||||||
/** 分组值 */
|
|
||||||
get value(): number {
|
|
||||||
return this._value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _name!: string;
|
|
||||||
/** 分组名 */
|
|
||||||
get name(): string {
|
|
||||||
return this._name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 碰撞掩码 */
|
|
||||||
get mask(): number {
|
|
||||||
return 1 << this._value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构造函数
|
|
||||||
* @param value 分组值
|
|
||||||
* @param name 分组名
|
|
||||||
*/
|
|
||||||
constructor(value: number, name: string) {
|
|
||||||
this._value = value;
|
|
||||||
this._name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
|
||||||
* 为了方便使用,将编辑器中的物理分组定义到代码。如果编辑器中有修改,确保同步到这里。
|
|
||||||
*/
|
|
||||||
export class PhysicsUtil {
|
|
||||||
/** 默认物理分组 */
|
|
||||||
static DEFAULT = new GroupItem(0, 'DEFAULT');
|
|
||||||
/** 能通过屏幕触摸中发出的射线检查到的游戏对象 */
|
|
||||||
static MONSTER = new GroupItem(2, 'MONSTER');
|
|
||||||
static HERO = new GroupItem(4, 'HERO');
|
|
||||||
static MONSTER_SKILL = new GroupItem(8, 'MONSTER_SKILL');
|
|
||||||
static HERO_SKILL = new GroupItem(16, 'HERO_SKILL');
|
|
||||||
|
|
||||||
static setNodeLayer(item: GroupItem, node: Node) {
|
|
||||||
node.layer = item.mask;
|
|
||||||
node.children.forEach(n => {
|
|
||||||
n.layer = item.mask;
|
|
||||||
PhysicsUtil.setNodeLayer(item, n);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.23",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "ea3b7cf5-1be6-4436-a5a3-df3e1c913cb5",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -35,6 +35,16 @@ export class CardControllerComp extends CCComp {
|
|||||||
this.load_cards()
|
this.load_cards()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cards_update(){
|
||||||
|
if(smc.vm_data.gold.min >= smc.vm_data.gold.up_cost){
|
||||||
|
smc.vm_data.gold.min -= smc.vm_data.gold.up_cost;
|
||||||
|
this.card_level += 1;
|
||||||
|
smc.vm_data.gold.up_cost += 1
|
||||||
|
console.log("card _level:"+this.card_level+"cost:"+smc.vm_data.gold.up_cost)
|
||||||
|
}else{
|
||||||
|
oops.gui.toast("金币不够");
|
||||||
|
}
|
||||||
|
}
|
||||||
palyer_ref(){
|
palyer_ref(){
|
||||||
if (this.in_load) {
|
if (this.in_load) {
|
||||||
return
|
return
|
||||||
@@ -66,9 +76,8 @@ export class CardControllerComp extends CCComp {
|
|||||||
let card = ecs.getEntity<HeroCard>(HeroCard);
|
let card = ecs.getEntity<HeroCard>(HeroCard);
|
||||||
let pos = v3(x,y)
|
let pos = v3(x,y)
|
||||||
card.load(pos,element[0],cards_node);
|
card.load(pos,element[0],cards_node);
|
||||||
x=x+100
|
x=x+120
|
||||||
});
|
});
|
||||||
this.node.getChildByName("cards").getChildByName("active").active = false
|
|
||||||
this.in_load = false;
|
this.in_load = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export class Hero extends ecs.Entity {
|
|||||||
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
||||||
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||||
|
|
||||||
sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].uuid);
|
sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].path);
|
||||||
});
|
});
|
||||||
this.hero_init(uuid,node)
|
this.hero_init(uuid,node)
|
||||||
oops.message.dispatchEvent("hero_load",this)
|
oops.message.dispatchEvent("hero_load",this)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export class HeroCard extends ecs.Entity {
|
|||||||
const url = 'game/heros/heros';
|
const url = 'game/heros/heros';
|
||||||
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
||||||
const sprite = node.getChildByName("hero").getComponent(Sprite);
|
const sprite = node.getChildByName("hero").getComponent(Sprite);
|
||||||
sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].uuid);
|
sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].path);
|
||||||
});
|
});
|
||||||
|
|
||||||
var hcv = node.getComponent(HeroCardViewComp)!;
|
var hcv = node.getComponent(HeroCardViewComp)!;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export class Monster extends ecs.Entity {
|
|||||||
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
||||||
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||||
|
|
||||||
sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].uuid);
|
sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].path);
|
||||||
});
|
});
|
||||||
this.hero_init(uuid,node)
|
this.hero_init(uuid,node)
|
||||||
oops.message.dispatchEvent("monster_load",this)
|
oops.message.dispatchEvent("monster_load",this)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export class MonsterViewComp extends CCComp {
|
|||||||
// collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
|
// collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
|
||||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
||||||
}
|
}
|
||||||
console.log(' hero_uuid:',this.hero_uuid);
|
this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = this.level.toString();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,9 +91,12 @@ export class SkillCom extends CCComp {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
toDestroy() {
|
toDestroy() {
|
||||||
setTimeout(() => {
|
if (this.node.isValid) {
|
||||||
this.ent.destroy()
|
setTimeout(() => {
|
||||||
}, 15);
|
this.ent.destroy()
|
||||||
|
}, 15);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||||
reset() {
|
reset() {
|
||||||
|
|||||||
Reference in New Issue
Block a user