ProgressController
Events
OnStartResearchFailed
Called when starting a research has failed. Returns a ProgressEventStats code
progressController.OnStartResearchFailed += OnResearchFailed;
void OnResearchFailed(ProgressEventData.ProgressEventStatus _status)
{
Debug.Log("Research failed! Status: " + _status);
}
OnStartResearch
Called when a research has been started
progressController.OnStartResearch += OnStartResearch
void OnStartResearch(ProgressNode _event)
{
if (_event != null)
{
Debug.Log("Research started " + _event.title);
}
}
OnResearchComplete
Called when a research has been completed
progressController.OnResearchComplete += OnResearchComplete;
void OnResearchComplete(ProgressNode _event)
{
if (_event != null)
{
Debug.Log("Research complete " + _event.title);
}
}
OnResearchUnlocked
Called when new nodes has been unlocked. Returns a list with all newly unlocked nodes.
progressController.OnResearchUnlocked += OnResearchUnlocked;
void OnResearchUnlocked(List<ProgressNode>_eventData)
{
Debug.Log("New nodes has been unlocked " + _eventData.Count);
}
OnResearchProgress
Constantly returns the current progress of a research.
progressController.OnResearchProgress += ResearchProgress;
void ResearchProgress(float _value)
{
Debug.Log("current progress: " + _value);
}
Methods
SetUIController
Set a different Progress UI controller. Can be used to switch between themes for example.
progressController.SetUIController(themeObject1);
LoadProgressGraph
Load a Progress Graph. You can optionally pass a name of a Progress Graph. If the name is empty the assigned Progress Graph will be loaded.
progressController.LoadProgressGraph();
progressController.LoadProgressGraph("PlayerProgress");
StartResearchInProgressGraphByTitle
Start a new research by its title name.
public void StartResearchSpecificNode()
{
// Research a specific node in the progress graph
var _node = progressController.StartResearchInProgressGraphByTitle("Bio Engineering");
if (_node != null)
{
_node.OnResearchProgress -= Progress;
_node.OnResearchProgress += Progress;
}
else
{
// Research failed. Maybe because we don't have enough resources
Debug.Log("Research failed, not enough resources");
}
}
Last updated