34 lines
882 B
C#
34 lines
882 B
C#
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;
|
|
}
|
|
}
|