mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(ComponentManager): 实现组件管理器并初始化子弹资源
refactor(DirTool): 添加获取无扩展名文件名的方法 feat(WorldManager): 初始化ComponentManager 新增多个子弹资源文件并移动至统一目录 包括ForeverRainbow、ArrowSeven、SunDance、HeavyCrystal和LightGun
This commit is contained in:
@@ -18,3 +18,5 @@ static func listdir(path: String) -> Array[String]:
|
|||||||
return files
|
return files
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
static func getBasenameWithoutExtension(path: String) -> String:
|
||||||
|
return path.get_file().get_basename()
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
class_name ComponentManager
|
class_name ComponentManager
|
||||||
|
|
||||||
var store = {}
|
static var bullets = {}
|
||||||
|
static var characters = {}
|
||||||
|
static var effects = {}
|
||||||
|
|
||||||
|
static func init():
|
||||||
|
for i in DirTool.listdir("res://components/Bullets"):
|
||||||
|
bullets[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||||
|
for i in DirTool.listdir("res://components/Characters"):
|
||||||
|
characters[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||||
|
for i in DirTool.listdir("res://components/Effects"):
|
||||||
|
effects[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||||
|
static func getBullet(name: String):
|
||||||
|
return bullets[name]
|
||||||
|
static func getCharacter(name: String):
|
||||||
|
return characters[name]
|
||||||
|
static func getEffect(name: String):
|
||||||
|
return effects[name]
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ static var runningTime: int = 0
|
|||||||
func _ready():
|
func _ready():
|
||||||
tree = get_tree()
|
tree = get_tree()
|
||||||
rootNode = self
|
rootNode = self
|
||||||
|
ComponentManager.init()
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
runningTime += delta * 1000
|
runningTime += delta * 1000
|
||||||
if EntityBase.mobCount() == 0 and runningTime > 3000:
|
if EntityBase.mobCount() == 0 and runningTime > 3000:
|
||||||
|
|||||||
Reference in New Issue
Block a user