public void InstanciatePlot(TowerPlot plot) { var position = new Vector3(plot.X * ModelScale, GetHeight(plot.X, plot.Z), plot.Z * ModelScale); var instance = GameObject.Instantiate(PrefabManager.Instance.GetPrefab("towerplot"), position, Quaternion.identity, gameObject.transform); var plotController = instance.AddComponent <TowerPlotController>(); plotController.Plot = plot; MapChildren.Add(instance); }
public void InstanciateTower(TowerPlot plot) { var position = new Vector3(plot.X * ModelScale, GetHeight(plot.X, plot.Z), plot.Z * ModelScale); var prefab = PrefabManager.Instance.GetPrefab(plot.Tower.IsStronghold ? "stronghold" : "tower"); var instance = Instantiate(prefab, position, Quaternion.identity); var plotController = instance.AddComponent <TowerPlotController>(); plotController.Build(plot, position, instance, plotController); MapChildren.Add(instance); }
public void Build(TowerPlot plot, Vector3 position, GameObject instance, TowerPlotController plotController) { plotController.Plot = plot; if (!plot.Tower.IsStronghold) { var baseElementPrototype = PrototypeManager.Instance.GetPrototype <ElementPrototype>(plot.Tower.BaseElementUri); var bodyElementPrototype = PrototypeManager.Instance.GetPrototype <ElementPrototype>(plot.Tower.BodyElementUri); var weaponElementPrototype = PrototypeManager.Instance.GetPrototype <ElementPrototype>(plot.Tower.WeaponElementUri); var basePart = AddTowerPart(baseElementPrototype, TowerSlotType.Base, position, instance); var h = basePart.GetComponent <Renderer>().bounds.size.y; var bodyPart = AddTowerPart(bodyElementPrototype, TowerSlotType.Body, position + new Vector3(0, h, 0), instance); h += bodyPart.GetComponent <Renderer>().bounds.size.y; plotController.Weapon = AddTowerPart(weaponElementPrototype, TowerSlotType.Weapon, position + new Vector3(0, h, 0), instance); plotController.WeaponCenter = h + plotController.Weapon.GetComponent <Renderer>().bounds.size.y / 2; tooltip = instance.AddComponent <WorldTooltipProvider>(); UpdateTooltip(baseElementPrototype, bodyElementPrototype, weaponElementPrototype); } }