Beispiel #1
0
        public Faction GenerateFaction(WorldManager world, int idx, int n)
        {
            var race = RaceLibrary.RandomIntelligentRace();

            var fact = new Faction(world)
            {
                Race              = race,
                Name              = TextGenerator.GenerateRandom(Datastructures.SelectRandom(race.FactionNameTemplates).ToArray()),
                PrimaryColor      = new HSLColor(idx * (255.0f / n), 255.0, MathFunctions.Rand(100.0f, 200.0f)),
                SecondaryColor    = new HSLColor(MathFunctions.Rand(0, 255.0f), 255.0, MathFunctions.Rand(100.0f, 200.0f)),
                TradeMoney        = (decimal)MathFunctions.Rand(250.0f, 20000.0f),
                Center            = new Point(MathFunctions.RandInt(0, Overworld.Map.GetLength(0)), MathFunctions.RandInt(0, Overworld.Map.GetLength(1))),
                GoodWill          = MathFunctions.Rand(-1, 1),
                DistanceToCapital = MathFunctions.Rand(100, 500),
                ClaimsColony      = MathFunctions.RandEvent(0.1f)
            };

            fact.Economy = new Economy(fact, fact.TradeMoney, world, new CompanyInformation()
            {
                LogoBackgroundColor = fact.SecondaryColor.ToVector4(), LogoSymbolColor = fact.PrimaryColor.ToVector4(), Name = fact.Name
            });
            return(fact);
        }
Beispiel #2
0
        private void OpenDiplomacyConversation(WorldManager World)
        {
            World.Paused = true;
            // Prepare conversation memory for an envoy conversation.
            var cMem = World.ConversationMemory;

            cMem.SetValue("$world", new Yarn.Value(World));
            cMem.SetValue("$envoy", new Yarn.Value(this));
            cMem.SetValue("$envoy_demands_tribute", new Yarn.Value(this.TributeDemanded != 0));
            cMem.SetValue("$envoy_tribute_demanded", new Yarn.Value((float)this.TributeDemanded.Value));
            cMem.SetValue("$envoy_name", new Yarn.Value(TextGenerator.GenerateRandom(Datastructures.SelectRandom(OwnerFaction.Race.NameTemplates).ToArray())));
            cMem.SetValue("$envoy_faction", new Yarn.Value(OwnerFaction.Name));
            cMem.SetValue("$player_faction", new Yarn.Value(this.OtherFaction));
            cMem.SetValue("$offensive_trades", new Yarn.Value(0));
            cMem.SetValue("$trades", new Yarn.Value(0));

            var politics = World.Diplomacy.GetPolitics(OtherFaction, OwnerFaction);

            cMem.SetValue("$faction_was_at_war", new Yarn.Value(politics.WasAtWar));
            cMem.SetValue("$envoy_relationship", new Yarn.Value(politics.GetCurrentRelationship().ToString()));

            GameState.Game.StateManager.PushState(new YarnState(OwnerFaction.World, OwnerFaction.Race.DiplomacyConversation, "Start", cMem));
        }
Beispiel #3
0
        public MudGolem(CreatureStats stats, Faction faction, ComponentManager manager, string name, Vector3 position) :
            base(manager, stats, faction, name)
        {
            Physics = new Physics(Manager, name, Matrix.CreateTranslation(position), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.0f, -0.25f, 0.0f), 1.0f, 1.0f, 0.999f, 0.999f, new Vector3(0, -10, 0));

            Physics.AddChild(this);

            Physics.Orientation = Physics.OrientMode.RotateY;
            CreateCosmeticChildren(Manager);

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

            Physics.AddChild(new GolemAI(Manager, Sensor)
            {
                Movement = { IsSessile = true, CanFly = false, CanSwim = false, CanWalk = false, CanClimb = false, CanClimbWalls = false }
            });

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

            var gems = Library.EnumerateResourceTypesWithTag(Resource.ResourceTags.Gem);

            for (int i = 0; i < 16; i++)
            {
                int num = MathFunctions.RandInt(1, 32 - i);
                Inventory.AddResource(new ResourceAmount(Datastructures.SelectRandom(gems), num));
                i += num - 1;
            }

            Physics.Tags.Add("MudGolem");
            Physics.Mass = 100;

            Stats.FullName = TextGenerator.GenerateRandom("$goblinname");
            Stats.BaseSize = 4;
            Resistances[DamageType.Fire] = 5;
            Resistances[DamageType.Acid] = 5;
            Resistances[DamageType.Cold] = 5;
        }
Beispiel #4
0
        public Chicken(Vector3 position, ComponentManager manager, string Asset) :
            // Creature base constructor
            base
            (
                manager,
                new CreatureStats(Asset, "Fowl", 0),
                manager.World.Factions.Factions["Herbivore"],
                Asset
            )
        {
            Physics = new Physics
                      (
                manager,
                Asset,
                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.AddChild(this);
            this.Asset          = Asset;
            Physics.Orientation = Physics.OrientMode.RotateY;

            CreateCosmeticChildren(Manager);

            Physics.AddChild(new EnemySensor(Manager, "EnemySensor", Matrix.Identity, new Vector3(5, 5, 5), Vector3.Zero));
            Physics.AddChild(new PacingCreatureAI(Manager, "AI", Sensor));
            Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.LocalBoundingBoxOffset));
            Physics.AddChild(new Flammable(Manager, "Flames"));

            Physics.Tags.Add(Asset);
            Physics.Tags.Add("Animal");
            Physics.Tags.Add("DomesticAnimal");
            Stats.FullName = TextGenerator.GenerateRandom("$firstname") + " the " + Asset;
        }
        public static Resource CreateMeal(ResourceType typeA, ResourceType typeB)
        {
            Resource componentA = Resources[typeA];
            Resource componentB = Resources[typeB];
            Resource toReturn   = new Resource(Resources[ResourceType.Meal])
            {
                FoodContent = componentA.FoodContent + componentB.FoodContent,
                Name        =
                    TextGenerator.GenerateRandom(new List <string>()
                {
                    componentA.Name, componentB.Name
                }, TextGenerator.GetAtoms(ContentPaths.Text.Templates.food)),
                MoneyValue = 2m * (componentA.MoneyValue + componentB.MoneyValue)
            };

            toReturn.ShortName = toReturn.Name;

            if (!Resources.ContainsKey(toReturn.Name))
            {
                Add(toReturn);
            }

            return(toReturn);
        }
Beispiel #6
0
        string GetRandomWorldName()
        {
            List <List <string> > templates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.worlds);

            return(TextGenerator.GenerateRandom(templates));
        }
Beispiel #7
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);
        }
Beispiel #8
0
        public void Initialize()
        {
            Physics.Orientation = Physics.OrientMode.RotateY;
            CreateSprite(Stats.CurrentClass, Manager);

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

            Physics.AddChild(new PacingCreatureAI(Manager, "Demon AI", Sensors, PlanService)
            {
                Movement = { CanFly = true, CanSwim = false, CanDig = true }
            });

            Attacks = new List <Attack>()
            {
                new Attack(Stats.CurrentClass.Attacks[0])
            };

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

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

            Physics.Tags.Add("Demon");

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

            NoiseMaker.Noises["Hurt"] = new List <string>
            {
                ContentPaths.Audio.Oscar.sfx_ic_demon_hurt_1,
                ContentPaths.Audio.Oscar.sfx_ic_demon_hurt_2,
            };


            MinimapIcon minimapIcon = Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 3, 1))) as MinimapIcon;



            NoiseMaker.Noises["Chew"] = new List <string>
            {
                ContentPaths.Audio.chew
            };

            NoiseMaker.Noises["Jump"] = new List <string>
            {
                ContentPaths.Audio.Oscar.sfx_ic_demon_angered,
            };

            NoiseMaker.Noises["Flap"] = new List <string>
            {
                ContentPaths.Audio.Oscar.sfx_ic_demon_flap_wings_1,
                ContentPaths.Audio.Oscar.sfx_ic_demon_flap_wings_2,
                ContentPaths.Audio.Oscar.sfx_ic_demon_flap_wings_3,
            };


            NoiseMaker.Noises["Chirp"] = new List <string>
            {
                ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_1,
                ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_2,
                ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_3,
                ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_4,
                ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_5,
                ContentPaths.Audio.Oscar.sfx_ic_demon_mumble_6,
                ContentPaths.Audio.Oscar.sfx_ic_demon_pleased,
            };

            Stats.FullName = TextGenerator.GenerateRandom("$goblinname");
            //Stats.LastName = TextGenerator.GenerateRandom("$elffamily");
            Stats.Size = 4;
            Species    = "Demon";
        }
Beispiel #9
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)
        {
            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";
        }
Beispiel #10
0
        public void Initialize(EmployeeClass dwarfClass)
        {
            Physics.Orientation = Physics.OrientMode.RotateY;
            Sprite = new CharacterSprite(Graphics, Manager, "Dwarf Sprite", Physics, Matrix.CreateTranslation(new Vector3(0, 0.15f, 0)));
            foreach (Animation animation in dwarfClass.Animations)
            {
                Sprite.AddAnimation(animation.Clone());
            }
            Sprite.SpriteSheet      = Sprite.Animations.First().Value.SpriteSheet;
            Sprite.CurrentAnimation = Sprite.Animations.First().Value;
            Sprite.CurrentAnimation.NextFrame();
            Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero);

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

            AI = new CreatureAI(this, "Dwarf AI", Sensors, PlanService);

            Attacks = new List <Attack>()
            {
                new Attack(Stats.CurrentClass.Attacks[0])
            };

            Inventory = new Inventory("Inventory", Physics)
            {
                Resources = new ResourceContainer
                {
                    MaxResources = 128
                }
            };

            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);

            shadowTransform.Translation = new Vector3(0.0f, -0.5f, 0.0f);

            Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform,
                                new SpriteSheet(ContentPaths.Effects.shadowcircle))
            {
                GlobalScale = 1.25f
            };
            List <Point> shP = new List <Point>
            {
                new Point(0, 0)
            };
            Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle), "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false);

            Shadow.AddAnimation(shadowAnimation);
            shadowAnimation.Play();
            Shadow.SetCurrentAnimation("sh");
            Physics.Tags.Add("Dwarf");

            DeathParticleTrigger = new ParticleTrigger("blood_particle", Manager, "Death Gibs", Physics, Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath  = true,
                TriggerAmount   = 1,
                BoxTriggerTimes = 10,
                SoundToPlay     = ContentPaths.Entities.Dwarf.Audio.dwarfhurt1,
            };
            Flames = new Flammable(Manager, "Flames", Physics, this);

            NoiseMaker.Noises["Hurt"] = new List <string>
            {
                ContentPaths.Entities.Dwarf.Audio.dwarfhurt1,
                ContentPaths.Entities.Dwarf.Audio.dwarfhurt2,
                ContentPaths.Entities.Dwarf.Audio.dwarfhurt3,
                ContentPaths.Entities.Dwarf.Audio.dwarfhurt4,
            };

            NoiseMaker.Noises["Ok"] = new List <string>()
            {
                ContentPaths.Audio.ok0,
                ContentPaths.Audio.ok1,
                ContentPaths.Audio.ok2
            };


            NoiseMaker.Noises["Chew"] = new List <string>
            {
                ContentPaths.Audio.chew
            };

            NoiseMaker.Noises["Jump"] = new List <string>
            {
                ContentPaths.Audio.jump
            };

            MinimapIcon minimapIcon = new MinimapIcon(Physics, new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.map_icons), 16, 0, 0));

            Stats.FullName            = TextGenerator.GenerateRandom("$firstname", " ", "$lastname");
            Stats.Size                = 5;
            Stats.CanSleep            = true;
            Stats.CanEat              = true;
            AI.Movement.CanClimbWalls = true;
            AI.Movement.SetCost(MoveType.ClimbWalls, 50.0f);
            AI.Movement.SetSpeed(MoveType.ClimbWalls, 0.15f);
            AI.TriggersMourning = true;
        }
Beispiel #11
0
        /// <summary>
        /// Initialize function creates all the required components for the bird.
        /// </summary>
        /// <param name="spriteSheet">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;


            // Create the sprite component for the bird.
            Sprite = new CharacterSprite
                         (Graphics,
                         Manager,
                         "Frog Sprite",
                         Physics,
                         Matrix.CreateTranslation(0, 0.5f, 0)
                         );

            CompositeAnimation.Descriptor descriptor =
                FileUtils.LoadJsonFromString <CompositeAnimation.Descriptor>(
                    ContentPaths.GetFileAsString(sprites));

            List <CompositeAnimation> animations = descriptor.GenerateAnimations("Rabbit");

            foreach (CompositeAnimation animation in animations)
            {
                Sprite.AddAnimation(animation);
            }

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

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

            // Controls the behavior of the creature
            AI = new CreatureAI(this, "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, ContentPaths.Audio.frog, ContentPaths.Effects.flash)
            };


            // The bird can hold one item at a time in its inventory
            Inventory = new Inventory("Inventory", Physics)
            {
                Resources = new ResourceContainer
                {
                    MaxResources = 1
                }
            };

            // The shadow is rotated 90 degrees along X, and is 0.25 blocks beneath the creature
            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);

            shadowTransform.Translation = new Vector3(0.0f, -0.25f, 0.0f);
            shadowTransform            *= Matrix.CreateScale(0.75f);

            SpriteSheet shadowTexture = new SpriteSheet(ContentPaths.Effects.shadowcircle);

            Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform, shadowTexture);

            // We set up the shadow's animation so that it's just a static black circle
            // TODO: Make the shadow set this up automatically
            List <Point> shP = new List <Point>
            {
                new Point(0, 0)
            };
            Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle), "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false);

            Shadow.AddAnimation(shadowAnimation);
            shadowAnimation.Play();
            Shadow.SetCurrentAnimation("sh");

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

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

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

            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.Add("Idle", new List <string>()
            {
                ContentPaths.Audio.frog
            });
            NoiseMaker.Noises.Add("Hurt", new List <string>()
            {
                ContentPaths.Audio.frog
            });
        }
Beispiel #12
0
        public void Initialize(string blood, int iconX, int iconY)
        {
            HasMeat             = false;
            HasBones            = false;
            Physics.Orientation = Physics.OrientMode.RotateY;
            CreateSprite(Stats.CurrentClass, Manager, 0.5f);

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

            Physics.AddChild(new MudGolemAI(Manager, Sensors, Manager.World.PlanService)
            {
                Movement = { IsSessile = true, CanFly = false, CanSwim = false, CanWalk = false, CanClimb = false, CanClimbWalls = false }
            });

            Attacks = new List <Attack>()
            {
                new Attack(Stats.CurrentClass.Attacks[0])
            };

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

            var gems = ResourceLibrary.GetResourcesByTag(Resource.ResourceTags.Gem);

            for (int i = 0; i < 16; i++)
            {
                int num = MathFunctions.RandInt(1, 32 - i);
                Inventory.AddResource(new ResourceAmount(Datastructures.SelectRandom(gems), num));
                i += num - 1;
            }

            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);

            shadowTransform.Translation = new Vector3(0.0f, -0.5f, 0.0f);


            Physics.Tags.Add("MudGolem");
            Physics.Mass = 100;

            Physics.AddChild(new ParticleTrigger(blood, Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath = true,
                TriggerAmount  = 5,
                SoundToPlay    = ContentPaths.Audio.gravel
            });

            NoiseMaker.Noises["Hurt"] = new List <string>
            {
                ContentPaths.Audio.demon0,
                ContentPaths.Audio.gravel,
            };


            Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, iconX, iconY)));

            Stats.FullName = TextGenerator.GenerateRandom("$goblinname");
            //Stats.LastName = TextGenerator.GenerateRandom("$elffamily");
            Stats.Size = 4;
            Resistances[DamageType.Fire] = 5;
            Resistances[DamageType.Acid] = 5;
            Resistances[DamageType.Cold] = 5;
            Species = "Mud Golem";
        }
Beispiel #13
0
        void Initialize()
        {
            Envoy.TradeMoney = Faction.TradeMoney + MathFunctions.Rand(-100.0f, 100.0f);
            Envoy.TradeMoney = Math.Max(Envoy.TradeMoney, 0.0f);
            TalkerName       = TextGenerator.GenerateRandom(Datastructures.SelectRandom(Faction.Race.NameTemplates).ToArray());
            Tabs             = new Dictionary <string, GUIComponent>();
            GUI = new DwarfGUI(Game, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default),
                               Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title),
                               Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input)
            {
                DebugDraw = false
            };
            IsInitialized = true;
            MainWindow    = new GUIComponent(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };

            Layout = new GridLayout(GUI, MainWindow, 11, 4);
            Layout.UpdateSizes();

            Talker = new SpeakerComponent(GUI, Layout, new Animation(Faction.Race.TalkAnimation));
            Layout.SetComponentPosition(Talker, 0, 0, 4, 4);

            DialougeSelector = new ListSelector(GUI, Layout)
            {
                Mode        = ListItem.SelectionMode.ButtonList,
                DrawButtons = true,
                DrawPanel   = false,
                Label       = "",
                ItemHeight  = 35,
                Padding     = 5
            };
            DialougeSelector.OnItemSelected += DialougeSelector_OnItemSelected;
            Layout.SetComponentPosition(DialougeSelector, 2, 3, 1, 8);

            BackButton = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));
            Layout.SetComponentPosition(BackButton, 2, 10, 1, 1);
            BackButton.OnClicked += back_OnClicked;
            BackButton.IsVisible  = false;
            DialougeTree          = new SpeechNode()
            {
                Text    = GetGreeting(),
                Actions = new List <SpeechNode.SpeechAction>()
                {
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Trade...",
                        Action = WaitForTrade
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Ask a question...",
                        Action = AskAQuestion
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Declare war!",
                        Action = DeclareWar
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Leave",
                        Action = () =>
                        {
                            BackButton.IsVisible = true;
                            if (Envoy != null)
                            {
                                Diplomacy.RecallEnvoy(Envoy);
                            }
                            return(SpeechNode.Echo(new SpeechNode()
                            {
                                Text = GetFarewell(),
                                Actions = new List <SpeechNode.SpeechAction>()
                            }));
                        }
                    }
                }
            };


            if (Politics.WasAtWar)
            {
                PreeTree = new SpeechNode()
                {
                    Text    = Datastructures.SelectRandom(Faction.Race.Speech.PeaceDeclarations),
                    Actions = new List <SpeechNode.SpeechAction>()
                    {
                        new SpeechNode.SpeechAction()
                        {
                            Text   = "Make peace with " + Faction.Name,
                            Action = () =>
                            {
                                if (!Politics.HasEvent("you made peace with us"))
                                {
                                    Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                                    {
                                        Change      = 0.4f,
                                        Description = "you made peace with us",
                                        Duration    = new TimeSpan(4, 0, 0, 0),
                                        Time        = World.Time.CurrentDate
                                    });
                                }
                                return(SpeechNode.Echo(DialougeTree));
                            }
                        },
                        new SpeechNode.SpeechAction()
                        {
                            Text   = "Continue the war with " + Faction.Name,
                            Action = DeclareWar
                        }
                    }
                };
                Transition(PreeTree);
                Politics.WasAtWar = false;
            }
            else
            {
                Transition(DialougeTree);
            }


            if (!Politics.HasMet)
            {
                Politics.HasMet = true;

                Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                {
                    Change      = 0.0f,
                    Description = "we just met",
                    Duration    = new TimeSpan(1, 0, 0, 0),
                    Time        = World.Time.CurrentDate
                });
            }

            Layout.UpdateSizes();
            Talker.TweenIn(Drawer2D.Alignment.Top, 0.25f);
            DialougeSelector.TweenIn(Drawer2D.Alignment.Right, 0.25f);
        }
Beispiel #14
0
        public static string GenerateMotto()
        {
            var templates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.mottos);

            return(TextGenerator.GenerateRandom(Datastructures.SelectRandom(templates).ToArray()));
        }
Beispiel #15
0
        public void Initialize(EmployeeClass dwarfClass)
        {
            Stats.Gender        = Mating.RandomGender();
            Physics.Orientation = Physics.OrientMode.RotateY;
            CreateDwarfSprite(dwarfClass, Manager);

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

            Physics.AddChild(new CreatureAI(Manager, "Dwarf AI", Sensors, PlanService));

            Attacks = new List <Attack>()
            {
                new Attack(Stats.CurrentClass.Attacks[0])
            };

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


            Physics.Tags.Add("Dwarf");

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

            Physics.AddChild(new Flammable(Manager, "Flames"));

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

            NoiseMaker.Noises["Hurt"] = new List <string>
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_hurt_1,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_hurt_2,
            };

            NoiseMaker.Noises["Ok"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_ok_1,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_ok_2,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_ok_3
            };

            NoiseMaker.Noises["Die"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_death
            };

            NoiseMaker.Noises["Pleased"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_pleased
            };

            NoiseMaker.Noises["Tantrum"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_tantrum_1,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_tantrum_2,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_tantrum_3,
            };
            NoiseMaker.Noises["Jump"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_jump
            };

            NoiseMaker.Noises["Climb"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_climb_1,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_climb_2,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_climb_3
            };

            MinimapIcon minimapIcon = Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 0, 0))) as MinimapIcon;

            Stats.FullName            = TextGenerator.GenerateRandom("$firstname", " ", "$lastname");
            Stats.Size                = 5;
            Stats.CanSleep            = true;
            Stats.CanEat              = true;
            Stats.CanGetBored         = true;
            AI.Movement.CanClimbWalls = true; // Why isn't this a flag like the below?
            AI.Movement.SetCan(MoveType.Teleport, true);
            AI.Movement.SetCost(MoveType.Teleport, 1.0f);
            AI.Movement.SetSpeed(MoveType.Teleport, 10.0f);
            AI.Movement.SetCost(MoveType.ClimbWalls, 50.0f);
            AI.Movement.SetSpeed(MoveType.ClimbWalls, 0.15f);
            AI.Movement.SetCan(MoveType.EnterVehicle, true);
            AI.Movement.SetCan(MoveType.ExitVehicle, true);
            AI.Movement.SetCan(MoveType.RideVehicle, true);
            AI.Movement.SetCost(MoveType.EnterVehicle, 1.0f);
            AI.Movement.SetCost(MoveType.ExitVehicle, 1.0f);
            AI.Movement.SetCost(MoveType.RideVehicle, 0.01f);
            AI.Movement.SetSpeed(MoveType.RideVehicle, 3.0f);
            AI.Movement.SetSpeed(MoveType.EnterVehicle, 1.0f);
            AI.Movement.SetSpeed(MoveType.ExitVehicle, 1.0f);
            if (AI.Stats.IsTaskAllowed(Task.TaskCategory.Dig))
            {
                AI.Movement.SetCan(MoveType.Dig, true);
            }
            AI.TriggersMourning = true;
            AI.Biography        = Applicant.GenerateBiography(AI.Stats.FullName, Stats.Gender);
            Species             = "Dwarf";
            Status.Money        = (decimal)MathFunctions.Rand(0, 150);

            Physics.AddChild(new VoxelRevealer(Manager, Physics, 5)).SetFlag(Flag.ShouldSerialize, false);

            Physics.AddChild(new DwarfThoughts(Manager, "Thoughts"));
        }
Beispiel #16
0
        public void Initialize(SpriteSheet spriteSheet)
        {
            Physics.Orientation = Physics.OrientMode.RotateY;

            SpriteAssets = spriteSheet;
            CreateSprite(ContentPaths.Entities.Animals.Deer.animations, Manager);
            // Add hands
            Hands = Physics.AddChild(new Grabber("hands", Manager, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero)) as Grabber;

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

            // Add AI
            AI = Physics.AddChild(new PacingCreatureAI(Manager, "Deer AI", Sensors, PlanService)) as CreatureAI;

            Attacks = new List <Attack> {
                new Attack("None", 0.0f, 0.0f, 0.0f, ContentPaths.Audio.Oscar.sfx_oc_deer_attack, ContentPaths.Effects.hit)
            };

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

            // Shadow
            Physics.AddChild(Shadow.Create(0.75f, 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,
                BoxTriggerTimes = 10,
                SoundToPlay     = ContentPaths.Audio.Oscar.sfx_oc_deer_hurt_1
            });


            NoiseMaker.Noises["Hurt"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_deer_hurt_1
            };
            NoiseMaker.Noises["Chirp"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_deer_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_deer_neutral_2
            };

            // 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("Deer");
            Physics.Tags.Add("Animal");
            Physics.Tags.Add("DomesticAnimal");
            Stats.FullName     = TextGenerator.GenerateRandom("$firstname");
            Stats.CurrentClass = new EmployeeClass()
            {
                Name   = "Deer",
                Levels = new List <EmployeeClass.Level>()
                {
                    new EmployeeClass.Level()
                    {
                        Index = 0, Name = "Deer"
                    }
                }
            };
            Species      = "Deer";
            CanReproduce = true;
            BabyType     = "Deer";
        }
Beispiel #17
0
        public void Initialize(EmployeeClass dwarfClass)
        {
            Physics.Orientation = Physics.OrientMode.RotateY;
            Sprite = new CharacterSprite(Graphics, Manager, "Fairy Sprite", Physics, Matrix.CreateTranslation(new Vector3(0, 0.5f, 0)));
            foreach (Animation animation in dwarfClass.Animations)
            {
                Sprite.AddAnimation(animation.Clone());
            }
            Sprite.LightsWithVoxels = false;

            Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero);

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

            AI = new CreatureAI(this, "Fairy AI", Sensors, PlanService);

            Attacks = new List <Attack>()
            {
                new Attack(Stats.CurrentClass.Attacks[0])
            };


            Inventory = new Inventory("Inventory", Physics)
            {
                Resources = new ResourceContainer
                {
                    MaxResources = 128
                }
            };

            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);

            shadowTransform.Translation = new Vector3(0.0f, -0.5f, 0.0f);

            Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform, new SpriteSheet(ContentPaths.Effects.shadowcircle));
            List <Point> shP = new List <Point>
            {
                new Point(0, 0)
            };
            Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle), "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false);

            Shadow.AddAnimation(shadowAnimation);
            shadowAnimation.Play();
            Shadow.SetCurrentAnimation("sh");
            Physics.Tags.Add("Dwarf");



            DeathParticleTrigger = new ParticleTrigger("star_particle", Manager, "Death Gibs", Physics, Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath = true,
                TriggerAmount  = 5,
                SoundToPlay    = ContentPaths.Audio.wurp,
            };

            NoiseMaker.Noises["Hurt"] = new List <string>
            {
                ContentPaths.Audio.tinkle
            };


            NoiseMaker.Noises["Chew"] = new List <string>
            {
                ContentPaths.Audio.tinkle
            };

            NoiseMaker.Noises["Jump"] = new List <string>
            {
                ContentPaths.Audio.tinkle
            };

            MinimapIcon minimapIcon = new MinimapIcon(Physics, new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.map_icons), 16, 0, 0));

            //new LightEmitter("Light Emitter", Sprite, Matrix.Identity, Vector3.One, Vector3.One, 255, 150);
            new Bobber(0.25f, 3.0f, MathFunctions.Rand(), Sprite);

            Stats.FullName = TextGenerator.GenerateRandom("$firstname");
            //Stats.LastName = "The Fairy";

            Stats.CanSleep = false;
            Stats.CanEat   = false;
        }
Beispiel #18
0
        public void GenerateRandom(EmployeeClass employeeClass, int level, CompanyInformation info)
        {
            Class = employeeClass;
            Level = Class.Levels[level];

            Name = TextGenerator.GenerateRandom("$firstname", " ", "$lastname");
            List <string> justifications = new List <string>()
            {
                "I have many relevant qualities!",
                "My expereince is extensive!",
                "I really need this job!",
                "I need to get away from it all!",
                "I will be your loyal servant!",
                "I've always wanted to work at " + info.Name + "!",
                "I am a very hard worker!",
                "I am an adventurous soul!"
            };

            CoverLetter =
                TextGenerator.GenerateRandom("Dear " + info.Name + ",\n",
                                             "${Please,Do}", " consider ", "${my,this}", " application for the position of " + Level.Name +
                                             ". " + justifications[MathFunctions.Random.Next(justifications.Count)] + "\n", "${Thanks,Sincerely,Yours}", ",\n    ", Name);

            if (level > 0)
            {
                FormerProfession = Class.Levels[level - 1].Name;
            }
            else
            {
                FormerProfession = TextGenerator.GenerateRandom("$profession");
            }

            List <string[]> templates = new List <string[]>
            {
                new[]
                {
                    "place",
                    " of the ",
                    "$color",
                    " ",
                    "$noun"
                },
                new[]
                {
                    "$place",
                    " of the ",
                    "$adjective",
                    " ",
                    "$noun"
                },
                new[]
                {
                    "$place",
                    " of the ",
                    "$material",
                    " ",
                    "$noun"
                },
                new[]
                {
                    "$place",
                    " of ",
                    "$noun"
                },
                new[]
                {
                    "$color",
                    " ",
                    "$material",
                    " ",
                    "$place"
                },
                new[]
                {
                    "$adjective",
                    " ",
                    "$place"
                },
                new []
                {
                    "$adjective",
                    "ville"
                },
                new []
                {
                    "$adjective",
                    "burg"
                },
                new []
                {
                    "$lastname",
                    "ton"
                }
            };

            HomeTown = TextGenerator.GenerateRandom(templates[MathFunctions.Random.Next(templates.Count)]);
        }
Beispiel #19
0
        /// <summary>
        /// Initialize function creates all the required components for the bat.
        /// </summary>
        public void Initialize()
        {
            // When true, causes the bird to face the direction its moving in
            Physics.Orientation = Physics.OrientMode.RotateY;

            CreateSprite(ContentPaths.Entities.Animals.Bat.bat_animations, Manager, 0.0f);

            // 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 BatAI(Manager, "Bat AI", Sensors, PlanService));
            AI.Movement.CanFly   = true;
            AI.Movement.CanSwim  = false;
            AI.Movement.CanClimb = false;
            AI.Movement.CanWalk  = false;

            // The bird can peck at its enemies (0.1 damage)
            Attacks = new List <Attack> {
                new Attack("Bite", 0.01f, 2.0f, 1.0f, ContentPaths.Audio.Oscar.sfx_oc_bat_attack_1, ContentPaths.Effects.bite)
                {
                    TriggerMode = Attack.AttackTrigger.Animation, TriggerFrame = 1, Mode = Attack.AttackMode.Dogfight, DiseaseToSpread = "Rabies"
                }
            };


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

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

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


            NoiseMaker.Noises["Hurt"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_bat_hurt_1
            };
            NoiseMaker.Noises["Chirp"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_oc_bat_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_bat_neutral_2
            };
            Species      = "Bat";
            CanReproduce = true;
            BabyType     = "Bat";
        }
Beispiel #20
0
        public void Initialize(SpriteSheet spriteSheet)
        {
            Physics.Orientation = Physics.OrientMode.RotateY;

            const int frameWidth  = 48;
            const int frameHeight = 40;

            Sprite = new CharacterSprite
                         (Graphics,
                         Manager,
                         "Deer Sprite",
                         Physics,
                         Matrix.CreateTranslation(Vector3.Up * 0.6f)
                         );

            // Add the idle animation
            Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Forward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 0, 0);
            Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Left, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 1, 0);
            Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Right, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 2, 0);
            Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Backward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 3, 0);

            // Add the running animation
            Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Forward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 4, 0, 1, 2, 3);
            Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Left, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 5, 0, 1, 2, 3);
            Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Right, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 6, 0, 1, 2, 3);
            Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Backward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 7, 0, 1, 2, 3);

            // Add the jumping animation
            Sprite.AddAnimation(CharacterMode.Jumping, OrientedAnimation.Orientation.Forward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 8, 0, 1);
            Sprite.AddAnimation(CharacterMode.Jumping, OrientedAnimation.Orientation.Left, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 9, 0, 1);
            Sprite.AddAnimation(CharacterMode.Jumping, OrientedAnimation.Orientation.Right, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 10, 0, 1);
            Sprite.AddAnimation(CharacterMode.Jumping, OrientedAnimation.Orientation.Backward, spriteSheet, ANIM_SPEED, frameWidth, frameHeight, 11, 0, 1);

            // Add hands
            Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero);

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

            // Add AI
            AI = new DeerAI(this, "Deer AI", Sensors, PlanService);

            Attacks = new List <Attack> {
                new Attack("None", 0.0f, 0.0f, 0.0f, ContentPaths.Audio.pick, ContentPaths.Effects.flash)
            };

            Inventory = new Inventory("Inventory", Physics)
            {
                Resources = new ResourceContainer
                {
                    MaxResources = 1
                }
            };

            // Shadow
            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);

            shadowTransform.Translation = new Vector3(0.0f, -.25f, 0.0f);
            SpriteSheet shadowTexture = new SpriteSheet(ContentPaths.Effects.shadowcircle);

            Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform, shadowTexture);

            List <Point> shP = new List <Point>
            {
                new Point(0, 0)
            };
            Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle), "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false);

            Shadow.AddAnimation(shadowAnimation);
            shadowAnimation.Play();
            Shadow.SetCurrentAnimation("sh");

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

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

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

            Stats.FullName     = TextGenerator.GenerateRandom("$firstname");
            Stats.CurrentClass = new EmployeeClass()
            {
                Name   = "Deer",
                Levels = new List <EmployeeClass.Level>()
                {
                    new EmployeeClass.Level()
                    {
                        Index = 0, Name = "Deer"
                    }
                }
            };
        }
Beispiel #21
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";
        }
Beispiel #22
0
        public void Initialize(EmployeeClass dwarfClass)
        {
            Gender = Mating.RandomGender();
            Physics.Orientation = Physics.OrientMode.RotateY;
            CreateSprite(dwarfClass, Manager);

            Hands = Physics.AddChild(new Grabber("hands", Manager, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero)) as Grabber;

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

            AI = Physics.AddChild(new CreatureAI(Manager, "Dwarf AI", Sensors, PlanService)) as CreatureAI;

            Attacks = new List <Attack>()
            {
                new Attack(Stats.CurrentClass.Attacks[0])
            };

            Inventory = Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.BoundingBoxPos)) as Inventory;


            Physics.Tags.Add("Dwarf");

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

            Physics.AddChild(new Flammable(Manager, "Flames"));

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

            NoiseMaker.Noises["Hurt"] = new List <string>
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_hurt_1,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_hurt_2,
            };

            NoiseMaker.Noises["Ok"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_ok_1,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_ok_2,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_ok_3
            };

            NoiseMaker.Noises["Die"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_death
            };

            NoiseMaker.Noises["Pleased"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_pleased
            };

            NoiseMaker.Noises["Tantrum"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_tantrum_1,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_tantrum_2,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_tantrum_3,
            };
            NoiseMaker.Noises["Jump"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_jump
            };

            NoiseMaker.Noises["Climb"] = new List <string>()
            {
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_climb_1,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_climb_2,
                ContentPaths.Audio.Oscar.sfx_ic_dwarf_climb_3
            };

            MinimapIcon minimapIcon = Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 0, 0))) as MinimapIcon;

            Stats.FullName            = TextGenerator.GenerateRandom("$firstname", " ", "$lastname");
            Stats.Size                = 5;
            Stats.CanSleep            = true;
            Stats.CanEat              = true;
            AI.Movement.CanClimbWalls = true;
            AI.Movement.SetCost(MoveType.ClimbWalls, 50.0f);
            AI.Movement.SetSpeed(MoveType.ClimbWalls, 0.15f);
            AI.TriggersMourning = true;
            AI.Biography        = Applicant.GenerateBiography(AI.Stats.FullName, Gender);
            Species             = "Dwarf";
        }
Beispiel #23
0
        public void Initialize()
        {
            Physics.Orientation = Physics.OrientMode.RotateY;
            Sprite = new CharacterSprite(Graphics, Manager, "Goblin Sprite", Physics, Matrix.CreateTranslation(new Vector3(0, 0.1f, 0)));
            foreach (Animation animation in Stats.CurrentClass.Animations)
            {
                Sprite.AddAnimation(animation.Clone());
            }

            HasMeat  = false;
            HasBones = false;

            Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero);

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

            AI = new CreatureAI(this, "Goblin AI", Sensors, PlanService);

            Attacks = new List <Attack>()
            {
                new Attack(Stats.CurrentClass.Attacks[0])
            };

            Inventory = new Inventory("Inventory", Physics)
            {
                Resources = new ResourceContainer
                {
                    MaxResources = 16
                }
            };

            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);

            shadowTransform.Translation = new Vector3(0.0f, -0.5f, 0.0f);

            SpriteSheet shadowTexture = new SpriteSheet(ContentPaths.Effects.shadowcircle);

            Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform, shadowTexture);
            List <Point> shP = new List <Point>
            {
                new Point(0, 0)
            };
            Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle), "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false);

            Shadow.AddAnimation(shadowAnimation);
            shadowAnimation.Play();
            Shadow.SetCurrentAnimation("sh");
            Physics.Tags.Add("Goblin");

            DeathParticleTrigger = new ParticleTrigger("blood_particle", Manager, "Death Gibs", Physics, Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath = true,
                TriggerAmount  = 3,
                SoundToPlay    = ContentPaths.Entities.Goblin.Audio.goblinhurt1
            };
            Flames = new Flammable(Manager, "Flames", Physics, this);


            NoiseMaker.Noises["Hurt"] = new List <string>
            {
                ContentPaths.Entities.Goblin.Audio.goblinhurt1,
                ContentPaths.Entities.Goblin.Audio.goblinhurt2,
                ContentPaths.Entities.Goblin.Audio.goblinhurt3,
                ContentPaths.Entities.Goblin.Audio.goblinhurt4,
            };


            MinimapIcon minimapIcon = new MinimapIcon(Physics, new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.map_icons), 16, 3, 0));



            NoiseMaker.Noises["Chew"] = new List <string>
            {
                ContentPaths.Audio.chew
            };

            NoiseMaker.Noises["Jump"] = new List <string>
            {
                ContentPaths.Audio.jump
            };

            Stats.FullName = TextGenerator.GenerateRandom("$goblinname");
            //Stats.LastName = TextGenerator.GenerateRandom("$goblinfamily");
            Stats.Size = 4;
        }
Beispiel #24
0
        public void Initialize()
        {
            HasMeat             = false;
            HasBones            = false;
            Physics.Orientation = Physics.OrientMode.RotateY;
            Sprite = new CharacterSprite(Graphics, Manager, "MudGolem Sprite", Physics, Matrix.CreateTranslation(new Vector3(0, 0.35f, 0)));
            foreach (Animation animation in Stats.CurrentClass.Animations)
            {
                Sprite.AddAnimation(animation.Clone());
            }

            Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero);

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

            AI = new MudGolemAI(this, Sensors, Manager.World.PlanService)
            {
                Movement = { IsSessile = true, CanFly = false, CanSwim = false, CanWalk = false, CanClimb = false, CanClimbWalls = false }
            };

            Attacks = new List <Attack>()
            {
                new Attack(Stats.CurrentClass.Attacks[0])
            };

            Inventory = new Inventory("Inventory", Physics)
            {
                Resources = new ResourceContainer
                {
                    MaxResources = 16
                }
            };

            var gems = ResourceLibrary.GetResourcesByTag(Resource.ResourceTags.Gem);

            for (int i = 0; i < 16; i++)
            {
                int num = MathFunctions.RandInt(1, 32 - i);
                Inventory.Resources.AddResource(new ResourceAmount(Datastructures.SelectRandom(gems), num));
                i += num - 1;
            }

            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);

            shadowTransform.Translation = new Vector3(0.0f, -0.5f, 0.0f);


            Physics.Tags.Add("MudGolem");
            Physics.Mass         = 100;
            DeathParticleTrigger = new ParticleTrigger("dirt_particle", Manager, "Death Gibs", Physics, Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath = true,
                TriggerAmount  = 5,
                SoundToPlay    = ContentPaths.Audio.gravel
            };

            NoiseMaker.Noises["Hurt"] = new List <string>
            {
                ContentPaths.Audio.demon0,
                ContentPaths.Audio.gravel,
            };


            MinimapIcon minimapIcon = new MinimapIcon(Physics, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 3, 0));


            NoiseMaker.Noises["Chew"] = new List <string>
            {
                ContentPaths.Audio.chew
            };

            Stats.FullName = TextGenerator.GenerateRandom("$goblinname");
            //Stats.LastName = TextGenerator.GenerateRandom("$elffamily");
            Stats.Size = 4;
            Resistances[DamageType.Fire] = 5;
            Resistances[DamageType.Acid] = 5;
            Resistances[DamageType.Cold] = 5;
        }
Beispiel #25
0
        public void Initialize(EmployeeClass dwarfClass)
        {
            Physics.Orientation = Physics.OrientMode.RotateY;
            CreateSprite(Stats.CurrentClass, Manager);
            Sprite.LightsWithVoxels = false;

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

            Physics.AddChild(new CreatureAI(Manager, "Fairy AI", Sensors, PlanService));

            Attacks = new List <Attack>()
            {
                new Attack(Stats.CurrentClass.Attacks[0])
            };

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

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

            Physics.Tags.Add("Dwarf");

            Physics.AddChild(new ParticleTrigger("star_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath = true,
                TriggerAmount  = 5,
                SoundToPlay    = ContentPaths.Audio.wurp,
            });

            NoiseMaker.Noises["Hurt"] = new List <string>
            {
                ContentPaths.Audio.tinkle
            };


            NoiseMaker.Noises["Chew"] = new List <string>
            {
                ContentPaths.Audio.tinkle
            };

            NoiseMaker.Noises["Jump"] = new List <string>
            {
                ContentPaths.Audio.tinkle
            };

            MinimapIcon minimapIcon = Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 0, 0))) as MinimapIcon;

            //new LightEmitter("Light Emitter", Sprite, Matrix.Identity, Vector3.One, Vector3.One, 255, 150);
            Stats.FullName = TextGenerator.GenerateRandom("$firstname");
            //Stats.LastName = "The Fairy";

            Stats.CanSleep            = false;
            Stats.CanEat              = false;
            AI.Movement.CanClimbWalls = true;
            AI.Movement.CanFly        = true;
            AI.Movement.SetCost(MoveType.Fly, 1.0f);
            AI.Movement.SetSpeed(MoveType.Fly, 1.0f);
            AI.Movement.SetCost(MoveType.ClimbWalls, 1.0f);
            AI.Movement.SetSpeed(MoveType.ClimbWalls, 1.0f);
            AI.Movement.SetCan(MoveType.Dig, true);
            Species = "Fairy";
        }
Beispiel #26
0
        /// <summary>
        /// Initialize function creates all the required components for the bird.
        /// </summary>
        /// <param name="spriteSheet">The sprite sheet to use for the bird</param>
        public void Initialize(SpriteSheet spriteSheet)
        {
            // When true, causes the bird to face the direction its moving in
            Physics.Orientation = Physics.OrientMode.RotateY;

            // The dimensions of each frame in the sprite sheet (in pixels), as given by the readme
            const int frameWidth  = 24;
            const int frameHeight = 16;

            // Create the sprite component for the bird.
            Sprite = new CharacterSprite
                         (Graphics,
                         Manager,
                         "Bird Sprite",
                         Physics,
                         Matrix.CreateTranslation(0, 0.25f, 0)
                         );

            // Flying animation (rows 4 5 6 and 7)
            Sprite.AddAnimation(CharacterMode.Flying,
                                OrientedAnimation.Orientation.Forward,
                                spriteSheet,
                                // animation will play at 15 FPS
                                15.0f,
                                frameWidth, frameHeight,
                                // animation begins at row 4
                                4,
                                // It consists of columns 0, 1 and 2 looped forever
                                0, 1, 2);
            Sprite.AddAnimation(CharacterMode.Flying,
                                OrientedAnimation.Orientation.Left,
                                spriteSheet,
                                15.0f,
                                frameWidth, frameHeight,
                                5,
                                0, 1, 2);
            Sprite.AddAnimation(CharacterMode.Flying,
                                OrientedAnimation.Orientation.Right,
                                spriteSheet,
                                15.0f,
                                frameWidth, frameHeight,
                                6,
                                0, 1, 2);
            Sprite.AddAnimation(CharacterMode.Flying,
                                OrientedAnimation.Orientation.Backward,
                                spriteSheet,
                                15.0f,
                                frameWidth, frameHeight,
                                7,
                                0, 1, 2);

            // Hopping animation (rows 0 1 2 and 3)
            Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Forward, spriteSheet, 5.0f, frameWidth, frameHeight, 0, 0, 1);
            Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Left, spriteSheet, 5.0f, frameWidth, frameHeight, 1, 0, 1);
            Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Right, spriteSheet, 5.0f, frameWidth, frameHeight, 2, 0, 1);
            Sprite.AddAnimation(CharacterMode.Walking, OrientedAnimation.Orientation.Backward, spriteSheet, 5.0f, frameWidth, frameHeight, 3, 0, 1);

            // Idle animation (rows 0 1 2 and 3)
            Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Forward, spriteSheet, 5.0f, frameWidth, frameHeight, 0, 0);
            Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Left, spriteSheet, 5.0f, frameWidth, frameHeight, 1, 0);
            Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Right, spriteSheet, 5.0f, frameWidth, frameHeight, 2, 0);
            Sprite.AddAnimation(CharacterMode.Idle, OrientedAnimation.Orientation.Backward, spriteSheet, 5.0f, frameWidth, frameHeight, 3, 0);

            // Used to grab other components
            Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero);

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

            // Controls the behavior of the creature
            AI = new BirdAI(this, "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, ContentPaths.Audio.pick, ContentPaths.Effects.flash)
            };


            // The bird can hold one item at a time in its inventory
            Inventory = new Inventory("Inventory", Physics)
            {
                Resources = new ResourceContainer
                {
                    MaxResources = 1
                }
            };

            // The shadow is rotated 90 degrees along X, and is 0.25 blocks beneath the creature
            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);

            shadowTransform.Translation = new Vector3(0.0f, -0.25f, 0.0f);
            shadowTransform            *= Matrix.CreateScale(0.75f);

            SpriteSheet shadowTexture = new SpriteSheet(ContentPaths.Effects.shadowcircle);

            Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform, shadowTexture);

            // We set up the shadow's animation so that it's just a static black circle
            // TODO: Make the shadow set this up automatically
            List <Point> shP = new List <Point>
            {
                new Point(0, 0)
            };
            Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle), "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false);

            Shadow.AddAnimation(shadowAnimation);
            shadowAnimation.Play();
            Shadow.SetCurrentAnimation("sh");

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

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

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

            NoiseMaker.Noises.Add("chirp", new List <string>()
            {
                ContentPaths.Audio.bird
            });

            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"
                    }
                }
            };
        }
Beispiel #27
0
        public Creature(Vector3 pos, CreatureDef def, string creatureClass, int creatureLevel, string faction) :
            this(new CreatureStats(EmployeeClass.Classes[creatureClass], creatureLevel),
                 faction,
                 PlayState.PlanService,
                 PlayState.ComponentManager.Factions.Factions[faction],
                 new Physics(def.Name, PlayState.ComponentManager.RootComponent, Matrix.CreateTranslation(pos), def.Size, new Vector3(0, -def.Size.Y * 0.5f, 0), def.Mass, 1.0f, 0.999f, 0.999f, Vector3.UnitY * -10, Physics.OrientMode.RotateY),
                 PlayState.ChunkManager,
                 GameState.Game.GraphicsDevice,
                 GameState.Game.Content,
                 def.Name)
        {
            HasMeat  = true;
            HasBones = true;
            EmployeeClass employeeClass = EmployeeClass.Classes[creatureClass];

            Physics.Orientation = Physics.OrientMode.RotateY;
            Sprite = new CharacterSprite(Graphics, Manager, "Sprite", Physics, Matrix.CreateTranslation(def.SpriteOffset));

            foreach (Animation animation in employeeClass.Animations)
            {
                Sprite.AddAnimation(animation.Clone());
            }

            Hands = new Grabber("hands", Physics, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero);

            Sensors = new EnemySensor(Manager, "EnemySensor", Physics, Matrix.Identity, def.SenseRange, Vector3.Zero);

            AI = new CreatureAI(this, "AI", Sensors, PlanService);

            Attacks = new List <Attack>();

            foreach (Attack attack in employeeClass.Attacks)
            {
                Attacks.Add(new Attack(attack));
            }


            Inventory = new Inventory("Inventory", Physics)
            {
                Resources = new ResourceContainer
                {
                    MaxResources = def.InventorySize
                }
            };

            if (def.HasShadow)
            {
                Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);
                shadowTransform.Translation = new Vector3(0.0f, -0.5f, 0.0f);

                Shadow = new Shadow(Manager, "Shadow", Physics, shadowTransform,
                                    new SpriteSheet(ContentPaths.Effects.shadowcircle))
                {
                    GlobalScale = def.ShadowScale
                };
                List <Point> shP = new List <Point>
                {
                    new Point(0, 0)
                };
                Animation shadowAnimation = new Animation(Graphics, new SpriteSheet(ContentPaths.Effects.shadowcircle),
                                                          "sh", 32, 32, shP, false, Color.Black, 1, 0.7f, 0.7f, false);
                Shadow.AddAnimation(shadowAnimation);
                shadowAnimation.Play();
                Shadow.SetCurrentAnimation("sh");
            }
            Physics.Tags.AddRange(def.Tags);

            DeathParticleTrigger = new ParticleTrigger(def.BloodParticle, Manager, "Death Gibs", Physics, Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath  = true,
                TriggerAmount   = 1,
                BoxTriggerTimes = 10,
                SoundToPlay     = ContentPaths.Entities.Dwarf.Audio.dwarfhurt1,
            };

            if (def.IsFlammable)
            {
                Flames = new Flammable(Manager, "Flames", Physics, this);
            }

            NoiseMaker.Noises["Hurt"] = def.HurtSounds;
            NoiseMaker.Noises["Chew"] = new List <string>()
            {
                def.ChewSound
            };
            NoiseMaker.Noises["Jump"] = new List <string>()
            {
                def.JumpSound
            };

            MinimapIcon minimapIcon = new MinimapIcon(Physics, def.MinimapIcon);

            Stats.FullName      = TextGenerator.GenerateRandom(PlayState.ComponentManager.Factions.Races[def.Race].NameTemplates);
            Stats.CanSleep      = def.CanSleep;
            Stats.CanEat        = def.CanEat;
            AI.TriggersMourning = def.TriggersMourning;
        }
Beispiel #28
0
        public void Initialize()
        {
            Physics.Orientation = Physics.OrientMode.RotateY;
            var sprite = Physics.AddChild(new CharacterSprite(Graphics, Manager, "Skeleton Sprite", Matrix.CreateTranslation(new Vector3(0, 0.1f, 0)))) as CharacterSprite;

            foreach (Animation animation in Stats.CurrentClass.Animations)
            {
                sprite.AddAnimation(animation);
            }



            Hands = Physics.AddChild(new Grabber("hands", Manager, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero)) as Grabber;

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

            AI = Physics.AddChild(new CreatureAI(Manager, "Skeleton AI", Sensors, PlanService)) as CreatureAI;

            Attacks = new List <Attack>()
            {
                new Attack(Stats.CurrentClass.Attacks[0])
            };

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

            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);

            shadowTransform.Translation = new Vector3(0.0f, -0.5f, 0.0f);

            SpriteSheet shadowTexture = new SpriteSheet(ContentPaths.Effects.shadowcircle);

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

            Physics.Tags.Add("Skeleton");

            Physics.AddChild(new ParticleTrigger("sand_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero)
            {
                TriggerOnDeath = true,
                TriggerAmount  = 5,
                SoundToPlay    = ContentPaths.Audio.Oscar.sfx_ic_necromancer_skeleton_hurt_1
            });

            Physics.AddChild(new Flammable(Manager, "Flames"));

            NoiseMaker.Noises["Hurt"] = new List <string>
            {
                ContentPaths.Audio.Oscar.sfx_ic_necromancer_skeleton_hurt_1,
                ContentPaths.Audio.Oscar.sfx_ic_necromancer_skeleton_hurt_2,
            };



            Physics.AddChild(new MinimapIcon(Manager, new NamedImageFrame(ContentPaths.GUI.map_icons, 16, 2, 1)));


            Stats.FullName = TextGenerator.GenerateRandom("$goblinname");
            //Stats.LastName = TextGenerator.GenerateRandom("$goblinfamily");
            Stats.Size = 3;
            AI.Movement.CanClimbWalls = true;
            AI.Movement.SetCost(MoveType.ClimbWalls, 50.0f);
            AI.Movement.SetSpeed(MoveType.ClimbWalls, 0.15f);
            Species = "Skeleton";
        }
Beispiel #29
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.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";
        }
Beispiel #30
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];
            }
        }