42 lines
939 B
C#
42 lines
939 B
C#
using Godot;
|
|
|
|
public class GameResource
|
|
{
|
|
public string name;
|
|
int currentAmount;
|
|
int maxAmount;
|
|
bool isEndless;
|
|
float extractionSpeed;
|
|
double timeSinceLastExtraction;
|
|
public ItemData item;
|
|
|
|
public GameResource(string name)
|
|
{
|
|
this.name = name;
|
|
maxAmount = GameData.rand.Next(1000, 10000);
|
|
currentAmount = maxAmount;
|
|
isEndless = false;
|
|
extractionSpeed = 1f;
|
|
item = GameData.availableItems[name];
|
|
}
|
|
|
|
public bool Extract(double delta)
|
|
{
|
|
timeSinceLastExtraction += delta;
|
|
if (timeSinceLastExtraction < extractionSpeed) return false;
|
|
timeSinceLastExtraction = 0;
|
|
if(isEndless) return true;
|
|
if (currentAmount > 0)
|
|
{
|
|
currentAmount--;
|
|
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool CanExtract()
|
|
{
|
|
return isEndless || currentAmount > 0;
|
|
}
|
|
} |