@cc-component/cc-core 1.4.6 → 1.4.8
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/home/BaseModuleConfig.ts.meta +9 -9
- package/assets/core/home/Tools.ts +17 -17
- package/assets/core/interface/App.ts +7 -5
- package/assets/core/interface/Interface.ts +4 -1
- package/assets/core/lib/ecs.meta +9 -9
- package/assets/core/lib/net/net/HttpManager.ts +4 -2
- package/assets/core/lib/tabbar/TabBarController.ts +15 -6
- package/index.ts.meta +9 -9
- package/package.json +1 -1
- package/package.json.meta +11 -11
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
{
|
|
2
|
-
"ver": "4.0.24",
|
|
3
|
-
"importer": "typescript",
|
|
4
|
-
"imported": true,
|
|
5
|
-
"uuid": "be82897c-95e5-4d69-9c19-4ff84d7f02eb",
|
|
6
|
-
"files": [],
|
|
7
|
-
"subMetas": {},
|
|
8
|
-
"userData": {}
|
|
9
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"ver": "4.0.24",
|
|
3
|
+
"importer": "typescript",
|
|
4
|
+
"imported": true,
|
|
5
|
+
"uuid": "be82897c-95e5-4d69-9c19-4ff84d7f02eb",
|
|
6
|
+
"files": [],
|
|
7
|
+
"subMetas": {},
|
|
8
|
+
"userData": {}
|
|
9
|
+
}
|
|
@@ -29,7 +29,7 @@ export enum NodeLayer {
|
|
|
29
29
|
@ccclass('Tools')
|
|
30
30
|
export class Tools {
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
SetNodeLayer(node: Node, layer: number) {
|
|
33
33
|
for (var i = 0; i < node.children.length; i++) {
|
|
34
34
|
let item = node.children[i];
|
|
35
35
|
item.layer = layer
|
|
@@ -41,7 +41,7 @@ export class Tools {
|
|
|
41
41
|
|
|
42
42
|
//#region 工具
|
|
43
43
|
/**任务进度队列 */
|
|
44
|
-
|
|
44
|
+
PromiseQueue<T>(promises: Promise<T>[], onProgress: (completed: number, total: number) => void): Promise<T[]> {
|
|
45
45
|
const total = promises.length;
|
|
46
46
|
let completed = 0;
|
|
47
47
|
|
|
@@ -78,7 +78,7 @@ export class Tools {
|
|
|
78
78
|
|
|
79
79
|
//抛物线
|
|
80
80
|
//计算贝塞尔曲线坐标函数
|
|
81
|
-
|
|
81
|
+
twoBezier(k3, startPos, controlPos, endPos) {
|
|
82
82
|
let twoBezier = (t: number, p1: Vec3, cp: Vec3, p2: Vec3) => {
|
|
83
83
|
let x = (1 - t) * (1 - t) * p1.x + 2 * t * (1 - t) * cp.x + t * t * p2.x;
|
|
84
84
|
let y = (1 - t) * (1 - t) * p1.y + 2 * t * (1 - t) * cp.y + t * t * p2.y;
|
|
@@ -88,25 +88,25 @@ export class Tools {
|
|
|
88
88
|
let result_pos = twoBezier(k3, startPos, controlPos, endPos)
|
|
89
89
|
return result_pos
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
customEaseOutInWithSpeed(t) {
|
|
92
92
|
let speedFactor = 0.6
|
|
93
93
|
if (t < 0.5) {
|
|
94
|
-
return 0.5 *
|
|
94
|
+
return 0.5 * this.customEaseOut(2 * t, speedFactor);
|
|
95
95
|
} else {
|
|
96
|
-
return 0.5 *
|
|
96
|
+
return 0.5 * this.customEaseIn(2 * t - 1, speedFactor) + 0.5;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
customEaseOut(t, speedFactor) {
|
|
101
101
|
return 1 - Math.pow(1 - t, 2 * speedFactor);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
customEaseIn(t, speedFactor) {
|
|
105
105
|
return Math.pow(t, 2 * speedFactor);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
//检测碰撞
|
|
109
|
-
|
|
109
|
+
Collision(box1: { x1: number, y1: number, x2: number, y2: number },
|
|
110
110
|
box2: { x1: number, y1: number, x2: number, y2: number }): boolean {
|
|
111
111
|
// 碰撞检测逻辑
|
|
112
112
|
return !(box1.x2 <= box2.x1 || box1.x1 >= box2.x2 ||
|
|
@@ -114,7 +114,7 @@ export class Tools {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
//朝向
|
|
117
|
-
|
|
117
|
+
CalculateAngle(pointA: Vec3, pointB: Vec3): number {
|
|
118
118
|
// const dx = pointB.x - pointA.x;
|
|
119
119
|
// const dy = pointB.y - pointA.y;
|
|
120
120
|
// return Math.atan2(dy, dx) * (180 / Math.PI);
|
|
@@ -126,15 +126,15 @@ export class Tools {
|
|
|
126
126
|
return angle
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
LookAtTarget(self: Vec3, target: Vec3) {
|
|
130
130
|
if (target == null) { return }
|
|
131
131
|
// //计算朝向
|
|
132
|
-
let angle =
|
|
132
|
+
let angle = this.CalculateAngle(self, target);
|
|
133
133
|
//物体朝向
|
|
134
134
|
return v3(0, 0, angle);
|
|
135
135
|
}
|
|
136
136
|
/**向量的新的位置 */
|
|
137
|
-
|
|
137
|
+
DirectionPosition(start: Vec3, endPos: Vec3, scalar: number) {
|
|
138
138
|
const direction = endPos.clone().subtract(start);
|
|
139
139
|
const pos = direction.normalize().multiplyScalar(scalar);
|
|
140
140
|
return pos
|
|
@@ -148,11 +148,11 @@ export class Tools {
|
|
|
148
148
|
* @param offset_ratio 最高点 的偏移量
|
|
149
149
|
* @param time 动画时间
|
|
150
150
|
*/
|
|
151
|
-
|
|
151
|
+
RunParabolaTween(item: Node, target_postion: Vec3, update: (ratio: number) => void, param?: { offset_ratio?: number, is_random: boolean, time?: number, start_position?: Vec3 }) {
|
|
152
152
|
new ParabolaTween().RunParabolaTween(item, target_postion, update, param);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
public
|
|
155
|
+
public IsTT() {
|
|
156
156
|
if (BYTEDANCE) {
|
|
157
157
|
//@ts-ignore
|
|
158
158
|
const info = tt.getSystemInfoSync();
|
|
@@ -213,8 +213,8 @@ export class Tools {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
//抖音排行榜数据
|
|
216
|
-
public
|
|
217
|
-
const isdy =
|
|
216
|
+
public UpdatePlayerRankData_tt(count: number) {
|
|
217
|
+
const isdy = this.IsTT()
|
|
218
218
|
// console.error('抖音22==', isdy)
|
|
219
219
|
if (!isdy) { return }
|
|
220
220
|
// const playerLevel = MeCenter.Ins.player.playerLevel;
|
|
@@ -40,7 +40,8 @@ export class App {
|
|
|
40
40
|
static get message(): EventManager { return this.instance._message };
|
|
41
41
|
/**声音 */
|
|
42
42
|
static get sound(): AudioUtil { return this.instance._sound };
|
|
43
|
-
|
|
43
|
+
/**声音 */
|
|
44
|
+
static get tools(): Tools { return this.instance._tools };
|
|
44
45
|
|
|
45
46
|
_gui: LayerUI;
|
|
46
47
|
_http: HttpManager;
|
|
@@ -50,7 +51,7 @@ export class App {
|
|
|
50
51
|
_language: LanguageManager;
|
|
51
52
|
_message: EventManager;
|
|
52
53
|
_sound: AudioUtil;
|
|
53
|
-
|
|
54
|
+
_tools: Tools;
|
|
54
55
|
private static instance: App | null = null;
|
|
55
56
|
public static get Ins(): App {
|
|
56
57
|
if (!App.instance) { App.instance = new App(); }
|
|
@@ -81,6 +82,7 @@ export class App {
|
|
|
81
82
|
self._http = new HttpManager();
|
|
82
83
|
self._message = new EventManager();
|
|
83
84
|
self._sound = new AudioUtil();
|
|
85
|
+
self._tools = new Tools();
|
|
84
86
|
|
|
85
87
|
if (EDITOR) { return }//编辑器环境,不执行下面逻辑
|
|
86
88
|
Logger.setLevel(ELoggerLevel.Error);
|
|
@@ -133,7 +135,7 @@ export class App {
|
|
|
133
135
|
static OffAll(target: any) { this.message.OffAll(target); }
|
|
134
136
|
|
|
135
137
|
//#region 监听模块消息
|
|
136
|
-
static OnRequstNet(param: { open: (finish: (isOk: boolean) => void) => void }) { App.http.
|
|
138
|
+
static OnRequstNet(param: { open: (finish: (isOk: boolean) => void) => void }) { App.http.param = param; }
|
|
137
139
|
static OnLoading(param: { open: (finish: () => void) => void, close: () => void }) { App.gui.loading_call = param; }
|
|
138
140
|
static OnProgess(param: { open: (finish: () => void) => void, close: () => void, progess: (progress: number) => void }) { App.gui.progess = param; }
|
|
139
141
|
|
|
@@ -179,7 +181,7 @@ export class App {
|
|
|
179
181
|
|
|
180
182
|
const userChoice = await new Promise<boolean>((resolve) => {
|
|
181
183
|
const finish = (isOk: boolean) => { resolve(isOk) }
|
|
182
|
-
App.http.open?.(finish)
|
|
184
|
+
App.http.param?.open?.(finish)
|
|
183
185
|
//param.callBack = (isOk: boolean) => resolve(isOk);
|
|
184
186
|
});
|
|
185
187
|
|
|
@@ -548,7 +550,7 @@ s */
|
|
|
548
550
|
}
|
|
549
551
|
}
|
|
550
552
|
|
|
551
|
-
static PromiseQueue<T>(promises: Promise<T>[], onProgress: (completed: number, total: number) => void): Promise<T[]> { return
|
|
553
|
+
static PromiseQueue<T>(promises: Promise<T>[], onProgress: (completed: number, total: number) => void): Promise<T[]> { return App.Ins._tools.PromiseQueue(promises, onProgress) }
|
|
552
554
|
}
|
|
553
555
|
|
|
554
556
|
window.App = App;
|
|
@@ -12,6 +12,7 @@ import { Component } from "cc";
|
|
|
12
12
|
import { MLogger } from "../lib/logger/MLogger";
|
|
13
13
|
import { EventManager } from "../home/EventManager";
|
|
14
14
|
import { AudioUtil } from "../home/AudioUtil";
|
|
15
|
+
import { Tools } from "../home/Tools";
|
|
15
16
|
|
|
16
17
|
declare global {
|
|
17
18
|
/** 日志打印类 */
|
|
@@ -34,7 +35,9 @@ declare global {
|
|
|
34
35
|
/**消息 */
|
|
35
36
|
const message: EventManager
|
|
36
37
|
/**声音 */
|
|
37
|
-
const sound: AudioUtil
|
|
38
|
+
const sound: AudioUtil;
|
|
39
|
+
/**工具类 */
|
|
40
|
+
const tools: Tools;
|
|
38
41
|
/**当前所在bundle名称 */
|
|
39
42
|
const bundleName: string;
|
|
40
43
|
/**=====================================⚠️⚠️⚠️ 初始化必须实现的监听======================= */
|
package/assets/core/lib/ecs.meta
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
{
|
|
2
|
-
"ver": "1.2.0",
|
|
3
|
-
"importer": "directory",
|
|
4
|
-
"imported": true,
|
|
5
|
-
"uuid": "becc7741-24ad-4102-b41f-b4e76ec62918",
|
|
6
|
-
"files": [],
|
|
7
|
-
"subMetas": {},
|
|
8
|
-
"userData": {}
|
|
9
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"ver": "1.2.0",
|
|
3
|
+
"importer": "directory",
|
|
4
|
+
"imported": true,
|
|
5
|
+
"uuid": "becc7741-24ad-4102-b41f-b4e76ec62918",
|
|
6
|
+
"files": [],
|
|
7
|
+
"subMetas": {},
|
|
8
|
+
"userData": {}
|
|
9
|
+
}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* @LastEditTime: 2022-09-09 18:10:50
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { IExtData } from "db://assets/
|
|
8
|
+
import { IExtData } from "db://assets/cc-core";
|
|
9
|
+
|
|
9
10
|
|
|
10
11
|
/** HTTP请求返回值 */
|
|
11
12
|
export class HttpReturn<T> {
|
|
@@ -63,7 +64,8 @@ export class HttpManager {
|
|
|
63
64
|
server: string = "http://127.0.0.1/";
|
|
64
65
|
/** 请求超时(毫秒) */
|
|
65
66
|
timeout: number = 10000;
|
|
66
|
-
|
|
67
|
+
/**内部使用 */
|
|
68
|
+
param: any;
|
|
67
69
|
/**
|
|
68
70
|
* GET请求获取文本格式数据
|
|
69
71
|
* @param name 协议名
|
|
@@ -33,27 +33,35 @@ export class TabBarController extends Component {
|
|
|
33
33
|
|
|
34
34
|
@property(Prefab)
|
|
35
35
|
HomeTabbarItem: Prefab = null;
|
|
36
|
-
|
|
36
|
+
@property(Node)
|
|
37
|
+
bottom: Node = null;
|
|
37
38
|
|
|
38
39
|
layout: Layout;
|
|
39
40
|
itemList: Node[] = [];
|
|
40
41
|
public selectRow: number = 0;
|
|
41
42
|
|
|
43
|
+
isonload = false;
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
isReload = false;
|
|
45
46
|
onLoad() {
|
|
46
|
-
this.layout = this.getComponent(Layout);
|
|
47
|
-
|
|
47
|
+
this.layout = this.bottom.getComponent(Layout);
|
|
48
|
+
this.isonload = true
|
|
49
|
+
if (this.isReload) {
|
|
50
|
+
this.reload();
|
|
51
|
+
}
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
reload() {
|
|
55
|
+
this.isReload = true
|
|
56
|
+
if (this.isReload && !this.isonload) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
51
59
|
for (let index = 0; index < this.count; index++) {
|
|
52
60
|
let node = this.itemList[index]
|
|
53
61
|
if (!node) {
|
|
54
62
|
node = instantiate(this.HomeTabbarItem)
|
|
55
63
|
this.itemList.push(node);
|
|
56
|
-
node.parent = this.
|
|
64
|
+
node.parent = this.bottom;
|
|
57
65
|
}
|
|
58
66
|
node.name = index.toString();
|
|
59
67
|
node.active = true;
|
|
@@ -72,6 +80,7 @@ export class TabBarController extends Component {
|
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
switchTab(index: number, isDefault: boolean = false) {
|
|
83
|
+
if (!this.isonload) return
|
|
75
84
|
if (this.selectRow === index && !isDefault) { return }
|
|
76
85
|
this.callbackSelect?.(index, this.itemList[index], this.itemList[this.selectRow])
|
|
77
86
|
this.selectRow = index;
|
package/index.ts.meta
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
{
|
|
2
|
-
"ver": "4.0.24",
|
|
3
|
-
"importer": "typescript",
|
|
4
|
-
"imported": true,
|
|
5
|
-
"uuid": "7a336b7d-79a3-48ef-9451-d925e367809b",
|
|
6
|
-
"files": [],
|
|
7
|
-
"subMetas": {},
|
|
8
|
-
"userData": {}
|
|
9
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"ver": "4.0.24",
|
|
3
|
+
"importer": "typescript",
|
|
4
|
+
"imported": true,
|
|
5
|
+
"uuid": "7a336b7d-79a3-48ef-9451-d925e367809b",
|
|
6
|
+
"files": [],
|
|
7
|
+
"subMetas": {},
|
|
8
|
+
"userData": {}
|
|
9
|
+
}
|
package/package.json
CHANGED
package/package.json.meta
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"ver": "2.0.1",
|
|
3
|
-
"importer": "json",
|
|
4
|
-
"imported": true,
|
|
5
|
-
"uuid": "561e76c1-e517-4977-ac87-442704e3de8f",
|
|
6
|
-
"files": [
|
|
7
|
-
".json"
|
|
8
|
-
],
|
|
9
|
-
"subMetas": {},
|
|
10
|
-
"userData": {}
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"ver": "2.0.1",
|
|
3
|
+
"importer": "json",
|
|
4
|
+
"imported": true,
|
|
5
|
+
"uuid": "561e76c1-e517-4977-ac87-442704e3de8f",
|
|
6
|
+
"files": [
|
|
7
|
+
".json"
|
|
8
|
+
],
|
|
9
|
+
"subMetas": {},
|
|
10
|
+
"userData": {}
|
|
11
|
+
}
|