public void GenerateRandom(EmployeeClass employeeClass, int level) { 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 " + PlayState.PlayerCompany.Name + "!", "I am a very hard worker!", "I am an adventurous soul!" }; CoverLetter = TextGenerator.GenerateRandom("Dear " + PlayState.PlayerCompany.Name + ",\n", "${Please,Do}", " consider ", "${my,this}", " application for the position of " + Level.Name + ". " + justifications[PlayState.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[PlayState.Random.Next(templates.Count)]); }
public void Initialize() { Physics.Orientation = Physics.OrientMode.RotateY; Sprite = new CharacterSprite(Graphics, Manager, "Demon 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 PacingCreatureAI(this, "Demon AI", Sensors, PlanService) { Movement = { CanFly = true, CanSwim = false } }; 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("Demon"); DeathParticleTrigger = new ParticleTrigger("blood_particle", Manager, "Death Gibs", Physics, Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 5, SoundToPlay = ContentPaths.Entities.Goblin.Audio.goblinhurt1 }; NoiseMaker.Noises["Hurt"] = new List <string> { ContentPaths.Audio.demon0, ContentPaths.Audio.demon1, ContentPaths.Audio.demon2, ContentPaths.Audio.demon3, }; 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("$elffamily"); Stats.Size = 4; }
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.LocalBoundingBoxOffset)) 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"; Physics.AddChild(new VoxelRevealer(Manager, Physics, 5)).SetFlag(Flag.ShouldSerialize, false); }
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 } }); 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"; }
/// <summary> /// Initialize function creates all the required components for the bird. /// </summary> /// <param name="sprites">The sprite sheet to use for the bird</param> public void Initialize(string sprites) { // When true, causes the bird to face the direction its moving in Physics.Orientation = Physics.OrientMode.RotateY; // Create the sprite component for the bird. Sprite = new CharacterSprite (Graphics, Manager, "Rabbit 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.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 PacingCreatureAI(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.bunny, ContentPaths.Effects.bite) }; // 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("Rabbit"); Physics.Tags.Add("Animal"); 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.Add("Hurt", new List <string>() { ContentPaths.Audio.bunny }); }
public void Initialize(string blood) { HasMeat = false; HasBones = false; Physics.Orientation = Physics.OrientMode.RotateY; CreateSprite(Stats.CurrentClass, 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 MudGolemAI(Manager, Sensors, Manager.World.PlanService) { Movement = { IsSessile = true, CanFly = false, CanSwim = false, CanWalk = false, CanClimb = false, CanClimbWalls = false } }) 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; 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, 2, 1))); 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"; }
private void LoadFromFile() { SetLoadingMessage("Creating Sky..."); Renderer.Sky = new SkyRenderer(); #region Reading game file SetLoadingMessage("Loading " + Overworld.GetInstancePath()); var gameFile = SaveGame.LoadMetaFromDirectory(Overworld.GetInstancePath()); if (gameFile == null) { throw new InvalidOperationException("Game File does not exist."); } if (gameFile.Metadata.Version != Program.Version && !Program.CompatibleVersions.Contains(gameFile.Metadata.Version)) { throw new InvalidOperationException(String.Format("Game file is from version {0}. Compatible versions are {1}.", gameFile.Metadata.Version, TextGenerator.GetListString(Program.CompatibleVersions))); } Renderer.Sky.TimeOfDay = gameFile.Metadata.TimeOfDay; Renderer.PersistentSettings = gameFile.Metadata.RendererSettings; Time = gameFile.Metadata.Time; WorldSizeInChunks = new Point3(Overworld.InstanceSettings.Cell.Bounds.Width, Overworld.zLevels, Overworld.InstanceSettings.Cell.Bounds.Height); #endregion #region Initialize static data bool actionComplete = false; Game.DoLazyAction(new Action(() => { Renderer.InstanceRenderer = new InstanceRenderer(); Renderer.bloom = new BloomComponent(Game) { Settings = BloomSettings.PresetSettings[5] }; Renderer.bloom.Initialize(); SoundManager.Content = Content; if (PlanService != null) { PlanService.Restart(); } MonsterSpawner = new MonsterSpawner(this); EntityFactory.Initialize(this); }), () => { actionComplete = true; return(true); }); while (!actionComplete) { Thread.Sleep(10); } #endregion PlanService = new PlanService(); SetLoadingMessage("Creating Liquids ..."); #region liquids Renderer.WaterRenderer = new WaterRenderer(GraphicsDevice); #endregion #region Load Components // Create updateable systems. foreach (var updateSystemFactory in AssetManager.EnumerateModHooks(typeof(UpdateSystemFactoryAttribute), typeof(EngineModule), new Type[] { typeof(WorldManager) })) { UpdateSystems.Add(updateSystemFactory.Invoke(null, new Object[] { this }) as EngineModule); } ChunkManager = new ChunkManager(Content, this); Splasher = new Splasher(ChunkManager); Renderer.ChunkRenderer = new ChunkRenderer(ChunkManager); SetLoadingMessage("Loading Terrain..."); ChunkManager.LoadChunks(gameFile.LoadChunks(), ChunkManager); SetLoadingMessage("Loading Entities..."); gameFile.LoadPlayData(Overworld.GetInstancePath(), this); PersistentData = gameFile.PlayData.PersistentData; Renderer.Camera = gameFile.PlayData.Camera; if (gameFile.PlayData.Stats != null) { Stats = gameFile.PlayData.Stats; } ComponentManager = new ComponentManager(gameFile.PlayData.Components, this); foreach (var component in gameFile.PlayData.Components.SaveableComponents) { if (!ComponentManager.HasComponent(component.GlobalID) && ComponentManager.HasComponent(component.Parent.GlobalID)) { // Logically impossible. throw new InvalidOperationException("Component exists in save data but not in manager."); } } ConversationMemory = gameFile.PlayData.ConversationMemory; Factions = gameFile.PlayData.Factions; ComponentManager.World = this; Renderer.Sky.TimeOfDay = gameFile.Metadata.TimeOfDay; Time = gameFile.Metadata.Time; PlayerFaction = Factions.Factions["Player"]; EventScheduler = new Events.Scheduler(); TutorialManager = new Tutorial.TutorialManager(); TutorialManager.SetFromSaveData(gameFile.PlayData.TutorialSaveData); Renderer.Camera.World = this; #endregion SetLoadingMessage("Creating Particles ..."); Game.DoLazyAction(new Action(() => ParticleManager = new ParticleManager(ComponentManager))); SetLoadingMessage("Creating GameMaster ..."); TaskManager = new TaskManager(); TaskManager.World = this; Time.NewDay += (time) => PayEmployees(); DwarfGame.LogSentryBreadcrumb("Loading", "Started new game with an existing file."); if (gameFile.PlayData.Tasks != null) { TaskManager = gameFile.PlayData.Tasks; TaskManager.World = this; } if (PlayerFaction.Economy.Information == null) { throw new InvalidProgramException(); } if (MathFunctions.RandEvent(0.01f)) { SetLoadingMessage("Reticulating Splines..."); } ChunkManager.NeedsMinimapUpdate = true; ChunkManager.StartThreads(); SetLoadingMessage("Presimulating ..."); ShowingWorld = false; OnLoadedEvent(); Thread.Sleep(1000); ShowingWorld = true; SetLoadingMessage("Complete."); // GameFile is no longer needed. gameFile = null; LoadStatus = LoadingStatus.Success; }
public Necromancer(CreatureStats stats, Faction faction, ComponentManager manager, string name, Vector3 position) : base(manager, stats, faction, name) { Physics = new Physics(manager, "Necromancer", 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(10, 5, 10), Vector3.Zero)); Physics.AddChild(new NecromancerAI(Manager, "Necromancer AI", Sensor)); Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.LocalBoundingBoxOffset)); Physics.Tags.Add("Necromancer"); Physics.AddChild(new Flammable(Manager, "Flames")); Stats.FullName = TextGenerator.GenerateRandom("$title") + " " + TextGenerator.ToTitleCase(TextGenerator.GenerateRandom("$names_undead")); Stats.BaseSize = 4; Stats.CanEat = false; AI.Movement.CanClimbWalls = true; AI.Movement.SetCost(MoveType.ClimbWalls, 50.0f); AI.Movement.SetSpeed(MoveType.ClimbWalls, 0.15f); AI.Movement.SetCan(MoveType.Dig, true); }
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); Species = "Fairy"; }
public static Resource CreateMeal(Resource componentA, Resource componentB) { Resource toReturn = new Resource(Resources[ResourceType.Meal]) { FoodContent = componentA.FoodContent + componentB.FoodContent, Type = TextGenerator.GenerateRandom(new List<string>() {componentA.ResourceName, componentB.ResourceName}, TextGenerator.GetAtoms(ContentPaths.Text.Templates.food)), MoneyValue = 2*(componentA.MoneyValue + componentB.MoneyValue) }; toReturn.ShortName = toReturn.Type; if (!Resources.ContainsKey(toReturn.Type)) Add(toReturn); return toReturn; }
/// <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.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 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.bird, 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" } } }; }
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; Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice); 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 = PlayState.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 = PlayState.Time.CurrentDate }); } Layout.UpdateSizes(); Talker.TweenIn(Drawer2D.Alignment.Top, 0.25f); DialougeSelector.TweenIn(Drawer2D.Alignment.Right, 0.25f); }
public static string GetRandomWorldName() { List <List <string> > templates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.worlds); return(TextGenerator.GenerateRandom(templates)); }
public Scorpion(Vector3 position, ComponentManager manager, string name) : base ( manager, new CreatureStats("Scorpion", "Scorpion", 0) { CanEat = true }, manager.World.Factions.Factions["Carnivore"], name ) { Physics = new Physics ( manager, // It is called "bird" "Scorpion", // It's attached to the root component of the component manager // It is located at a position passed in as an argument Matrix.CreateTranslation(position), // It has a size of 0.25 blocks new Vector3(0.375f, 0.375f, 0.375f), // Its bounding box is located in its center new Vector3(0.0f, 0.0f, 0.0f), //It has a mass of 1, a moment of intertia of 1, and very small friction/restitution 1.0f, 1.0f, 0.999f, 0.999f, // It has a gravity of 10 blocks per second downward new Vector3(0, -10, 0) ); Physics.AddChild(this); // When true, causes the bird to face the direction its moving in Physics.Orientation = Physics.OrientMode.RotateY; CreateCosmeticChildren(Manager); // Used to sense hostile creatures Physics.AddChild(new EnemySensor(Manager, "EnemySensor", Matrix.Identity, new Vector3(5, 5, 5), Vector3.Zero)); // Controls the behavior of the creature Physics.AddChild(new PacingCreatureAI(Manager, "Scorpion AI", Sensor)); // 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 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"; 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); }
public void Chat() { var Employee = this; Func <string> get_status = () => Employee.Stats.GetStatusAdjective(); Employee.World.Paused = true; // Prepare conversation memory for an envoy conversation. var cMem = Employee.World.ConversationMemory; cMem.SetValue("$world", new Yarn.Value(Employee.World)); cMem.SetValue("$employee", new Yarn.Value(Employee)); cMem.SetValue("$employee_name", new Yarn.Value(Employee.Stats.FullName)); cMem.SetValue("$employee_status", new Yarn.Value(get_status())); var timeOfDay = "Morning"; int hour = Employee.World.Time.CurrentDate.Hour; if (hour > 12) { timeOfDay = "Afternoon"; } if (hour > 16) { timeOfDay = "Evening"; } cMem.SetValue("$time_of_day", new Yarn.Value(timeOfDay)); cMem.SetValue("$is_asleep", new Yarn.Value(Employee.Stats.IsAsleep)); cMem.SetValue("$is_on_strike", new Yarn.Value(Employee.Stats.IsOnStrike)); if (Employee.Creature.Physics.GetComponent <DwarfThoughts>().HasValue(out var thoughts)) { cMem.SetValue("$grievences", new Yarn.Value(TextGenerator.GetListString(thoughts.Thoughts.Where(thought => thought.HappinessModifier < 0).Select(thought => thought.Description)))); cMem.SetValue("$good_things", new Yarn.Value(TextGenerator.GetListString(thoughts.Thoughts.Where(thought => thought.HappinessModifier >= 0).Select(thought => thought.Description)))); } else { cMem.SetValue("$grievences", new Yarn.Value("")); cMem.SetValue("$good_things", new Yarn.Value("")); } String[] personalities = { "happy", "grumpy", "anxious" }; var myRandom = new Random(Employee.Stats.RandomSeed); cMem.SetValue("$personality", new Yarn.Value(personalities[myRandom.Next(0, personalities.Length)])); cMem.SetValue("$motto", new Yarn.Value(Employee.World.PlayerFaction.Economy.Information.Motto)); cMem.SetValue("$company_name", new Yarn.Value(Employee.World.PlayerFaction.Economy.Information.Name)); cMem.SetValue("$employee_task", new Yarn.Value(Employee.CurrentTask.HasValue(out var currentTask) ? "Nothing" : currentTask.Name)); cMem.SetValue("$employee_class", new Yarn.Value(Employee.Stats.CurrentClass.Name)); var injuries = TextGenerator.GetListString(Employee.Creature.Stats.Buffs.OfType <Disease>().Select(disease => disease.Name)); if (injuries == "") { injuries = "no problems"; } cMem.SetValue("$injuries", new Yarn.Value(injuries)); cMem.SetValue("$employee_pay", new Yarn.Value((float)(decimal)Employee.Stats.CurrentLevel.Pay)); cMem.SetValue("$employee_bonus", new Yarn.Value(4 * (float)(decimal)Employee.Stats.CurrentLevel.Pay)); cMem.SetValue("$company_money", new Yarn.Value((float)(decimal)Employee.Faction.Economy.Funds)); if (Employee.Physics.GetComponent <Flammable>().HasValue(out var flames)) { cMem.SetValue("$is_on_fire", new Yarn.Value(flames.IsOnFire)); } else { cMem.SetValue("$is_on_fire", new Yarn.Value(false)); } var state = new YarnState(World, ContentPaths.employee_conversation, "Start", cMem); state.AddEmployeePortrait(Employee); state.SetVoicePitch(Employee.Stats.VoicePitch); GameStateManager.PushState(state); }
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 PacingCreatureAI(this, "Deer AI", Sensors, PlanService); Attacks = new List <Attack> { new Attack("None", 0.0f, 0.0f, 0.0f, ContentPaths.Audio.pick, ContentPaths.Effects.hit) }; 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" } } }; }
/// <summary> /// Initialize function creates all the required components for the bird. /// </summary> /// <param name="sprites">The sprite sheet to use for the bird</param> public void Initialize(string sprites) { // When true, causes the bird to face the direction its moving in Physics.Orientation = Physics.OrientMode.RotateY; SpriteAsset = sprites; CreateSprite(SpriteAsset, Manager, 0.35f); // Used to sense hostile creatures Physics.AddChild(new EnemySensor(Manager, "EnemySensor", Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero)); // Controls the behavior of the creature Physics.AddChild(new PacingCreatureAI(Manager, "Rabbit AI", Sensors, PlanService)); // The bird can peck at its enemies (0.1 damage) Attacks = new List <Attack> { new Attack("Bite", 0.01f, 2.0f, 1.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_frog_attack), ContentPaths.Effects.bite) }; // The bird can hold one item at a time in its inventory Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.LocalBoundingBoxOffset)); Physics.AddChild(Shadow.Create(0.25f, Manager)); // The bird will emit a shower of blood when it dies Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1, SoundToPlay = ContentPaths.Audio.Oscar.sfx_oc_frog_hurt_1 }); // The bird is flammable, and can die when exposed to fire. Physics.AddChild(new Flammable(Manager, "Flames")); // Tag the physics component with some information // that can be used later Physics.Tags.Add("Frog"); Physics.Tags.Add("Animal"); Physics.Tags.Add("DomesticAnimal"); Stats.FullName = TextGenerator.GenerateRandom("$firstname") + " the frog"; Stats.CurrentClass = new EmployeeClass() { Name = "Frog", Levels = new List <EmployeeClass.Level>() { new EmployeeClass.Level() { Index = 0, Name = "Frog" } } }; NoiseMaker.Noises["Idle"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_frog_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_frog_neutral_2 }; NoiseMaker.Noises["Chrip"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_frog_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_frog_neutral_2 }; NoiseMaker.Noises["Hurt"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_frog_hurt_1, ContentPaths.Audio.Oscar.sfx_oc_frog_hurt_2 }; Species = "Frog"; CanReproduce = true; BabyType = "Frog"; }
/// <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); // 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 BatAI(Manager, "Bat AI", Sensors, PlanService)) as BatAI; 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 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("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"; }
/// <summary> /// Initialize function creates all the required components for the bird. /// </summary> /// <param name="sprites">The sprite sheet to use for the bird</param> /// <param name="species"></param> public void Initialize(string sprites, string species) { // When true, causes the bird to face the direction its moving in Physics.Orientation = Physics.OrientMode.RotateY; CreateSprite(ContentPaths.Entities.Animals.fowl[Species], Manager); // Used to sense hostile creatures Physics.AddChild(new EnemySensor(Manager, "EnemySensor", Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero)); // Controls the behavior of the creature Physics.AddChild(new PacingCreatureAI(Manager, "AI", Sensors, PlanService)); // The bird can peck at its enemies (0.1 damage) Attacks = new List <Attack> { new Attack("Peck", 0.01f, 2.0f, 0.5f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_chicken_attack), ContentPaths.Effects.pierce) { Mode = Attack.AttackMode.Melee, TriggerFrame = 2, TriggerMode = Attack.AttackTrigger.Animation } }; // The bird can hold one item at a time in its inventory Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.LocalBoundingBoxOffset)); Physics.AddChild(Shadow.Create(0.5f, Manager)); // The bird will emit a shower of blood when it dies Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1 }); Physics.AddChild(new ParticleTrigger("feather", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 10 }); // The bird is flammable, and can die when exposed to fire. Physics.AddChild(new Flammable(Manager, "Flames")); // Tag the physics component with some information // that can be used later Physics.Tags.Add(species); Physics.Tags.Add("Animal"); Physics.Tags.Add("DomesticAnimal"); Stats.FullName = TextGenerator.GenerateRandom("$firstname") + " the " + species; Stats.CurrentClass = new EmployeeClass() { Name = species, Levels = new List <EmployeeClass.Level>() { new EmployeeClass.Level() { Index = 0, Name = species } } }; NoiseMaker.Noises["Hurt"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_chicken_hurt_1, ContentPaths.Audio.Oscar.sfx_oc_chicken_hurt_2 }; NoiseMaker.Noises["Chirp"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_chicken_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_chicken_neutral_2 }; NoiseMaker.Noises["Lay Egg"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_chicken_lay_egg }; Species = species; var deathParticleTrigger = Parent.EnumerateAll().OfType <ParticleTrigger>().FirstOrDefault(); if (deathParticleTrigger != null) { deathParticleTrigger.SoundToPlay = NoiseMaker.Noises["Hurt"][0]; } }
public void OrderEnemyAttack() { foreach (CreatureAI enemy in Sensor.Enemies) { Task task = new KillEntityTask(enemy.Physics, KillEntityTask.KillType.Auto); if (!HasTaskWithName(task)) { Creature.AI.Tasks.Add(task); if (Faction == PlayState.PlayerFaction) { PlayState.AnnouncementManager.Announce(Stats.FullName + Drawer2D.WrapColor(" is fighting ", Color.DarkRed) + TextGenerator.IndefiniteArticle(enemy.Creature.Name), Stats.FullName + " the " + Stats.CurrentLevel.Name + " is fighting " + TextGenerator.IndefiniteArticle(enemy.Stats.CurrentLevel.Name) + " " + enemy.Faction.Race.Name, ZoomToMe); } } } }
/// <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, 0.6f); // 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, "Chimp AI", Sensors)); // The bird can peck at its enemies (0.1 damage) Attacks = new List <Attack> { new Attack("Hit", 5.0f, 0.5f, 2.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_rabbit_attack), ContentPaths.Effects.hit) { DiseaseToSpread = "Rabies", TriggerMode = Attack.AttackTrigger.Animation, TriggerFrame = 2 } }; // The bird can hold one item at a time in its inventory Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.LocalBoundingBoxOffset)); Physics.AddChild(Shadow.Create(0.5f, Manager)); // The bird will emit a shower of blood when it dies Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1 }); // 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("Chimp"); Physics.Tags.Add("Animal"); Physics.Tags.Add("DomesticAnimal"); Stats.FullName = TextGenerator.GenerateRandom("$firstname") + " the Chimp"; Stats.CurrentClass = new EmployeeClass() { Name = "Chimp", Levels = new List <EmployeeClass.Level>() { new EmployeeClass.Level() { Index = 0, Name = "Chimp" } } }; 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 = "Chimp"; CanReproduce = true; BabyType = Name; var deathParticleTrigger = Parent.EnumerateAll().OfType <ParticleTrigger>().FirstOrDefault(); if (deathParticleTrigger != null) { deathParticleTrigger.SoundToPlay = NoiseMaker.Noises["Hurt"][0]; } AI.Movement.SetCan(MoveType.ClimbWalls, true); }
private void LoadThreaded() { // Ensure we're using the invariant culture. Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; LoadStatus = LoadingStatus.Loading; SetLoadingMessage("Initializing ..."); while (GraphicsDevice == null) { Thread.Sleep(100); } Thread.Sleep(1000); #if !DEBUG try { #endif bool fileExists = !string.IsNullOrEmpty(ExistingFile); SetLoadingMessage("Creating Sky..."); Sky = new SkyRenderer(); #region Reading game file if (fileExists) { SetLoadingMessage("Loading " + ExistingFile); gameFile = SaveGame.CreateFromDirectory(ExistingFile); if (gameFile == null) { throw new InvalidOperationException("Game File does not exist."); } // Todo: REMOVE THIS WHEN THE NEW SAVE SYSTEM IS COMPLETE. if (gameFile.Metadata.Version != Program.Version && !Program.CompatibleVersions.Contains(gameFile.Metadata.Version)) { throw new InvalidOperationException(String.Format("Game file is from version {0}. Compatible versions are {1}.", gameFile.Metadata.Version, TextGenerator.GetListString(Program.CompatibleVersions))); } Sky.TimeOfDay = gameFile.Metadata.TimeOfDay; Time = gameFile.Metadata.Time; WorldOrigin = gameFile.Metadata.WorldOrigin; WorldScale = gameFile.Metadata.WorldScale; WorldSize = gameFile.Metadata.NumChunks; GameID = gameFile.Metadata.GameID; if (gameFile.Metadata.OverworldFile != null && gameFile.Metadata.OverworldFile != "flat") { SetLoadingMessage("Loading world " + gameFile.Metadata.OverworldFile); Overworld.Name = gameFile.Metadata.OverworldFile; DirectoryInfo worldDirectory = Directory.CreateDirectory(DwarfGame.GetWorldDirectory() + Path.DirectorySeparatorChar + Overworld.Name); var overWorldFile = new NewOverworldFile(worldDirectory.FullName); Overworld.Map = overWorldFile.Data.Data; Overworld.Name = overWorldFile.Data.Name; } else { SetLoadingMessage("Generating flat world.."); Overworld.CreateUniformLand(GraphicsDevice); } } #endregion #region Initialize static data { Vector3 origin = new Vector3(0, 0, 0); Vector3 extents = new Vector3(1500, 1500, 1500); OctTree = new OctTreeNode(origin - extents, origin + extents); PrimitiveLibrary.Initialize(GraphicsDevice, Content); InstanceRenderer = new InstanceRenderer(GraphicsDevice, Content); Color[] white = new Color[1]; white[0] = Color.White; pixel = new Texture2D(GraphicsDevice, 1, 1); pixel.SetData(white); Tilesheet = AssetManager.GetContentTexture(ContentPaths.Terrain.terrain_tiles); AspectRatio = GraphicsDevice.Viewport.AspectRatio; DefaultShader = new Shader(Content.Load <Effect>(ContentPaths.Shaders.TexturedShaders), true); DefaultShader.ScreenWidth = GraphicsDevice.Viewport.Width; DefaultShader.ScreenHeight = GraphicsDevice.Viewport.Height; CraftLibrary.InitializeDefaultLibrary(); PotionLibrary.Initialize(); VoxelLibrary.InitializeDefaultLibrary(GraphicsDevice); GrassLibrary.InitializeDefaultLibrary(); DecalLibrary.InitializeDefaultLibrary(); bloom = new BloomComponent(Game) { Settings = BloomSettings.PresetSettings[5] }; bloom.Initialize(); SoundManager.Content = Content; if (PlanService != null) { PlanService.Restart(); } JobLibrary.Initialize(); MonsterSpawner = new MonsterSpawner(this); EntityFactory.Initialize(this); } #endregion SetLoadingMessage("Creating Planner ..."); PlanService = new PlanService(); SetLoadingMessage("Creating Shadows..."); Shadows = new ShadowRenderer(GraphicsDevice, 1024, 1024); SetLoadingMessage("Creating Liquids ..."); #region liquids WaterRenderer = new WaterRenderer(GraphicsDevice); #endregion SetLoadingMessage("Generating Initial Terrain Chunks ..."); if (!fileExists) { GameID = MathFunctions.Random.Next(0, 1024); } ChunkGenerator = new ChunkGenerator(VoxelLibrary, Seed, 0.02f) { SeaLevel = SeaLevel }; #region Load Components if (fileExists) { ChunkManager = new ChunkManager(Content, this, ChunkGenerator, WorldSize.X, WorldSize.Y, WorldSize.Z); Splasher = new Splasher(ChunkManager); ChunkRenderer = new ChunkRenderer(ChunkManager.ChunkData); SetLoadingMessage("Loading Terrain..."); gameFile.ReadChunks(ExistingFile); ChunkManager.ChunkData.LoadFromFile(ChunkManager, gameFile, SetLoadingMessage); SetLoadingMessage("Loading Entities..."); gameFile.LoadPlayData(ExistingFile, this); Camera = gameFile.PlayData.Camera; DesignationDrawer = gameFile.PlayData.Designations; Vector3 origin = new Vector3(WorldOrigin.X, 0, WorldOrigin.Y); Vector3 extents = new Vector3(1500, 1500, 1500); if (gameFile.PlayData.Resources != null) { foreach (var resource in gameFile.PlayData.Resources) { if (!ResourceLibrary.Resources.ContainsKey(resource.Key)) { ResourceLibrary.Add(resource.Value); } } } ComponentManager = new ComponentManager(gameFile.PlayData.Components, this); foreach (var component in gameFile.PlayData.Components.SaveableComponents) { if (!ComponentManager.HasComponent(component.GlobalID) && ComponentManager.HasComponent(component.Parent.GlobalID)) { // Logically impossible. throw new InvalidOperationException("Component exists in save data but not in manager."); } } ConversationMemory = gameFile.PlayData.ConversationMemory; Factions = gameFile.PlayData.Factions; ComponentManager.World = this; Sky.TimeOfDay = gameFile.Metadata.TimeOfDay; Time = gameFile.Metadata.Time; WorldOrigin = gameFile.Metadata.WorldOrigin; WorldScale = gameFile.Metadata.WorldScale; // Restore native factions from deserialized data. Natives = new List <Faction>(); foreach (Faction faction in Factions.Factions.Values) { if (faction.Race.IsNative && faction.Race.IsIntelligent && !faction.IsRaceFaction) { Natives.Add(faction); } } Diplomacy = gameFile.PlayData.Diplomacy; GoalManager = new Goals.GoalManager(); GoalManager.Initialize(new List <Goals.Goal>());// gameFile.PlayData.Goals); TutorialManager = new Tutorial.TutorialManager(); TutorialManager.SetFromSaveData(gameFile.PlayData.TutorialSaveData); } else { Time = new WorldTime(); Camera = new OrbitCamera(this, new Vector3(VoxelConstants.ChunkSizeX, VoxelConstants.ChunkSizeY - 1.0f, VoxelConstants.ChunkSizeZ), new Vector3(VoxelConstants.ChunkSizeY, VoxelConstants.ChunkSizeY - 1.0f, VoxelConstants.ChunkSizeZ) + Vector3.Up * 10.0f + Vector3.Backward * 10, MathHelper.PiOver4, AspectRatio, 0.1f, GameSettings.Default.VertexCullDistance); ChunkManager = new ChunkManager(Content, this, ChunkGenerator, WorldSize.X, WorldSize.Y, WorldSize.Z); Splasher = new Splasher(ChunkManager); ChunkRenderer = new ChunkRenderer(ChunkManager.ChunkData); Camera.Position = new Vector3(0, 10, 0) + new Vector3(WorldSize.X * VoxelConstants.ChunkSizeX, 0, WorldSize.Z * VoxelConstants.ChunkSizeZ) * 0.5f; Camera.Target = new Vector3(0, 10, 1) + new Vector3(WorldSize.X * VoxelConstants.ChunkSizeX, 0, WorldSize.Z * VoxelConstants.ChunkSizeZ) * 0.5f; // If there's no file, we have to initialize the first chunk coordinate if (gameFile == null) { ChunkManager.GenerateInitialChunks(SpawnRect, new GlobalChunkCoordinate(0, 0, 0), SetLoadingMessage); } ComponentManager = new ComponentManager(this); ComponentManager.SetRootComponent(new Body(ComponentManager, "root", Matrix.Identity, Vector3.Zero, Vector3.Zero)); if (Natives == null) // Todo: Always true?? { FactionLibrary library = new FactionLibrary(); library.Initialize(this, CompanyMakerState.CompanyInformation); Natives = new List <Faction>(); for (int i = 0; i < 10; i++) { Natives.Add(library.GenerateFaction(this, i, 10)); } } #region Prepare Factions foreach (Faction faction in Natives) { faction.World = this; if (faction.RoomBuilder == null) { faction.RoomBuilder = new RoomBuilder(faction, this); } } Factions = new FactionLibrary(); if (Natives != null && Natives.Count > 0) { Factions.AddFactions(this, Natives); } Factions.Initialize(this, CompanyMakerState.CompanyInformation); Point playerOrigin = new Point((int)(WorldOrigin.X), (int)(WorldOrigin.Y)); Factions.Factions["Player"].Center = playerOrigin; Factions.Factions["The Motherland"].Center = new Point(playerOrigin.X + 50, playerOrigin.Y + 50); #endregion Diplomacy = new Diplomacy(this); Diplomacy.Initialize(Time.CurrentDate); // Initialize goal manager here. GoalManager = new Goals.GoalManager(); GoalManager.Initialize(new List <Goals.Goal>()); TutorialManager = new Tutorial.TutorialManager(); TutorialManager.TutorialEnabled = !GameSettings.Default.TutorialDisabledGlobally; Tutorial("new game start"); foreach (var item in CraftLibrary.EnumerateCraftables()) { if (!String.IsNullOrEmpty(item.Tutorial)) { TutorialManager.AddTutorial(item.Name, item.Tutorial, item.Icon); } } } Camera.World = this; //Drawer3D.Camera = Camera; #endregion SetLoadingMessage("Creating Particles ..."); ParticleManager = new ParticleManager(ComponentManager); SetLoadingMessage("Creating GameMaster ..."); Master = new GameMaster(Factions.Factions["Player"], Game, ComponentManager, ChunkManager, Camera, GraphicsDevice); if (gameFile != null) { if (gameFile.PlayData.Tasks != null) { Master.NewArrivals = gameFile.PlayData.NewArrivals ?? new List <GameMaster.ApplicantArrival>(); Master.TaskManager = gameFile.PlayData.Tasks; Master.TaskManager.Faction = Master.Faction; } if (gameFile.PlayData.InitialEmbark != null) { InitialEmbark = gameFile.PlayData.InitialEmbark; } ChunkManager.World.Master.SetMaxViewingLevel(gameFile.Metadata.Slice > 0 ? gameFile.Metadata.Slice : ChunkManager.World.Master.MaxViewingLevel); } if (Master.Faction.Economy.Company.Information == null) { Master.Faction.Economy.Company.Information = new CompanyInformation(); } CreateInitialEmbarkment(); foreach (var chunk in ChunkManager.ChunkData.ChunkMap) { chunk.CalculateInitialSunlight(); } if (RevealSurface) { VoxelHelpers.InitialReveal(ChunkManager, ChunkManager.ChunkData, new VoxelHandle( ChunkManager.ChunkData.GetChunkEnumerator().FirstOrDefault(), new LocalVoxelCoordinate(0, VoxelConstants.ChunkSizeY - 1, 0))); } foreach (var chunk in ChunkManager.ChunkData.ChunkMap) { ChunkManager.InvalidateChunk(chunk); } ChunkManager.StartThreads(); SetLoadingMessage("Presimulating ..."); ShowingWorld = false; OnLoadedEvent(); Thread.Sleep(1000); ShowingWorld = true; SetLoadingMessage("Complete."); // GameFile is no longer needed. gameFile = null; LoadStatus = LoadingStatus.Success; #if !DEBUG } catch (Exception exception) { Game.CaptureException(exception); LoadingException = exception; LoadStatus = LoadingStatus.Failure; ProgramData.WriteExceptionLog(exception); } #endif }
public void Initialize(SpriteSheet spriteSheet) { Physics.Orientation = Physics.OrientMode.RotateY; SpriteAssets = spriteSheet; CreateSprites(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.BoundingBoxPos)) 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"; }
public static string GenerateRandomMotto() { var templates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.mottos); return(TextGenerator.GenerateRandom(Datastructures.SelectRandom(templates).ToArray())); }
public Bird(string sprites, Vector3 position, ComponentManager manager, string name) : base ( manager, new CreatureStats { Dexterity = 6, Constitution = 1, Strength = 1, Wisdom = 1, Charisma = 1, Intelligence = 1, Size = 0.25f, CanSleep = false, LaysEggs = true }, "Herbivore", manager.World.PlanService, manager.World.Factions.Factions["Herbivore"], name ) { Physics = new Physics ( manager, // It is called "bird" "A Bird", // It's attached to the root component of the component manager // It is located at a position passed in as an argument Matrix.CreateTranslation(position), // It has a size of 0.25 blocks new Vector3(0.25f, 0.25f, 0.25f), // Its bounding box is located in its center new Vector3(0.0f, 0.0f, 0.0f), //It has a mass of 1, a moment of intertia of 1, and very small friction/restitution 1.0f, 1.0f, 0.999f, 0.999f, // It has a gravity of 10 blocks per second downward new Vector3(0, -10, 0) ); Physics.AddChild(this); Physics.AddChild(new SelectionCircle(Manager) { IsVisible = false }); SpriteAsset = sprites; CreateSpriteSheet(Manager); // Used to grab other components Hands = Physics.AddChild(new Grabber("hands", Manager, Matrix.Identity, new Vector3(0.2f, 0.2f, 0.2f), Vector3.Zero)) as Grabber; // Used to sense hostile creatures Sensors = Physics.AddChild(new EnemySensor(Manager, "EnemySensor", Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero)) as EnemySensor; // Controls the behavior of the creature AI = Physics.AddChild(new BirdAI(Manager, "Bird AI", Sensors, PlanService)) as BirdAI; // The bird can peck at its enemies (0.1 damage) Attacks = new List <Attack> { new Attack("Peck", 0.1f, 2.0f, 1.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_bird_attack), ContentPaths.Effects.pierce) { Mode = Attack.AttackMode.Dogfight } }; // The bird can hold one item at a time in its inventory Inventory = Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.BoundingBoxPos)) as Inventory; Physics.AddChild(Shadow.Create(0.25f, Manager)); // The bird will emit a shower of blood when it dies Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1, SoundToPlay = ContentPaths.Audio.Oscar.sfx_oc_bird_hurt }); // The bird is flammable, and can die when exposed to fire. Physics.AddChild(new Flammable(Manager, "Flames")); // Tag the physics component with some information // that can be used later Physics.Tags.Add("Bird"); Physics.Tags.Add("Animal"); Physics.Tags.Add("DomesticAnimal"); NoiseMaker.Noises.Add("chirp", new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_bird_neutral_2 }); NoiseMaker.Noises["Hurt"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_hurt }; NoiseMaker.Noises["Lay Egg"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_lay_egg }; Stats.FullName = TextGenerator.GenerateRandom("$firstname") + " the bird"; Stats.CurrentClass = new EmployeeClass() { Name = "Bird", Levels = new List <EmployeeClass.Level>() { new EmployeeClass.Level() { Index = 0, Name = "Bird" } } }; AI.Movement.CanFly = true; AI.Movement.CanWalk = false; AI.Movement.CanClimb = false; Species = "Bird"; }
public static string GenerateRandomName() { var templates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.company_exploration); return(TextGenerator.GenerateRandom(Datastructures.SelectRandom(templates).ToArray())); }
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; }
/// <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); Physics.AddChild(Shadow.Create(0.25f, 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, "Scorpion AI", Sensors, PlanService)) as CreatureAI; // 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 Inventory = Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.LocalBoundingBoxOffset)) as Inventory; // 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"; }
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["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.TriggersMourning = true; }
public Bird(string sprites, Vector3 position, ComponentManager manager, string name) : base ( manager, new CreatureStats { Dexterity = 6, Constitution = 1, Strength = 1, Wisdom = 1, Charisma = 1, Intelligence = 1, Size = 0.25f, CanSleep = false, LaysEggs = true, IsMigratory = true }, "Herbivore", manager.World.PlanService, manager.World.Factions.Factions["Herbivore"], name ) { Physics = new Physics ( manager, "A Bird", Matrix.CreateTranslation(position), new Vector3(0.25f, 0.25f, 0.25f), new Vector3(0.0f, 0.0f, 0.0f), 1.0f, 1.0f, 0.999f, 0.999f, new Vector3(0, -10, 0) ); Physics.Orientation = Physics.OrientMode.RotateY; Physics.AddChild(this); SpriteAsset = sprites; BaseMeatResource = "Bird Meat"; CreateSprite(ContentPaths.Entities.Animals.Birds.GetBirdAnimations(SpriteAsset), Manager); // Used to sense hostile creatures Physics.AddChild(new EnemySensor(Manager, "EnemySensor", Matrix.Identity, new Vector3(20, 5, 20), Vector3.Zero)); // Controls the behavior of the creature Physics.AddChild(new BirdAI(Manager, "Bird AI", Sensors, PlanService)); // The bird can peck at its enemies (0.1 damage) Attacks = new List <Attack> { new Attack("Peck", 0.1f, 2.0f, 1.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_oc_bird_attack), ContentPaths.Effects.pierce) { Mode = Attack.AttackMode.Dogfight } }; // The bird can hold one item at a time in its inventory Physics.AddChild(new Inventory(Manager, "Inventory", Physics.BoundingBox.Extents(), Physics.LocalBoundingBoxOffset)); Physics.AddChild(Shadow.Create(0.25f, Manager)); // The bird will emit a shower of blood when it dies Physics.AddChild(new ParticleTrigger("blood_particle", Manager, "Death Gibs", Matrix.Identity, Vector3.One, Vector3.Zero) { TriggerOnDeath = true, TriggerAmount = 1, SoundToPlay = ContentPaths.Audio.Oscar.sfx_oc_bird_hurt }); // The bird is flammable, and can die when exposed to fire. Physics.AddChild(new Flammable(Manager, "Flames")); // Tag the physics component with some information // that can be used later Physics.Tags.Add("Bird"); Physics.Tags.Add("Animal"); Physics.Tags.Add("DomesticAnimal"); NoiseMaker.Noises.Add("chirp", new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_neutral_1, ContentPaths.Audio.Oscar.sfx_oc_bird_neutral_2 }); NoiseMaker.Noises["Hurt"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_hurt }; NoiseMaker.Noises["Lay Egg"] = new List <string>() { ContentPaths.Audio.Oscar.sfx_oc_bird_lay_egg }; Stats.FullName = TextGenerator.GenerateRandom("$firstname") + " the bird"; Stats.CurrentClass = new EmployeeClass() { Name = "Bird", Levels = new List <EmployeeClass.Level>() { new EmployeeClass.Level() { Index = 0, Name = "Bird" } } }; AI.Movement.CanFly = true; AI.Movement.CanWalk = false; AI.Movement.CanClimb = false; Species = "Bird"; }