Implemented research cost, tweaked some values.
This commit is contained in:
@@ -23,12 +23,20 @@ public partial class ResearchList : PanelContainer
|
||||
if(currentResearch.Count > 0) toDelete = new List<Research>();
|
||||
foreach (Research research in currentResearch)
|
||||
{
|
||||
if (research.Execute(delta) == ResearchResult.FINISHED)
|
||||
ResearchResult result = research.Execute(delta);
|
||||
if (result == ResearchResult.FINISHED)
|
||||
{
|
||||
toDelete.Add(research);
|
||||
RecalculateResearchStates();
|
||||
SetupGraph();
|
||||
}
|
||||
else if (result == ResearchResult.FAILED)
|
||||
{
|
||||
research.state = ResearchState.AVAILABLE;
|
||||
toDelete.Add(research);
|
||||
RecalculateResearchStates();
|
||||
SetupGraph();
|
||||
}
|
||||
}
|
||||
foreach (Research delete in toDelete)
|
||||
{
|
||||
@@ -133,8 +141,8 @@ public partial class ResearchList : PanelContainer
|
||||
|
||||
Button button = new Button
|
||||
{
|
||||
Text = "Research",
|
||||
Disabled = state != ResearchState.AVAILABLE,
|
||||
Text = GetResearchButtonText(GameData.availableResearch[id], state),
|
||||
Disabled = state != ResearchState.AVAILABLE || !GameData.availableResearch[id].CanStart(),
|
||||
TooltipText = tooltipText
|
||||
};
|
||||
|
||||
@@ -171,21 +179,57 @@ public partial class ResearchList : PanelContainer
|
||||
|
||||
private void OnResearchPressed(string id)
|
||||
{
|
||||
GameData.availableResearch[id].state = ResearchState.RESEARCHING;
|
||||
currentResearch.Add(GameData.availableResearch[id]);
|
||||
Research research = GameData.availableResearch[id];
|
||||
if (!research.CanStart()) return;
|
||||
if (currentResearch.Contains(research)) return;
|
||||
|
||||
research.state = ResearchState.RESEARCHING;
|
||||
currentResearch.Add(research);
|
||||
RecalculateResearchStates();
|
||||
SetupGraph();
|
||||
}
|
||||
|
||||
private string GetResearchButtonText(Research research, ResearchState state)
|
||||
{
|
||||
if (state == ResearchState.RESEARCHED) return "Done";
|
||||
if (state == ResearchState.RESEARCHING) return "Researching";
|
||||
if (state == ResearchState.LOCKED) return "Locked";
|
||||
if (!research.CanStart()) return "Missing items";
|
||||
|
||||
return "Research";
|
||||
}
|
||||
|
||||
private string GetResearchTooltip(Research research)
|
||||
{
|
||||
if (research.data.Effects == null || research.data.Effects.Count <= 0)
|
||||
{
|
||||
return Research.GetReadableName(research.data.Id);
|
||||
}
|
||||
|
||||
StringBuilder tooltip = new StringBuilder(Research.GetReadableName(research.data.Id));
|
||||
tooltip.AppendLine();
|
||||
tooltip.AppendLine();
|
||||
tooltip.AppendLine("Costs:");
|
||||
|
||||
if (research.data.Inputs.Count <= 0)
|
||||
{
|
||||
tooltip.AppendLine("- None");
|
||||
}
|
||||
|
||||
foreach (Ingredient ingredient in research.data.Inputs)
|
||||
{
|
||||
tooltip.Append("- ");
|
||||
tooltip.Append(ItemData.GetReadableName(ingredient.Item));
|
||||
tooltip.Append(": ");
|
||||
tooltip.Append(GameData.inventory.GetItemAmount(ingredient.Item));
|
||||
tooltip.Append("/");
|
||||
tooltip.AppendLine(ingredient.Amount.ToString());
|
||||
}
|
||||
|
||||
tooltip.AppendLine();
|
||||
tooltip.Append("Time: ");
|
||||
tooltip.AppendLine(research.data.CraftTime.ToString("0"));
|
||||
|
||||
if (research.data.Effects == null || research.data.Effects.Count <= 0)
|
||||
{
|
||||
return tooltip.ToString();
|
||||
}
|
||||
|
||||
tooltip.AppendLine();
|
||||
tooltip.AppendLine("Effects:");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user