/// <summary> /// Insert a cluster at the given coordinates in cluster space. /// </summary> /// <param name="clusterCoordinates"></param> private static void AddCluster(World world, Coordinates clusterCoordinates) { Cluster cluster = new Cluster(ClusterType.Evergreen, clusterCoordinates); Matrix clusterOffset = Matrix.CreateTranslation(new Vector3(-0.5f, -0.5f, 0)); Matrix tileTranslate = /*TilePositionTransform **/ TileClusterTransform * clusterOffset * ClusterTileTransform ; for (int y = 0; y < Constants.ClusterHeight; ++y) { for (int x = 0; x < Constants.ClusterWidth; ++x) { Vector2 tilePos = Vector2.Transform(new Vector2(x, y), tileTranslate); Tile t = cluster.GetTileAt(x, y); t.Type = TileType.Grass; cluster.SetTileAt(x, y, t); } } world.AddCluster(cluster); }
public Cluster CreateCluster(int clusterX, int clusterY) { Cluster cluster = new Cluster(ClusterType.Evergreen, clusterX, clusterY); for (int y = 0; y < Constants.ClusterHeight; ++y) { for (int x = 0; x < Constants.ClusterWidth; ++x) { Vector2 tilePos = new Vector2( x - Constants.ClusterWidth / 2, y - Constants.ClusterHeight / 2 ); Tile t = cluster.GetTileAt(x, y); if ((x == 0 || x == Constants.ClusterWidth - 1) || (y == 0 || y == Constants.ClusterHeight - 1)) { t.Type = TileType.Grass; } else { t.Type = TileType.Water; } //t.Type = (TileType)(rand.Next() % 2 + 1); cluster.SetTileAt(x, y, t); } } return cluster; }