/// <summary> /// Converts Floor Data into a serialized form for storage. /// </summary> /// <param name="readFrom">FloorMap to serialize</param> /// <returns>Serialized Grid representing the floor</returns> public static Int16[,] SerializeDungeon(FloorMap readFrom) { Int16[,] tempGrid = new Int16[readFrom.Width, readFrom.Height]; foreach( return tempGrid; }
/// <summary> /// Read a Noise Map and interpret into a FloorMap /// </summary> /// <param name="sourceFloor"></param> /// <returns></returns> protected FloorMap ExpandFloor(short[,] sourceNoiseMap, int sourceComplexity = FloorMap.DEFAULT_COMPLEXITY, int sourceSeed = FloorMap.DEFAULT_SEED) { //Tempted to make a constructor to do this for me automatically. Might not be a bad idea. //Think about making use of global scaling instead of per axis FloorMap tempFloor = new FloorMap((UInt32)sourceNoiseMap.GetLength(0) * this.MinWidth, (UInt32)sourceNoiseMap.GetLength(1) * this.MinHeight, sourceComplexity, sourceSeed); //how do I want to do this? It would likely be best to simply loop through tempFloor, and read the value from (ushort)floor(ix / scale) and (ushort)floor(iy / scale) // The current idea of how to generate a floor, is to generate a noiseMap, and then extrapolate that into a FloorMap. // On loading a map, the map gets populated, which entails placing default objects, and then applying the delta (if exists) // I will likely require a method to determine if a FloorTile is "active" so that mobs and events are rendered. // If I didn't need to track the position with an index, I'd love to do a simple foreach. Is it possible? // If I can't, is it possible to break the problem into 4 threads to run independently? Will need a lock. for (UInt32 ix = 0; ix < tempFloor.Width; ix++) { for (UInt32 iy = 0; iy < tempFloor.Height; iy++) { //Read the value -- Don't like this multiple casting. Look into a redesign. //Might be better to read the sourceFloor once, then apply the value using another set of for loops. //If the scaling factor was set, could hard code it in. Think about doing that for small standard scaling (4 or 8). tempFloor.SetPoint(ix, iy, sourceFloor.Floor[(UInt32)Math.Floor((double)ix / this.MinWidth), (UInt32)Math.Floor((double)iy / this.MinHeight)]); //This will work for a rough start } } return tempFloor; }
/// <summary> /// Deep Copy /// </summary> /// <param name="copyFrom">Object to Copy From</param> public FloorMap(FloorMap copyFrom) { this.Floor = copyFrom.Floor; //Add more fields obviously }
/// <summary> /// Generates a new Dungeon Floor, adding it to the end of the list. /// </summary> public void Generate() { //empty floor map FloorMap tempFloor;// = new FloorMap(this.Width, this.Height); UInt32 scaledWidth = this.Width / this.MinWidth; UInt32 scaledHeight = this.Height / this.MinHeight; FloorMap scaledFloor = new FloorMap(scaledWidth, scaledHeight, this.Complexity); //get noise type from MainWindow //Using Random for testing purposes FloorMap.NoiseTypes noiseType = FloorMap.NoiseTypes.Random; scaledFloor.GenerateFloor(noiseType, 0.5); //Fill out the tempFloor by multiplying the coords by the scaling factor tempFloor = ExpandFloor(scaledFloor); floors.Add(tempFloor); }