public TurretAssembly Assemble(RootModel model) { GameObject assemblyObject = UnityEngine.Object.Instantiate(Resources.Load <GameObject>(ASSEMBLY_PREFAB_PATH)); TurretAssembly assembly = assemblyObject.GetComponent <TurretAssembly>(); ObjectModel obj = model.Root as ObjectModel; assembly.Name = obj.GetValue <string>("Name"); assembly.Description = obj.GetValue <string>("Description"); ObjectModel tiers = obj.GetObject("Tiers"); UpgradeMap upgrades = _valueAssembler.Assemble(obj.GetObject("UpgradeMap"), typeof(UpgradeMap), new AssemblyContext()) as UpgradeMap; foreach (var tierProperty in tiers.GetProperties()) { Transform tierObj = AssembleTier(tierProperty.Model as ObjectModel, assembly).transform; Tier tier = Tier.Parse(tierProperty.Name); tierObj.gameObject.SetActive(false); tierObj.gameObject.name = tier.ToString(); assembly.AddTier(tierObj, tier); } assembly.UpgradeMap = upgrades; assembly.SetTier(Tier.Initial); return(assembly); }
private bool UpgradeTo(Tier tier) { var cost = GetCost(tier); if (Player.Player.Resources.TrySpend(cost)) { _assembly.SetTier(tier); _assembly.InvokeChanged(); } return(true); }
public void SetTier(Tier tier) { CurrentAsssembly.SetTier(tier); StatDisplay.SetTarget(GetWorkingTierParent().gameObject); }