12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using KairoEngine.Stats;
- using Sirenix.OdinInspector;
- namespace KairoEngine.Stockpiles
- {
- [System.Serializable]
- public class StockpileGroup
- {
- [FoldoutGroup("@groupName"), PropertySpace(4,4)] public string owner;
- public string groupName { get { return $"{owner} Resources"; }}
- [FoldoutGroup("@groupName"), HideIf("@stats.statGroup != null")]
- public List<Stockpile> initialStockpiles = new List<Stockpile>();
- [FoldoutGroup("@groupName"), InlineProperty, HideLabel, HideIf("@stats.statGroup == null"), PropertySpace(4,2)]
- public StatsController stats = new StatsController();
- public void Initialize(List<StockpilePreset> resourceTypes)
- {
- StatGroup statGroup = (StatGroup)ScriptableObject.CreateInstance("StatGroup");
- StatTemplate statTemplateSource = (StatTemplate)ScriptableObject.CreateInstance("StatTemplate");
- for (int i = 0; i < resourceTypes.Count; i++)
- {
- StatTemplate statTemplate = ScriptableObject.Instantiate(statTemplateSource);
- statTemplate.minValue = 0;
- statTemplate.maxValue = 0;
- statTemplate.initialValue = 0;
- statTemplate.title = resourceTypes[i].title;
- statTemplate.minValue = resourceTypes[i].minValue;
- statTemplate.maxValue = resourceTypes[i].maxValue;
- statTemplate.initialValue = resourceTypes[i].initialValue;
- for (int v = 0; v < initialStockpiles.Count; v++)
- {
- if(initialStockpiles[v].stockpileType.title == resourceTypes[i].title)
- {
- statTemplate.initialValue += initialStockpiles[v].ammount;
- statTemplate.maxValue += initialStockpiles[v].capacity;
- }
- }
- statGroup.statTemplates.Add(statTemplate);
- }
- stats.statGroup = statGroup;
- stats.Initialize();
- }
- }
- }
|