Class ResourcesController
Keep track of all the ResourceManager and ResourceRegeneration for each Resource for a GameObject.
It will Update every ResourceRegeneration timers automatically.
We can also add new ResourceManager or new ResourceRegeneration at runtime, initialize them with Values from UniData InitialResourcesValue for example.
Inheritance
object
ResourcesController
Assembly: cs.temp.dll.dll
Syntax
public class ResourcesController : MonoBehaviour
Fields
_initialized
Declaration
protected bool _initialized
Field Value
_progressBars
We can populate the list of ProgressBar to add them automatically at runtime to the corresponding ResourceManager.
Declaration
protected List<ProgressBar> _progressBars
Field Value
_regenerateResources
Declaration
protected bool _regenerateResources
Field Value
_resourceManagers
Declaration
protected List<ResourceManager> _resourceManagers
Field Value
_resourcesRegeneration
Declaration
protected List<ResourceRegeneration> _resourcesRegeneration
Field Value
Properties
Initialized
Determines if the script is initialized, it's done in the Awake method.
Declaration
public bool Initialized { get; }
Property Value
ProgressBars
ReadOnly list of the ProgressBar.
Declaration
public IReadOnlyList<ProgressBar> ProgressBars { get; }
Property Value
RegenerateResources
Determines if it calls the Regenerate method of all the ResourceRegeneration inside the Update method.
It should be true unless you want to make your own script to update every ResourceRegeneration
inside a single component for slightly better performance.
Declaration
public bool RegenerateResources { get; set; }
Property Value
ResourceManagers
ReadOnly list of the ResourceManager.
Call AddResourceManager method if you need to add ResourceManager at runtime.
Declaration
public IReadOnlyList<ResourceManager> ResourceManagers { get; }
Property Value
ResourcesRegeneration
ReadOnly list of the ResourceRegeneration.
Call AddResourceRegeneration method if you need to add ResourceRegeneration at runtime.
Declaration
public IReadOnlyList<ResourceRegeneration> ResourcesRegeneration { get; }
Property Value
Methods
AddResourceManager(ResourceManager)
Tries to add a ResourceManager if it doesn't exist already for the Resource.
Declaration
public bool AddResourceManager(ResourceManager resourceManager)
Parameters
Returns
AddResourceRegeneration(ResourceRegeneration)
Tries to add a ResourceRegeneration if it doesn't exist already for the Resource.
Declaration
public bool AddResourceRegeneration(ResourceRegeneration resourceRegeneration)
Parameters
Returns
Awake()
Declaration
protected virtual void Awake()
GetProgressBar(Resource)
Returns the ProgressBar corresponding to the Resource.
Declaration
public ProgressBar GetProgressBar(Resource resource)
Parameters
Returns
GetResourceManager(Resource)
Returns the ResourceManager corresponding to the Resource.
Declaration
public ResourceManager GetResourceManager(Resource resource)
Parameters
Returns
Type |
Description |
ResourceManager |
Null if the there is no ResourceValueManager associated to the Resource.
|
GetResourceRegeneration(Resource)
Returns the ResourceRegeneration corresponding to the Resource.
Declaration
public ResourceRegeneration GetResourceRegeneration(Resource resource)
Parameters
Returns
Type |
Description |
ResourceRegeneration |
Null if the there is no ResourceRegeneration associated to the Resource.
|
InitializeResourceManagers()
Initialize every ResourceManager.
Declaration
protected virtual void InitializeResourceManagers()
InitializeResourceRegenerations()
Get the value manager for each ResourceRegeneration to initialize them.
Declaration
protected virtual void InitializeResourceRegenerations()
ResourceManagerExist(Resource)
Determines if a ResourceManager already exist for a specific resource.
Declaration
public bool ResourceManagerExist(Resource resource)
Parameters
Returns
ResourceRegenerationExist(Resource)
Determines if a ResourceManager already exist for a specific resource.
Declaration
public bool ResourceRegenerationExist(Resource resource)
Parameters
Returns