public virtual BaseTile CopyOf(BaseTile _base) { MyType = _base.MyType; Description = _base.Description; TileName = _base.TileName; Walkable = _base.Walkable; Pos = _base.Pos; ChanceAtMonsters = SingleTon.PercentChanceBetween(_base.MinChanceMonster, _base.MaxChanceMonster); return(this); }
private void GenerateTown(object MD) { AllNPCs = new List <TileNPC>(); MapData Temp = (MapData)MD; List <BaseTile> tiles = Temp.tiles; NPCS = Temp.SpawnAbleEnemies.Select(x => (BaseNPC)x).ToList(); for (int y = 0; y < MapSize.Y; y++) { for (int x = 0; x < MapSize.X; x++) { Tiles[x, y] = new BaseTile().CopyOf(tiles[1]); Tiles[x, y].Pos = new Cord { X = x, Y = y }; } } for (int i = 0; i < Temp.AmountOfDungeonOrHouses; i++) { if (CheckHouse()) { CreateHouse(Location, Temp.tiles[0]); } else { i--; } } while (true) { bool foutain = false; while (foutain == false) { Location = new Cord { X = SingleTon.GetRandomNum(0, MapSize.X), Y = SingleTon.GetRandomNum(0, MapSize.Y) }; if (Tiles[Location.X, Location.Y].MyType == TileType.Normal) { Tiles[Location.X, Location.Y] = new BaseTile().CopyOf(tiles[2]); } } Location = new Cord { X = SingleTon.GetRandomNum(0, MapSize.X), Y = SingleTon.GetRandomNum(0, MapSize.Y) }; if (Tiles[Location.X, Location.Y].MyType == TileType.Normal) { SpawnPoint = Tiles[Location.X, Location.Y]; return; } } }
public Thread GenerateMapThread(List <BaseTile> tiles, List <BaseCharacters> npcs, int house, BaseTile ThisTile) { MyTile = ThisTile; Thread Generator; Generator = new Thread(new ParameterizedThreadStart(GenerateTown)); MapData MD; MD.Locations = new List <CityTile>(); MD.tiles = tiles; MD.SpawnAbleEnemies = npcs; MD.AmountOfDungeonOrHouses = house; Generator.Start(MD); return(Generator); }
private void GenerateDungeon(object MD) { MapData Temp = (MapData)MD; List <BaseTile> tiles = Temp.tiles; for (int y = 0; y < MapSize.Y; y++) { for (int x = 0; x < MapSize.X; x++) { Tiles[x, y] = new BaseTile().CopyOf(tiles[1]); Tiles[x, y].Pos = new Cord { X = x, Y = y }; } } SpawnPoint = Tiles[0, 0]; }
private void FillOutNull() { BaseTile ImPassble = new BaseTile() { TileName = "Moutain", Walkable = false, MyType = TileType.Inpassable }; //fill all the empthy areas with impassble things for (int x = 0; x < MapSize.X; x++) { for (int y = 0; y < MapSize.Y; y++) { Tiles[x, y] = new BaseTile().CopyOf(ImPassble); Tiles[x, y].Pos = new Cord { X = x, Y = y }; } } }
private void CreateHouse(Cord cord, BaseTile Wall) { List <Cord> CheckList = new List <Cord> { new Cord { X = Location.X - 1, Y = Location.Y }, new Cord { X = Location.X - 2, Y = Location.Y }, new Cord { X = Location.X - 2, Y = Location.Y - 1 }, new Cord { X = Location.X - 2, Y = Location.Y - 2 }, new Cord { X = Location.X - 2, Y = Location.Y - 3 }, new Cord { X = Location.X - 2, Y = Location.Y - 4 }, new Cord { X = Location.X - 1, Y = Location.Y - 4 }, new Cord { X = Location.X, Y = Location.Y - 4 }, new Cord { X = Location.X + 1, Y = Location.Y - 4 }, new Cord { X = Location.X + 2, Y = Location.Y - 4 }, new Cord { X = Location.X + 2, Y = Location.Y - 3 }, new Cord { X = Location.X + 2, Y = Location.Y - 2 }, new Cord { X = Location.X + 2, Y = Location.Y - 1 }, new Cord { X = Location.X + 2, Y = Location.Y }, new Cord { X = Location.X + 1, Y = Location.Y } }; foreach (Cord element in CheckList) { Tiles[element.X, element.Y] = Wall; } if (NPCS.Count >= 2) { int rand = SingleTon.GetRandomNum(0, 3); if (rand != 0) { for (int b = 0; b < rand; ++b) { BaseNPC npc = NPCS[SingleTon.GetRandomNum(0, NPCS.Count)]; Cord pos = new Cord { X = SingleTon.GetRandomNum(Location.X - 1, Location.X + 2), Y = SingleTon.GetRandomNum(Location.Y - 3, Location.Y) }; Tiles[pos.X, pos.Y] = new TileNPC(npc.Name, true, pos); AllNPCs.Add((TileNPC)Tiles[pos.X, pos.Y]); NPCS.Remove(npc); } } } else if (NPCS.Count == 1) { Cord pos = new Cord { X = SingleTon.GetRandomNum(Location.X - 1, Location.X + 2), Y = SingleTon.GetRandomNum(Location.Y - 3, Location.Y) }; Tiles[pos.X, pos.Y] = new TileNPC(NPCS[0].Name, true, pos); NPCS.RemoveAt(0); } }