37 lines
907 B
C#
37 lines
907 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using TransportGame.Model;
|
|
using TransportGame.Noise;
|
|
using UnityEngine;
|
|
|
|
namespace TransportGame.Generator
|
|
{
|
|
public class PopulationCentersGenerator
|
|
{
|
|
System.Random random = new System.Random();
|
|
|
|
public void Generate(Map map)
|
|
{
|
|
// Generate a number of points
|
|
int maxPoints = map.Width * map.Height / (1024 * 512);
|
|
int points = random.Next(maxPoints / 4, maxPoints);
|
|
|
|
for (int i = 0; i < points; ++i)
|
|
{
|
|
int px, py;
|
|
|
|
do
|
|
{
|
|
px = random.Next(map.Width);
|
|
py = random.Next(map.Height);
|
|
}
|
|
while (map.IsWater(px, py));
|
|
|
|
map.PopulationCenters.Add(new Point(px, py));
|
|
}
|
|
}
|
|
}
|
|
}
|