public static Dictionary <T, T2> GenerateDicFromJson <T, T2>(DicWrapper <T2> wrapper) where T : struct, IConvertible where T2 : class { Dictionary <T, T2> dic = new Dictionary <T, T2>(); foreach (PairWrapper <T2> obj in wrapper.objects) { T type = PropertyUtils.CastEnum <T>(obj.key); if (!dic.ContainsKey(type)) { dic.Add(type, obj.value); } } return(dic); }
public void Init(string pnjKey) { NPCWrap info = null; int l = ResourcesManager.Instance.NPCs.objects.Count; for (int i = 0; i < l; i++) { NPCWrap wrap = ResourcesManager.Instance.NPCs.objects[i]; if (wrap.ID == pnjKey) { info = wrap; break; } } if (info != null) { EWorldImpactType baseImpact = PropertyUtils.CastEnum <EWorldImpactType>(info.impactType); impacts.Add(baseImpact); type = ResourcesManager.GetBuildingType(baseImpact); BudgetValues values; if (ResourcesManager.Instance.BudgetValues.ContainsKey(baseImpact)) { values = ResourcesManager.Instance.BudgetValues[baseImpact]; } else { values = ResourcesManager.Instance.BudgetValues[EWorldImpactType.None]; } initialBudget = values.initialBudget; workingLimitBudget = values.workingLimitBudget; budget = values.initialBudget; productBenefit = values.productBenefit; } SetWorking(); ResourcesManager.Instance.AddBudgetComponent(this); }