Debug zombie spawner
This commit is contained in:
parent
116ebff0c2
commit
0fff33d196
69 changed files with 564 additions and 100 deletions
91
scripts/systems/GameRegistry.cs
Normal file
91
scripts/systems/GameRegistry.cs
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
using Godot;
|
||||
using Newlon;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class GameRegistry : Node
|
||||
{
|
||||
private const string PLANT_RESOURCE_PATH = "res://resources/plants/";
|
||||
private const string ZOMBIE_RESOURCE_PATH = "res://resources/zombies/";
|
||||
public static GameRegistry Instance { get; private set; }
|
||||
private Dictionary<string, PlantResource> PlantDictionary = [];
|
||||
private Dictionary<string, ZombieResource> ZombieDictionary = [];
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
//Plant init
|
||||
string[] plantFiles = DirAccess.GetFilesAt(PLANT_RESOURCE_PATH);
|
||||
|
||||
foreach (var file in plantFiles)
|
||||
{
|
||||
if (ResourceLoader.Exists(PLANT_RESOURCE_PATH + file))
|
||||
{
|
||||
var plant = ResourceLoader.Load<PlantResource>(PLANT_RESOURCE_PATH + file);
|
||||
PlantDictionary.Add(file.ToLower().Split('.')[0], plant);
|
||||
}
|
||||
}
|
||||
|
||||
//Zombie init
|
||||
string[] zombieFiles = DirAccess.GetFilesAt(ZOMBIE_RESOURCE_PATH);
|
||||
|
||||
foreach (var file in zombieFiles)
|
||||
{
|
||||
if (ResourceLoader.Exists(ZOMBIE_RESOURCE_PATH + file))
|
||||
{
|
||||
var zombie = ResourceLoader.Load<ZombieResource>(ZOMBIE_RESOURCE_PATH + file);
|
||||
ZombieDictionary.Add(file.ToLower().Split('.')[0], zombie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static PlantResource GetPlantByName(string name)
|
||||
{
|
||||
if (Instance.PlantDictionary.ContainsKey(name) == false) return null;
|
||||
return Instance.PlantDictionary[name];
|
||||
}
|
||||
public static List<string> GetPlantNames()
|
||||
{
|
||||
List<string> result = [];
|
||||
foreach (var key in Instance.PlantDictionary.Keys)
|
||||
{
|
||||
result.Add(key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static List<PlantResource> GetPlants()
|
||||
{
|
||||
List<PlantResource> result = [];
|
||||
foreach (var value in Instance.PlantDictionary.Values)
|
||||
{
|
||||
result.Add(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static ZombieResource GetZombieByName(string name)
|
||||
{
|
||||
if (Instance.ZombieDictionary.ContainsKey(name) == false) return null;
|
||||
return Instance.ZombieDictionary[name];
|
||||
}
|
||||
public static List<string> GetZombieNames()
|
||||
{
|
||||
List<string> result = [];
|
||||
foreach (var key in Instance.ZombieDictionary.Keys)
|
||||
{
|
||||
result.Add(key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static List<ZombieResource> GetZombies()
|
||||
{
|
||||
List<ZombieResource> result = [];
|
||||
foreach (var value in Instance.ZombieDictionary.Values)
|
||||
{
|
||||
result.Add(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
1
scripts/systems/GameRegistry.cs.uid
Normal file
1
scripts/systems/GameRegistry.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b66j681wn5tjn
|
||||
Loading…
Add table
Add a link
Reference in a new issue