예제 #1
0
        public static void InitializeDefaultLibrary(GraphicsDevice graphics, Texture2D cubeTexture)
        {
            if (PrimitiveMap.Count > 0)
            {
                return;
            }

            BoxPrimitive grassCube       = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(0, 0), new Point(2, 0), new Point(2, 0));
            BoxPrimitive dirtCube        = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(2, 0), new Point(2, 0), new Point(2, 0));
            BoxPrimitive stoneCube       = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(4, 2), new Point(1, 0), new Point(4, 2));
            BoxPrimitive sandCube        = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(1, 1), new Point(1, 1), new Point(1, 1));
            BoxPrimitive ironCube        = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(4, 1), new Point(1, 2), new Point(4, 1));
            BoxPrimitive goldCube        = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(3, 1), new Point(0, 2), new Point(3, 1));
            BoxPrimitive coalCube        = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(3, 2), new Point(2, 2), new Point(2, 2));
            BoxPrimitive manaCube        = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(7, 1), new Point(6, 1), new Point(7, 1));
            BoxPrimitive frostCube       = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(0, 1), new Point(2, 1), new Point(2, 0));
            BoxPrimitive snowCube        = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(3, 7), new Point(3, 7), new Point(3, 7));
            BoxPrimitive iceCube         = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(2, 7), new Point(2, 7), new Point(2, 7));
            BoxPrimitive scaffoldCube    = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(7, 0), new Point(7, 0), new Point(7, 0));
            BoxPrimitive plankCube       = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(4, 0), new Point(4, 0), new Point(4, 0));
            BoxPrimitive waterCube       = CreatePrimitive(graphics, cubeTexture, cubeTexture.Width, cubeTexture.Height, new Point(0, 0), new Point(0, 0), new Point(0, 0));
            BoxPrimitive cobblestoneCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(5, 2), new Point(5, 2), new Point(5, 2));
            BoxPrimitive magicCube       = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(0, 10), new Point(0, 10), new Point(0, 10));
            BoxPrimitive bedrockCube     = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(6, 2), new Point(6, 2), new Point(6, 2));
            BoxPrimitive brownTileCube   = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(5, 0), new Point(5, 0), new Point(5, 0));
            BoxPrimitive blueTileCube    = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(6, 0), new Point(6, 0), new Point(6, 0));
            BoxPrimitive tilledSoilCube  = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(5, 1), new Point(2, 0), new Point(2, 0));

            BoxPrimitive redGemCube    = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(0, 11), new Point(0, 12), new Point(0, 11));
            BoxPrimitive orangeGemCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(1, 11), new Point(1, 12), new Point(1, 11));
            BoxPrimitive yellowGemCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(2, 11), new Point(2, 12), new Point(2, 11));
            BoxPrimitive greenGemCube  = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(3, 11), new Point(3, 12), new Point(3, 11));
            BoxPrimitive blueGemCube   = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(4, 11), new Point(4, 12), new Point(4, 11));
            BoxPrimitive purpleGemCube = CreatePrimitive(graphics, cubeTexture, 32, 32, new Point(5, 11), new Point(5, 12), new Point(5, 11));

            emptyType = new VoxelType
            {
                Name             = "empty",
                ReleasesResource = false,
                IsBuildable      = false
            };

            SoundSource dirtPicks = SoundSource.Create(ContentPaths.Audio.Oscar.pick_dirt_1,
                                                       ContentPaths.Audio.Oscar.pick_dirt_2, ContentPaths.Audio.Oscar.pick_dirt_3);

            SoundSource stonePicks = SoundSource.Create(ContentPaths.Audio.Oscar.pick_stone_1,
                                                        ContentPaths.Audio.Oscar.pick_stone_2, ContentPaths.Audio.Oscar.pick_stone_3);

            SoundSource woodPicks = SoundSource.Create(ContentPaths.Audio.Oscar.pick_wood_1,
                                                       ContentPaths.Audio.Oscar.pick_wood_2, ContentPaths.Audio.Oscar.pick_wood_3);

            VoxelType tilledSoil = new VoxelType
            {
                Name             = "TilledSoil",
                ReleasesResource = false,
                StartingHealth   = 20,
                CanRamp          = true,
                IsBuildable      = false,
                ParticleType     = "dirt_particle",
                IsSoil           = true,
                IsSurface        = true,
                ExplosionSound   = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_dirt_destroy),
                HitSound         = dirtPicks
            };

            RegisterType(tilledSoil, tilledSoilCube);

            VoxelType brownTile = new VoxelType
            {
                Name              = "Brown Tile",
                ReleasesResource  = true,
                ResourceToRelease = ResourceLibrary.ResourceType.Stone,
                IsBuildable       = true,
                StartingHealth    = 20,
                CanRamp           = false,
                ParticleType      = "stone_particle",
                ExplosionSound    = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_stone_destroy),
                HitSound          = stonePicks
            };

            RegisterType(brownTile, brownTileCube);

            VoxelType blueTileFloor = new VoxelType
            {
                Name              = "Blue Tile",
                ReleasesResource  = true,
                ResourceToRelease = ResourceLibrary.ResourceType.Stone,
                IsBuildable       = true,
                StartingHealth    = 20,
                CanRamp           = false,
                ParticleType      = "stone_particle",
                ExplosionSound    = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_stone_destroy),
                HitSound          = stonePicks
            };

            RegisterType(blueTileFloor, blueTileCube);

            VoxelType cobblestoneFloor = new VoxelType
            {
                Name                  = "Cobble",
                ReleasesResource      = true,
                ResourceToRelease     = ResourceLibrary.ResourceType.Stone,
                IsBuildable           = true,
                StartingHealth        = 20,
                CanRamp               = false,
                ParticleType          = "stone_particle",
                HasTransitionTextures = true,
                ExplosionSound        = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_stone_destroy),
                HitSound              = stonePicks
            };

            RegisterType(cobblestoneFloor, cobblestoneCube);
            CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 8), new Point(5, 2), new Point(5, 2), cobblestoneFloor.TransitionTextures);

            VoxelType stockpileType = new VoxelType
            {
                Name                  = "Stockpile",
                ReleasesResource      = false,
                StartingHealth        = 20,
                CanRamp               = false,
                IsBuildable           = false,
                ParticleType          = "stone_particle",
                HasTransitionTextures = true,
                ExplosionSound        = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_wood_destroy),
                HitSound              = woodPicks
            };

            RegisterType(stockpileType, plankCube);

            CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 9), new Point(4, 0), new Point(4, 0), stockpileType.TransitionTextures);

            VoxelType plankType = new VoxelType
            {
                Name = "Plank",
                ProbabilityOfRelease = 1.0f,
                ResourceToRelease    = ResourceLibrary.ResourceType.Wood,
                StartingHealth       = 20,
                ReleasesResource     = true,
                CanRamp               = true,
                RampSize              = 0.5f,
                IsBuildable           = true,
                ParticleType          = "stone_particle",
                HasTransitionTextures = true,
                ExplosionSound        = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_wood_destroy),
                HitSound              = woodPicks
            };


            CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 9), new Point(4, 0), new Point(4, 0), plankType.TransitionTextures);

            VoxelType magicType = new VoxelType
            {
                Name = "Magic",
                ProbabilityOfRelease = 0.0f,
                ResourceToRelease    = ResourceLibrary.ResourceType.Mana,
                StartingHealth       = 1,
                ReleasesResource     = true,
                CanRamp               = false,
                IsBuildable           = false,
                ParticleType          = "star_particle",
                ExplosionSound        = SoundSource.Create(ContentPaths.Audio.wurp),
                HasTransitionTextures = false,
                EmitsLight            = true
            };


            CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 10), new Point(15, 10), new Point(15, 10), magicType.TransitionTextures);


            VoxelType scaffoldType = new VoxelType
            {
                Name                 = "Scaffold",
                StartingHealth       = 20,
                ProbabilityOfRelease = 1.0f,
                ResourceToRelease    = ResourceLibrary.ResourceType.Wood,
                ReleasesResource     = false,
                CanRamp              = false,
                RampSize             = 0.5f,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                ExplosionSound       = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_wood_destroy),
                HitSound             = woodPicks
            };

            VoxelType grassType = new VoxelType
            {
                Name = "Grass",
                ProbabilityOfRelease = 0.1f,
                ResourceToRelease    = ResourceLibrary.ResourceType.Dirt,
                StartingHealth       = 10,
                ReleasesResource     = true,
                CanRamp               = true,
                RampSize              = 0.5f,
                IsBuildable           = false,
                ParticleType          = "dirt_particle",
                HasTransitionTextures = true,
                IsSoil         = true,
                IsSurface      = true,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_dirt_destroy),
                HitSound       = dirtPicks
            };

            CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 3), new Point(2, 0), new Point(2, 0), grassType.TransitionTextures);



            VoxelType frostType = new VoxelType
            {
                Name = "Frost",
                ProbabilityOfRelease = 0.1f,
                ResourceToRelease    = ResourceLibrary.ResourceType.Dirt,
                StartingHealth       = 10,
                ReleasesResource     = true,
                CanRamp               = true,
                RampSize              = 0.5f,
                IsBuildable           = false,
                ParticleType          = "dirt_particle",
                HasTransitionTextures = true,
                IsSurface             = true,
                ExplosionSound        = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_dirt_destroy),
                HitSound              = dirtPicks
            };

            CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 4), new Point(2, 0), new Point(2, 0), frostType.TransitionTextures);

            VoxelType snowType = new VoxelType
            {
                Name                  = "Snow",
                StartingHealth        = 1,
                ReleasesResource      = false,
                CanRamp               = true,
                RampSize              = 0.5f,
                IsBuildable           = false,
                ParticleType          = "snow_particle",
                HasTransitionTextures = false,
                IsSurface             = true,
                IsSoil                = false,
                ExplosionSound        = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_snow_destroy),
                HitSound              = dirtPicks
            };

            RegisterType(snowType, snowCube);

            VoxelType iceType = new VoxelType
            {
                Name                  = "Ice",
                StartingHealth        = 1,
                ReleasesResource      = false,
                CanRamp               = false,
                IsBuildable           = false,
                ParticleType          = "snow_particle",
                HasTransitionTextures = false,
                IsSurface             = true,
                IsSoil                = false,
                ExplosionSound        = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_snow_destroy),
                HitSound              = dirtPicks
            };

            RegisterType(iceType, iceCube);


            VoxelType desertGrass = new VoxelType
            {
                Name = "DesertGrass",
                ProbabilityOfRelease = 0.1f,
                ResourceToRelease    = ResourceLibrary.ResourceType.Sand,
                StartingHealth       = 20,
                ReleasesResource     = true,
                CanRamp               = true,
                RampSize              = 0.5f,
                IsBuildable           = false,
                ParticleType          = "sand_particle",
                HasTransitionTextures = true,
                IsSurface             = true,
                IsSoil         = true,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_dirt_destroy),
                HitSound       = dirtPicks
            };

            CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 6), new Point(1, 1), new Point(1, 1), desertGrass.TransitionTextures);

            VoxelType jungleGrass = new VoxelType
            {
                Name = "JungleGrass",
                ProbabilityOfRelease = 0.1f,
                ResourceToRelease    = ResourceLibrary.ResourceType.Dirt,
                StartingHealth       = 30,
                ReleasesResource     = true,
                CanRamp               = true,
                RampSize              = 0.5f,
                IsBuildable           = false,
                ParticleType          = "dirt_particle",
                HasTransitionTextures = true,
                IsSurface             = true,
                IsSoil         = true,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_dirt_destroy),
                HitSound       = dirtPicks
            };

            CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 5), new Point(2, 0), new Point(2, 0), jungleGrass.TransitionTextures);


            VoxelType caveFungus = new VoxelType
            {
                Name = "CaveFungus",
                ProbabilityOfRelease = 0.25f,
                ResourceToRelease    = ResourceLibrary.ResourceType.Stone,
                StartingHealth       = 30,
                ReleasesResource     = true,
                CanRamp               = false,
                RampSize              = 0.5f,
                IsBuildable           = false,
                ParticleType          = "stone_particle",
                HasTransitionTextures = true,
                IsSurface             = false,
                IsSoil         = true,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_dirt_destroy),
                HitSound       = dirtPicks
            };

            CreateTransitionUVs(graphics, cubeTexture, 32, 32, new Point(0, 13), new Point(1, 0), new Point(1, 0), caveFungus.TransitionTextures);


            VoxelType dirtType = new VoxelType
            {
                Name                 = "Dirt",
                ReleasesResource     = true,
                ResourceToRelease    = ResourceLibrary.ResourceType.Dirt,
                ProbabilityOfRelease = 0.3f,
                StartingHealth       = 10,
                RampSize             = 0.5f,
                CanRamp              = true,
                IsBuildable          = true,
                ParticleType         = "dirt_particle",
                IsSoil               = true,
                ExplosionSound       = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_dirt_destroy),
                HitSound             = dirtPicks
            };

            VoxelType stoneType = new VoxelType
            {
                Name = "Stone",
                ProbabilityOfRelease = 0.5f,
                ReleasesResource     = true,
                ResourceToRelease    = ResourceLibrary.ResourceType.Stone,
                StartingHealth       = 40,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                ExplosionSound       = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_stone_destroy),
                HitSound             = stonePicks
            };

            VoxelType bedrockType = new VoxelType
            {
                Name           = "Bedrock",
                StartingHealth = 255,
                IsBuildable    = false,
                IsInvincible   = true,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_stone_destroy),
                HitSound       = stonePicks
            };

            VoxelType waterType = new VoxelType
            {
                Name             = "water",
                ReleasesResource = false,
                IsBuildable      = false,
                StartingHealth   = 255
            };

            VoxelType sandType = new VoxelType
            {
                Name                 = "Sand",
                ReleasesResource     = true,
                StartingHealth       = 15,
                CanRamp              = true,
                RampSize             = 0.5f,
                IsBuildable          = true,
                ParticleType         = "sand_particle",
                IsSurface            = true,
                ResourceToRelease    = ResourceLibrary.ResourceType.Sand,
                ProbabilityOfRelease = 0.5f,
                ExplosionSound       = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_sand_destroy),
                HitSound             = dirtPicks
            };

            VoxelType ironType = new VoxelType
            {
                Name = "Iron",
                ProbabilityOfRelease = 0.99f,
                ReleasesResource     = true,
                ResourceToRelease    = ResourceLibrary.ResourceType.Iron,
                StartingHealth       = 80,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                SpawnClusters        = true,
                ClusterSize          = 5,
                SpawnVeins           = true,
                VeinLength           = 10,
                Rarity           = 0.0f,
                MinSpawnHeight   = 8,
                MaxSpawnHeight   = 40,
                SpawnProbability = 0.99f,
                ExplosionSound   = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_metal_destroy),
                HitSound         = stonePicks
            };


            VoxelType coalType = new VoxelType
            {
                Name = "Coal",
                ProbabilityOfRelease = 0.99f,
                ReleasesResource     = true,
                ResourceToRelease    = ResourceLibrary.ResourceType.Coal,
                StartingHealth       = 75,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                SpawnClusters        = true,
                ClusterSize          = 5,
                MinSpawnHeight       = 15,
                MaxSpawnHeight       = 50,
                SpawnProbability     = 0.3f,
                Rarity         = 0.05f,
                SpawnOnSurface = true,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_metal_destroy),
                HitSound       = stonePicks
            };


            VoxelType goldType = new VoxelType
            {
                Name = "Gold",
                ProbabilityOfRelease = 1.0f,
                ReleasesResource     = true,
                ResourceToRelease    = ResourceLibrary.ResourceType.Gold,
                StartingHealth       = 90,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                SpawnVeins           = true,
                VeinLength           = 20,
                Rarity           = 0.2f,
                MinSpawnHeight   = 0,
                MaxSpawnHeight   = 20,
                SpawnProbability = 0.99f,
                ExplosionSound   = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_metal_destroy),
                HitSound         = stonePicks
            };

            VoxelType greenGem = new VoxelType
            {
                Name = "Emerald",
                ProbabilityOfRelease = 1.0f,
                ReleasesResource     = true,
                ResourceToRelease    = "Emerald",
                StartingHealth       = 90,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                SpawnClusters        = true,
                ClusterSize          = 3,
                MinSpawnHeight       = 0,
                MaxSpawnHeight       = 18,
                SpawnProbability     = 0.8f,
                Rarity         = 0.9f,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_metal_destroy),
                HitSound       = stonePicks
            };

            VoxelType redGem = new VoxelType
            {
                Name = "Ruby",
                ProbabilityOfRelease = 1.0f,
                ReleasesResource     = true,
                ResourceToRelease    = "Ruby",
                StartingHealth       = 90,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                SpawnClusters        = true,
                ClusterSize          = 3,
                MinSpawnHeight       = 0,
                MaxSpawnHeight       = 18,
                SpawnProbability     = 0.8f,
                Rarity         = 0.9f,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_metal_destroy),
                HitSound       = stonePicks
            };


            VoxelType purpleGem = new VoxelType
            {
                Name = "Amethyst",
                ProbabilityOfRelease = 1.0f,
                ReleasesResource     = true,
                ResourceToRelease    = "Amethyst",
                StartingHealth       = 90,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                ClusterSize          = 3,
                SpawnClusters        = true,
                MinSpawnHeight       = 0,
                MaxSpawnHeight       = 18,
                SpawnProbability     = 0.8f,
                Rarity         = 0.9f,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_metal_destroy),
                HitSound       = stonePicks
            };

            VoxelType blueGem = new VoxelType
            {
                Name = "Sapphire",
                ProbabilityOfRelease = 1.0f,
                ReleasesResource     = true,
                ResourceToRelease    = "Sapphire",
                StartingHealth       = 90,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                SpawnClusters        = true,
                ClusterSize          = 3,
                MinSpawnHeight       = 0,
                MaxSpawnHeight       = 18,
                SpawnProbability     = 0.8f,
                Rarity         = 0.9f,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_metal_destroy),
                HitSound       = stonePicks
            };

            VoxelType yellowGem = new VoxelType
            {
                Name = "Citrine",
                ProbabilityOfRelease = 1.0f,
                ReleasesResource     = true,
                ResourceToRelease    = "Citrine",
                StartingHealth       = 90,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                SpawnClusters        = true,
                ClusterSize          = 3,
                MinSpawnHeight       = 0,
                MaxSpawnHeight       = 18,
                SpawnProbability     = 0.8f,
                Rarity         = 0.9f,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_metal_destroy),
                HitSound       = stonePicks
            };

            VoxelType orangeGem = new VoxelType
            {
                Name = "Garnet",
                ProbabilityOfRelease = 1.0f,
                ReleasesResource     = true,
                ResourceToRelease    = "Garnet",
                StartingHealth       = 90,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                SpawnClusters        = true,
                ClusterSize          = 3,
                MinSpawnHeight       = 0,
                MaxSpawnHeight       = 18,
                SpawnProbability     = 0.8f,
                Rarity         = 0.9f,
                ExplosionSound = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_metal_destroy),
                HitSound       = stonePicks
            };


            VoxelType manaType = new VoxelType
            {
                Name = "Mana",
                ProbabilityOfRelease = 1.0f,
                ReleasesResource     = true,
                ResourceToRelease    = ResourceLibrary.ResourceType.Mana,
                StartingHealth       = 200,
                IsBuildable          = true,
                ParticleType         = "stone_particle",
                SpawnVeins           = true,
                VeinLength           = 25,
                Rarity           = 0.1f,
                MinSpawnHeight   = 0,
                MaxSpawnHeight   = 14,
                SpawnProbability = 0.99f,
                ExplosionSound   = SoundSource.Create(ContentPaths.Audio.Oscar.voxel_metal_destroy),
                HitSound         = stonePicks
            };

            RegisterType(greenGem, greenGemCube);
            RegisterType(redGem, redGemCube);
            RegisterType(purpleGem, purpleGemCube);
            RegisterType(blueGem, blueGemCube);
            RegisterType(orangeGem, orangeGemCube);
            RegisterType(yellowGem, yellowGemCube);

            RegisterType(grassType, grassCube);
            RegisterType(frostType, frostCube);
            RegisterType(desertGrass, grassCube);
            RegisterType(jungleGrass, grassCube);
            RegisterType(caveFungus, grassCube);
            RegisterType(emptyType, null);
            RegisterType(dirtType, dirtCube);
            RegisterType(stoneType, stoneCube);
            RegisterType(waterType, waterCube);
            RegisterType(sandType, sandCube);
            RegisterType(ironType, ironCube);
            RegisterType(goldType, goldCube);
            RegisterType(manaType, manaCube);
            RegisterType(plankType, plankCube);
            RegisterType(scaffoldType, scaffoldCube);
            RegisterType(bedrockType, bedrockCube);
            RegisterType(coalType, coalCube);
            RegisterType(magicType, magicCube);

            foreach (VoxelType type in VoxelType.TypeList)
            {
                Types[type.Name] = type;
            }
        }
예제 #2
0
        /// <summary>
        /// Initialize function creates all the required components for the bird.
        /// </summary>
        /// <param name="sprites">The sprite sheet to use for the bird</param>
        public void Initialize(string sprites)
        {
            SpriteAsset = sprites;
            HasBones    = false;
            // When true, causes the bird to face the direction its moving in
            Physics.Orientation = Physics.OrientMode.RotateY;

            CreateSprite(sprites, Manager);
            // Used to grab other components
            Hands = Physics.AddChild(new Grabber("hands", Manager, Matrix.Identity, new Vector3(0.2f, 0.2f, 0.2f), Vector3.Zero)) as Grabber;

            // Used to sense hostile creatures
            Sensors = Physics.AddChild(new EnemySensor(Manager, "EnemySensor", Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero)) as EnemySensor;

            // Controls the behavior of the creature
            AI = Physics.AddChild(new PacingCreatureAI(Manager, "Spider AI", Sensors, PlanService)) as CreatureAI;

            // The bird can peck at its enemies (0.1 damage)
            Attacks = new List <Attack> {
                new Attack("Sting", 0.01f, 1.0f, 3.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_giant_spider_attack_1, ContentPaths.Audio.Oscar.sfx_oc_giant_spider_attack_2), ContentPaths.Effects.bite),
                new Attack("Web", 0.0f, 1.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_giant_spider_attack_1, ContentPaths.Audio.Oscar.sfx_oc_giant_spider_attack_2), ContentPaths.Effects.claws)
                {
                    Mode = Attack.AttackMode.Ranged, LaunchSpeed = 10, ProjectileType = "Web"
                }
            };


            // The bird can hold one item at a time in its inventory
            Inventory = Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.BoundingBoxPos)) as Inventory;

            Physics.AddChild(Shadow.Create(0.25f, Manager));

            // The bird will emit a shower of blood when it dies
            Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath = true,
                TriggerAmount  = 1
            });

            // The bird is flammable, and can die when exposed to fire.
            Physics.AddChild(new Flammable(Manager, "Flames"));

            // Tag the physics component with some information
            // that can be used later
            Physics.Tags.Add("Spider");
            Physics.Tags.Add("Animal");

            Stats.FullName     = TextGenerator.GenerateRandom("$firstname") + " the Spider";
            Stats.CurrentClass = new EmployeeClass()
            {
                Name   = "Spider",
                Levels = new List <EmployeeClass.Level>()
                {
                    new EmployeeClass.Level()
                    {
                        Index = 0, Name = "Spider"
                    }
                }
            };

            NoiseMaker.Noises["Hurt"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_giant_spider_hurt_1
            };
            NoiseMaker.Noises["Chirp"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_giant_spider_neutral_1,
                ContentPaths.Audio.Oscar.sfx_oc_giant_spider_neutral_2
            };
            AI.Movement.CanClimbWalls = true;
            AI.Movement.CanSwim       = false;
            Species      = "Spider";
            CanReproduce = true;
            BabyType     = "Spider";
        }
예제 #3
0
        public void Initialize()
        {
            Physics.Orientation = Physics.OrientMode.Fixed;
            Species             = "Snake";
            CreateGraphics();

            // Add sensor
            Physics.AddChild(new EnemySensor(Manager, "EnemySensor", Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero));

            // Add AI
            Physics.AddChild(new PacingCreatureAI(Manager, "snake AI", Sensors, PlanService));


            Attacks = new List <Attack>()
            {
                new Attack("Bite", 50.0f, 1.0f, 3.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_giant_snake_attack_1), ContentPaths.Effects.bite)
                {
                    TriggerMode  = Attack.AttackTrigger.Animation,
                    TriggerFrame = 2,
                }
            };

            Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.LocalBoundingBoxOffset));

            Physics.Tags.Add("Snake");
            Physics.Tags.Add("Animal");
            AI.Movement.SetCan(MoveType.ClimbWalls, true);
            AI.Stats.FullName     = "Giant Snake";
            AI.Stats.CurrentClass = new EmployeeClass()
            {
                Name   = "Giant Snake",
                Levels = new List <EmployeeClass.Level>()
                {
                    new EmployeeClass.Level()
                    {
                        BaseStats = new CreatureStats.StatNums()
                        {
                            Charisma     = AI.Stats.Charisma,
                            Constitution = AI.Stats.Constitution,
                            Dexterity    = AI.Stats.Dexterity,
                            Intelligence = AI.Stats.Intelligence,
                            Size         = AI.Stats.Size,
                            Strength     = AI.Stats.Strength,
                            Wisdom       = AI.Stats.Wisdom
                        },
                        Name  = "Giant Snake",
                        Index = 0
                    },
                }
            };
            AI.Stats.LevelIndex = 0;

            Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath  = true,
                TriggerAmount   = 1,
                BoxTriggerTimes = 10,
                SoundToPlay     = ContentPaths.Audio.Oscar.sfx_oc_giant_snake_hurt_1,
            });


            NoiseMaker.Noises["Hurt"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_giant_snake_hurt_1
            };
            NoiseMaker.Noises["Chirp"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_giant_snake_neutral_1,
                ContentPaths.Audio.Oscar.sfx_oc_giant_snake_neutral_2
            };

            Physics.AddChild(new Flammable(Manager, "Flames"));
        }
예제 #4
0
파일: Bird.cs 프로젝트: johan74/dwarfcorp
        public Bird(string sprites, Vector3 position, ComponentManager manager, string name) :
            base
            (
                manager,
                new CreatureStats
        {
            Dexterity    = 6,
            Constitution = 1,
            Strength     = 1,
            Wisdom       = 1,
            Charisma     = 1,
            Intelligence = 1,
            Size         = 0.25f,
            CanSleep     = false,
            LaysEggs     = true,
            IsMigratory  = true
        },
                "Herbivore",
                manager.World.PlanService,
                manager.World.Factions.Factions["Herbivore"],
                name
            )
        {
            Physics = new Physics
                      (
                manager,
                "A Bird",
                Matrix.CreateTranslation(position),
                new Vector3(0.25f, 0.25f, 0.25f),
                new Vector3(0.0f, 0.0f, 0.0f),
                1.0f, 1.0f, 0.999f, 0.999f,
                new Vector3(0, -10, 0)
                      );

            Physics.Orientation = Physics.OrientMode.RotateY;

            Physics.AddChild(this);


            SpriteAsset      = sprites;
            BaseMeatResource = "Bird Meat";
            CreateSprite(ContentPaths.Entities.Animals.Birds.GetBirdAnimations(SpriteAsset), Manager);

            // Used to sense hostile creatures
            Physics.AddChild(new EnemySensor(Manager, "EnemySensor", Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero));

            // Controls the behavior of the creature
            Physics.AddChild(new BirdAI(Manager, "Bird AI", Sensors, PlanService));

            // The bird can peck at its enemies (0.1 damage)
            Attacks = new List <Attack> {
                new Attack("Peck", 0.1f, 2.0f, 1.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_bird_attack), ContentPaths.Effects.pierce)
                {
                    Mode = Attack.AttackMode.Dogfight
                }
            };


            // The bird can hold one item at a time in its inventory
            Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.LocalBoundingBoxOffset));

            Physics.AddChild(Shadow.Create(0.25f, Manager));

            // The bird will emit a shower of blood when it dies
            Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath = true,
                TriggerAmount  = 1,
                SoundToPlay    = ContentPaths.Audio.Oscar.sfx_oc_bird_hurt
            });

            // The bird is flammable, and can die when exposed to fire.
            Physics.AddChild(new Flammable(Manager, "Flames"));

            // Tag the physics component with some information
            // that can be used later
            Physics.Tags.Add("Bird");
            Physics.Tags.Add("Animal");
            Physics.Tags.Add("DomesticAnimal");
            NoiseMaker.Noises.Add("chirp", new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_bird_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_bird_neutral_2
            });
            NoiseMaker.Noises["Hurt"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_bird_hurt
            };
            NoiseMaker.Noises["Lay Egg"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_bird_lay_egg
            };
            Stats.FullName     = TextGenerator.GenerateRandom("$firstname") + " the bird";
            Stats.CurrentClass = new EmployeeClass()
            {
                Name   = "Bird",
                Levels = new List <EmployeeClass.Level>()
                {
                    new EmployeeClass.Level()
                    {
                        Index = 0, Name = "Bird"
                    }
                }
            };

            AI.Movement.CanFly   = true;
            AI.Movement.CanWalk  = false;
            AI.Movement.CanClimb = false;
            Species = "Bird";
        }
예제 #5
0
        public static void InitializeDefaultLibrary(GraphicsDevice graphics)
        {
            if (TypeList != null)
            {
                return;
            }

            var cubeTexture = AssetManager.GetContentTexture(ContentPaths.Terrain.terrain_tiles);

            TypeList = FileUtils.LoadJsonListFromDirectory <VoxelType>(ContentPaths.voxel_types, null, v => v.Name);

            emptyType       = TypeList.FirstOrDefault(v => v.Name == "_empty");
            DesignationType = TypeList.FirstOrDefault(v => v.Name == "_designation");

            // Todo: Stabalize ids across save games.
            short id = 2;

            foreach (VoxelType type in TypeList)
            {
                Types[type.Name] = type;

                if (type.Name == "_empty")
                {
                    emptyType = type;
                    type.ID   = 0;
                }
                else
                {
                    PrimitiveMap[type.Name] = CreatePrimitive(graphics, cubeTexture, 32, 32, type.Top, type.Bottom, type.Sides);
                    if (type.Name == "_designation")
                    {
                        DesignationType = type;
                        type.ID         = 1;
                    }
                    else
                    {
                        type.ID = id;
                        id     += 1;
                    }
                }

                if (type.HasTransitionTextures)
                {
                    type.TransitionTextures = CreateTransitionUVs(graphics, cubeTexture, 32, 32, type.TransitionTiles, type.Transitions);
                }

                type.ExplosionSound = SoundSource.Create(type.ExplosionSoundResource);
                type.HitSound       = SoundSource.Create(type.HitSoundResources);
                if (type.ReleasesResource)
                {
                    if (ResourceLibrary.GetResourceByName(type.Name) == null)
                    {
                        var resource = new Resource(ResourceLibrary.GetResourceByName(type.ResourceToRelease))
                        {
                            Name      = type.Name,
                            ShortName = type.Name,
                            Tint      = type.Tint,
                            Generated = false
                        };
                        ResourceLibrary.Add(resource);
                        type.ResourceToRelease = resource.Name;
                    }
                }
            }

            TypeList = TypeList.OrderBy(v => v.ID).ToList();

            if (TypeList.Count > VoxelConstants.MaximumVoxelTypes)
            {
                throw new InvalidProgramException(String.Format("There can be only {0} voxel types.", VoxelConstants.MaximumVoxelTypes));
            }
        }