@cc-component/cc-core 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/core/config/LayerUI.ts +4 -6
- package/assets/core/editor/LanguageManager.ts +4 -4
- package/assets/core/editor/i18nEditorComponent.ts +7 -7
- package/assets/core/home/BaseBoxView.ts +1 -1
- package/assets/core/home/BaseLoading.ts +1 -1
- package/assets/core/home/BaseSkeleton.ts +4 -4
- package/assets/core/home/CameraAngel.ts +41 -41
- package/assets/core/home/FollowCamera.ts +28 -29
- package/assets/core/home/InViewCenter.ts +1 -1
- package/assets/core/home/ResourceManager.ts +12 -12
- package/assets/core/home/StateMachine.ts +9 -9
- package/assets/core/home/StorageManager.ts +1 -1
- package/assets/core/home/ThirdFreeLookCamera.ts +2 -2
- package/assets/core/home/TimeManager.ts +1 -1
- package/assets/core/home/util/RandomUtil.ts +41 -41
- package/assets/core/interface/MainModule.ts +30 -25
- package/assets/core/lib/language/Language.ts +3 -4
- package/assets/core/lib/language/LanguageData.ts +2 -2
- package/assets/core/lib/language/LanguageLabel.ts +2 -2
- package/assets/core/lib/language/LanguagePack.ts +4 -5
- package/assets/core/lib/language/LanguageSprite.ts +1 -1
- package/assets/core/lib/logger/ELoggerLevel.ts +0 -12
- package/assets/core/lib/logger/MLogger.ts +7 -8
- package/assets/core/lib/net/net/HttpManager.ts +2 -2
- package/assets/core/lib/net/net/NetNode.ts +16 -17
- package/assets/core/lib/net/net/WebSock.ts +1 -2
- package/assets/core/lib/net/net/custom/NetGameTips.ts +8 -9
- package/assets/core/lib/net/net/custom/NetNodeGame.ts +1 -1
- package/package.json +1 -1
- package/assets/core/lib/Logger.ts +0 -286
- package/assets/core/lib/Logger.ts.meta +0 -9
|
@@ -5,11 +5,11 @@ import { LayerType } from './LayerType';
|
|
|
5
5
|
import { Canvas, director } from 'cc';
|
|
6
6
|
import { ResourceManager } from '../home/ResourceManager';
|
|
7
7
|
import { IInitConfig } from './CommonEnum';
|
|
8
|
-
import { Logger, LogType } from '../lib/Logger';
|
|
9
8
|
import { ISceneParam } from '../interface/ISceneParam';
|
|
10
9
|
import { BlockInputEvents } from 'cc';
|
|
11
10
|
import { BaseLaunchComponent } from '../home/BaseLaunchComponent';
|
|
12
11
|
import { AssetManager } from 'cc';
|
|
12
|
+
import { assetManager } from 'cc';
|
|
13
13
|
|
|
14
14
|
const { ccclass, property } = _decorator;
|
|
15
15
|
|
|
@@ -42,7 +42,8 @@ export class LayerUI {
|
|
|
42
42
|
const parent = this.launch.node
|
|
43
43
|
const data = await MainModule.loadAsset<JsonAsset>(params.bundleName, "config", JsonAsset)
|
|
44
44
|
this.config = data.json as IConfig;
|
|
45
|
-
|
|
45
|
+
MainModule.releaseAssetPath('config', params.bundleName)
|
|
46
|
+
//Logger.debug(this.config)
|
|
46
47
|
|
|
47
48
|
const config = this.config;
|
|
48
49
|
config.gui.forEach(element => {
|
|
@@ -95,11 +96,8 @@ export class LayerUI {
|
|
|
95
96
|
setBundleName(value: string) { this.bundleName = value; }
|
|
96
97
|
initLog() {
|
|
97
98
|
const debug = this.config.debug
|
|
98
|
-
Logger.setTags(debug ? null : LogType.Close)
|
|
99
|
-
Logger.logView(debug);
|
|
100
|
-
|
|
101
99
|
if (debug) {
|
|
102
|
-
|
|
100
|
+
Logger.debug("是debug模式");
|
|
103
101
|
} else {
|
|
104
102
|
console.log("发布模式");
|
|
105
103
|
console.log = function () { }; // 关闭普通日志输出
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
// try {
|
|
117
117
|
// let index = 0;
|
|
118
118
|
// return value.replace(/d%/g, function () {
|
|
119
|
-
// //
|
|
119
|
+
// //Logger.debug(`${index}个参数:${args[index]}`);
|
|
120
120
|
|
|
121
121
|
// let str = args[index++] || "";
|
|
122
122
|
// return str;
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
// assetManager.loadBundle(bundleName, (err, bundle) => {
|
|
162
162
|
// bundle.load(url, SpriteFrame, (err, spriteFrame: SpriteFrame) => {
|
|
163
163
|
// if (err) {
|
|
164
|
-
// if (DEBUG)
|
|
164
|
+
// if (DEBUG) Logger.warn(err);
|
|
165
165
|
// return cb(null);
|
|
166
166
|
// }
|
|
167
167
|
// cb(spriteFrame);
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
// try {
|
|
280
280
|
// let index = 0;
|
|
281
281
|
// return value.replace(/d%/g, function () {
|
|
282
|
-
// //
|
|
282
|
+
// //Logger.debug(`${index}个参数:${args[index]}`);
|
|
283
283
|
|
|
284
284
|
// let str = args[index++] || "d%";
|
|
285
285
|
// return str;
|
|
@@ -315,7 +315,7 @@
|
|
|
315
315
|
// break;
|
|
316
316
|
// }
|
|
317
317
|
// }
|
|
318
|
-
// //
|
|
318
|
+
// //Logger.debug("bundleName:",bundleName);
|
|
319
319
|
// return bundleName;
|
|
320
320
|
// }
|
|
321
321
|
// }
|
|
@@ -29,7 +29,7 @@ export class i18nEditorComponent extends Component {
|
|
|
29
29
|
await this.loadConfig()
|
|
30
30
|
LanguageData.current = language
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Logger.debug("编辑器语言设置成功", language);
|
|
33
33
|
// MainModule.language.setLanguage('', language)
|
|
34
34
|
// this.node.children.forEach(child => {
|
|
35
35
|
// console.error(child.name)
|
|
@@ -60,7 +60,7 @@ export class i18nEditorComponent extends Component {
|
|
|
60
60
|
let url = absoluteUrl.split("://");
|
|
61
61
|
let paths = url[1].split("/");
|
|
62
62
|
dbUrl = url[0] + "://" + paths[0] + "/" + paths[1];
|
|
63
|
-
//
|
|
63
|
+
// Logger.debug("absoluteUrl11:", absoluteUrl, dbUrl);
|
|
64
64
|
//label
|
|
65
65
|
return dbUrl
|
|
66
66
|
|
|
@@ -68,7 +68,7 @@ export class i18nEditorComponent extends Component {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
public editorChangeBundle(language: string) {
|
|
71
|
-
|
|
71
|
+
Logger.debug("bundle", language);
|
|
72
72
|
MainModule.language.setLanguage('', language)
|
|
73
73
|
//i18nMgr.editorChangeBundle(language);
|
|
74
74
|
}
|
|
@@ -78,7 +78,7 @@ export class i18nEditorComponent extends Component {
|
|
|
78
78
|
let uuid = await Editor.Message.request("asset-db", "query-uuid", db_json);
|
|
79
79
|
await new Promise<void>((resolve) => {
|
|
80
80
|
assetManager.loadAny(uuid, (err, jsonAsset: JsonAsset) => {
|
|
81
|
-
//
|
|
81
|
+
//Logger.debug("加载表格", jsonAsset, err);
|
|
82
82
|
MainModule.gui.config = jsonAsset.json as IConfig;
|
|
83
83
|
//console.error(MainModule.gui.config)
|
|
84
84
|
resolve()
|
|
@@ -89,10 +89,10 @@ export class i18nEditorComponent extends Component {
|
|
|
89
89
|
/**编辑器环境下改变多语言 */
|
|
90
90
|
public async changeLabel(dbUrl: string, language?: string) {
|
|
91
91
|
const db_json = dbUrl + `/${MainModule.gui.config.language.path.json}/${language}.json`
|
|
92
|
-
|
|
92
|
+
Logger.debug(db_json)
|
|
93
93
|
let uuid = await Editor.Message.request("asset-db", "query-uuid", db_json);
|
|
94
94
|
assetManager.loadAny(uuid, (err, jsonAsset: JsonAsset) => {
|
|
95
|
-
//
|
|
95
|
+
// Logger.debug("加载表格", jsonAsset, err);
|
|
96
96
|
if (!jsonAsset) return;
|
|
97
97
|
let labelData = jsonAsset.json;
|
|
98
98
|
LanguageData.language.set(LanguageDataType.Json, jsonAsset.json);
|
|
@@ -121,7 +121,7 @@ export class i18nEditorComponent extends Component {
|
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
assetManager.loadAny(uuid, (err, imageAsset: ImageAsset) => {
|
|
124
|
-
//
|
|
124
|
+
//Logger.debug("加载图片", imageAsset, err);
|
|
125
125
|
if (!imageAsset) return;
|
|
126
126
|
let spriteFrame = SpriteFrame.createWithImage(imageAsset);
|
|
127
127
|
com.updateSpriteEditor(spriteFrame)
|
|
@@ -37,7 +37,7 @@ export class BaseBoxView extends Component {
|
|
|
37
37
|
// const box2 = this.GetBox(this.target_enemy);
|
|
38
38
|
|
|
39
39
|
// const ok = MainModule.Collision(box1, box2);
|
|
40
|
-
// //
|
|
40
|
+
// // Logger.debug("碰撞了吗?", ok, this.node.name)
|
|
41
41
|
// return ok
|
|
42
42
|
// }
|
|
43
43
|
|
|
@@ -27,10 +27,10 @@ export class SkeletonAnim {
|
|
|
27
27
|
// 设置事件监听器
|
|
28
28
|
skeleton.setEventListener((entry, event: sp.spine.Event) => {
|
|
29
29
|
const index = animations.findIndex((anim => anim.name === entry.animation.name))
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
30
|
+
// Logger.debug("1--事件", event.data.name, event.data.intValue, event.data)
|
|
31
|
+
// Logger.debug("2--事件", event.data.intValue)
|
|
32
|
+
// Logger.debug("2--事件", event.data.stringValue)
|
|
33
|
+
// Logger.debug("2--事件", event.data.floatValue,entry.animation.name)
|
|
34
34
|
animations[index].event?.(event.data.name)
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -18,8 +18,8 @@ export class CameraAngel extends Component {
|
|
|
18
18
|
|
|
19
19
|
distance = 50;
|
|
20
20
|
|
|
21
|
-
touNode:Node;
|
|
22
|
-
touNodeSize:UITransform;
|
|
21
|
+
touNode: Node;
|
|
22
|
+
touNodeSize: UITransform;
|
|
23
23
|
start() {
|
|
24
24
|
|
|
25
25
|
// this.node.on(Node.EventType.MOUSE_DOWN, this.MouseDown, this);
|
|
@@ -42,16 +42,16 @@ export class CameraAngel extends Component {
|
|
|
42
42
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
StartGame(targetCube:Node) {
|
|
45
|
+
StartGame(targetCube: Node) {
|
|
46
46
|
this.targetCube = targetCube;
|
|
47
47
|
this.followCamera = this.getComponent(FollowCamera)
|
|
48
|
-
this.followCamera.StartGame(this.targetCube,this.distance)
|
|
48
|
+
this.followCamera.StartGame(this.targetCube, this.distance)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
private MouseDown(e: Event) {
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
Logger.debug("222");
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
|
|
@@ -59,7 +59,7 @@ export class CameraAngel extends Component {
|
|
|
59
59
|
if (this.targetCube) {
|
|
60
60
|
let fff = Vec3.FORWARD
|
|
61
61
|
fff = v3(0, 0, -1).multiplyScalar(0.01)
|
|
62
|
-
//
|
|
62
|
+
// Logger.debug(fff);
|
|
63
63
|
// this.targetCube.worldPosition = this.targetCube.worldPosition.add(fff)
|
|
64
64
|
// this.UpdatePos(0, 0)
|
|
65
65
|
// this.SetPos();
|
|
@@ -83,18 +83,18 @@ export class CameraAngel extends Component {
|
|
|
83
83
|
private TouchStart(e: EventTouch) {
|
|
84
84
|
this.isTouching = true;
|
|
85
85
|
this.touchStartPos = this.GetPos(e);
|
|
86
|
-
|
|
86
|
+
//å Logger.debug("开始", this.touchStartPos)
|
|
87
87
|
|
|
88
88
|
this.isHave = false
|
|
89
89
|
this.f_x = v3(0)
|
|
90
90
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
GetPos(e:EventTouch){
|
|
93
|
+
GetPos(e: EventTouch) {
|
|
94
94
|
|
|
95
95
|
let super_pos = this.touNode.parent.worldPosition
|
|
96
|
-
let pos = v3(super_pos.x
|
|
97
|
-
return v3(e.getUILocation().x-pos.x, e.getUILocation().y-pos.y,0)
|
|
96
|
+
let pos = v3(super_pos.x, super_pos.y, 0)//this.touNode.parent.position;
|
|
97
|
+
return v3(e.getUILocation().x - pos.x, e.getUILocation().y - pos.y, 0)
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
}
|
|
@@ -111,56 +111,56 @@ export class CameraAngel extends Component {
|
|
|
111
111
|
|
|
112
112
|
let pos = this.GetPos(e);;
|
|
113
113
|
this.UpdatePos(pos.x, pos.y);
|
|
114
|
-
|
|
114
|
+
|
|
115
115
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
private TouchEnd(e: EventTouch) {
|
|
119
119
|
|
|
120
120
|
this.ResetPos();
|
|
121
|
-
if(
|
|
122
|
-
this.touNode.position = v3(75,75)
|
|
121
|
+
if (this.touNode) {
|
|
122
|
+
this.touNode.position = v3(75, 75)
|
|
123
123
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
ResetPos(){
|
|
130
|
+
ResetPos() {
|
|
131
131
|
this.followCamera.isMove = false;
|
|
132
132
|
this.followCamera.resetPos();
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
UpdatePos(x, y) {
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
if (this.followCamera.isUpdatePos) {
|
|
139
139
|
return
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
if(this.touNode){
|
|
144
|
-
this.touNode.position = v3(x,y)
|
|
145
|
-
|
|
142
|
+
|
|
143
|
+
if (this.touNode) {
|
|
144
|
+
this.touNode.position = v3(x, y)
|
|
145
|
+
|
|
146
146
|
|
|
147
147
|
}
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
// Logger.debug(x,y)
|
|
149
|
+
// Logger.debug("ddd");
|
|
150
150
|
this.followCamera.isMove = true;
|
|
151
151
|
let currentPos = new Vec3(x, y, 0);
|
|
152
152
|
let delta = currentPos.clone().subtract(this.touchStartPos);
|
|
153
153
|
|
|
154
154
|
if (delta.x < this.f_x.x && !this.f_x.equals(v3(0), 0.01)) {
|
|
155
155
|
this.touchStartPos = this.f_x
|
|
156
|
-
//
|
|
156
|
+
// Logger.debug("转");
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
//
|
|
159
|
+
//Logger.debug(currentPos)
|
|
160
160
|
this.f_x = currentPos.clone();
|
|
161
161
|
// 根据 deltaX 进行旋转
|
|
162
|
-
|
|
163
|
-
this.rotateByDeltaX(delta.x,delta.y);
|
|
162
|
+
// Logger.debug(delta);
|
|
163
|
+
this.rotateByDeltaX(delta.x, delta.y);
|
|
164
164
|
//this.rotateAndLookAtTarget()
|
|
165
165
|
|
|
166
166
|
this.touchStartPos.clone().set(currentPos);
|
|
@@ -231,11 +231,11 @@ export class CameraAngel extends Component {
|
|
|
231
231
|
// 创建围绕X轴和Y轴旋转的两个四元数
|
|
232
232
|
let rotationQuatX = this.fromRotation(v3(1, 1, 0), misc.radiansToDegrees(rotationAngleX));
|
|
233
233
|
let rotationQuatY = this.fromRotation(v3(0, 1, 0), misc.radiansToDegrees(rotationAngleY));
|
|
234
|
-
|
|
234
|
+
// let rotationQuatz = this.fromRotation(v3(0, 0, 1), misc.radiansToDegrees(rotationAngleY));
|
|
235
235
|
|
|
236
236
|
let combinedQuat = rotationQuatY//this.multiplyQuaternions(rotationQuatX, rotationQuatY)
|
|
237
237
|
// 将两个四元数相乘,以获得综合的旋转效果
|
|
238
|
-
|
|
238
|
+
// let combinedQuat = math.Quat.multiply(rotationQuatX, rotationQuatY, rotationQuatX);
|
|
239
239
|
|
|
240
240
|
// 计算从相机到targetCube的向量
|
|
241
241
|
let cameraToTarget = this.node.worldPosition.clone().subtract(this.targetCube.worldPosition);
|
|
@@ -254,17 +254,17 @@ export class CameraAngel extends Component {
|
|
|
254
254
|
this.node.lookAt(this.targetCube.worldPosition);
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
multiplyQuaternions(quat1: math.Quat, quat2: math.Quat): math.Quat {
|
|
258
|
+
let result = new math.Quat();
|
|
259
259
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
// Quaternion multiplication formula: result = quat2 * quat1
|
|
261
|
+
result.x = quat2.x * quat1.w + quat2.y * quat1.z - quat2.z * quat1.y + quat2.w * quat1.x;
|
|
262
|
+
result.y = -quat2.x * quat1.z + quat2.y * quat1.w + quat2.z * quat1.x + quat2.w * quat1.y;
|
|
263
|
+
result.z = quat2.x * quat1.y - quat2.y * quat1.x + quat2.z * quat1.w + quat2.w * quat1.z;
|
|
264
|
+
result.w = -quat2.x * quat1.x - quat2.y * quat1.y - quat2.z * quat1.z + quat2.w * quat1.w;
|
|
265
265
|
|
|
266
|
-
|
|
267
|
-
}
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
268
268
|
|
|
269
269
|
rotateAndLookAtTarget() {
|
|
270
270
|
if (!this.targetCube) {
|
|
@@ -283,7 +283,7 @@ export class CameraAngel extends Component {
|
|
|
283
283
|
let rotatedPos = this.targetCube.worldPosition.clone().add(rotatedDirection.clone().multiplyScalar(distance));
|
|
284
284
|
let rotatedPos2 = this.targetCube.worldPosition.clone().add(this.node.forward.multiplyScalar(distance * -1));
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
Logger.debug(rotatedDirection.clone(), rotatedPos2)
|
|
287
287
|
// 更新相机位置
|
|
288
288
|
this.node.setWorldPosition(rotatedPos);
|
|
289
289
|
|
|
@@ -312,11 +312,11 @@ export class CameraAngel extends Component {
|
|
|
312
312
|
this.targetCube.worldPosition = this.targetCube.worldPosition.add3f(this.speed * director.getDeltaTime(), 0, 0);
|
|
313
313
|
break;
|
|
314
314
|
}
|
|
315
|
-
|
|
315
|
+
|
|
316
316
|
|
|
317
317
|
this.ResetPos()
|
|
318
318
|
|
|
319
|
-
|
|
319
|
+
// this.targetCube_lastPos = this.targetCube.worldPosition.clone();
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
onKeyUp(event: EventKeyboard) {
|
|
@@ -39,37 +39,37 @@ export class FollowCamera extends Component {
|
|
|
39
39
|
protected _targetWorldPos = new Vec3;
|
|
40
40
|
protected _lastTargetPos = new Vec3;
|
|
41
41
|
|
|
42
|
-
private static Deg2Rad:number=(Math.PI) / 180;
|
|
42
|
+
private static Deg2Rad: number = (Math.PI) / 180;
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
isMove = false;
|
|
46
46
|
start() {
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
// let node = find("Canvas/yaogan")
|
|
49
49
|
|
|
50
50
|
// node.on(Node.EventType.TOUCH_START, this.TouchStart, this);
|
|
51
51
|
// node.on(Node.EventType.TOUCH_MOVE, this.TouchMove, this);
|
|
52
52
|
// node.on(Node.EventType.TOUCH_END, this.TouchEnd, this);
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
StartGame(focusTarget:Node,dis:number){
|
|
58
|
+
StartGame(focusTarget: Node, dis: number) {
|
|
59
|
+
|
|
59
60
|
|
|
60
|
-
|
|
61
61
|
this.focusTarget = focusTarget;
|
|
62
62
|
this._lastTargetPos.set(this.focusTarget.worldPosition.clone());
|
|
63
63
|
this.distance = dis
|
|
64
64
|
this._updateTargetWorldPos();
|
|
65
65
|
|
|
66
66
|
tween(this.node)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
.to(0.5, { worldPosition: this._targetWorldPos })
|
|
68
|
+
.start();
|
|
69
|
+
|
|
70
70
|
//this.node.setWorldPosition(this._targetWorldPos);
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
// this.UpdatePos(0, 0)
|
|
73
73
|
}
|
|
74
74
|
protected _updateTargetWorldPos() {
|
|
75
75
|
this._targetWorldPos.set(this.focusTarget.worldPosition.clone());
|
|
@@ -79,16 +79,16 @@ export class FollowCamera extends Component {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
this._targetWorldPos.add(this.node.forward.multiplyScalar(this.distance * -1));
|
|
82
|
-
|
|
82
|
+
// this._targetWorldPos.add3f(this._targetWorldPos.x,this._targetWorldPos.y,this._targetWorldPos.z);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
update() {
|
|
86
86
|
if (!this.focusTarget) {
|
|
87
87
|
return
|
|
88
88
|
}
|
|
89
|
-
if(this.isMove){
|
|
89
|
+
if (this.isMove) {
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
// Logger.debug("阻止")
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -96,7 +96,7 @@ export class FollowCamera extends Component {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
isUpdatePos = false;
|
|
99
|
-
UpdateP(){
|
|
99
|
+
UpdateP() {
|
|
100
100
|
if (!this._lastTargetPos.equals(this.focusTarget.worldPosition.clone())) {
|
|
101
101
|
this._lastTargetPos.set(this.focusTarget.worldPosition.clone());
|
|
102
102
|
this._updateTargetWorldPos();
|
|
@@ -111,17 +111,17 @@ export class FollowCamera extends Component {
|
|
|
111
111
|
let ret = this.node.worldPosition.clone().add(diff.multiplyScalar(this.speedFactor));
|
|
112
112
|
//ret = ret.add(v3(0,0.5,0));
|
|
113
113
|
this.node.setWorldPosition(ret);
|
|
114
|
-
//
|
|
114
|
+
//Logger.debug('-----',this.node.worldPosition);
|
|
115
115
|
//this.node.setWorldPosition(v3(ret.x,37,ret.z));
|
|
116
116
|
|
|
117
117
|
this.isUpdatePos = true
|
|
118
|
-
}else{
|
|
118
|
+
} else {
|
|
119
119
|
this.isUpdatePos = false
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
|
|
124
|
-
IsMovePos(){
|
|
124
|
+
IsMovePos() {
|
|
125
125
|
|
|
126
126
|
v3_1.set(this._targetWorldPos);
|
|
127
127
|
let diff = v3_1.subtract(this.node.worldPosition);
|
|
@@ -143,22 +143,21 @@ export class FollowCamera extends Component {
|
|
|
143
143
|
* @param axis 旋转轴
|
|
144
144
|
* @param angle 旋转角度
|
|
145
145
|
*/
|
|
146
|
-
public static RotationAroundNode(self:Node,pos:Vec3,axis:Vec3,angle:number):Quat
|
|
147
|
-
|
|
148
|
-
let
|
|
149
|
-
let
|
|
150
|
-
let
|
|
151
|
-
let
|
|
152
|
-
let rad=angle* this.Deg2Rad;
|
|
146
|
+
public static RotationAroundNode(self: Node, pos: Vec3, axis: Vec3, angle: number): Quat {
|
|
147
|
+
let _quat = new Quat();
|
|
148
|
+
let v1 = new Vec3();
|
|
149
|
+
let v2 = new Vec3();
|
|
150
|
+
let pos2: Vec3 = self.position;
|
|
151
|
+
let rad = angle * this.Deg2Rad;
|
|
153
152
|
//根据旋转轴和旋转弧度计算四元数
|
|
154
|
-
Quat.fromAxisAngle(_quat,axis,rad);
|
|
153
|
+
Quat.fromAxisAngle(_quat, axis, rad);
|
|
155
154
|
//相减,目标点与相机点之间的向量
|
|
156
|
-
Vec3.subtract(v1,pos2,pos);
|
|
155
|
+
Vec3.subtract(v1, pos2, pos);
|
|
157
156
|
//把向量dir根据计算到的四元数旋转,然后计算出旋转后的距离
|
|
158
|
-
Vec3.transformQuat(v2,v1,_quat);
|
|
159
|
-
self.position=Vec3.add(v2,pos,v2);
|
|
157
|
+
Vec3.transformQuat(v2, v1, _quat);
|
|
158
|
+
self.position = Vec3.add(v2, pos, v2);
|
|
160
159
|
//根据轴和弧度绕世界空间下指定轴旋转四元数
|
|
161
|
-
Quat.rotateAround(_quat,self.rotation,axis,rad);
|
|
160
|
+
Quat.rotateAround(_quat, self.rotation, axis, rad);
|
|
162
161
|
return _quat;
|
|
163
162
|
}
|
|
164
163
|
|
|
@@ -201,5 +200,5 @@ export class FollowCamera extends Component {
|
|
|
201
200
|
|
|
202
201
|
|
|
203
202
|
|
|
204
|
-
|
|
203
|
+
|
|
205
204
|
}
|
|
@@ -44,7 +44,7 @@ export class InViewCenter {
|
|
|
44
44
|
|
|
45
45
|
isPointInsideCanvas(point: Vec3): boolean {
|
|
46
46
|
const canvasSize = this.screenSize;
|
|
47
|
-
//
|
|
47
|
+
//Logger.debug(this.width)
|
|
48
48
|
return (point.x >= -this.width && point.x <= this.width &&
|
|
49
49
|
point.y >= -this.height && point.y <= this.height);
|
|
50
50
|
}
|
|
@@ -208,7 +208,7 @@ export class ResourceManager {
|
|
|
208
208
|
list.push({ name: asset.name, refCount: asset.refCount })
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
|
-
|
|
211
|
+
Logger.warn("资源计数:\n", list)
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
LogAssetsAll() {
|
|
@@ -229,10 +229,10 @@ export class ResourceManager {
|
|
|
229
229
|
const { asset, refCount } = record;
|
|
230
230
|
list.push({ bundle_name: record.bundleName, name: asset.name, refCount: refCount, refCountAsset: asset.refCount })
|
|
231
231
|
});
|
|
232
|
-
|
|
232
|
+
Logger.warn("资源计数:\n", Array.from(bundle_map.values()))
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
Logger.warn("资源总数:", assetManager.assets.count)
|
|
235
|
+
Logger.warn("资源总数:", assetManager.assets)
|
|
236
236
|
}, 500)
|
|
237
237
|
|
|
238
238
|
}
|
|
@@ -294,7 +294,7 @@ export class ResourceManager {
|
|
|
294
294
|
let asset = bundle.get(path);
|
|
295
295
|
|
|
296
296
|
if (asset) {
|
|
297
|
-
//
|
|
297
|
+
//Logger.debug('已加载==', asset.refCount)
|
|
298
298
|
// 记录加载的资源
|
|
299
299
|
ResourceManager.instance.trackAsset(path, asset, bundleName);
|
|
300
300
|
ResourceManager.instance.LogAssets(bundleName)
|
|
@@ -309,7 +309,7 @@ export class ResourceManager {
|
|
|
309
309
|
resolve(null);
|
|
310
310
|
return;
|
|
311
311
|
}
|
|
312
|
-
|
|
312
|
+
Logger.debug('--加载', path)
|
|
313
313
|
// 记录加载的资源
|
|
314
314
|
ResourceManager.instance.trackAsset(path, asset, bundleName);
|
|
315
315
|
ResourceManager.instance.LogAssets(bundleName)
|
|
@@ -335,7 +335,7 @@ export class ResourceManager {
|
|
|
335
335
|
//加载bundle——预制体
|
|
336
336
|
assetManager.loadBundle(name, (err, ab: AssetManager.Bundle) => {
|
|
337
337
|
if (err) {
|
|
338
|
-
|
|
338
|
+
Logger.warn(`bundle名称:${name} `, err);
|
|
339
339
|
return;
|
|
340
340
|
}
|
|
341
341
|
resolve(ab);
|
|
@@ -358,7 +358,7 @@ export class ResourceManager {
|
|
|
358
358
|
|
|
359
359
|
static async loadDir(bundleName: string, dirName: string, type: any, pre: Function) {
|
|
360
360
|
return new Promise<void>(resolve => {
|
|
361
|
-
//
|
|
361
|
+
//Logger.warn(bundleName, dirName)
|
|
362
362
|
|
|
363
363
|
assetManager.getBundle(bundleName).loadDir(dirName, type, (finished: number, total: number, item: any) => {
|
|
364
364
|
pre(Math.floor((finished / total * 100)));
|
|
@@ -366,7 +366,7 @@ export class ResourceManager {
|
|
|
366
366
|
// 记录加载的资源
|
|
367
367
|
assets.forEach(asset => {
|
|
368
368
|
const asset_info: { uuid: string, path: string } = assetManager.getBundle(bundleName).getAssetInfo(asset.uuid) as { uuid: string, path: string }
|
|
369
|
-
//
|
|
369
|
+
//Logger.warn(asset_info.path)
|
|
370
370
|
ResourceManager.instance.trackAsset(asset_info.path, asset, bundleName);
|
|
371
371
|
});
|
|
372
372
|
resolve();
|
|
@@ -382,7 +382,7 @@ export class ResourceManager {
|
|
|
382
382
|
static async loadScene(bundleName: string, name: string, pre: Function): Promise<SceneAsset> {
|
|
383
383
|
var promise = new Promise<SceneAsset>(async resolve => {
|
|
384
384
|
let bundle = assetManager.getBundle(bundleName)
|
|
385
|
-
//
|
|
385
|
+
// Logger.warn("-111-加载c错了=", bun);
|
|
386
386
|
if (!bundle) {
|
|
387
387
|
bundle = await new Promise<any>(resolve => {
|
|
388
388
|
assetManager.loadBundle(bundleName, (err, bundle) => {
|
|
@@ -395,7 +395,7 @@ export class ResourceManager {
|
|
|
395
395
|
pre(Math.floor((finished / total * 100)));
|
|
396
396
|
}, (err, prefab) => {
|
|
397
397
|
if (err) {
|
|
398
|
-
|
|
398
|
+
Logger.warn("--加载c错了=", bundleName, name, err);
|
|
399
399
|
}
|
|
400
400
|
resolve(prefab);
|
|
401
401
|
});
|
|
@@ -415,7 +415,7 @@ export class ResourceManager {
|
|
|
415
415
|
pre(Math.floor((finished / total * 100)));
|
|
416
416
|
}, (err) => {
|
|
417
417
|
if (err) {
|
|
418
|
-
|
|
418
|
+
Logger.warn("预加载c错了=", bundleName, name, err);
|
|
419
419
|
}
|
|
420
420
|
resolve(null)
|
|
421
421
|
});
|
|
@@ -8,7 +8,7 @@ abstract class GameState {
|
|
|
8
8
|
abstract enter(): void;
|
|
9
9
|
abstract execute(): void;
|
|
10
10
|
exit(): void {
|
|
11
|
-
|
|
11
|
+
Logger.debug(`${this.constructor.name} 状态退出`);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export interface IStateMachine {
|
|
@@ -50,27 +50,27 @@ export class GameController {
|
|
|
50
50
|
|
|
51
51
|
// 具体状态类:开始游戏
|
|
52
52
|
export class StartGameState extends GameState {
|
|
53
|
-
enter() {
|
|
53
|
+
enter() { Logger.debug("进入游戏..."); }
|
|
54
54
|
execute() {
|
|
55
|
-
|
|
55
|
+
Logger.debug("准备开始游戏...");
|
|
56
56
|
setTimeout(() => this.delegate.next(), 1000); // 自动进入下一个状态
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// 具体状态类:游戏中
|
|
61
61
|
export class InGameState extends GameState {
|
|
62
|
-
enter() {
|
|
62
|
+
enter() { Logger.debug("进入游戏中..."); }
|
|
63
63
|
execute() {
|
|
64
|
-
|
|
64
|
+
Logger.debug("正在游戏中...");
|
|
65
65
|
setTimeout(() => this.delegate.next(), 1000);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// 具体状态类:弹出选择框
|
|
70
70
|
export class PopupState extends GameState {
|
|
71
|
-
enter() {
|
|
71
|
+
enter() { Logger.debug("弹出选择框..."); }
|
|
72
72
|
execute() {
|
|
73
|
-
|
|
73
|
+
Logger.debug("等待玩家选择...");
|
|
74
74
|
setTimeout(() => {
|
|
75
75
|
const choice = prompt("请选择 (确认/取消): ");
|
|
76
76
|
this.onUserChoice(choice || "取消");
|
|
@@ -88,6 +88,6 @@ export class PopupState extends GameState {
|
|
|
88
88
|
|
|
89
89
|
// 具体状态类:结束游戏
|
|
90
90
|
export class EndGameState extends GameState {
|
|
91
|
-
enter() {
|
|
92
|
-
execute() {
|
|
91
|
+
enter() { Logger.debug("游戏结束..."); }
|
|
92
|
+
execute() { Logger.debug("感谢您的游玩!"); }
|
|
93
93
|
}
|