@cc-component/cc-core 1.2.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.
Files changed (194) hide show
  1. package/.cc-ex-component.md +12 -0
  2. package/assets/core/config/CommonEnum.ts +94 -0
  3. package/assets/core/config/CommonEnum.ts.meta +9 -0
  4. package/assets/core/config/IConfig.ts +89 -0
  5. package/assets/core/config/IConfig.ts.meta +9 -0
  6. package/assets/core/config/LayerType.ts +44 -0
  7. package/assets/core/config/LayerType.ts.meta +9 -0
  8. package/assets/core/config/LayerUI.ts +113 -0
  9. package/assets/core/config/LayerUI.ts.meta +9 -0
  10. package/assets/core/config.meta +9 -0
  11. package/assets/core/editor/LanguageManager.ts +323 -0
  12. package/assets/core/editor/LanguageManager.ts.meta +9 -0
  13. package/assets/core/editor/SpineRunner.ts +39 -0
  14. package/assets/core/editor/SpineRunner.ts.meta +9 -0
  15. package/assets/core/editor/i18nEditorComponent.ts +137 -0
  16. package/assets/core/editor/i18nEditorComponent.ts.meta +9 -0
  17. package/assets/core/editor.meta +9 -0
  18. package/assets/core/home/AudioUtil.ts +164 -0
  19. package/assets/core/home/AudioUtil.ts.meta +9 -0
  20. package/assets/core/home/BaseBoxView.ts +60 -0
  21. package/assets/core/home/BaseBoxView.ts.meta +9 -0
  22. package/assets/core/home/BaseLaunchComponent.ts +9 -0
  23. package/assets/core/home/BaseLaunchComponent.ts.meta +9 -0
  24. package/assets/core/home/BaseLoading.ts +136 -0
  25. package/assets/core/home/BaseLoading.ts.meta +9 -0
  26. package/assets/core/home/BaseSkeleton.ts +39 -0
  27. package/assets/core/home/BaseSkeleton.ts.meta +9 -0
  28. package/assets/core/home/CameraAngel.ts +326 -0
  29. package/assets/core/home/CameraAngel.ts.meta +9 -0
  30. package/assets/core/home/DouYinShow.ts +27 -0
  31. package/assets/core/home/DouYinShow.ts.meta +9 -0
  32. package/assets/core/home/EventManager.ts +39 -0
  33. package/assets/core/home/EventManager.ts.meta +9 -0
  34. package/assets/core/home/ExView.ts +9 -0
  35. package/assets/core/home/ExView.ts.meta +9 -0
  36. package/assets/core/home/FollowCamera.ts +205 -0
  37. package/assets/core/home/FollowCamera.ts.meta +9 -0
  38. package/assets/core/home/InViewCenter.ts +52 -0
  39. package/assets/core/home/InViewCenter.ts.meta +9 -0
  40. package/assets/core/home/JsonUtil.ts +102 -0
  41. package/assets/core/home/JsonUtil.ts.meta +9 -0
  42. package/assets/core/home/LoadingWindow.ts +44 -0
  43. package/assets/core/home/LoadingWindow.ts.meta +9 -0
  44. package/assets/core/home/ParabolaTween.ts +110 -0
  45. package/assets/core/home/ParabolaTween.ts.meta +9 -0
  46. package/assets/core/home/ProgessView.ts +96 -0
  47. package/assets/core/home/ProgessView.ts.meta +9 -0
  48. package/assets/core/home/Quaternion.ts +237 -0
  49. package/assets/core/home/Quaternion.ts.meta +9 -0
  50. package/assets/core/home/ResUtil.ts +132 -0
  51. package/assets/core/home/ResUtil.ts.meta +9 -0
  52. package/assets/core/home/ResourceManager.ts +430 -0
  53. package/assets/core/home/ResourceManager.ts.meta +9 -0
  54. package/assets/core/home/StateMachine.ts +93 -0
  55. package/assets/core/home/StateMachine.ts.meta +9 -0
  56. package/assets/core/home/StorageManager.ts +161 -0
  57. package/assets/core/home/StorageManager.ts.meta +9 -0
  58. package/assets/core/home/ThirdFreeLookCamera.ts +201 -0
  59. package/assets/core/home/ThirdFreeLookCamera.ts.meta +9 -0
  60. package/assets/core/home/TimeManager.ts +486 -0
  61. package/assets/core/home/TimeManager.ts.meta +9 -0
  62. package/assets/core/home/Tools.ts +103 -0
  63. package/assets/core/home/Tools.ts.meta +9 -0
  64. package/assets/core/home/prefabs.meta +12 -0
  65. package/assets/core/home/util/EncryptUtil.ts +60 -0
  66. package/assets/core/home/util/EncryptUtil.ts.meta +11 -0
  67. package/assets/core/home/util/MathUtil.ts +22 -0
  68. package/assets/core/home/util/MathUtil.ts.meta +9 -0
  69. package/assets/core/home/util/Md5.ts +202 -0
  70. package/assets/core/home/util/Md5.ts.meta +11 -0
  71. package/assets/core/home/util/RandomUtil.ts +61 -0
  72. package/assets/core/home/util/RandomUtil.ts.meta +9 -0
  73. package/assets/core/home/util/ResUtil.ts +129 -0
  74. package/assets/core/home/util/ResUtil.ts.meta +9 -0
  75. package/assets/core/home/util/crypto-js.d.ts +30 -0
  76. package/assets/core/home/util/crypto-js.d.ts.meta +11 -0
  77. package/assets/core/home/util/crypto-js.js +6030 -0
  78. package/assets/core/home/util/crypto-js.js.meta +9 -0
  79. package/assets/core/home/util.meta +12 -0
  80. package/assets/core/home.meta +12 -0
  81. package/assets/core/interface/ISceneParam.ts +11 -0
  82. package/assets/core/interface/ISceneParam.ts.meta +9 -0
  83. package/assets/core/interface/Interface.ts +160 -0
  84. package/assets/core/interface/Interface.ts.meta +1 -0
  85. package/assets/core/interface/MainModule.ts +1019 -0
  86. package/assets/core/interface/MainModule.ts.meta +9 -0
  87. package/assets/core/interface.meta +9 -0
  88. package/assets/core/lib/Logger.ts +286 -0
  89. package/assets/core/lib/Logger.ts.meta +9 -0
  90. package/assets/core/lib/language/.language.md +1 -0
  91. package/assets/core/lib/language/Language.ts +133 -0
  92. package/assets/core/lib/language/Language.ts.meta +13 -0
  93. package/assets/core/lib/language/LanguageData.ts +114 -0
  94. package/assets/core/lib/language/LanguageData.ts.meta +9 -0
  95. package/assets/core/lib/language/LanguageLabel.ts +172 -0
  96. package/assets/core/lib/language/LanguageLabel.ts.meta +13 -0
  97. package/assets/core/lib/language/LanguagePack.ts +126 -0
  98. package/assets/core/lib/language/LanguagePack.ts.meta +13 -0
  99. package/assets/core/lib/language/LanguagePointLabel.ts.meta +16 -0
  100. package/assets/core/lib/language/LanguageSpine.ts +60 -0
  101. package/assets/core/lib/language/LanguageSpine.ts.meta +9 -0
  102. package/assets/core/lib/language/LanguageSprite.ts +138 -0
  103. package/assets/core/lib/language/LanguageSprite.ts.meta +13 -0
  104. package/assets/core/lib/language.meta +9 -0
  105. package/assets/core/lib/logger/ELoggerLevel.ts +16 -0
  106. package/assets/core/lib/logger/ELoggerLevel.ts.meta +9 -0
  107. package/assets/core/lib/logger/MLogger.ts +118 -0
  108. package/assets/core/lib/logger/MLogger.ts.meta +9 -0
  109. package/assets/core/lib/logger.meta +9 -0
  110. package/assets/core/lib/net/libs/proto/output/protobuf.d.ts +2729 -0
  111. package/assets/core/lib/net/libs/proto/output/protobuf.d.ts.meta +9 -0
  112. package/assets/core/lib/net/libs/proto/output/protobuf.min.js +8 -0
  113. package/assets/core/lib/net/libs/proto/output/protobuf.min.js.meta +9 -0
  114. package/assets/core/lib/net/libs/proto/output/protobuf_custom.d.ts +102 -0
  115. package/assets/core/lib/net/libs/proto/output/protobuf_custom.d.ts.meta +9 -0
  116. package/assets/core/lib/net/libs/proto/output/protobuf_custom.js +222 -0
  117. package/assets/core/lib/net/libs/proto/output/protobuf_custom.js.meta +9 -0
  118. package/assets/core/lib/net/libs/proto/output.meta +9 -0
  119. package/assets/core/lib/net/libs/proto/source/Cmd.proto +6 -0
  120. package/assets/core/lib/net/libs/proto/source/Cmd.proto.meta +11 -0
  121. package/assets/core/lib/net/libs/proto/source/UserLogin.proto +12 -0
  122. package/assets/core/lib/net/libs/proto/source/UserLogin.proto.meta +11 -0
  123. package/assets/core/lib/net/libs/proto/source/base.proto +24 -0
  124. package/assets/core/lib/net/libs/proto/source/base.proto.meta +11 -0
  125. package/assets/core/lib/net/libs/proto/source/command.proto +31 -0
  126. package/assets/core/lib/net/libs/proto/source/command.proto.meta +11 -0
  127. package/assets/core/lib/net/libs/proto/source/domain/boos_battle_info.proto +13 -0
  128. package/assets/core/lib/net/libs/proto/source/domain/boos_battle_info.proto.meta +11 -0
  129. package/assets/core/lib/net/libs/proto/source/domain/player_auth.proto +26 -0
  130. package/assets/core/lib/net/libs/proto/source/domain/player_auth.proto.meta +11 -0
  131. package/assets/core/lib/net/libs/proto/source/domain.meta +9 -0
  132. package/assets/core/lib/net/libs/proto/source/message/game_push.proto +23 -0
  133. package/assets/core/lib/net/libs/proto/source/message/game_push.proto.meta +11 -0
  134. package/assets/core/lib/net/libs/proto/source/message/game_request.proto +24 -0
  135. package/assets/core/lib/net/libs/proto/source/message/game_request.proto.meta +11 -0
  136. package/assets/core/lib/net/libs/proto/source/message/game_response.proto +24 -0
  137. package/assets/core/lib/net/libs/proto/source/message/game_response.proto.meta +11 -0
  138. package/assets/core/lib/net/libs/proto/source/message.meta +9 -0
  139. package/assets/core/lib/net/libs/proto/source/push/boss_battle_events.proto +43 -0
  140. package/assets/core/lib/net/libs/proto/source/push/boss_battle_events.proto.meta +11 -0
  141. package/assets/core/lib/net/libs/proto/source/push.meta +9 -0
  142. package/assets/core/lib/net/libs/proto/source.meta +12 -0
  143. package/assets/core/lib/net/libs/proto.meta +9 -0
  144. package/assets/core/lib/net/libs.meta +9 -0
  145. package/assets/core/lib/net/net/HttpManager.ts +307 -0
  146. package/assets/core/lib/net/net/HttpManager.ts.meta +9 -0
  147. package/assets/core/lib/net/net/NetInterface.ts +114 -0
  148. package/assets/core/lib/net/net/NetInterface.ts.meta +9 -0
  149. package/assets/core/lib/net/net/NetManager.ts +77 -0
  150. package/assets/core/lib/net/net/NetManager.ts.meta +9 -0
  151. package/assets/core/lib/net/net/NetNode.ts +471 -0
  152. package/assets/core/lib/net/net/NetNode.ts.meta +9 -0
  153. package/assets/core/lib/net/net/WebSock.ts +81 -0
  154. package/assets/core/lib/net/net/WebSock.ts.meta +9 -0
  155. package/assets/core/lib/net/net/custom/NetChannelManager.ts +41 -0
  156. package/assets/core/lib/net/net/custom/NetChannelManager.ts.meta +9 -0
  157. package/assets/core/lib/net/net/custom/NetConfig.ts +11 -0
  158. package/assets/core/lib/net/net/custom/NetConfig.ts.meta +9 -0
  159. package/assets/core/lib/net/net/custom/NetErrorCode.ts +4 -0
  160. package/assets/core/lib/net/net/custom/NetErrorCode.ts.meta +9 -0
  161. package/assets/core/lib/net/net/custom/NetGameTips.ts +53 -0
  162. package/assets/core/lib/net/net/custom/NetGameTips.ts.meta +9 -0
  163. package/assets/core/lib/net/net/custom/NetNodeGame.ts +105 -0
  164. package/assets/core/lib/net/net/custom/NetNodeGame.ts.meta +9 -0
  165. package/assets/core/lib/net/net/custom.meta +9 -0
  166. package/assets/core/lib/net/net/protocol/NetProtocolJson.ts +39 -0
  167. package/assets/core/lib/net/net/protocol/NetProtocolJson.ts.meta +9 -0
  168. package/assets/core/lib/net/net/protocol/NetProtocolProtobuf.ts +85 -0
  169. package/assets/core/lib/net/net/protocol/NetProtocolProtobuf.ts.meta +9 -0
  170. package/assets/core/lib/net/net/protocol.meta +9 -0
  171. package/assets/core/lib/net/net.meta +9 -0
  172. package/assets/core/lib/net/prompt.meta +9 -0
  173. package/assets/core/lib/net.meta +9 -0
  174. package/assets/core/lib/old/VM2.ts +619 -0
  175. package/assets/core/lib/old/VM2.ts.meta +9 -0
  176. package/assets/core/lib/old/ViewModel.ts +905 -0
  177. package/assets/core/lib/old/ViewModel.ts.meta +9 -0
  178. package/assets/core/lib/old/ViewSearch.ts +125 -0
  179. package/assets/core/lib/old/ViewSearch.ts.meta +9 -0
  180. package/assets/core/lib/old.meta +9 -0
  181. package/assets/core/lib/tabbar/TabBarComponent.ts +113 -0
  182. package/assets/core/lib/tabbar/TabBarComponent.ts.meta +9 -0
  183. package/assets/core/lib/tabbar/TabBarController.ts +86 -0
  184. package/assets/core/lib/tabbar/TabBarController.ts.meta +9 -0
  185. package/assets/core/lib/tabbar/TabBarItem.ts +52 -0
  186. package/assets/core/lib/tabbar/TabBarItem.ts.meta +9 -0
  187. package/assets/core/lib/tabbar.meta +9 -0
  188. package/assets/core/lib.meta +12 -0
  189. package/assets/core.meta +9 -0
  190. package/assets.meta +9 -0
  191. package/index.ts +3 -0
  192. package/index.ts.meta +9 -0
  193. package/package.json +19 -0
  194. package/package.json.meta +11 -0
@@ -0,0 +1,164 @@
1
+ //AudioUtil.ts
2
+ import { Node, AudioSource, AudioClip, resources, director } from 'cc';
3
+ import { ResourceManager } from './ResourceManager';
4
+ import { BundleConfigName } from '../config/CommonEnum';
5
+ /**
6
+ * @en
7
+ * this is a sington class for audio play, can be easily called from anywhere in you project.
8
+ * @zh
9
+ * 这是一个用于播放音频的单件类,可以很方便地在项目的任何地方调用。
10
+ */
11
+ export class AudioUtil {
12
+ private static _inst: AudioUtil;
13
+ public static get inst(): AudioUtil {
14
+ if (this._inst == null) {
15
+ this._inst = new AudioUtil();
16
+ }
17
+ return this._inst;
18
+ }
19
+
20
+ private _audioSource: AudioSource;
21
+ private _audioSource2: AudioSource;
22
+
23
+ constructor() {
24
+ //@en create a node as AudioUtil
25
+ //@zh 创建一个节点作为 AudioUtil
26
+ let AudioUtil = new Node();
27
+ AudioUtil.name = '__AudioUtil__';
28
+
29
+ //@en add to the scene.
30
+ //@zh 添加节点到场景
31
+ director.getScene().addChild(AudioUtil);
32
+
33
+ //@en make it as a persistent node, so it won't be destroied when scene change.
34
+ //@zh 标记为常驻节点,这样场景切换的时候就不会被销毁了
35
+ director.addPersistRootNode(AudioUtil);
36
+
37
+ //@en add AudioSource componrnt to play audios.
38
+ //@zh 添加 AudioSource 组件,用于播放音频。
39
+ this._audioSource = AudioUtil.addComponent(AudioSource);
40
+ this._audioSource.playOnAwake = false
41
+
42
+ this.AddAudio2()
43
+ }
44
+
45
+ AddAudio2() {
46
+ let AudioUtil2 = new Node();
47
+ this._audioSource.node.addChild(AudioUtil2)
48
+ AudioUtil2.name = '__AudioUtil__2';
49
+ this._audioSource2 = AudioUtil2.addComponent(AudioSource);
50
+ this._audioSource2.playOnAwake = false
51
+ this._audioSource2.loop = false
52
+ }
53
+
54
+ public get audioSource() {
55
+ return this._audioSource;
56
+ }
57
+
58
+ /**
59
+ * @en
60
+ * play short audio, such as strikes,explosions
61
+ * @zh
62
+ * 播放短音频,比如 打击音效,爆炸音效等
63
+ * @param sound clip or url for the audio
64
+ * @param volume
65
+ */
66
+ async playOneShot(sound: AudioClip | string, volume: number = 0.5) {
67
+ const v = this.sound_volume
68
+ if (sound instanceof AudioClip) {
69
+ this._audioSource.playOneShot(sound, v);
70
+ }
71
+ else {
72
+ let clip = await ResourceManager.loadAsset<AudioClip>(BundleConfigName.common, sound, AudioClip)
73
+ this._audioSource.playOneShot(clip, v);
74
+ }
75
+ }
76
+
77
+ get sound_volume(): number {
78
+ const v = MainModule.storage.getNumber('sound_volume', 1)
79
+ return v
80
+ }
81
+ set sound_volume(value: number) {
82
+ MainModule.storage.set('sound_volume', value)
83
+ }
84
+
85
+ get music_volume(): number {
86
+ const v = MainModule.storage.getNumber('music_volume', 1)
87
+ return v
88
+ }
89
+ set music_volume(value: number) {
90
+ this._audioSource.volume = value;
91
+ MainModule.storage.set('music_volume', value)
92
+ }
93
+ /**
94
+ * @en
95
+ * play long audio, such as the bg music
96
+ * @zh
97
+ * 播放长音频,比如 背景音乐
98
+ * @param sound clip or url for the sound
99
+ * @param volume
100
+ */
101
+ async play(sound: AudioClip | string, volume: number = 1.0) {
102
+ volume = this.music_volume;
103
+ if (sound instanceof AudioClip) {
104
+ this._audioSource.clip = sound;
105
+ this._audioSource.play();
106
+ this.audioSource.volume = volume;
107
+ }
108
+ else {
109
+
110
+ if (!this._audioSource.playing) {
111
+ let clip = await ResourceManager.loadAsset<AudioClip>(BundleConfigName.common, sound, AudioClip)
112
+ this._audioSource.clip = clip;
113
+ this._audioSource.loop = true
114
+ this._audioSource.play();
115
+ this.audioSource.volume = volume;
116
+ }
117
+
118
+ }
119
+ }
120
+
121
+ /**
122
+ * stop the audio play
123
+ */
124
+ stop() {
125
+ this._audioSource.stop();
126
+ }
127
+
128
+ /**
129
+ * pause the audio play
130
+ */
131
+ pause() {
132
+ this._audioSource.pause();
133
+ }
134
+
135
+ /**
136
+ * resume the audio play
137
+ */
138
+ resume() {
139
+ this._audioSource.play();
140
+ }
141
+
142
+
143
+ async playJump(sound: AudioClip | string, volume: number = 1.0) {
144
+ if (sound instanceof AudioClip) {
145
+ this._audioSource2.clip = sound;
146
+ this._audioSource2.play();
147
+ this._audioSource2.volume = volume;
148
+ }
149
+ else {
150
+ let clip = await ResourceManager.loadAsset<AudioClip>(BundleConfigName.common, sound, AudioClip)
151
+ this._audioSource2.clip = clip;
152
+ this._audioSource2.loop = false
153
+ this._audioSource2.play();
154
+ this._audioSource2.volume = volume;
155
+ }
156
+ }
157
+
158
+ /**
159
+ * stop the audio play
160
+ */
161
+ stopJump() {
162
+ this._audioSource2.stop();
163
+ }
164
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "9e9135e1-d91a-4b38-af74-ef75f06b0714",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -0,0 +1,60 @@
1
+ import { _decorator, Component, Node, Size, UITransform, v2, Vec2 } from 'cc';
2
+ import { ViewSearch, vsearch } from '../lib/old/ViewSearch';
3
+ const { ccclass, property } = _decorator;
4
+
5
+ @ViewSearch
6
+ @ccclass('BaseBoxView')
7
+ export class BaseBoxView extends Component {
8
+ box_size: any = { width: 100, height: 100 };//获取碰撞盒大小
9
+ @vsearch(Node)
10
+ box_node: Node;
11
+ @vsearch(Node)
12
+ box_center: Node;
13
+ box_node_ut: UITransform;
14
+
15
+ ut: UITransform;
16
+
17
+ protected onLoad(): void {
18
+ this.ut = this.node.getComponent(UITransform);
19
+ if (this.box_node) {
20
+ this.box_node_ut = this.box_node.getComponent(UITransform);
21
+ this.node.BoxView = this;
22
+ }
23
+ }
24
+
25
+
26
+ UpdateBox(target: Node) {
27
+ const data = CommonModule.Get_MapCenter().map_view.GetMapModel(0, 0)
28
+ target = data.node;
29
+ if (this.box_node) {
30
+ this.box_node.scale = target.scale;
31
+ const targetUT = target.getComponent(UITransform);
32
+ this.box_node_ut.anchorPoint = v2(0.5, 0);
33
+ this.box_node_ut.contentSize = new Size(targetUT.contentSize.width, targetUT.contentSize.height);
34
+ this.box_size.width = this.box_node_ut.width;
35
+ this.box_size.height = this.box_node_ut.height;
36
+ }
37
+ }
38
+ // Collision(target_enemy: BoxView) {
39
+ // const box1 = this.GetBox(this);
40
+ // const box2 = this.GetBox(this.target_enemy);
41
+
42
+ // const ok = MainModule.Collision(box1, box2);
43
+ // // console.log("碰撞了吗?", ok, this.node.name)
44
+ // return ok
45
+ // }
46
+
47
+ public GetBox() {
48
+ const player = this;
49
+ const node = this.box_node;
50
+ const width = this.box_size.width;
51
+ const height = this.box_size.height;
52
+ const x = node.worldPosition.x - width * 0.5;
53
+ const y = node.worldPosition.y - height * 0.5;
54
+ return {
55
+ x1: x, y1: y,
56
+ x2: x + player.box_size.width, y2: y + player.box_size.height
57
+ };
58
+ }
59
+ }
60
+
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "059d5775-9444-4838-921a-0ecb204f9272",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -0,0 +1,9 @@
1
+ import { _decorator, Component, Node } from 'cc';
2
+ const { ccclass, property } = _decorator;
3
+
4
+ @ccclass('BaseLaunchComponent')
5
+ export abstract class BaseLaunchComponent extends Component {
6
+ abstract InitGame(): Promise<void>;
7
+ }
8
+
9
+
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "8c5c6e47-0b0e-4c41-a884-eb9ea97c0018",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -0,0 +1,136 @@
1
+ import { _decorator, CCString, Component, Enum, instantiate, Node, Prefab } from 'cc';
2
+
3
+ import { ISceneParam } from '../interface/ISceneParam';
4
+ import { DEBUG } from 'cc/env';
5
+ import { ResourceManager } from './ResourceManager';
6
+ import { ProgessView } from './ProgessView';
7
+ import { AssetType, BundleConfig, BundleConfigName, GetAssetType } from '../config/CommonEnum';
8
+ import { LanguageData } from '../lib/language/LanguageData';
9
+ const { ccclass, property } = _decorator;
10
+
11
+ @ccclass(`LoadGameResItem`)
12
+ export class LoadGameResItem {
13
+ @property({ type: BundleConfig, tooltip: "bundle名称" })
14
+ bundleName: BundleConfig = BundleConfig.home;
15
+ @property({ tooltip: `资源路径文件夹名称` })
16
+ path: string = `home/prefabs`
17
+ @property({ type: AssetType, tooltip: `资源路径文件夹名称` })
18
+ type: AssetType = AssetType.prefab
19
+ // @property({ tooltip: `节点挂载的自定义组件\n如果需要监听 NodePool 的重用/回收事件,确保你的自定义组件已经实现了 YXCollectionViewCell 接口并配置此属性为你的自定义组件名\n如果不需要,可以忽略此配置` })
20
+ // comp: string = ``
21
+ }
22
+ @ccclass('BaseLoading')
23
+ export abstract class BaseLoading extends Component {
24
+ @property({ serializable: true, type: [LoadGameResItem] })
25
+ path_list: LoadGameResItem[] = []
26
+
27
+ /**进度比例 */
28
+ progress_ratio: number = 1
29
+ /**总进度 值范围 0-100*/
30
+ pro_total: number;
31
+
32
+ sceneParam: ISceneParam = {
33
+ param: null,
34
+ bundleName: '',
35
+ sceneName: '',
36
+ error: null
37
+ }
38
+ protected onLoad(): void {
39
+ this.sceneParam = MainModule.scenesParm
40
+ const first = this.path_list[this.path_list.length - 1]
41
+ const bundleName = BundleConfig[first?.bundleName] ?? BundleConfigName.home
42
+ MainModule.gui.setBundleName(bundleName)
43
+ this.setLanguage()
44
+ MainModule.RegisterModule(this.RegisterModule())
45
+ this.Init();
46
+ }
47
+
48
+ async Init() {
49
+ const count = this.path_list.length;
50
+ const ratio = 1 / count * this.progress_ratio;
51
+ this.pro_total = 0;
52
+
53
+ for (let index = 0; index < this.path_list.length; index++) {
54
+ const key_path = this.path_list[index];
55
+ let temp_pro = 0;
56
+ await MainModule.loadDir(BundleConfig[key_path.bundleName], key_path.path, GetAssetType(key_path.type), (pro: number) => {
57
+ temp_pro = pro * ratio
58
+ const progess = (this.pro_total + pro * ratio)
59
+ MainModule.gui.progess.progess?.(progess)//进度在OpenScene方法中先打开才可以 设置进度
60
+ })
61
+ this.pro_total = (this.pro_total + temp_pro)
62
+ }
63
+ console.log("完成", this.pro_total)
64
+ // ✅ 先调用子类的 Finish(允许子类做自定义操作)
65
+ await this.Finish(); // 支持异步
66
+ this.FinishLoad()
67
+ }
68
+
69
+
70
+ setLanguage() {
71
+ LanguageData.path_json = MainModule.gui.config.language.path.json;
72
+ LanguageData.path_texture = MainModule.gui.config.language.path.texture;
73
+ LanguageData.path_spine = MainModule.gui.config.language.path.spine;
74
+ MainModule.language.setLanguage(MainModule.bundleName, MainModule.gui.config.language.default)
75
+ }
76
+ /**刷新进度 */
77
+ addProgess(progess: number): void {
78
+ const pro = this.getRemainingProgress()
79
+ MainModule.gui.progess.progess?.(this.pro_total + (pro * progess))
80
+ }
81
+
82
+ /**获取剩余进度 */
83
+ getRemainingProgress() {
84
+ return (1 - this.progress_ratio) * 100
85
+ }
86
+ FinishLoad() {
87
+ MainModule.gui.progess.close?.()
88
+ if (DEBUG) {
89
+ ResourceManager.instance.LogAssetsAll()
90
+ }
91
+ }
92
+
93
+
94
+ // 抽象方法:子类实现自己的逻辑
95
+ abstract Finish(): Promise<void>; // 推荐加 async/await 支持
96
+
97
+ /**注册模块,返回你的模块 构造函数 */
98
+ abstract RegisterModule(): any
99
+
100
+ }
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ // async init() {
109
+ // //初始化日志
110
+ // Logger.setLevel(ELoggerLevel.Debug)
111
+ // //初始化首页模块
112
+ // HomeModule.Init()
113
+ // const list: Promise<any>[] = []
114
+ // list.push(new Promise<void>((resolve) => {
115
+ // setTimeout(() => {
116
+ // resolve()
117
+ // }, 1000)
118
+ // }))
119
+
120
+ // list.push(new Promise<void>((resolve) => {
121
+ // //初始化日志
122
+ // setTimeout(() => {
123
+ // resolve()
124
+ // }, 2000)
125
+ // }))
126
+
127
+ // list.push(new Promise<void>((resolve) => {
128
+ // //初始化日志
129
+ // setTimeout(() => {
130
+ // resolve()
131
+ // }, 3000)
132
+ // }))
133
+
134
+ // //进度更新
135
+ // await MainModule.PromiseQueue(list, (completed, total) => { this.addProgess(completed / total) })
136
+ // }
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "0304ea13-7a88-442e-8cfc-342af5d6f33e",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -0,0 +1,39 @@
1
+
2
+
3
+
4
+ import { _decorator, Component, sp, Node } from 'cc';
5
+
6
+ export class SkeletonAnim {
7
+ static Play(skeleton: sp.Skeleton, animations: { name: string, loop?: boolean, call?: (name?: string) => void, event?: (name?: string) => void }[]) {
8
+ skeleton.setCompleteListener(null)
9
+ skeleton.setEventListener(null)
10
+ skeleton.clearTracks();
11
+ skeleton.clearAnimation();
12
+ // 设置动画队列和回调队列
13
+ animations.forEach((animationName, index) => {
14
+ if (index === 0) {
15
+ skeleton.setAnimation(0, animationName.name, animationName.loop ?? false);
16
+ } else {
17
+ skeleton.addAnimation(0, animationName.name, animationName.loop ?? false);
18
+ }
19
+ });
20
+
21
+ // 设置完成事件监听器
22
+ skeleton.setCompleteListener((data) => {
23
+ const index = animations.findIndex((anim => anim.name === data.animation.name))
24
+ animations[index].call?.(data.animation.name)
25
+ });
26
+
27
+ // 设置事件监听器
28
+ skeleton.setEventListener((entry, event: sp.spine.Event) => {
29
+ const index = animations.findIndex((anim => anim.name === entry.animation.name))
30
+ // console.log("1--事件", event.data.name, event.data.intValue, event.data)
31
+ // console.log("2--事件", event.data.intValue)
32
+ // console.log("2--事件", event.data.stringValue)
33
+ // console.log("2--事件", event.data.floatValue,entry.animation.name)
34
+ animations[index].event?.(event.data.name)
35
+ });
36
+ }
37
+
38
+
39
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "9ca64a42-77ad-4ea2-a0bd-74b8ab2f6336",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }