34 lines
857 B
C#
34 lines
857 B
C#
using Godot;
|
|
|
|
public class Research
|
|
{
|
|
public ResearchData data;
|
|
public double elapsedResearchTime = 0;
|
|
public bool paidResources = false;
|
|
public ResearchState state;
|
|
|
|
public Research(ResearchData data)
|
|
{
|
|
this.data = data;
|
|
state = ResearchState.UNDEFINED;
|
|
}
|
|
|
|
public ResearchResult Execute(double delta)
|
|
{
|
|
if (!paidResources)
|
|
{
|
|
foreach (Ingredient ingredient in data.Inputs)
|
|
{
|
|
GameData.inventory.RemoveItem(ingredient.Item, ingredient.Amount);
|
|
}
|
|
paidResources = true;
|
|
}
|
|
elapsedResearchTime += delta;
|
|
if (elapsedResearchTime >= data.CraftTime)
|
|
{
|
|
state = ResearchState.RESEARCHED;
|
|
return ResearchResult.FINISHED;
|
|
}
|
|
return ResearchResult.RESEARCHING;
|
|
}
|
|
} |