Beispiel #1
0
    public void Build(BuildableData buildable)
    {
        Vector3 avgPos = Vector3.zero;

        for (int i = 0; i < placedInArea.Count; i++)
        {
            avgPos += placedInArea[i].transform.position;
            Destroy(placedInArea[i].gameObject);
        }
        avgPos /= placedInArea.Count;
        placedInArea.Clear();
        areaDirty = true;
        if (placementLocation != null)
        {
            PlacementManager.Instance.SetTempArea(AreaType.Play);
            placementLocation.SetPlacable(buildable);
            PlacementManager.Instance.RestoreArea();
        }
        else
        {
            PlayerManager.Instance.AddInventory(buildable);
        }
        if (upgrading != null)
        {
            SetUpgrading(buildable as UpgradableData);
            builtObj = null;
        }
        else
        {
            builtObj = Instantiate(buildable.Prefab, avgPos, Quaternion.identity, transform);
        }
        StartCoroutine(StoreBuilt());
    }