Cleaned up project with better structure.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
public class ResourceDistributor
|
||||
{
|
||||
public static Dictionary<string, Texture2D> resources = ResourceLoader.LoadResourceSymbols();
|
||||
|
||||
public static string GetResource(List<string> current)
|
||||
{
|
||||
List<string> availableResources = GetUnusedResources(current);
|
||||
if (availableResources.Count <= 0)
|
||||
{
|
||||
availableResources = new List<string>(resources.Keys);
|
||||
}
|
||||
|
||||
return availableResources[GameData.rand.Next(availableResources.Count)];
|
||||
}
|
||||
|
||||
private static List<string> GetUnusedResources(List<string> current)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
|
||||
foreach (string resource in resources.Keys)
|
||||
{
|
||||
if (!current.Contains(resource))
|
||||
{
|
||||
result.Add(resource);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user