コード例 #1
0
ファイル: Gremlin.cs プロジェクト: Rod995/dwarfcorp
 public void InitializeWeapons()
 {
     Attacks = new List <Attack>()
     {
         new Attack("Wrench", 1.0f, 1.0f, 1.5f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_ic_goblin_attack_1, ContentPaths.Audio.Oscar.sfx_ic_goblin_attack_2, ContentPaths.Audio.Oscar.sfx_ic_goblin_attack_3), ContentPaths.Effects.claw)
         {
             Knockback    = 2.5f,
             TriggerMode  = Attack.AttackTrigger.Animation,
             TriggerFrame = 2
         }
     };
 }
コード例 #2
0
        private static void InitializeVoxels()
        {
            if (VoxelsInitialized)
            {
                return;
            }
            VoxelsInitialized = true;

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

            VoxelTypeList = FileUtils.LoadJsonListFromDirectory <VoxelType>(ContentPaths.voxel_types, null, v => v.Name);
            var terrainTiles = new Gui.TileSheet(cubeTexture.Width, cubeTexture.Height, cubeTexture.Bounds, 32, 32, false);

            short id = 2;

            foreach (VoxelType type in VoxelTypeList)
            {
                VoxelTypes[type.Name]      = type;
                VoxelPrimitives[type.Name] = CreateVoxelPrimitive(cubeTexture, 32, 32, type.Top, type.Bottom, type.Sides);
                if (type.Name == "_empty")
                {
                    _EmptyVoxelType = type;
                    type.ID         = 0;
                }
                else if (type.Name == "_designation")
                {
                    _DesignationVoxelType = type;
                    type.ID = 1;
                }
                else
                {
                    type.ID = id;
                    id     += 1;
                }

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

                type.ExplosionSound = SoundSource.Create(type.ExplosionSoundResource);
                type.HitSound       = SoundSource.Create(type.HitSoundResources);
            }

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

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

            Console.WriteLine("Loaded Voxel Library.");
        }
コード例 #3
0
 public void InitializeWeapons()
 {
     Attacks = new List <Attack>()
     {
         new Attack("Fairy Dust", 10.0f, 0.2f, 2.0f, SoundSource.Create(ContentPaths.Audio.tinkle), ContentPaths.Effects.hit)
         {
             Knockback    = 0.5f,
             HitParticles = "star_particle",
             TriggerMode  = Attack.AttackTrigger.Animation,
             TriggerFrame = 2
         }
     };
 }
コード例 #4
0
 public void InitializeWeapons()
 {
     Attacks = new List <Attack>()
     {
         new Attack("Claws", 1.0f, 0.5f, 2.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_ic_necromancer_skeleton_attack_1, ContentPaths.Audio.Oscar.sfx_ic_necromancer_skeleton_hurt_2), ContentPaths.Effects.claw)
         {
             Knockback       = 0.5f,
             TriggerMode     = Attack.AttackTrigger.Animation,
             TriggerFrame    = 2,
             DiseaseToSpread = "Necrorot"
         }
     };
 }
コード例 #5
0
 public void InitializeWeapons()
 {
     Attacks = new List <Attack>()
     {
         new Attack("Axe", 4.0f, 0.5f, 2.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_ic_dwarf_attack_sword_1,
                                                                ContentPaths.Audio.Oscar.sfx_ic_dwarf_attack_sword_2, ContentPaths.Audio.Oscar.sfx_ic_dwarf_attack_sword_3), ContentPaths.Effects.slash)
         {
             Knockback    = 10.0f,
             TriggerMode  = Attack.AttackTrigger.Animation,
             TriggerFrame = 2
         }
     };
 }
コード例 #6
0
 public void InitializeWeapons()
 {
     Attacks = new List <Attack>()
     {
         new Attack("Slam", 15.0f, 2.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_ic_demon_hurt_1, ContentPaths.Audio.Oscar.sfx_ic_demon_hurt_2, ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_1), ContentPaths.Effects.rings)
         {
             Knockback    = 2.5f,
             TriggerMode  = Attack.AttackTrigger.Animation,
             TriggerFrame = 3,
             Mode         = Attack.AttackMode.Area,
             HitParticles = "dirt_particle"
         }
     };
 }
コード例 #7
0
 public void InitializeWeapons()
 {
     Attacks = new List <Attack>
     {
         new Attack("Musket", 20.0f, 2.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_ic_dwarf_attack_musket_1,
                                                                    ContentPaths.Audio.Oscar.sfx_ic_dwarf_attack_musket_2, ContentPaths.Audio.Oscar.sfx_ic_dwarf_attack_musket_3), ContentPaths.Effects.explode)
         {
             Mode           = Attack.AttackMode.Ranged,
             LaunchSpeed    = 30.0f,
             ProjectileType = "Bullet",
             TriggerMode    = Attack.AttackTrigger.Animation,
             TriggerFrame   = 2
         }
     };
 }
コード例 #8
0
 public void InitializeWeapons()
 {
     Attacks = new List <Attack>()
     {
         new Attack("Fireball", 0.1f, 1.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_ic_demon_fire_spit_1, ContentPaths.Audio.Oscar.sfx_ic_demon_fire_spit_2), ContentPaths.Effects.hit)
         {
             Mode           = Attack.AttackMode.Ranged,
             LaunchSpeed    = 10.0f,
             ProjectileType = "Fireball",
             TriggerMode    = Attack.AttackTrigger.Animation,
             TriggerFrame   = 2,
             DamageAmount   = 15
         }
     };
 }
コード例 #9
0
ファイル: Attack.cs プロジェクト: jeason1997/dwarfcorp
 public Attack(string name, float damage, float time, float range, SoundSource noise, string animation)
 {
     Name           = name;
     DamageAmount   = damage;
     RechargeTimer  = new Timer(time + MathFunctions.Rand(-0.2f, 0.2f), false);
     Range          = range;
     HitNoise       = noise;
     Mode           = AttackMode.Melee;
     Knockback      = 0.0f;
     HitAnimation   = null;
     HitColor       = Color.White;
     HitParticles   = "";
     ProjectileType = "";
     AnimationAsset = animation;
     HitAnimation   = AnimationLibrary.CreateSimpleAnimation(AnimationAsset);
 }
コード例 #10
0
        public static void InitializeDefaultLibrary(GraphicsDevice graphics)
        {
            if (TypeList != null)
            {
                return;
            }

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

            TypeList        = FileUtils.LoadJsonListFromMultipleSources <VoxelType>(ContentPaths.voxel_types, null, v => v.Name);
            emptyType       = TypeList[0];
            DesignationType = TypeList[1];

            short ID = 0;

            foreach (VoxelType type in TypeList)
            {
                type.ID = ID;
                ++ID;

                Types[type.Name]   = type;
                PrimitiveMap[type] = type.ID == 0 ? null : CreatePrimitive(graphics, cubeTexture, 32, 32, type.Top, type.Bottom, type.Sides);

                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;
                    }
                }
            }
        }
コード例 #11
0
 public Weapon(Weapon other)
 {
     Name            = other.Name;
     DamageAmount    = other.DamageAmount;
     Range           = other.Range;
     HitNoise        = other.HitNoise;
     Mode            = other.Mode;
     Knockback       = other.Knockback;
     HitParticles    = other.HitParticles;
     HitColor        = other.HitColor;
     ProjectileType  = other.ProjectileType;
     LaunchSpeed     = other.LaunchSpeed;
     AnimationAsset  = other.AnimationAsset;
     TriggerMode     = other.TriggerMode;
     TriggerFrame    = other.TriggerFrame;
     HasTriggered    = false;
     DiseaseToSpread = other.DiseaseToSpread;
     ShootLaser      = other.ShootLaser;
 }
コード例 #12
0
        public TurretTrap(ComponentManager manager, Vector3 position, Faction faction, List <ResourceAmount> resources) :
            base(manager, "TurretTrap", Matrix.CreateTranslation(position),
                 new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero, new CraftDetails(manager, "Turret", resources))
        {
            Allies = faction;
            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32, 32);

            Weapon = new Attack("BowAttack", 5.0f, 1.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_trap_turret_shoot_1, ContentPaths.Audio.Oscar.sfx_trap_turret_shoot_2), ContentPaths.Effects.pierce)
            {
                ProjectileType = "Arrow",
                Mode           = Attack.AttackMode.Ranged,
                LaunchSpeed    = 15
            };

            AddChild(new ParticleTrigger("explode", Manager, "DeathParticles",
                                         Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), Vector3.Zero)
            {
                SoundToPlay = ContentPaths.Audio.Oscar.sfx_trap_turret_shoot_1
            });

            AddChild(new Health(Manager, "health", 50.0f, 0.0f, 50.0f));

            Sensor = AddChild(new EnemySensor(Manager, "sensor", Matrix.Identity, new Vector3(8, 8, 8),
                                              Vector3.Zero)
            {
                Allies        = faction,
                DetectCloaked = true
            }) as EnemySensor;

            Sensor.OnEnemySensed        += Sensor_OnEnemySensed;
            BaseSprite                   = AddChild(new SimpleSprite(Manager, "Turret", Matrix.Identity, spriteSheet, new Point(2, 7))) as SimpleSprite;
            BaseSprite.OrientationType   = SimpleSprite.OrientMode.YAxis;
            TurretSprite                 = AddChild(new SimpleSprite(Manager, "Turret", Matrix.CreateTranslation(Vector3.Up * 0.25f), spriteSheet, new Point(1, 7))) as SimpleSprite;
            TurretSprite.OrientationType = SimpleSprite.OrientMode.Fixed;
            SetTurretAngle(0.0f);
            CreateCosmeticChildren(manager);
            AddChild(new MagicalObject(Manager));
        }
コード例 #13
0
ファイル: VoxelSelector.cs プロジェクト: hhy5277/dwarfcorp
        // Todo: Remove unused arguments
        public VoxelSelector(WorldManager World)
        {
            this.World = World;

            SelectionType            = VoxelSelectionType.SelectEmpty;
            SelectionColor           = Color.White;
            SelectionWidth           = 0.1f;
            CurrentWidth             = 0.08f;
            CurrentColor             = Color.White;
            SelectionBuffer          = new List <VoxelHandle>();
            Dragged                  = DraggedCallback;
            Selected                 = SelectedCallback;
            Enabled                  = true;
            DeleteColor              = Color.Red;
            BoxYOffset               = 0;
            LastMouseWheel           = 0;
            ClickSound               = SoundSource.Create(ContentPaths.Audio.Oscar.sfx_gui_change_selection);
            ClickSound.RandomPitch   = false;
            DragSound                = SoundSource.Create(ContentPaths.Audio.Oscar.sfx_gui_click_voxel);
            DragSound.RandomPitch    = false;
            ReleaseSound             = SoundSource.Create(ContentPaths.Audio.Oscar.sfx_gui_confirm_selection);
            ReleaseSound.RandomPitch = false;
        }
コード例 #14
0
        public VoxelType(VoxelType parent, string subtype)
        {
            ID = maxID;
            maxID++;
            Name                  = subtype;
            ReleasesResource      = parent.ReleasesResource;
            ResourceToRelease     = parent.ResourceToRelease;
            StartingHealth        = parent.StartingHealth;
            ProbabilityOfRelease  = parent.ProbabilityOfRelease;
            CanRamp               = parent.CanRamp;
            RampSize              = parent.RampSize;
            IsBuildable           = parent.IsBuildable;
            ParticleType          = parent.ParticleType;
            IsInvincible          = parent.IsInvincible;
            ExplosionSound        = parent.ExplosionSound;
            HasTransitionTextures = parent.HasTransitionTextures;
            TransitionTextures    = parent.TransitionTextures;
            IsSoil                = parent.IsSoil;
            EmitsLight            = parent.EmitsLight;
            Tint                  = parent.Tint;
            IsSurface             = parent.IsSurface;
            if (!TypeList.Contains(this))
            {
                TypeList.Add(this);
            }

            MinSpawnHeight   = -999;
            MaxSpawnHeight   = 999;
            SpawnProbability = 1.0f;
            ClusterSize      = 0.0f;
            VeinLength       = 0.0f;
            SpawnClusters    = false;
            SpawnVeins       = false;
            Rarity           = 1.0f;
            SpawnOnSurface   = false;
            HitSound         = parent.HitSound;
        }
コード例 #15
0
        public static void InitializeDefaultLibrary(GraphicsDevice graphics, Texture2D cubeTexture)
        {
            TypeList  = FileUtils.LoadJson <List <VoxelType> >(ContentPaths.voxel_types, false);
            emptyType = TypeList[0];

            short ID = 0;

            foreach (VoxelType type in TypeList)
            {
                type.ID = ID;
                ++ID;

                Types[type.Name]   = type;
                PrimitiveMap[type] = type.ID == 0 ? null : CreatePrimitive(graphics, cubeTexture, 32, 32, type.Top, type.Bottom, type.Sides);

                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);
            }
        }
コード例 #16
0
 public VoxelType()
 {
     ID = maxID;
     maxID++;
     Name                  = "";
     IsSurface             = false;
     ReleasesResource      = false;
     ResourceToRelease     = ResourceLibrary.ResourceType.Dirt;
     StartingHealth        = 0.0f;
     ProbabilityOfRelease  = 0.0f;
     CanRamp               = false;
     RampSize              = 0.0f;
     IsBuildable           = false;
     ParticleType          = "puff";
     IsInvincible          = false;
     ExplosionSound        = SoundSource.Create(ContentPaths.Audio.gravel);
     HasTransitionTextures = false;
     TransitionTextures    = new Dictionary <TransitionTexture, BoxPrimitive.BoxTextureCoords>();
     IsSoil                = false;
     EmitsLight            = false;
     Tint                  = Color.White;
     if (!TypeList.Contains(this))
     {
         TypeList.Add(this);
     }
     MinSpawnHeight   = -999;
     MaxSpawnHeight   = 999;
     SpawnProbability = 1.0f;
     ClusterSize      = 0.0f;
     VeinLength       = 0.0f;
     SpawnClusters    = false;
     SpawnVeins       = false;
     Rarity           = 1.0f;
     SpawnOnSurface   = false;
     HitSound         = SoundSource.Create(ContentPaths.Audio.pick);
 }
コード例 #17
0
        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, 0.35f);

            // 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));

            // 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";
        }
コード例 #18
0
        public Spider(ComponentManager manager, Vector3 position) :
            base
            (
                manager,
                new CreatureStats
        {
            Dexterity    = 6,
            Constitution = 3,
            Strength     = 3,
            Wisdom       = 3,
            Charisma     = 3,
            Intelligence = 3,
            Size         = 0.25f,
            CanSleep     = false
        },
                "Carnivore",
                manager.World.PlanService,
                manager.World.Factions.Factions["Carnivore"],
                "Spider"
            )
        {
            Physics = new Physics(
                manager,
                "Spider",
                Matrix.CreateTranslation(position),
                new Vector3(0.375f, 0.375f, 0.375f),
                new Vector3(0.0f, 0.0f, 0.0f),
                1.0f, 1.0f, 0.999f, 0.999f,
                new Vector3(0, -10, 0)
                );

            Physics.AddChild(this);

            HasBones = false;

            Physics.Orientation = Physics.OrientMode.RotateY;

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

            Physics.AddChild(new PacingCreatureAI(Manager, "Spider AI", Sensors, PlanService));

            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.claw)
                {
                    Mode           = Attack.AttackMode.Ranged,
                    LaunchSpeed    = 10,
                    ProjectileType = "Web"
                }
            };

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

            // 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";

            CreateCosmetics(manager);
        }
コード例 #19
0
ファイル: Scorpion.cs プロジェクト: polytronicgr/dwarfcorp
        /// <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)
        {
            HasBones = false;
            // When true, causes the bird to face the direction its moving in
            Physics.Orientation = Physics.OrientMode.RotateY;

            SpriteAsset = sprites;
            CreateSprite(sprites, Manager, 0.35f);

            Physics.AddChild(Shadow.Create(0.3f, 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 PacingCreatureAI(Manager, "Scorpion AI", Sensors, PlanService));

            // The bird can peck at its enemies (0.1 damage)
            Attacks = new List <Attack> {
                new Attack("Sting", 4.0f, 2.0f, 1.5f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_scorpion_attack_1, ContentPaths.Audio.Oscar.sfx_oc_scorpion_attack_2), ContentPaths.Effects.pierce)
                {
                    TriggerFrame = 2, TriggerMode = Attack.AttackTrigger.Animation
                }
            };


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

            // 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("Scorpion");
            Physics.Tags.Add("Animal");

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

            NoiseMaker.Noises["Hurt"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_scorpion_hurt_1
            };
            NoiseMaker.Noises["Chirp"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_scorpion_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_scorpion_neutral_2
            };
            AI.Movement.CanClimbWalls = true;
            AI.Movement.CanSwim       = false;
            AI.Movement.SetSpeed(MoveType.Jump, 1.5f);
            AI.Movement.SetSpeed(MoveType.Climb, 1.5f);
            AI.Movement.SetCost(MoveType.Climb, 0.1f);
            Species      = "Scorpion";
            CanReproduce = true;
            BabyType     = "Scorpion";
        }
コード例 #20
0
ファイル: WizardClass.cs プロジェクト: polytronicgr/dwarfcorp
 void InitializeLevels()
 {
     Levels = new List <Level>
     {
         new Level
         {
             Index     = 0,
             Name      = "Bachelor of Magical Studies",
             Pay       = 25,
             XP        = 0,
             BaseStats = new CreatureStats.StatNums(),
         },
         new Level
         {
             Index     = 1,
             Name      = "Master of Magical Studies",
             Pay       = 50,
             XP        = 100,
             BaseStats = new CreatureStats.StatNums()
             {
                 Intelligence = 6,
                 Constitution = 6
             }
         },
         new Level
         {
             Index     = 2,
             Name      = "PhM Candidate",
             Pay       = 100,
             XP        = 250,
             BaseStats = new CreatureStats.StatNums()
             {
                 Intelligence = 7,
                 Constitution = 6,
                 Charisma     = 6
             },
             HealingPower = 1
         },
         new Level
         {
             Index     = 3,
             Name      = "Adjunct Wizard",
             Pay       = 200,
             XP        = 500,
             BaseStats = new CreatureStats.StatNums()
             {
                 Intelligence = 7,
                 Constitution = 7,
                 Charisma     = 6,
                 Dexterity    = 6
             },
             HealingPower = 5,
             ExtraAttacks = new List <Attack>()
             {
                 new Attack("Fireball", 5.0f, 3.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_env_lava_spread), ContentPaths.Effects.explode)
                 {
                     Mode         = Attack.AttackMode.Area,
                     TriggerFrame = 2,
                     TriggerMode  = Attack.AttackTrigger.Animation,
                     HitParticles = "flame",
                     ShootLaser   = true
                 }
             }
         },
         new Level
         {
             Index     = 4,
             Name      = "Associate Wizard",
             Pay       = 500,
             XP        = 1000,
             BaseStats = new CreatureStats.StatNums()
             {
                 Intelligence = 8,
                 Constitution = 7,
                 Charisma     = 6,
                 Dexterity    = 6
             },
             HealingPower = 10,
             ExtraAttacks = new List <Attack>()
             {
                 new Attack("Fireball", 15.0f, 3.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_env_lava_spread), ContentPaths.Effects.explode)
                 {
                     Mode         = Attack.AttackMode.Area,
                     TriggerFrame = 2,
                     TriggerMode  = Attack.AttackTrigger.Animation,
                     HitParticles = "flame",
                     ShootLaser   = true
                 }
             }
         },
         new Level
         {
             Index     = 5,
             Name      = "Tenured Wizard",
             Pay       = 1000,
             XP        = 5000,
             BaseStats = new CreatureStats.StatNums()
             {
                 Intelligence = 9,
                 Constitution = 8,
                 Charisma     = 7,
                 Dexterity    = 7
             },
             HealingPower = 15,
             ExtraAttacks = new List <Attack>()
             {
                 new Attack("Fireball", 20.0f, 3.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_env_lava_spread), ContentPaths.Effects.explode)
                 {
                     Mode         = Attack.AttackMode.Area,
                     TriggerFrame = 2,
                     TriggerMode  = Attack.AttackTrigger.Animation,
                     HitParticles = "flame",
                     ShootLaser   = true
                 }
             }
         },
         new Level
         {
             Index     = 6,
             Name      = "Wizarding Fellow",
             Pay       = 5000,
             XP        = 10000,
             BaseStats = new CreatureStats.StatNums()
             {
                 Intelligence = 10,
                 Constitution = 8,
                 Charisma     = 8,
                 Dexterity    = 8
             },
             HealingPower = 20,
             ExtraAttacks = new List <Attack>()
             {
                 new Attack("Fireball", 40.0f, 3.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_env_lava_spread), ContentPaths.Effects.explode)
                 {
                     Mode         = Attack.AttackMode.Area,
                     TriggerFrame = 2,
                     TriggerMode  = Attack.AttackTrigger.Animation,
                     HitParticles = "flame",
                     ShootLaser   = true
                 }
             }
         },
         new Level
         {
             Index     = 7,
             Name      = "Dean of Wizarding",
             Pay       = 10000,
             XP        = 20000,
             BaseStats = new CreatureStats.StatNums()
             {
                 Intelligence = 10,
                 Constitution = 9,
                 Charisma     = 9,
                 Dexterity    = 9,
                 Strength     = 6
             },
             HealingPower = 20,
             ExtraAttacks = new List <Attack>()
             {
                 new Attack("Fireball", 40.0f, 3.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_env_lava_spread), ContentPaths.Effects.explode)
                 {
                     Mode         = Attack.AttackMode.Area,
                     TriggerFrame = 2,
                     TriggerMode  = Attack.AttackTrigger.Animation,
                     HitParticles = "flame",
                     ShootLaser   = true
                 }
             }
         },
         new Level
         {
             Index     = 8,
             Name      = "Chair of Wizarding",
             Pay       = 50000,
             XP        = 1000000,
             BaseStats = new CreatureStats.StatNums()
             {
                 Intelligence = 10,
                 Constitution = 10,
                 Charisma     = 10,
                 Dexterity    = 10,
                 Strength     = 6
             },
             HealingPower = 20,
             ExtraAttacks = new List <Attack>()
             {
                 new Attack("Fireball", 40.0f, 3.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_env_lava_spread), ContentPaths.Effects.explode)
                 {
                     Mode         = Attack.AttackMode.Area,
                     TriggerFrame = 2,
                     TriggerMode  = Attack.AttackTrigger.Animation,
                     HitParticles = "flame",
                     ShootLaser   = true
                 }
             }
         },
         new Level
         {
             Index     = 9,
             Name      = "Magical Provost",
             Pay       = 100000,
             XP        = 2000000,
             BaseStats = new CreatureStats.StatNums()
             {
                 Intelligence = 10,
                 Constitution = 10,
                 Charisma     = 10,
                 Dexterity    = 10,
                 Strength     = 10
             },
             HealingPower = 20,
             ExtraAttacks = new List <Attack>()
             {
                 new Attack("Fireball", 40.0f, 3.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_env_lava_spread), ContentPaths.Effects.explode)
                 {
                     Mode         = Attack.AttackMode.Area,
                     TriggerFrame = 2,
                     TriggerMode  = Attack.AttackTrigger.Animation,
                     HitParticles = "flame",
                     ShootLaser   = true
                 }
             }
         },
         new Level
         {
             Index     = 10,
             Name      = "Wizard Emeritus",
             Pay       = 100000,
             XP        = 5000000,
             BaseStats = new CreatureStats.StatNums()
             {
                 Intelligence = 10,
                 Constitution = 10,
                 Charisma     = 10,
                 Dexterity    = 10,
                 Strength     = 10
             },
             HealingPower = 20,
             ExtraAttacks = new List <Attack>()
             {
                 new Attack("Fireball", 40.0f, 3.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_env_lava_spread), ContentPaths.Effects.explode)
                 {
                     Mode         = Attack.AttackMode.Area,
                     TriggerFrame = 2,
                     TriggerMode  = Attack.AttackTrigger.Animation,
                     HitParticles = "flame",
                     ShootLaser   = true
                 }
             }
         }
     };
 }
コード例 #21
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;
            // 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.1f, 0.1f, 0.1f), 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, "Rabbit AI", Sensors, PlanService)) as CreatureAI;

            // The bird can peck at its enemies (0.1 damage)
            Attacks = new List <Attack> {
                new Attack("Bite", 0.01f, 2.0f, 1.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_rabbit_attack), ContentPaths.Effects.bite)
                {
                    DiseaseToSpread = "Rabies"
                }
            };


            // 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("Rabbit");
            Physics.Tags.Add("Animal");
            Physics.Tags.Add("DomesticAnimal");
            Stats.FullName     = TextGenerator.GenerateRandom("$firstname") + " the rabbit";
            Stats.CurrentClass = new EmployeeClass()
            {
                Name   = "Rabbit",
                Levels = new List <EmployeeClass.Level>()
                {
                    new EmployeeClass.Level()
                    {
                        Index = 0, Name = "Rabbit"
                    }
                }
            };


            NoiseMaker.Noises["Hurt"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_rabbit_hurt_1, ContentPaths.Audio.Oscar.sfx_oc_rabbit_hurt_2
            };
            NoiseMaker.Noises["Chirp"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_rabbit_neutral_1,
                ContentPaths.Audio.Oscar.sfx_oc_rabbit_neutral_2
            };
            Species      = "Rabbit";
            CanReproduce = true;
            BabyType     = Name;

            var deathParticleTrigger = Parent.EnumerateAll().OfType <ParticleTrigger>().FirstOrDefault();

            if (deathParticleTrigger != null)
            {
                deathParticleTrigger.SoundToPlay = NoiseMaker.Noises["Hurt"][0];
            }
        }
コード例 #22
0
ファイル: Snake.cs プロジェクト: Rod995/dwarfcorp
        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));


            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.Movement.SetCan(MoveType.Dig, 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"));
        }
コード例 #23
0
ファイル: Frog.cs プロジェクト: polytronicgr/dwarfcorp
        /// <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)
        {
            // When true, causes the bird to face the direction its moving in
            Physics.Orientation = Physics.OrientMode.RotateY;

            SpriteAsset = sprites;

            CreateSprite(SpriteAsset, Manager, 0.35f);

            // 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 PacingCreatureAI(Manager, "Rabbit AI", Sensors, PlanService));

            // The bird can peck at its enemies (0.1 damage)
            Attacks = new List <Attack> {
                new Attack("Bite", 0.01f, 2.0f, 1.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_frog_attack), ContentPaths.Effects.bite)
            };


            // 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_frog_hurt_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("Frog");
            Physics.Tags.Add("Animal");
            Physics.Tags.Add("DomesticAnimal");
            Stats.FullName     = TextGenerator.GenerateRandom("$firstname") + " the frog";
            Stats.CurrentClass = new EmployeeClass()
            {
                Name   = "Frog",
                Levels = new List <EmployeeClass.Level>()
                {
                    new EmployeeClass.Level()
                    {
                        Index = 0, Name = "Frog"
                    }
                }
            };


            NoiseMaker.Noises["Idle"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_frog_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_frog_neutral_2
            };
            NoiseMaker.Noises["Chrip"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_frog_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_frog_neutral_2
            };
            NoiseMaker.Noises["Hurt"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_frog_hurt_1, ContentPaths.Audio.Oscar.sfx_oc_frog_hurt_2
            };
            Species      = "Frog";
            CanReproduce = true;
            BabyType     = "Frog";
        }
コード例 #24
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;
            }
        }
コード例 #25
0
ファイル: Chicken.cs プロジェクト: polytronicgr/dwarfcorp
        /// <summary>
        /// Initialize function creates all the required components for the bird.
        /// </summary>
        /// <param name="sprites">The sprite sheet to use for the bird</param>
        /// <param name="species"></param>
        public void Initialize(string sprites, string species)
        {
            // When true, causes the bird to face the direction its moving in
            Physics.Orientation = Physics.OrientMode.RotateY;


            CreateSprite(ContentPaths.Entities.Animals.fowl[Species], 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 PacingCreatureAI(Manager, "AI", Sensors, PlanService));

            // The bird can peck at its enemies (0.1 damage)
            Attacks = new List <Attack>
            {
                new Attack("Peck", 0.01f, 2.0f, 0.5f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_chicken_attack), ContentPaths.Effects.pierce)
                {
                    Mode         = Attack.AttackMode.Melee,
                    TriggerFrame = 2,
                    TriggerMode  = Attack.AttackTrigger.Animation
                }
            };


            // 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.5f, 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
            });

            Physics.AddChild(new ParticleTrigger("feather", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath = true,
                TriggerAmount  = 10
            });

            // 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(species);
            Physics.Tags.Add("Animal");
            Physics.Tags.Add("DomesticAnimal");
            Stats.FullName     = TextGenerator.GenerateRandom("$firstname") + " the " + species;
            Stats.CurrentClass = new EmployeeClass()
            {
                Name   = species,
                Levels = new List <EmployeeClass.Level>()
                {
                    new EmployeeClass.Level()
                    {
                        Index = 0, Name = species
                    }
                }
            };


            NoiseMaker.Noises["Hurt"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_chicken_hurt_1, ContentPaths.Audio.Oscar.sfx_oc_chicken_hurt_2
            };
            NoiseMaker.Noises["Chirp"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_chicken_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_chicken_neutral_2
            };
            NoiseMaker.Noises["Lay Egg"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_chicken_lay_egg
            };
            Species = species;

            var deathParticleTrigger = Parent.EnumerateAll().OfType <ParticleTrigger>().FirstOrDefault();

            if (deathParticleTrigger != null)
            {
                deathParticleTrigger.SoundToPlay = NoiseMaker.Noises["Hurt"][0];
            }
        }
コード例 #26
0
        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
        },
                "Herbivore",
                manager.World.PlanService,
                manager.World.Factions.Factions["Herbivore"],
                name
            )
        {
            Physics = new Physics
                      (
                manager,
                // It is called "bird"
                "A Bird",
                // It's attached to the root component of the component manager
                // It is located at a position passed in as an argument
                Matrix.CreateTranslation(position),
                // It has a size of 0.25 blocks
                new Vector3(0.25f, 0.25f, 0.25f),
                // Its bounding box is located in its center
                new Vector3(0.0f, 0.0f, 0.0f),
                //It has a mass of 1, a moment of intertia of 1, and very small friction/restitution
                1.0f, 1.0f, 0.999f, 0.999f,
                // It has a gravity of 10 blocks per second downward
                new Vector3(0, -10, 0)
                      );

            Physics.AddChild(this);

            Physics.AddChild(new SelectionCircle(Manager)
            {
                IsVisible = false
            });

            SpriteAsset = sprites;
            CreateSpriteSheet(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 BirdAI(Manager, "Bird AI", Sensors, PlanService)) as BirdAI;

            // 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
            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,
                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";
        }
コード例 #27
0
ファイル: Spider.cs プロジェクト: jeason1997/dwarfcorp
        /// <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.claw)
                {
                    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.LocalBoundingBoxOffset)) 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";
        }
コード例 #28
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));
            }
        }