Beispiel #1
0
    public GameObject byHeight(TilePosition p)
    {
        float sum = 0.0f;

        for (int i = 0; i < 20; i++)
        {
            sum += weights [0, i] * (float)Math.Sin((float)(p.GetX() - offsets[0, i]) * 2 / (i + 1));
            sum += weights [1, i] * (float)Math.Sin((float)(p.GetY() - offsets[1, i]) * 2 / (i + 1));
            sum += weights [2, i] * (float)Math.Sin((float)(p.GetZ() - offsets[2, i]) * 2 / (i + 1));
        }
        if (sum > 3.4 || sum < -3.4)
        {
            return(Instantiate(tree));
        }
        else if (sum > 1.7 || sum < -1.7)
        {
            if ((sum - sum % 0.01) % 0.1 == 0.06)
            {
                return(Instantiate(village));
            }
            else
            {
                return(Instantiate(ground));
            }
        }
        else
        {
            return(Instantiate(water));
        }
    }
Beispiel #2
0
 public T this[TilePosition p] {
     get {
         TilePosition rounded = p.Round();
         return(this [(int)rounded.GetX(), (int)rounded.GetY(), (int)rounded.GetZ()]);
     }
     set {
         TilePosition rounded = p.Round();
         this [(int)rounded.GetX(), (int)rounded.GetY(), (int)rounded.GetZ()] = value;
     }
 }
Beispiel #3
0
 public float Distance(TilePosition other)
 {
     return(Math.Abs(GetX() - other.GetX()) + Math.Abs(GetY() - other.GetY()) + Math.Abs(GetZ() - other.GetZ()));
 }
Beispiel #4
0
 bool isLand(TilePosition p)
 {
     return(isLand((int)p.GetX(), (int)p.GetY(), (int)p.GetZ()));
 }