示例#1
0
        /// <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);
        }
示例#2
0
 /// <summary>
 /// Initializes the worldmanager instance.
 /// </summary>
 private void Initialize(World world)
 {
     currentWorld = world;
 }
示例#3
0
        /// <summary>
        /// Creates a world with a set of initial clusters as defined
        /// by the parameters.
        /// </summary>
        /// <param name="left">Max left cluster coordinate.</param>
        /// <param name="right">Max right cluster coordinate.</param>
        /// <param name="top">Max top cluster coordinate.</param>
        /// <param name="bottom">Max bottom cluster coordinate.</param>
        /// <returns></returns>
        public static World CreateWorld(int left, int right, int top, int bottom)
        {
            World world = new World((right - left) * (bottom - top));

              for (int y = top; y <= bottom; ++y)
              {
            for (int x = left; x <= right; ++x)
            {
              world.AddCluster(world.CreateCluster(x, y));
              //AddCluster(world, new Coordinates(x, y));
            }
              }

              return world;
        }