This commit is contained in:
2024-05-01 19:13:01 +08:00
parent cf008327aa
commit 80a32d9b1b
150 changed files with 8561 additions and 5045 deletions

View File

@@ -1,4 +1,5 @@
import { _decorator, Component, instantiate, Node, Prefab } from 'cc'
import { Component, Node, Prefab, _decorator, instantiate } from 'cc'
import PrefabLoader from '../../engine/utils/PrefabLoader'
import { GameConfig } from '../config/GameConfig'
@@ -6,29 +7,30 @@ const { ccclass, property } = _decorator
@ccclass('ResourcePrefab')
export default class ResourcePrefab extends Component {
private static prefab: Prefab | null = null
public static instance: Node
@property({ type: Prefab })
private scorePrefab: Prefab | null = null
public static preLoad(): Promise<void> {
return new Promise((resolve, reject) => {
PrefabLoader.loadPrefab(
GameConfig.GameName + '/' + 'game/prefab/ResourcePrefab',
(loadedResource: Prefab) => {
ResourcePrefab.prefab = loadedResource
ResourcePrefab.instance = instantiate(loadedResource)
resolve()
}
)
})
}
private static prefab: Prefab | null = null
public static instance: Node
@property({ type: Prefab })
private scorePrefab: Prefab | null = null
public static clear() {
ResourcePrefab.instance = null
ResourcePrefab.prefab = null
}
public static preLoad(): Promise<void> {
return new Promise((resolve, reject) => {
PrefabLoader.loadPrefab(
`${GameConfig.GameName}/game/prefab/ResourcePrefab`,
(loadedResource: Prefab) => {
ResourcePrefab.prefab = loadedResource
ResourcePrefab.instance = instantiate(loadedResource)
resolve()
},
)
})
}
public static getScorePrefab() {
return ResourcePrefab.instance.getComponent(ResourcePrefab).scorePrefab
}
public static clear() {
ResourcePrefab.instance = null
ResourcePrefab.prefab = null
}
public static getScorePrefab() {
return ResourcePrefab.instance.getComponent(ResourcePrefab).scorePrefab
}
}