/// <summary> /// Helper to place objects on the map /// </summary> /// <param name="areaColorCoordinates">area color coordinates</param> /// <param name="altitude">altitude of textures</param> /// <param name="itemid">item id</param> /// <param name="zItem">item z</param> /// <param name="texture">texture</param> /// <param name="normal">is it cliff or not</param> /// <returns>true</returns> public bool PlaceObject(AreaColorCoordinates areaColorCoordinates, sbyte altitude, int itemid, sbyte zItem, int texture, bool normal = true) { var mapObject = !normal ? Center : SouthEast; if (mapObject.Occupied != 0 && (mapObject.Occupied != (byte)TypeColor.WaterCoast && itemid != (int)SpecialAboutItems.ClearAll)) { return(true); } if (itemid >= 0) { mapObject.Items = new List <ItemClone> { new ItemClone { Id = itemid, Z = zItem } } } ; if (itemid == (int)SpecialAboutItems.ClearAll) { mapObject.Items = null; } mapObject.Occupied = (byte)areaColorCoordinates.Center.Type; if (texture >= 0) { Center.Texture = (short)texture; } Center.Altitude = altitude; return(true); }
/// <summary> /// Helper to place objects on the map /// </summary> /// <param name="areaColorCoordinates">area color coordinates</param> /// <param name="altitude">altitude of textures</param> /// <param name="itemid">item id</param> /// <param name="zItem">item z</param> /// <param name="texture">texture</param> /// <param name="normal">is it cliff or not</param> /// <returns>true</returns> public bool PlaceObject(AreaColorCoordinates areaColorCoordinates, sbyte altitude, int itemid, sbyte zItem, int texture, bool normal = true) { var mapObject = !normal ? Center : SouthEast; if (mapObject.Occupied != 0 && (mapObject.Occupied != (byte)TypeColor.WaterCoast && itemid != (int)SpecialAboutItems.ClearAll)) return true; if (itemid >= 0) mapObject.Items = new List<ItemClone> { new ItemClone { Id = itemid, Z = zItem } }; if (itemid == (int)SpecialAboutItems.ClearAll) mapObject.Items = null; mapObject.Occupied = (byte)areaColorCoordinates.Center.Type; if (texture >= 0) Center.Texture = (short)texture; Center.Altitude = altitude; return true; }
/// <summary> /// function to make the translations with items /// </summary> /// <param name="coordinates"> </param> /// <param name="areaColorCoordinates"> </param> /// <param name="mapObjectCoordinates"> </param> private void ItemsTransitions (Coordinates coordinates, AreaColorCoordinates areaColorCoordinates, MapObjectCoordinates mapObjectCoordinates, Random random) { if (areaColorCoordinates.Center.Type == TypeColor.Cliff) return; if (mapObjectCoordinates.Center.Items != null || mapObjectCoordinates.Center.Occupied != 0) return; //int special = 0; var texturelist = areaColorCoordinates.List.Select(o => o.TextureIndex).Distinct(); if (texturelist.Count() <= 1) return; var transitionList = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems; if (!transitionList.List.Any()) return; transitionList.InitializeSeaches(); if (areaColorCoordinates.List.All(o => o.Color == areaColorCoordinates.Center.Color)) return; var indexes = areaColorCoordinates.List.Select(o => o.TextureIndex); AreaTransitionItem k = null; foreach (var id in indexes) { k = transitionList.FindById(id); if (k != null) break; } if (k == null) return; int zlev = 0; var item = new ItemClone(); #region Border //Border //GB //xG if (areaColorCoordinates.NorthEast.Color != areaColorCoordinates.Center.Color) { var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.NorthEast.Color); //7 if (transation != null) item = new ItemClone() {Id = RandomFromList(transation.BorderSouthWest.List, random)}; } //BG //Gx if (areaColorCoordinates.NorthWest.Color != areaColorCoordinates.Center.Color) { var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.NorthWest.Color); //6 if (transation != null) item = new ItemClone {Id = RandomFromList(transation.BorderSouthEast.List, random)}; } //Gx //BG if (areaColorCoordinates.SouthWest.Color != areaColorCoordinates.Center.Color) { var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.SouthWest.Color); //5 if (transation != null) item = new ItemClone {Id = RandomFromList(transation.BorderNorthEast.List, random)}; } //xG //GB if (areaColorCoordinates.SouthEast.Color != areaColorCoordinates.Center.Color) { var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.SouthEast.Color); //4 if (transation != null) item = new ItemClone {Id = RandomFromList(transation.BorderNorthWest.List, random)}; } #endregion //Border #region Line //Line // B //GxG if (areaColorCoordinates.North.TextureIndex != areaColorCoordinates.Center.TextureIndex) { //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.North.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById( areaColorCoordinates.North.TextureIndex); //2 if (transition != null) item = new ItemClone {Id = RandomFromList(transition.LineSouth.List, random)}; } //GxG // B if (areaColorCoordinates.South.TextureIndex != areaColorCoordinates.Center.TextureIndex) { //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.South.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems. FindById( areaColorCoordinates.South.TextureIndex); //0 if (transition != null) item = new ItemClone {Id = RandomFromList(transition.LineNorth.List, random)}; } //G //xB //G if (areaColorCoordinates.East.TextureIndex != areaColorCoordinates.Center.TextureIndex) { //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.East.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById( areaColorCoordinates.East.TextureIndex); //3 if (transition != null) item = new ItemClone {Id = RandomFromList(transition.LineWest.List, random)}; } // G //Bx // G if (areaColorCoordinates.West.TextureIndex != areaColorCoordinates.Center.TextureIndex) { //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.West.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById( areaColorCoordinates.West.TextureIndex); //1 if (transition != null) item = new ItemClone {Id = RandomFromList(transition.LineEast.List, random)}; } #endregion //Line #region Edge //Edge //B //xB if ( areaColorCoordinates.East.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.North.TextureIndex != areaColorCoordinates.Center.TextureIndex ) { //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.NorthEast.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById( areaColorCoordinates.NorthEast.TextureIndex); //11 if (transition != null) item = new ItemClone {Id = RandomFromList(transition.EdgeSouthWest.List, random)}; } // B //Bx if ( areaColorCoordinates.West.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.North.TextureIndex != areaColorCoordinates.Center.TextureIndex ) { //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.NorthWest.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById( areaColorCoordinates.NorthWest.TextureIndex); //10 if (transition != null) item = new ItemClone {Id = RandomFromList(transition.EdgeSouthEast.List, random)}; } //Bx // B if ( areaColorCoordinates.West.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.South.TextureIndex != areaColorCoordinates.Center.TextureIndex ) { //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.SouthWest.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById( areaColorCoordinates.SouthWest.TextureIndex); //9 if (transition != null) item = new ItemClone {Id = RandomFromList(transition.EdgeNorthEast.List, random)}; } //xB //B if ( areaColorCoordinates.East.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.South.TextureIndex != areaColorCoordinates.Center.TextureIndex ) { var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].CollectionAreaItems.FindById( areaColorCoordinates.SouthEast.TextureIndex); //var transation = areaColorCoordinates.Center.FindTransationItemByColor(areaColorCoordinates.SouthEast.Color); //8 if (transition != null) item = new ItemClone {Id = RandomFromList(transition.EdgeNorthWest.List, random)}; } #endregion //Edge if (item.Id == 0) return; var coast = areaColorCoordinates.Center; if (coast.Type == TypeColor.Water) { //zlev = random.Next(coast.Min, coast.Max); item.Z = (sbyte) areaColorCoordinates.Center.ItemsAltitude; } if (mapObjectCoordinates.Center.Items == null) mapObjectCoordinates.Center.Items = new List<ItemClone>(); mapObjectCoordinates.Center.Items.Add(item); }
/// <summary> /// transitions from a kind of terrain to anotherkind /// </summary> /// <param name="coordinates"> </param> /// <param name="areaColorCoordinates"> </param> /// <param name="mapObjectCoordinates"> </param> private void TextureTransition(Coordinates coordinates, AreaColorCoordinates areaColorCoordinates, MapObjectCoordinates mapObjectCoordinates, Random random) { var textureids = areaColorCoordinates.List.Select(o => o.TextureIndex).Distinct(); var enumerable = textureids as int[] ?? textureids.ToArray(); if (enumerable.Count() == 1) return; if (areaColorCoordinates.Center.Type == TypeColor.Cliff) return; var transitionList = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture; if (!transitionList.List.Any()) return; transitionList.InitializeSeaches(); if (areaColorCoordinates.List.All(o => o.Color == areaColorCoordinates.Center.Color)) return; AreaTransitionTexture textureTransition = null; foreach (var id in enumerable) { textureTransition = transitionList.FindById(id); if (textureTransition != null) break; } if (textureTransition == null) return; int special = 0; int z = 0; if (mapObjectCoordinates.Center.Occupied != 0) return; #region Line //Line // B //xAx //y1 = y - 1; if ( areaColorCoordinates.North.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.East.TextureIndex != areaColorCoordinates.North.TextureIndex && areaColorCoordinates.West.TextureIndex != areaColorCoordinates.North.TextureIndex ) { var transation = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.North.TextureIndex); if (transation != null) { special = 1; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transation.LineSouth.List, random); z = mapObjectCoordinates.North.Altitude + mapObjectCoordinates.South.Altitude; } } //xAx // B ////y1 = y + 1; if ( areaColorCoordinates.South.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.East.TextureIndex != areaColorCoordinates.South.TextureIndex && areaColorCoordinates.West.TextureIndex != areaColorCoordinates.South.TextureIndex ) { var transation = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.South.TextureIndex); if (transation != null) { special = 2; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transation.LineNorth.List, random); z = mapObjectCoordinates.South.Altitude + mapObjectCoordinates.North.Altitude; } } //x //AB //x //x1 = x + 1; if ( areaColorCoordinates.East.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.North.TextureIndex != areaColorCoordinates.East.TextureIndex && areaColorCoordinates.South.TextureIndex != areaColorCoordinates.East.TextureIndex ) { var transation = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.East.TextureIndex); if (transation != null) { special = 2; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transation.LineWest.List, random); z = mapObjectCoordinates.East.Altitude + mapObjectCoordinates.West.Altitude; } } // x //BA // x //x1 = x - 1; if ( areaColorCoordinates.West.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.West.TextureIndex != areaColorCoordinates.North.TextureIndex && areaColorCoordinates.West.TextureIndex != areaColorCoordinates.South.TextureIndex ) { var transation = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.West.TextureIndex); if (transation != null) { special = 1; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transation.LineEast.List, random); z = mapObjectCoordinates.West.Altitude + mapObjectCoordinates.East.Altitude; } } #endregion //Line #region Border //Border //xB //Ax if ( areaColorCoordinates.NorthEast.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.East.TextureIndex != areaColorCoordinates.NorthEast.TextureIndex && areaColorCoordinates.North.TextureIndex != areaColorCoordinates.NorthEast.TextureIndex ) { //var transition = areaColorCoordinates.Center.FindTransitionTexture(areaColorCoordinates.NorthEast.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.NorthEast.TextureIndex); special = 2; if (transition != null) { mapObjectCoordinates.Center.Texture = (short) RandomFromList(transition.BorderSouthWest.List, random); z = mapObjectCoordinates.NorthEast.Altitude + mapObjectCoordinates.SouthWest.Altitude; } } //Bx //xA if ( areaColorCoordinates.NorthWest.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.West.TextureIndex != areaColorCoordinates.NorthWest.TextureIndex && areaColorCoordinates.North.TextureIndex != areaColorCoordinates.NorthWest.TextureIndex ) { //var transition = areaColorCoordinates.Center.FindTransitionTexture(areaColorCoordinates.NorthWest.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.NorthWest.TextureIndex); if (transition != null) { special = 1; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transition.BorderSouthEast.List, random); z = mapObjectCoordinates.NorthWest.Altitude + mapObjectCoordinates.SouthEast.Altitude; } } //GA //BG if ( areaColorCoordinates.SouthWest.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.West.TextureIndex != areaColorCoordinates.SouthWest.TextureIndex && areaColorCoordinates.South.TextureIndex != areaColorCoordinates.SouthWest.TextureIndex ) { //var transation = areaColorCoordinates.Center.FindTransitionTexture(areaColorCoordinates.SouthWest.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.SouthWest.TextureIndex); if (transition != null) { special = 2; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transition.BorderNorthEast.List, random); z = mapObjectCoordinates.NorthWest.Altitude + mapObjectCoordinates.NorthEast.Altitude; } } //Ax //xB if ( areaColorCoordinates.SouthEast.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.East.TextureIndex != areaColorCoordinates.SouthEast.TextureIndex && areaColorCoordinates.South.TextureIndex != areaColorCoordinates.SouthEast.TextureIndex ) { //var transation = areaColorCoordinates.Center.FindTransitionTexture(areaColorCoordinates.SouthEast.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.SouthEast.TextureIndex); if (transition != null) { special = 2; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transition.BorderNorthWest.List, random); z = _mapObjects[coordinates.SouthEast].Altitude + _mapObjects[coordinates.NorthWest].Altitude; } } #endregion // Border #region Edge //Edge //B //AB if ( areaColorCoordinates.NorthEast.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.North.TextureIndex == areaColorCoordinates.NorthEast.TextureIndex && areaColorCoordinates.NorthEast.TextureIndex == areaColorCoordinates.East.TextureIndex ) { //var transition = // areaColorCoordinates.Center.FindTransitionTexture(areaColorCoordinates.NorthEast.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.NorthEast.TextureIndex); if (transition != null) { special = 2; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transition.EdgeSouthWest.List, random); z = mapObjectCoordinates.NorthEast.Altitude + mapObjectCoordinates.SouthWest.Altitude; } } // B //BA if ( areaColorCoordinates.NorthWest.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.North.TextureIndex == areaColorCoordinates.NorthWest.TextureIndex && areaColorCoordinates.NorthWest.TextureIndex == areaColorCoordinates.West.TextureIndex ) { //var transation = // areaColorCoordinates.Center.FindTransitionTexture(areaColorCoordinates.West.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.West.TextureIndex); if (transition != null) { special = 1; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transition.EdgeSouthEast.List, random); z = mapObjectCoordinates.NorthEast.Altitude + mapObjectCoordinates.SouthWest.Altitude; } } //BA // B if ( areaColorCoordinates.SouthWest.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.South.TextureIndex == areaColorCoordinates.SouthWest.TextureIndex && areaColorCoordinates.SouthWest.TextureIndex == areaColorCoordinates.West.TextureIndex ) { //var transation = // areaColorCoordinates.Center.FindTransitionTexture(areaColorCoordinates.SouthWest.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.SouthWest.TextureIndex); if (transition != null) { special = 2; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transition.EdgeNorthEast.List, random); z = mapObjectCoordinates.SouthWest.Altitude + mapObjectCoordinates.NorthEast.Altitude; } } //AB //B if ( areaColorCoordinates.SouthEast.TextureIndex != areaColorCoordinates.Center.TextureIndex && areaColorCoordinates.South.TextureIndex == areaColorCoordinates.SouthEast.TextureIndex && areaColorCoordinates.East.TextureIndex == areaColorCoordinates.SouthEast.TextureIndex ) { //var transation = // areaColorCoordinates.Center.FindTransitionTexture(areaColorCoordinates.SouthEast.Color); var transition = TextureAreas._fast[areaColorCoordinates.Center.TextureIndex].AreaTransitionTexture.FindById( areaColorCoordinates.SouthEast.TextureIndex); if (transition != null) { special = 2; mapObjectCoordinates.Center.Texture = (short) RandomFromList(transition.EdgeNorthWest.List, random); z = mapObjectCoordinates.SouthEast.Altitude + mapObjectCoordinates.NorthWest.Altitude; } } if (special > 0) mapObjectCoordinates.Center.Occupied = 1; if (_bitmapZ[coordinates.Center] == 128) { _mapObjects[coordinates.Center].Altitude = (sbyte) (z/2); } #endregion Edge }
/// <summary> /// method to init the mountains textures /// </summary> private void Mountain(AreaColorCoordinates areacoord, MapObjectCoordinates mapObjectCoordinates, Coordinates coord, Random random) { if (areacoord.Center == null || areacoord.Center.Type != TypeColor.Moutains) return; mapObjectCoordinates.Center.Altitude = (sbyte) random.Next(areacoord.Center.Min, areacoord.Center.Max); if (!areacoord.Center.ModeAutomatic) return; for (int index = 0; index < areacoord.Center.List.Count; index++) { var cirlce = areacoord.Center.List[index]; var areacircles = new AreaColorCoordinates( new Coordinates(index, index, coord.X, coord.Y, _stride, _bitmapAreaColor.Length), _bitmapAreaColor); if (areacircles.List == null) { break; } if (areacircles.List.Any(c => c == null || c.Type != TypeColor.Moutains)) { break; } mapObjectCoordinates.Center.Altitude = (sbyte) random.Next(cirlce.From, cirlce.To); if (mapObjectCoordinates.Center.Altitude > 127) mapObjectCoordinates.Center.Altitude = (sbyte) (random.Next(120, 125)); if (index >= (areacoord.Center.List.Count/3)*2 && areacoord.Center.IndexColorTopMountain != 0) { var area = _bitmapAreaColor[coord.Center]; area = CollectionAreaColor.FindByIndex(area.IndexColorTopMountain); mapObjectCoordinates.Center.Texture = (short) RandomTexture(area.TextureIndex, random); _bitmapAreaColor[coord.Center] = CollectionAreaColor.FindByColor(area.ColorTopMountain); } } }
private void PlaceTextures(AreaColorCoordinates areaColorCoordinates, MapObjectCoordinates mapObjectCoordinates, Coordinates coordinates, Random random) { if (areaColorCoordinates.Center == null) return; if (mapObjectCoordinates.Center.Texture == 0) mapObjectCoordinates.Center.Texture = (short) RandomTexture(areaColorCoordinates.Center.TextureIndex, random); }
/// <summary> /// Thread task to read the bmp file and generate the mapobject relatives /// </summary> /// <param name="X">max X coordinate</param> /// <param name="Y">max Y coordinate</param> /// <param name="minX">min X coordinate</param> /// <param name="minY">min Y coordinate </param> private void BuildMapThread(int X, int Y, int minX, int minY) { try { var random = new Random(); for (var x = minX; x < X - 1; x++) { for (var y = minY; y < Y - 1; y++) { var coordinates = MakeIndexesDirections(x, y, 1, 1); var areacolorcoordinates = new AreaColorCoordinates(coordinates, _bitmapAreaColor); var buildMapCoordinates = new MapObjectCoordinates(coordinates, _mapObjects); if (AutomaticZMode) Mountain(areacolorcoordinates, buildMapCoordinates, coordinates, random); TransparentFluid(areacolorcoordinates, buildMapCoordinates, coordinates, random); MakeCoastUolStyle(areacolorcoordinates, buildMapCoordinates, coordinates, random); TextureTransition(coordinates, areacolorcoordinates, buildMapCoordinates, random); MakeCliffs(coordinates, areacolorcoordinates, buildMapCoordinates, random); ItemsTransitions(coordinates, areacolorcoordinates, buildMapCoordinates, random); PlaceTextures(areacolorcoordinates, buildMapCoordinates, coordinates, random); if (!AutomaticZMode) ProcessZ(AutomaticZMode, buildMapCoordinates, coordinates); } } var percent1 = (100*(X - minX))/(_X); _progressPerc += percent1; OnProgressText(new ProgressEventArgs() {PayLoad = "Making Map", Progress = (byte) Math.Round(_progressPerc)}); } catch (Exception e) { throw e; } }
/// <summary> /// method to make cliff /// </summary> /// <param name="coordinates"> </param> /// <param name="Areacoordinates"> </param> /// <param name="mapObjectCoordinates"> </param> private static void MakeCliffs(Coordinates coordinates, AreaColorCoordinates Areacoordinates, MapObjectCoordinates mapObjectCoordinates, Random random) { if (Areacoordinates.Center.Type != TypeColor.Cliff) return; mapObjectCoordinates.Center.Altitude = 0; //********************** //* Line * //********************** if (Areacoordinates.North.Type == TypeColor.Cliff && Areacoordinates.South.Type == TypeColor.Cliff) { var areaTransitionCliffTexture = Areacoordinates.West.TransitionCliffTextures.FirstOrDefault( o => o.Directions == DirectionCliff.WestEast && o.ColorTo == Areacoordinates.East.Color); if (areaTransitionCliffTexture != null) mapObjectCoordinates.Center.Texture = (short)RandomFromList(areaTransitionCliffTexture.List, random); return; } if (Areacoordinates.East.Type == TypeColor.Cliff && Areacoordinates.West.Type == TypeColor.Cliff) { var areaTransitionCliffTexture = Areacoordinates.North.TransitionCliffTextures.FirstOrDefault( o => o.Directions == DirectionCliff.NorthSouth && o.ColorTo == Areacoordinates.South.Color); if (areaTransitionCliffTexture != null) mapObjectCoordinates.Center.Texture = (short)RandomFromList(areaTransitionCliffTexture.List, random); return; } ////********************** ////* Anfang und Ende * ////********************** // ! // ?X? // C if (Areacoordinates.South.Type == TypeColor.Cliff && Areacoordinates.North.Type != TypeColor.Cliff && Areacoordinates.East.Type != TypeColor.Cliff && Areacoordinates.West.Type != TypeColor.Cliff) { AreaTransitionCliffTexture areaTransitionCliffTexture = null; if (Areacoordinates.North.Type != TypeColor.Cliff) areaTransitionCliffTexture = Areacoordinates.North.TransitionCliffTextures.FirstOrDefault( c => c.Directions == DirectionCliff.NorthEnd && c.ColorTo == Areacoordinates.North.Color); if (areaTransitionCliffTexture != null) AddTexture(RandomFromList(areaTransitionCliffTexture.List, random), mapObjectCoordinates); return; } // ? // CX! // ? if (Areacoordinates.West.Type == TypeColor.Cliff && Areacoordinates.East.Type != TypeColor.Cliff && Areacoordinates.North.Type != TypeColor.Cliff && Areacoordinates.South.Type != TypeColor.Cliff) { var areaTransitionCliffTexture = Areacoordinates.South.TransitionCliffTextures. FirstOrDefault( c => c.Directions == DirectionCliff.EastEnd && c.ColorTo == Areacoordinates.North.Color); if (areaTransitionCliffTexture != null) AddTexture(RandomFromList(areaTransitionCliffTexture.List, random), mapObjectCoordinates); return; } // C // ?X? // ! if (Areacoordinates.South.Type != TypeColor.Cliff && Areacoordinates.North.Type == TypeColor.Cliff && Areacoordinates.East.Type != TypeColor.Cliff && Areacoordinates.West.Type != TypeColor.Cliff) { var areaTransitionCliffTexture = Areacoordinates.East.TransitionCliffTextures. FirstOrDefault(c => c.Directions == DirectionCliff.SouthEnd && c.ColorTo == Areacoordinates.West.Color); if (areaTransitionCliffTexture != null) AddTexture(RandomFromList(areaTransitionCliffTexture.List, random), mapObjectCoordinates); return; } // ? // !XC // ? if (Areacoordinates.East.Type == TypeColor.Cliff && Areacoordinates.West.Type != TypeColor.Cliff && Areacoordinates.North.Type != TypeColor.Cliff && Areacoordinates.South.Type != TypeColor.Cliff) { var areaTransitionCliffTexture = Areacoordinates.South.TransitionCliffTextures. FirstOrDefault(c => c.Directions == DirectionCliff.WestEnd && c.ColorTo == Areacoordinates.North.Color); if (areaTransitionCliffTexture != null) AddTexture(RandomFromList(areaTransitionCliffTexture.List, random), mapObjectCoordinates); return; } //********************** //* Rundungen * //********************** // C // CX // ? if (Areacoordinates.West.Type == TypeColor.Cliff && Areacoordinates.North.Type == TypeColor.Cliff && Areacoordinates.NorthWest.Type != TypeColor.Cliff) { var areaTransitionCliffTexture = Areacoordinates.NorthWest.TransitionCliffTextures. FirstOrDefault(c => c.Directions == DirectionCliff.NorthWestRounding && c.ColorTo == Areacoordinates.NorthWest.Color); if (areaTransitionCliffTexture != null) AddTexture(RandomFromList(areaTransitionCliffTexture.List, random), mapObjectCoordinates); return; } // C // XC // ? if (Areacoordinates.East.Type == TypeColor.Cliff && Areacoordinates.North.Type == TypeColor.Cliff && Areacoordinates.NorthEast.Type != TypeColor.Cliff) { var areaTransitionCliffTexture = Areacoordinates.NorthEast.TransitionCliffTextures. FirstOrDefault( c => c.Directions == DirectionCliff.NorthEastRounding && c.ColorTo == Areacoordinates.NorthEast.Color); if (areaTransitionCliffTexture != null) AddTexture(RandomFromList(areaTransitionCliffTexture.List, random), mapObjectCoordinates); return; } // ? // XC // C if (Areacoordinates.East.Type == TypeColor.Cliff && Areacoordinates.South.Type == TypeColor.Cliff && Areacoordinates.SouthEast.Type != TypeColor.Cliff) { var areaTransitionCliffTexture = Areacoordinates.SouthEast.TransitionCliffTextures. FirstOrDefault( c => c.Directions == DirectionCliff.SouthEastRounding && c.ColorTo == Areacoordinates.SouthEast.Color); if (areaTransitionCliffTexture != null) AddTexture(RandomFromList(areaTransitionCliffTexture.List, random), mapObjectCoordinates); return; } // ? // CX // C if (Areacoordinates.West.Type == TypeColor.Cliff && Areacoordinates.South.Type == TypeColor.Cliff && Areacoordinates.SouthWest.Type != TypeColor.Cliff) { var areaTransitionCliffTexture = Areacoordinates.SouthWest.TransitionCliffTextures. FirstOrDefault( c => c.Directions == DirectionCliff.SouthWestRounding && c.ColorTo == Areacoordinates.SouthWest.Color); if (areaTransitionCliffTexture != null) AddTexture(RandomFromList(areaTransitionCliffTexture.List, random), mapObjectCoordinates); return; } }
private static void NorthEastSmooth (Coordinates coordinates, int xmax, int ymax, int stride, AreaColor[] bitmap, MapObject[] mapobjects, Random random) { for (int i = 0; i < bitmap[coordinates.Center].CoastSmoothCircles.Count; i++) { var coordnew = new Coordinates(i + 1, i + 1, coordinates.X, coordinates.Y, stride, xmax * ymax); var areacoloronew = new AreaColorCoordinates(coordnew, bitmap); var mapobjectCoordnew = new MapObjectCoordinates(coordnew, mapobjects); SmoothWorker(areacoloronew.East, areacoloronew.Center, mapobjectCoordnew.East, random, i); SmoothWorker(areacoloronew.North, areacoloronew.Center, mapobjectCoordnew.North, random, i); SmoothWorker(areacoloronew.NorthEast, areacoloronew.Center, mapobjectCoordnew.NorthEast, random, i); } }
private void MakeCoastUolStyle ( AreaColorCoordinates areaColorCoordinates, MapObjectCoordinates mapObjectCoordinates, Coordinates coordinates, Random random ) { if (areaColorCoordinates.Center.Type == TypeColor.Water) return; var hue = areaColorCoordinates.Center.Coasts.Coast.Hue; if (areaColorCoordinates.List.All(o => o.Type != TypeColor.WaterCoast)) return; #region WaterCoasts if (areaColorCoordinates.Center.Type == TypeColor.WaterCoast) { mapObjectCoordinates.PlaceObjectOcc(areaColorCoordinates, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), areaColorCoordinates.Center.CliffCoast?areaColorCoordinates.Center.Coasts.Coast.Texture:(int)SpecialAboutItems.Nothing, (sbyte)areaColorCoordinates.Center.ItemsAltitude, RandomTexture(areaColorCoordinates.Center.TextureIndex, random),true,true,hue); if (areaColorCoordinates.List.All(o => o.Type == TypeColor.WaterCoast || o.Type == TypeColor.Water)) { mapObjectCoordinates.PlaceObjectOcc( areaColorCoordinates, (sbyte)random.Next(areaColorCoordinates.Center.Min,areaColorCoordinates.Center.Max), areaColorCoordinates.Center.CliffCoast?areaColorCoordinates.Center.Coasts.Coast.Texture:(int)SpecialAboutItems.Nothing, (sbyte)areaColorCoordinates.Center.ItemsAltitude, RandomTexture(areaColorCoordinates.Center.TextureIndex, random), false,true,hue); return; } #region Borders if ( PlaceObjectBorder ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min,areaColorCoordinates.Center.Max), areaColorCoordinates.Center.Coasts.Coast.Texture, areaColorCoordinates.NorthWest,-1,false,true,hue ) ) { if(DebugWater) mapObjectCoordinates.Center.Altitude = 65; if (areaColorCoordinates.North.CliffCoast) mapObjectCoordinates.Center.Texture =(short) RandomFromList(areaColorCoordinates.North.Coasts.Ground.BorderNorthEast.List, random); return; } if ( PlaceObjectBorder ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), areaColorCoordinates.Center.Coasts.Coast.Texture, areaColorCoordinates.SouthEast, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 70; return; } if ( PlaceObjectBorder ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), areaColorCoordinates.Center.Coasts.Coast.Texture, areaColorCoordinates.NorthEast, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 75; return; } if ( PlaceObjectBorder ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), areaColorCoordinates.Center.Coasts.Coast.Texture, areaColorCoordinates.SouthWest, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 80; return; } #endregion //Borders #region Edges if ( PlaceObjectNorthWestEdge ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, //-5, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), //-15, non per le coste basse //-5, areaColorCoordinates.Center.Coasts.Coast.Texture, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 85; if (areaColorCoordinates.North.CliffCoast)//non sicuro mapObjectCoordinates.Center.Texture =(short) RandomFromList(areaColorCoordinates.North.Coasts.Ground.BorderNorthEast.List, random); return; } if ( PlaceObjectSouthWestEdge ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), //-5, //-15, non per le coste basse //-5, areaColorCoordinates.Center.Coasts.Coast.Texture, random, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 90; return; } if ( PlaceObjectSouthEastEdge ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), //-5, //-15, non per le coste //-5, areaColorCoordinates.Center.Coasts.Coast.Texture, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 90; return; } if ( PlaceObjectNorthEastEdge ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, //-5, //-15, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), areaColorCoordinates.Center.Coasts.Coast.Texture, random, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 95; return; } #endregion //edges #region Lines if ( PlaceObjectSouth ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, //-5, //-15, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), areaColorCoordinates.Center.Coasts.Coast.Texture, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 100; return; } if ( PlaceObjectWest ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, //-5, //-15, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), areaColorCoordinates.Center.Coasts.Coast.Texture, random, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 100; return; } if ( PlaceObjectEast ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, //-5, //-15, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), areaColorCoordinates.Center.Coasts.Coast.Texture, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 105; return; } if ( PlaceObjectNorth ( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, //-5, //-15, (sbyte)areaColorCoordinates.Center.ItemsAltitude, (sbyte)random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max), areaColorCoordinates.Center.Coasts.Coast.Texture, random, -1, false, true, hue ) ) { if (DebugWater) mapObjectCoordinates.Center.Altitude = 110; return; } #endregion //Lines return; } #endregion //watercoasts #region casual #region BORDER #region NORTH WEST //NWB corretto if ( PlaceObjectBorder(areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.EdgeNorthWest.List, random), areaColorCoordinates.NorthWest, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.EdgeNorthWest.List, random), areaColorCoordinates.Center.CliffCoast,true,hue)) { if(DebugCoast) mapObjectCoordinates.Center.Altitude = 40; if (areaColorCoordinates.Center.CliffCoast && !DebugCoast) mapObjectCoordinates.SouthEast.Altitude = (sbyte)(random.Next(areaColorCoordinates.SouthEast.Min, areaColorCoordinates.SouthEast.Max) + random.Next(1, 5)); if (!DebugCoast && !areaColorCoordinates.Center.CliffCoast) SouthEastSmooth(coordinates, _X, _Y, _stride, _bitmapAreaColor, _mapObjects, random); return; } #endregion #region NORTH EAST //NEB if ( PlaceObjectBorder( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, areaColorCoordinates.Center.CliffCoast ? (sbyte)(random.Next(areaColorCoordinates.Center.Min,areaColorCoordinates.Center.Max)+random.Next(-2,3)) : (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.EdgeNorthEast.List, random), areaColorCoordinates.NorthEast, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.EdgeNorthEast.List, random), areaColorCoordinates.Center.CliffCoast, true, hue )) { if (!DebugCoast && !areaColorCoordinates.Center.CliffCoast) SouthEastSmooth(coordinates, _X, _Y, _stride, _bitmapAreaColor, _mapObjects, random); //OK if(DebugCoast) mapObjectCoordinates.Center.Altitude = 35; return; } #endregion //NEB #region SOUTH EAST //SEB if ( PlaceObjectBorder( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, areaColorCoordinates.Center.CliffCoast ? (sbyte)(random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max) + random.Next(-3, -1)) : (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.EdgeSouthEast.List, random), areaColorCoordinates.SouthEast, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.EdgeSouthEast.List, random), areaColorCoordinates.Center.CliffCoast, true, hue)) { if(DebugCoast) mapObjectCoordinates.Center.Altitude = 30; return; } #endregion //SEB #region SOUTHWEST //SWB if ( PlaceObjectBorder( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, areaColorCoordinates.Center.CliffCoast ? (sbyte)(random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max) + random.Next(-3, -1)) : (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.EdgeSouthWest.List, random), areaColorCoordinates.SouthWest, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.EdgeSouthWest.List, random), areaColorCoordinates.Center.CliffCoast, true, hue)) { if(DebugCoast) mapObjectCoordinates.Center.Altitude = 25; return; } #endregion //SWB #endregion //BORDER #region Double Border //INS if (PlaceDoubleBorder(areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, 0, 0, 0, areaColorCoordinates.SouthWest, areaColorCoordinates.NorthWest, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.BorderSouthWest.List, random), true, true, hue)) return; //IWE if (PlaceDoubleBorder(areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, 0, 0, 0, areaColorCoordinates.NorthWest, areaColorCoordinates.SouthEast, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.BorderSouthWest.List, random), true, true, hue)) return; #endregion //DOUBLE BORDER #region Lines #region NORTH if ( PlaceObjectNorth(areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.LineNorth.List, random), random, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.LineNorth.List, random), areaColorCoordinates.Center.CliffCoast, true, hue)) { if (areaColorCoordinates.Center.CliffCoast && !DebugCoast) mapObjectCoordinates.South.Altitude = (sbyte)(random.Next((areaColorCoordinates.South.Min), areaColorCoordinates.South.Max) + random.Next(-3, 0)); if (!DebugCoast && !areaColorCoordinates.Center.CliffCoast) SouthSmooth(coordinates, _X, _Y, _stride, _bitmapAreaColor, _mapObjects, random); if(DebugCoast) mapObjectCoordinates.Center.Altitude = 60; return; } #endregion //NORTH #region WEST if ( PlaceObjectWest(areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.LineWest.List, random), random, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.LineWest.List, random), areaColorCoordinates.Center.CliffCoast, true, hue)) { if (areaColorCoordinates.Center.CliffCoast && !DebugCoast) mapObjectCoordinates.East.Altitude = (sbyte) (random.Next((areaColorCoordinates.East.Min), areaColorCoordinates.East.Max) + random.Next(-3, -2)); if (!DebugCoast && !areaColorCoordinates.Center.CliffCoast) SouthEastSmooth(coordinates, _X, _Y, _stride, _bitmapAreaColor, _mapObjects, random); //OK if(DebugCoast) mapObjectCoordinates.Center.Altitude = 45; return; } #endregion //WEST #region EAST if ( PlaceObjectEast( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, areaColorCoordinates.Center.CliffCoast?(sbyte)(random.Next(areaColorCoordinates.Center.Min,areaColorCoordinates.Center.Max) +random.Next(-2,5)) :(sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.LineEast.List, random), RandomFromList(areaColorCoordinates.Center.Coasts.Ground.LineEast.List, random), areaColorCoordinates.Center.CliffCoast, true, hue)) { if (!DebugCoast && !areaColorCoordinates.Center.CliffCoast) WestSmooth(coordinates, _X, _Y, _stride, _bitmapAreaColor, _mapObjects, random); if(DebugCoast) mapObjectCoordinates.Center.Altitude = 50; return; } #endregion //EAST #region SOUTH if ( PlaceObjectSouth(areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, areaColorCoordinates.Center.CliffCoast?(sbyte)(random.Next(areaColorCoordinates.Center.Min,areaColorCoordinates.Center.Max)+random.Next(-3,1)): (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.LineSouth.List, random), RandomFromList(areaColorCoordinates.Center.Coasts.Ground.LineSouth.List, random), areaColorCoordinates.Center.CliffCoast, true, hue)) { if (!DebugCoast && !areaColorCoordinates.Center.CliffCoast) NorthSmooth(coordinates, _X, _Y, _stride, _bitmapAreaColor, _mapObjects, random); if(DebugCoast) mapObjectCoordinates.Center.Altitude = 55; return; } #endregion //NS #endregion //Lines #region Edges #region North East Edge if (PlaceObjectNorthEastEdge( areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.BorderNorthEast.List, random), random, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.BorderNorthEast.List, random), areaColorCoordinates.Center.CliffCoast, true, hue)) { if(!DebugCoast && !areaColorCoordinates.Center.CliffCoast) SouthWestSmooth(coordinates, _X, _Y, _stride, _bitmapAreaColor, _mapObjects, random); // precedentemente c'era una linea nord? if (DebugCoast) mapObjectCoordinates.Center.Altitude = 20; //OK return; } #endregion //North East Edge #region South West Edge if (PlaceObjectSouthWestEdge(areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, //-5, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.BorderSouthWest.List, random), random, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.BorderSouthWest.List, random), areaColorCoordinates.Center.CliffCoast, true, hue)) { if (!DebugCoast && !areaColorCoordinates.Center.CliffCoast) NorthEastSmooth(coordinates, _X, _Y, _stride, _bitmapAreaColor, _mapObjects, random); if(DebugCoast) mapObjectCoordinates.Center.Altitude = 5; return; } #endregion // South West Edge #region North West Edge if (PlaceObjectNorthWestEdge (areaColorCoordinates , mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.BorderNorthWest.List, random), RandomFromList(areaColorCoordinates.Center.Coasts.Ground.BorderNorthWest.List, random), areaColorCoordinates.Center.CliffCoast, true, hue)) { if (!DebugCoast && !areaColorCoordinates.Center.CliffCoast) SouthEastSmooth(coordinates, _X, _Y, _stride, _bitmapAreaColor, _mapObjects, random); if (!DebugCoast && areaColorCoordinates.Center.CliffCoast) mapObjectCoordinates.SouthEast.Altitude = (sbyte) (random.Next(areaColorCoordinates.SouthEast.Min, areaColorCoordinates.SouthEast.Max) + random.Next(-4, -2)); if(DebugCoast) mapObjectCoordinates.Center.Altitude = 10; return; } #endregion //North West Edge #region South East Edge if (PlaceObjectSouthEastEdge(areaColorCoordinates, mapObjectCoordinates, coordinates, areaColorCoordinates.Center.Type, (sbyte)areaColorCoordinates.Center.CoastAltitude, areaColorCoordinates.Center.CliffCoast ? (sbyte)(random.Next(areaColorCoordinates.Center.Min, areaColorCoordinates.Center.Max) + random.Next(-3, 1)) : (sbyte)areaColorCoordinates.Center.MinCoastTextureZ, RandomFromList(areaColorCoordinates.Center.Coasts.Coast.BorderSouthEast.List, random), //-1, RandomFromList(areaColorCoordinates.Center.Coasts.Ground.BorderSouthEast.List, random), areaColorCoordinates.Center.CliffCoast, true, hue)) { if (!DebugCoast && !areaColorCoordinates.Center.CliffCoast) NorthWestSmooth(coordinates, _X, _Y, _stride, _bitmapAreaColor, _mapObjects, random); if (DebugCoast) mapObjectCoordinates.Center.Altitude = 15; return; } #endregion //South East Edge #endregion //Edges var coasts = areaColorCoordinates.List.FirstOrDefault(o => o.Type == TypeColor.WaterCoast); _bitmapAreaColor[coordinates.Center] = coasts; areaColorCoordinates = new AreaColorCoordinates(coordinates,_bitmapAreaColor); MakeCoastUolStyle(areaColorCoordinates, mapObjectCoordinates, coordinates, random); #endregion //casual }
private void TransparentFluid(AreaColorCoordinates areaColorCoordinates, MapObjectCoordinates mapObjectCoordinates, Coordinates coordinates, Random random) { if (areaColorCoordinates.Center.Type != TypeColor.TransparentFluid) return; var hue = areaColorCoordinates.Center.Coasts.Coast.Hue; var z = areaColorCoordinates.Center.ItemsAltitude; var item = areaColorCoordinates.Center.Coasts.Coast.Texture; var index = areaColorCoordinates.Center.Index; var area = areaColorCoordinates.Center; if(areaColorCoordinates.IsAllColor()) { mapObjectCoordinates.Center.AddItem(item, hue, (sbyte)z); return; } #region casual #region BORDER #region NORTH WEST //NWB corretto if (areaColorCoordinates.List.Count(o => o != areaColorCoordinates.NorthWest && o.Index == index) == 8 ) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.BorderSouthEast.List,random),hue,(sbyte)z); return; } #endregion #region NORTH EAST //NEB if (areaColorCoordinates.List.Count(o => o != areaColorCoordinates.NorthEast && o.Index == index) == 8) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.BorderSouthWest.List, random), hue, (sbyte)z); return; } #endregion //NEB #region SOUTH EAST //SEB if (areaColorCoordinates.List.Count(o => o != areaColorCoordinates.SouthEast && o.Index == index) == 8 ) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.BorderNorthWest.List, random), hue, (sbyte)z); return; } #endregion //SEB #region SOUTHWEST //SWB if (areaColorCoordinates.List.Count(o => o != areaColorCoordinates.SouthWest && o.Index == index) == 8) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.BorderNorthEast.List, random), hue, (sbyte)z); return; } #endregion //SWB #endregion //BORDER #region Lines #region NORTH if (areaColorCoordinates.IsNorthLine(index)) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.LineSouth.List, random), hue, (sbyte)z); return; } #endregion //NORTH #region WEST if (areaColorCoordinates.IsWestLine(index)) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.LineEast.List, random), hue, (sbyte)z); return; } #endregion //WEST #region EAST if (areaColorCoordinates.IsEastLine(index)) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.LineWest.List, random), hue, (sbyte)z); return; } #endregion //EAST #region SOUTH if (areaColorCoordinates.IsSouthLine(index)) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.LineNorth.List, random), hue, (sbyte)z); return; } #endregion //NS #endregion //Lines #region Edges #region North East Edge if (areaColorCoordinates.IsNortEastEdge(index)) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.EdgeSouthWest.List, random), hue, (sbyte)z); return; } #endregion //North East Edge #region South West Edge if (areaColorCoordinates.IsSouthWestEdge(index)) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.EdgeNorthEast.List, random), hue, (sbyte)z); return; } #endregion // South West Edge #region North West Edge if (areaColorCoordinates.IsNorthWestEdge(index)) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.EdgeSouthEast.List, random), hue, (sbyte)z); return; } #endregion //North West Edge #region South East Edge if (areaColorCoordinates.IsSouthEastEdge(index)) { mapObjectCoordinates.Center.AddItem(RandomFromList(area.Coasts.Coast.EdgeNorthWest.List, random), hue, (sbyte)z); return; } #endregion //South East Edge #endregion //Edges }
private static bool PlaceDoubleBorder ( AreaColorCoordinates areaColorCoordinates, MapObjectCoordinates mapObjectCoordinates, Coordinates coordinates, TypeColor type, sbyte zItem, sbyte altitude, int itemid, AreaColor border, AreaColor border2, int texture = -1, bool ground = false, bool occupied = true, int hue = 0 ) { return areaColorCoordinates.List.Count(o => o.Type == type && o != border && o != border2) == 7 && mapObjectCoordinates.PlaceObjectOcc(areaColorCoordinates, altitude, itemid, zItem, texture, ground,occupied,hue); }
private static bool PlaceObjectNorthWestEdge( AreaColorCoordinates areaColorCoordinates, MapObjectCoordinates mapObjectCoordinates, Coordinates coordinates, TypeColor type, sbyte zItem, sbyte altitude, int itemid, int texture = -1, bool ground = false, bool occupied = true, int hue = 0 ) { return areaColorCoordinates.IsNorthWestEdge(type) && mapObjectCoordinates.PlaceObjectOcc( areaColorCoordinates, altitude, itemid, zItem, texture, ground,occupied,hue); }