LivingObject(LivingObjectBuilder builder) : base(ObjectType.Living, builder) { Debug.Assert(builder.LivingID != Dwarrowdelf.LivingID.Undefined); this.LivingID = builder.LivingID; m_maxHitPoints = m_hitPoints = builder.HitPoints; m_naturalArmorClass = builder.NaturalAC; m_strength = builder.Str; m_dexterity = builder.Dex; m_constitution = builder.Con; m_intelligence = builder.Int; m_wisdom = builder.Wis; m_charisma = builder.Cha; m_size = builder.Siz; m_gender = builder.Gender; m_visionRange = builder.VisionRange; m_assignment = ""; m_skillMap = new Dictionary <SkillID, byte>(); foreach (var kvp in builder.SkillMap) { if (kvp.Value != 0) { m_skillMap[kvp.Key] = kvp.Value; } } RecalcArmorClass(); }
LivingObject(LivingObjectBuilder builder) : base(ObjectType.Living, builder) { Debug.Assert(builder.LivingID != Dwarrowdelf.LivingID.Undefined); this.LivingID = builder.LivingID; m_maxHitPoints = m_hitPoints = builder.HitPoints; m_naturalArmorClass = builder.NaturalAC; m_strength = builder.Str; m_dexterity = builder.Dex; m_constitution = builder.Con; m_intelligence = builder.Int; m_wisdom = builder.Wis; m_charisma = builder.Cha; m_size = builder.Siz; m_gender = builder.Gender; m_visionRange = builder.VisionRange; m_assignment = ""; m_skillMap = new Dictionary<SkillID, byte>(); foreach (var kvp in builder.SkillMap) if (kvp.Value != 0) m_skillMap[kvp.Key] = kvp.Value; RecalcArmorClass(); }
internal static LivingObject Create(World world, LivingObjectBuilder builder) { var ob = new LivingObject(builder); ob.Initialize(world); return(ob); }
LivingObject CreateDwarf(int i) { var builder = new LivingObjectBuilder(LivingID.Dwarf) { Color = (GameColor)Helpers.GetRandomInt(GameColorRGB.NUMCOLORS - 1) + 1, Gender = LivingGender.Male, }; switch (i) { case 0: builder.Name = "Doc"; builder.SetSkillLevel(SkillID.Mining, 80); builder.SetSkillLevel(SkillID.Fighting, 40); break; case 1: builder.Name = "Grumpy"; builder.SetSkillLevel(SkillID.Carpentry, 80); builder.SetSkillLevel(SkillID.Fighting, 40); break; case 2: builder.Name = "Happy"; builder.SetSkillLevel(SkillID.WoodCutting, 80); builder.SetSkillLevel(SkillID.Fighting, 40); break; case 3: builder.Name = "Sleepy"; builder.SetSkillLevel(SkillID.Masonry, 80); builder.SetSkillLevel(SkillID.Fighting, 40); break; case 4: builder.Name = "Bashful"; builder.SetSkillLevel(SkillID.BlackSmithing, 80); builder.SetSkillLevel(SkillID.Fighting, 40); break; case 5: builder.Name = "Sneezy"; builder.SetSkillLevel(SkillID.GemCutting, 80); builder.SetSkillLevel(SkillID.Fighting, 40); break; case 6: builder.Name = "Dopey"; builder.SetSkillLevel(SkillID.Smelting, 80); builder.SetSkillLevel(SkillID.Fighting, 40); break; } var dwarf = builder.Create(this.World); Helpers.AddGem(dwarf); Helpers.AddBattleGear(dwarf); return dwarf; }
LivingObject CreateDwarf(int i) { var builder = new LivingObjectBuilder(LivingID.Dwarf) { Color = (GameColor)m_random.Next(GameColorRGB.NUMCOLORS - 1) + 1, }; switch (i) { case 0: builder.Name = "Doc"; builder.SetSkillLevel(SkillID.Fighting, 100); break; case 1: builder.Name = "Grumpy"; builder.SetSkillLevel(SkillID.Fighting, 100); break; case 2: builder.Name = "Happy"; builder.SetSkillLevel(SkillID.Fighting, 100); break; case 3: builder.Name = "Sleepy"; builder.SetSkillLevel(SkillID.Fighting, 100); break; case 4: builder.Name = "Bashful"; builder.SetSkillLevel(SkillID.Fighting, 100); break; case 5: builder.Name = "Sneezy"; builder.SetSkillLevel(SkillID.Fighting, 100); break; case 6: builder.Name = "Dopey"; builder.SetSkillLevel(SkillID.Fighting, 100); break; } var dwarf = builder.Create(this.World); dwarf.SetAI(new DwarfAI(dwarf)); var gemMaterials = Materials.GetMaterials(MaterialCategory.Gem).ToArray(); var material = gemMaterials[m_random.Next(gemMaterials.Length)].ID; var itemBuilder = new ItemObjectBuilder(ItemID.Gem, material); var item = itemBuilder.Create(this.World); item.MoveTo(dwarf); return dwarf; }
AI.Group CreateHerd(int numAnimals, LivingID livingID) { var world = m_env.World; var group = new AI.Group(); var center = m_env.GetRandomEnterableSurfaceLocation(); using (var iter = IntVector2.SquareSpiral(center.ToIntVector2(), 20).GetEnumerator()) { for (int i = 0; i < numAnimals; ++i) { bool ok = true; while (true) { if (iter.MoveNext() == false) { ok = false; break; } var p2 = iter.Current; if (m_env.Size.Plane.Contains(p2) == false) { continue; } var p = m_env.GetSurfaceLocation(p2); if (m_env.CanEnter(p) == false) { continue; } var livingBuilder = new LivingObjectBuilder(livingID); var living = livingBuilder.Create(world); var ai = new Dwarrowdelf.AI.HerbivoreAI(living, world.PlayerID); ai.Group = group; living.SetAI(ai); living.MoveToMustSucceed(m_env, p); break; } if (!ok) { break; } } } return(group); }
AI.Group CreateHerd(int numAnimals, LivingID livingID) { var world = m_env.World; var group = new AI.Group(); var center = m_env.GetRandomEnterableSurfaceLocation(); using (var iter = IntVector2.SquareSpiral(center.ToIntVector2(), 20).GetEnumerator()) { for (int i = 0; i < numAnimals; ++i) { bool ok = true; while (true) { if (iter.MoveNext() == false) { ok = false; break; } var p2 = iter.Current; if (m_env.Size.Plane.Contains(p2) == false) continue; var p = m_env.GetSurfaceLocation(p2); if (m_env.CanEnter(p) == false) continue; var livingBuilder = new LivingObjectBuilder(livingID); var living = livingBuilder.Create(world); var ai = new Dwarrowdelf.AI.HerbivoreAI(living, world.PlayerID); ai.Group = group; living.SetAI(ai); living.MoveToMustSucceed(m_env, p); break; } if (!ok) break; } } return group; }
public void InitializeWorld(World world) { var envBuilder = new EnvironmentObjectBuilder(new IntSize3(64, 64, 4), VisibilityMode.AllVisible); TileData td; int surfaceLevel = 2; td = new TileData() { TerrainID = TerrainID.NaturalWall, TerrainMaterialID = MaterialID.Granite, InteriorID = InteriorID.Empty }; FillVolume(envBuilder, new IntBox(envBuilder.Bounds.Plane, 0), td); FillVolume(envBuilder, new IntBox(envBuilder.Bounds.Plane, 1), td); td = new TileData() { TerrainID = TerrainID.NaturalFloor, TerrainMaterialID = MaterialID.Granite, InteriorID = InteriorID.Empty }; FillVolume(envBuilder, new IntBox(envBuilder.Bounds.Plane, 2), td); td = new TileData() { TerrainID = TerrainID.Empty, InteriorID = InteriorID.Empty }; FillVolume(envBuilder, new IntBox(envBuilder.Bounds.Plane, 3), td); td = new TileData() { TerrainID = TerrainID.NaturalWall, TerrainMaterialID = MaterialID.Granite, InteriorID = InteriorID.Empty }; DrawRect(envBuilder, new IntRectZ(envBuilder.Bounds.Plane, 2), td); var env = envBuilder.Create(world); env.HomeLocation = new IntPoint3(envBuilder.Width / 2, 4, surfaceLevel); /* Add Monsters */ CreateSheep(env, surfaceLevel); { var builder = new LivingObjectBuilder(LivingID.Wolf); var wolf = builder.Create(env.World); var ai = new Dwarrowdelf.AI.CarnivoreAI(wolf); wolf.SetAI(ai); wolf.MoveTo(env, GetRandomSurfaceLocation(env, surfaceLevel)); } { var builder = new LivingObjectBuilder(LivingID.Dragon); var dragon = builder.Create(env.World); var ai = new Dwarrowdelf.AI.MonsterAI(dragon); dragon.SetAI(ai); dragon.MoveTo(env, GetRandomSurfaceLocation(env, surfaceLevel)); } }
static void AddMonsters(EnvironmentObject env) { var world = env.World; for (int i = 0; i < NUM_ORCS; ++i) { var livingBuilder = new LivingObjectBuilder(LivingID.Orc) { Color = GetRandomColor(), }; var living = livingBuilder.Create(world); living.SetAI(new Dwarrowdelf.AI.MonsterAI(living, world.PlayerID)); Helpers.AddGem(living); Helpers.AddBattleGear(living); living.MoveToMustSucceed(env, env.GetRandomEnterableSurfaceLocation()); } }
void CreateSheep(Environment env, int surfaceLevel) { var group = new Group(); for (int i = 0; i < NUM_SHEEP; ++i) { var sheepBuilder = new LivingObjectBuilder(LivingID.Sheep) { Color = this.GetRandomColor(), }; var sheep = sheepBuilder.Create(env.World); var ai = new HerbivoreAI(sheep); ai.Group = group; sheep.SetAI(ai); CreateItems(sheep, i); sheep.MoveTo(env, GetRandomSurfaceLocation(env, surfaceLevel)); } }
internal static LivingObject Create(World world, LivingObjectBuilder builder) { var ob = new LivingObject(builder); ob.Initialize(world); return ob; }
static void AddMonsters(EnvironmentObject env) { var world = env.World; for (int i = 0; i < NUM_SHEEP; ++i) { var livingBuilder = new LivingObjectBuilder(LivingID.Sheep) { Color = GetRandomColor(), }; var living = livingBuilder.Create(world); living.SetAI(new Dwarrowdelf.AI.HerbivoreAI(living, 0)); living.MoveTo(env, GetRandomSurfaceLocation(env)); } for (int i = 0; i < NUM_ORCS; ++i) { var livingBuilder = new LivingObjectBuilder(LivingID.Orc) { Color = GetRandomColor(), }; var living = livingBuilder.Create(world); living.SetAI(new Dwarrowdelf.AI.MonsterAI(living, 0)); Helpers.AddGem(living); Helpers.AddBattleGear(living); living.MoveTo(env, GetRandomSurfaceLocation(env)); } }