Beispiel #1
0
    void SetTowns()
    {
        foreach (var reg in regions)
        {
            if (!reg.iswater)
            {
                GameObject go = new GameObject(reg.id.ToString());
                reg.Town = go;
                go.tag   = "Town";
                go.AddComponent <SphereCollider>().radius = 0.71f;
                go.transform.SetParent(Towns);
                go.layer = 9;
                GameObject town = new GameObject();
                town.transform.SetParent(go.transform);
                town.transform.localPosition = Vector3.zero;

                town = Instantiate(flagPrefab, go.transform);
                town.transform.localPosition = Vector3.zero;
                reg.flag = town.transform;
                reg.pos  = NavAgent.FromV3(go.transform.position = MapMetrics.RayCastedGround(reg.Capital + Vector2.one * 0.5f));
                go.transform.rotation = Quaternion.Euler(0, UnityEngine.Random.Range(-90, 90), 0);
                go.transform.GetChild(1).localRotation = Quaternion.Inverse(go.transform.rotation);
                if (reg.portIdto >= 0)
                {
                    BuildPort(reg);
                }
                else
                {
                    reg.data.buildings[(int)BuildingType.Port] = 0;
                }

                TownBar bar = Instantiate(PrefabHandler.GethpTownBarPrefab, instance.mainCanvas);
                reg.bar           = bar;
                bar.currentRegion = reg;
                reg.RebuildTown();
            }
        }
    }