protected override void GenerateDetails(ProtoArray <Chunk> map, Random random) { int chunkWidth = map.Width; int chunkHeight = map.Height; int chunkX = StaticRandom.Rand(0, chunkWidth); int chunkY = StaticRandom.Rand(0, chunkHeight); int x = StaticRandom.Rand(0, Chunk.Width); int y = StaticRandom.Rand(0, Chunk.Height); while (map[chunkX, chunkY].Tiles[x, y].Resources != null) { chunkX = StaticRandom.Rand(0, chunkWidth); chunkY = StaticRandom.Rand(0, chunkHeight); x = StaticRandom.Rand(0, Chunk.Width); y = StaticRandom.Rand(0, Chunk.Height); } HumanFactory hFactory = new HumanFactory(); Point2D entityLocation = new Point2D(((chunkX * Chunk.Width) + x), (chunkY * Chunk.Height) + y); Human human = hFactory.GenerateHuman(entityLocation, this.Dimension); map[chunkX, chunkY].Creatures.Add(human); }
/// <summary> /// Spawns a character at a random position in the map without spawning the character in the same space as another character. /// </summary> /// <param name="playerID"></param> public static void SpawnRandomCharacter(Guid playerID, int dimension) { Point2D randomLocation = FindRandomLocation(dimension); HumanFactory humanFactory = new HumanFactory(); Human human = humanFactory.GenerateHuman(randomLocation, dimension, playerID); World.Data.World.GetChunkByTile(dimension, randomLocation.X, randomLocation.Y).Creatures.Add(human.ID, human); if (World.Data.World.Mode == Networking.EngineMode.ServerOnly) { ServerSendRecieve.SendAll(new WorldModifierMessage(new LivingCreatedModifier(human))); } }
public override ProtoArray <Tile> GenerateDetails(ProtoArray <Tile> map, Random r) { int xSize = map.Width; int ySize = map.Height; int x = StaticRandom.Rand(0, xSize); int y = StaticRandom.Rand(0, ySize); HumanFactory hFactory = new HumanFactory(); map[x, y].Living = (hFactory.GenerateHuman(new Point(x, y))); return(map); }
public void TestJobSerialization() { this.Setup(); MineJob job = new MineJob(new MagicalLifeAPI.DataTypes.Point2D(3, 6)); HumanFactory humanFactory = new HumanFactory(); Human human = humanFactory.GenerateHuman(new MagicalLifeAPI.DataTypes.Point2D(1, 3), 0, Guid.NewGuid()); JobAssignedMessage message = new JobAssignedMessage(human, job); byte[] data = ProtoUtil.Serialize(message); Assert.IsNotNull(data); JobAssignedMessage result = (JobAssignedMessage)ProtoUtil.Deserialize(data); }
protected override void GenerateDetails(ProtoArray <Chunk> map, Random r) { int chunkWidth = map.Width; int chunkHeight = map.Height; int chunkX = StaticRandom.Rand(0, chunkWidth); int chunkY = StaticRandom.Rand(0, chunkHeight); int x = StaticRandom.Rand(0, Chunk.Width); int y = StaticRandom.Rand(0, Chunk.Height); HumanFactory hFactory = new HumanFactory(); Point2D location = new Point2D(((chunkX * Chunk.Width) + x), (chunkY * Chunk.Height) + y); map[chunkX, chunkY].Creatures.Add(hFactory.GenerateHuman(location, this.Dimension)); }
protected override ProtoArray <Chunk> GenerateDetails(ProtoArray <Chunk> map, Random r) { int chunkWidth = map.Width; int chunkHeight = map.Height; int chunkX = StaticRandom.Rand(0, chunkWidth); int chunkY = StaticRandom.Rand(0, chunkHeight); int x = StaticRandom.Rand(0, Chunk.Width); int y = StaticRandom.Rand(0, Chunk.Height); HumanFactory hFactory = new HumanFactory(); map[chunkX, chunkY].Creatures.Add(hFactory.GenerateHuman(new Point((chunkX * Chunk.Width) + x), (chunkY * Chunk.Height) + y)); return(map); }