示例#1
0
 private static GameComponent __factory(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Necromancer(
                new CreatureStats(new NecromancerClass(), 0),
                "Undead",
                Manager.World.PlanService,
                Manager.World.Factions.Factions["Undead"],
                Manager,
                "Necromancer",
                Position).Physics);
 }
示例#2
0
 private static GameComponent __factory0(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new MudGolem(
                new CreatureStats("MudGolem", "MudGolem", 0),
                Manager.World.Factions.Factions["Evil"],
                Manager,
                "Mud Golem",
                Position));
 }
示例#3
0
 private static GameComponent __factory07(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Seedling(Manager, "Candycane", Position, "candycanesprout")
     {
         GrowthHours = 24.0f,
         MaxSize = 2.0f,
         GoodBiomes = "Tiaga Jolly Forest",
         BadBiomes = "Desert Tundra Waste Haunted Forest"
     });
 }
示例#4
0
文件: Frog.cs 项目: Rod995/dwarfcorp
 private static GameComponent __factory1(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Frog(ContentPaths.Entities.Animals.Frog.frog1_animation, Position, Manager, "Frog"));
 }
示例#5
0
        // Create an entity and make it a transparent ghost object that doesn't interact with anything.
        // This is for displaying stuff, for example in tools.
        public static Body CreateGhostedEntity <T>(string id, Vector3 location, Color tint, Blackboard data = null) where T : Body
        {
            var ent = CreateEntity <T>(id, location, data);

            ent.SetFlagRecursive(GameComponent.Flag.Active, false);
            var tinters = ent.EnumerateAll().OfType <Tinter>();

            foreach (var tinter in tinters)
            {
                tinter.VertexColorTint = tint;
            }
            return(ent);
        }
示例#6
0
 private static GameComponent __factory(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Scorpion(Position, Manager, "Scorpion"));
 }
示例#7
0
 private static GameComponent __factory1(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new NonPlayerDwarf(
                Manager,
                new CreatureStats("Dwarf", "Soldier", 0)
     {
         RandomSeed = MathFunctions.Random.Next(),
     },
                Manager.World.Factions.Factions["Dwarves"], "Dwarf", Position).Physics);
 }
示例#8
0
        private static GameComponent __factory1(ComponentManager Manager, Vector3 Position, Blackboard Data)
        {
            var r = new Snake(true, Position, Manager, "Snake");

            r.Attacks[0].DiseaseToSpread = "Necrorot";
            return(r.Physics);
        }
示例#9
0
 private static GameComponent __factory1(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Cloud(Manager, 0.1f, 50, 40, Position)
     {
         TypeofStorm = StormType.RainStorm
     });
 }
示例#10
0
        public void GenerateVegetation(VoxelChunk chunk, ComponentManager components, ContentManager content, GraphicsDevice graphics)
        {
            int   waterHeight = (int)(SeaLevel * chunk.SizeY);
            bool  updated     = false;
            Voxel v           = chunk.MakeVoxel(0, 0, 0);
            Voxel vUnder      = chunk.MakeVoxel(0, 0, 0);

            for (int x = 0; x < chunk.SizeX; x++)
            {
                for (int z = 0; z < chunk.SizeZ; z++)
                {
                    Vector2         vec       = new Vector2(x + chunk.Origin.X, z + chunk.Origin.Z) / WorldScale;
                    Overworld.Biome biome     = Overworld.Map[(int)MathFunctions.Clamp(vec.X, 0, Overworld.Map.GetLength(0) - 1), (int)MathFunctions.Clamp(vec.Y, 0, Overworld.Map.GetLength(1) - 1)].Biome;
                    BiomeData       biomeData = BiomeLibrary.Biomes[biome];

                    int y = chunk.GetFilledVoxelGridHeightAt(x, chunk.SizeY - 1, z);

                    if (!chunk.IsCellValid(x, (int)(y - chunk.Origin.Y), z))
                    {
                        continue;
                    }

                    v.GridPosition = new Vector3(x, y, z);

                    if (!v.IsEmpty || chunk.Data.Water[v.Index].WaterLevel != 0 || y <= waterHeight)
                    {
                        continue;
                    }

                    foreach (VegetationData veg in biomeData.Vegetation)
                    {
                        if (y <= 0)
                        {
                            continue;
                        }

                        if (!MathFunctions.RandEvent(veg.SpawnProbability))
                        {
                            continue;
                        }

                        if (NoiseGenerator.Noise(vec.X / veg.ClumpSize, veg.NoiseOffset, vec.Y / veg.ClumpSize) < veg.ClumpThreshold)
                        {
                            continue;
                        }

                        int yh = chunk.GetFilledVoxelGridHeightAt(x, y, z);

                        if (yh > 0)
                        {
                            vUnder.GridPosition = new Vector3(x, yh - 1, z);
                            if (!vUnder.IsEmpty && vUnder.TypeName == biomeData.GrassLayer.VoxelType)
                            {
                                vUnder.Type = VoxelLibrary.GetVoxelType(biomeData.SoilLayer.VoxelType);
                                updated     = true;
                                float offset = veg.VerticalOffset;
                                if (vUnder.RampType != RampType.None)
                                {
                                    offset -= 0.25f;
                                }
                                float treeSize = MathFunctions.Rand() * veg.SizeVariance + veg.MeanSize;
                                EntityFactory.CreateEntity <Body>(veg.Name, chunk.Origin + new Vector3(x, y, z) + new Vector3(0, treeSize * offset, 0), Blackboard.Create("Scale", treeSize));
                            }
                        }

                        break;
                    }
                }
            }

            if (updated)
            {
                chunk.ShouldRebuild = true;
            }
        }
示例#11
0
        public void GenerateCaves(VoxelChunk chunk, WorldManager world)
        {
            Vector3      origin     = chunk.Origin;
            int          chunkSizeX = chunk.SizeX;
            int          chunkSizeY = chunk.SizeY;
            int          chunkSizeZ = chunk.SizeZ;
            BiomeData    biome      = BiomeLibrary.Biomes[Overworld.Biome.Cave];
            List <Voxel> neighbors  = new List <Voxel>();
            Voxel        vUnder     = chunk.MakeVoxel(0, 0, 0);

            for (int x = 0; x < chunkSizeX; x++)
            {
                for (int z = 0; z < chunkSizeZ; z++)
                {
                    int h = chunk.GetFilledVoxelGridHeightAt(x, chunk.SizeY - 1, z);
                    for (int i = 0; i < CaveLevels.Count; i++)
                    {
                        int y = CaveLevels[i];
                        if (y <= 0 || y >= h - 1)
                        {
                            continue;
                        }
                        Vector3 vec       = new Vector3(x, y, z) + chunk.Origin;
                        double  caveNoise = CaveNoise.GetValue((x + origin.X) * CaveNoiseScale * CaveFrequencies[i],
                                                               (y + origin.Y) * CaveNoiseScale * 3.0f, (z + origin.Z) * CaveNoiseScale * CaveFrequencies[i]);

                        double heightnoise = NoiseGenerator.Noise((x + origin.X) * NoiseScale * CaveFrequencies[i],
                                                                  (y + origin.Y) * NoiseScale * 3.0f, (z + origin.Z) * NoiseScale * CaveFrequencies[i]);

                        int caveHeight = Math.Min(Math.Max((int)(heightnoise * 5), 1), 3);

                        if (caveNoise > CaveSize)
                        {
                            bool waterFound = false;
                            for (int dy = 0; dy < caveHeight; dy++)
                            {
                                int index = chunk.Data.IndexAt(x, y - dy, z);
                                chunk.GetNeighborsManhattan(x, y - dy, z, neighbors);

                                if (neighbors.Any(v => v != null && v.WaterLevel > 0))
                                {
                                    waterFound = true;
                                }

                                if (waterFound)
                                {
                                    break;
                                }

                                chunk.Data.Types[index] = 0;
                            }

                            if (!waterFound && caveNoise > CaveSize * 1.8f && y - caveHeight > 0)
                            {
                                int indexunder = chunk.Data.IndexAt(x, y - caveHeight, z);
                                chunk.Data.Types[indexunder]      = (byte)VoxelLibrary.GetVoxelType(biome.GrassLayer.VoxelType).ID;
                                chunk.Data.Health[indexunder]     = (byte)VoxelLibrary.GetVoxelType(biome.GrassLayer.VoxelType).StartingHealth;
                                chunk.Data.IsExplored[indexunder] = false;
                                foreach (VegetationData veg in biome.Vegetation)
                                {
                                    if (!MathFunctions.RandEvent(veg.SpawnProbability))
                                    {
                                        continue;
                                    }

                                    if (NoiseGenerator.Noise(vec.X / veg.ClumpSize, veg.NoiseOffset, vec.Y / veg.ClumpSize) < veg.ClumpThreshold)
                                    {
                                        continue;
                                    }


                                    vUnder.GridPosition = new Vector3(x, y - 1, z);
                                    if (!vUnder.IsEmpty && vUnder.TypeName == biome.GrassLayer.VoxelType)
                                    {
                                        vUnder.Type = VoxelLibrary.GetVoxelType(biome.SoilLayer.VoxelType);
                                        float offset = veg.VerticalOffset;
                                        if (vUnder.RampType != RampType.None)
                                        {
                                            offset -= 0.25f;
                                        }
                                        float         treeSize = MathFunctions.Rand() * veg.SizeVariance + veg.MeanSize;
                                        GameComponent entity   = EntityFactory.CreateEntity <GameComponent>(veg.Name, chunk.Origin + new Vector3(x, y, z) + new Vector3(0, treeSize * offset, 0), Blackboard.Create("Scale", treeSize));
                                        entity.GetEntityRootComponent().SetActiveRecursive(false);
                                        entity.GetEntityRootComponent().SetVisibleRecursive(false);
                                        if (GameSettings.Default.FogofWar)
                                        {
                                            ExploredListener listener = new ExploredListener(
                                                world.ComponentManager, entity, world.ChunkManager, vUnder);
                                        }
                                    }
                                }
                            }

                            foreach (FaunaData animal in biome.Fauna)
                            {
                                if (y <= 0 || !(MathFunctions.Random.NextDouble() < animal.SpawnProbability))
                                {
                                    continue;
                                }


                                var entity = EntityFactory.CreateEntity <GameComponent>(animal.Name, chunk.Origin + new Vector3(x, y, z) + Vector3.Up * 1.0f);

                                if (GameSettings.Default.FogofWar)
                                {
                                    entity.GetEntityRootComponent().SetActiveRecursive(false);
                                    entity.GetEntityRootComponent().SetVisibleRecursive(false);

                                    ExploredListener listener = new ExploredListener
                                                                    (world.ComponentManager,
                                                                    entity,
                                                                    world.ChunkManager, chunk.MakeVoxel(x, y, z));
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#12
0
 private static GameComponent __factory6(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Table("Iron Table", Manager, Position, Data.GetData <Resource>("Resource", null), new Point(4, 7), new Point(5, 7)));
 }
示例#13
0
 private static GameComponent __factory4(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Table("Wooden Table", Manager, Position, Data.GetData <Resource>("Resource", null), DefaultTopFrame, DefaultLegsFrame));
 }
示例#14
0
 private static GameComponent __factory3(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Table("Apothecary", Manager, Position, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32), new Point(1, 4), Data.GetData <Resource>("Resource", null), DefaultTopFrame, DefaultLegsFrame)
     {
         Tags = new List <string>()
         {
             "Research", "Apothecary"
         }
     });
 }
示例#15
0
 private static GameComponent __factory1(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Chair(Manager, Position, Data.GetData <Resource>("Resource", null), "Wooden Chair", DefaultTopSprite, DefaultLegsSprite));
 }
示例#16
0
 private static GameComponent __factory2(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     Weather.CreateForecast(Manager.World.Time.CurrentDate, Manager.World.ChunkManager.Bounds, Manager.World, 3);
     Weather.CreateStorm(MathFunctions.RandVector3Cube() * 10, MathFunctions.Rand(0.05f, 1.0f), Manager.World);
     return(new Cloud(Manager, 0.1f, 50, 40, Position));
 }
示例#17
0
 private static GameComponent __factory3(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Chair(Manager, Position, Data.GetData <Resource>("Resource", null), "Iron Chair", new Point(6, 7), new Point(7, 7)));
 }
示例#18
0
文件: Bird.cs 项目: johan74/dwarfcorp
 private static GameComponent __factory(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Bird(ContentPaths.Entities.Animals.Birds.GetRandomBird(), Position, Manager, "Bird"));
 }
示例#19
0
 private static GameComponent __factory(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     // Todo: Why are we passing in the graphic here?
     return(new Scorpion(ContentPaths.Entities.Animals.Scorpion.scorption_animation, Position, Manager, "Scorpion"));
 }
示例#20
0
 private static GameComponent __factory(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Forge(Manager, Position, Data.GetData <List <ResourceAmount> >("Resources", null)));
 }
示例#21
0
 private static GameComponent __factory2(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new NonPlayerDwarf(
                Manager,
                new CreatureStats("Dwarf", "Crafter", 0)
     {
         RandomSeed = MathFunctions.Random.Next(),
     },
                Manager.World.Factions.Factions["Dwarves"], "Dwarf", Position).Physics); // Todo: Why are we adding them to a faction? Don't they just immediately get added to a different one?
 }
示例#22
0
文件: Elf.cs 项目: johan74/dwarfcorp
 private static GameComponent __factory(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Elf(
                new CreatureStats(new ElfClass(), 0),
                "Elf",
                Manager.World.PlanService,
                Manager.World.Factions.Factions["Elf"],
                Manager,
                "Elf",
                Position).Physics);
 }
示例#23
0
 private static GameComponent __factory(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new StoneDoor(Manager, Position, Manager.World.PlayerFaction, Data.GetData <Resource>("Resource", null)));
 }
示例#24
0
 private static GameComponent __factory5(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(GenerateDwarf(Position, Manager, "Manager", 0, Mating.RandomGender(), MathFunctions.Random.Next()));
 }
示例#25
0
 private static GameComponent __factory(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new TurretTrap(Manager, Position, Manager.World.PlayerFaction, Data.GetData <List <ResourceAmount> >("Resources", null)));
 }
示例#26
0
 private static GameComponent __factory0(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Snake(Position, Manager, "Snake").Physics);
 }
示例#27
0
 private static GameComponent __factory06(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Tree("Candycane", Manager, Position, "candycane", ResourceType.Peppermint, Data.GetData("Scale", 1.0f)));
 }
示例#28
0
 private static GameComponent __factory(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Strawman(Manager, Position, Data.GetData <Resource>("Resource", null)));
 }
示例#29
0
 private static GameComponent __factory08(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Tree("Palm Tree", Manager, Position, "palm", ResourceType.Coconut, Data.GetData("Scale", 1.0f)));
 }
示例#30
0
 private static GameComponent __factory(ComponentManager Manager, Vector3 Position, Blackboard Data)
 {
     return(new Fire(Manager, Position));
 }