Beispiel #1
0
    /// <summary>
    /// Creates a province starting at the given position.
    /// </summary>
    /// <param name="coords">The starting location of the province.</param>
    /// <param name="faction">The faction to which this province belongs.</param>
    /// <param name="range">The radius of the new province.</param>
    public static void CreateProvinceAt(TileCoordinates coords, Faction faction, string name, int range = 3)
    {
        Province province = worldManager.CreateProvince();

        province.faction = faction;
        province.name    = name.Replace(" ", "\n");

        // add territory within the range
        for (int x = -range; x <= range; x++)
        {
            for (int z = -range; z <= range; z++)
            {
                if (Math.Abs(x + z) > range)
                {
                    continue;
                }

                Tile tile = GetTileAt(new TileCoordinates(x + coords.x, z + coords.z));
                if (tile == null || tile.faction != null)
                {
                    continue;                                         // if the tile doesn't exist or the tile is already owned
                }
                province.AddTile(tile);
            }
        }

        _provinces.Add(province);
        faction.AddProvince(province);
        worldManager.CreateProvinceLabel(coords, name);

        InvalidateProvinceMesh();
    }