public static string GenerateRandomName() { var templates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.company_exploration); return(TextGenerator.GenerateRandom(Datastructures.SelectRandom(templates).ToArray())); }
public static string GenerateRandom(List <List <string> > templates) { return(GenerateRandom(Datastructures.SelectRandom(templates).ToArray())); }
private string GetGoodTradeText() { return(Datastructures.SelectRandom(Faction.Race.Speech.GoodTrades)); }
public static string GenerateRandomMotto() { var templates = TextGenerator.GetAtoms(ContentPaths.Text.Templates.mottos); return(TextGenerator.GenerateRandom(Datastructures.SelectRandom(templates).ToArray())); }
public static Race RandomIntelligentRace() { return(Datastructures.SelectRandom(Races.Values.Where(r => r.IsIntelligent && r.IsNative))); }
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 MaybeNull <Race> GetRandomIntelligentRace() { InitializeRaces(); return(Datastructures.SelectRandom(Races.Values.Where(r => r.IsIntelligent && r.IsNative))); }
public List <ResourceAmount> GenerateResources() { Dictionary <ResourceLibrary.ResourceType, ResourceAmount> toReturn = new Dictionary <ResourceLibrary.ResourceType, ResourceAmount>(); Resource.ResourceTags[] blacklistTags = { Resource.ResourceTags.Money, Resource.ResourceTags.Corpse }; foreach (var tags in TradeGoods) { int num = MathFunctions.RandInt(tags.Value - 5, tags.Value + 5); IEnumerable <Resource> resources = ResourceLibrary.GetResourcesByTag(tags.Key); if (resources.Count() <= 0) { continue; } for (int i = 0; i < num; i++) { Resource randResource = Datastructures.SelectRandom(resources); if (randResource.Tags.Any(blacklistTags.Contains)) { continue; } if (randResource.Type == ResourceLibrary.ResourceType.Trinket || randResource.Type == ResourceLibrary.ResourceType.GemTrinket || tags.Key == Resource.ResourceTags.Craft) { Resource.ResourceTags craftTag = Datastructures.SelectRandom(Crafts); IEnumerable <Resource> availableCrafts = ResourceLibrary.GetResourcesByTag(craftTag); Resource trinket = ResourceLibrary.GenerateTrinket( Datastructures.SelectRandom(availableCrafts).Type, MathFunctions.Rand(0.1f, 3.0f)); if (MathFunctions.RandEvent(0.3f) && Encrustings.Count > 0) { IEnumerable <Resource> availableGems = ResourceLibrary.GetResourcesByTag(Datastructures.SelectRandom(Encrustings)); randResource = ResourceLibrary.EncrustTrinket(trinket.Type, Datastructures.SelectRandom(availableGems).Type); } else { randResource = trinket; } } if (!toReturn.ContainsKey(randResource.Type)) { toReturn[randResource.Type] = new ResourceAmount(randResource.Type, 1); } else { toReturn[randResource.Type].NumResources += 1; } } } List <ResourceAmount> resList = toReturn.Select(amount => amount.Value).ToList(); return(resList); }
public void Play(Vector3 position, float pitch = 0.0f) { SoundManager.PlaySound(Datastructures.SelectRandom(Sounds), position, RandomPitch, Volume, pitch); }
public OverworldFaction GenerateOverworldFaction(Overworld Settings, int idx, int n) { var race = Library.GetRandomIntelligentRace(); var fact = new OverworldFaction() { Race = race.Name, Name = TextGenerator.ToTitleCase(TextGenerator.GenerateRandom(Datastructures.SelectRandom(race.FactionNameTemplates).ToArray())), PrimaryColor = new HSLColor(idx * (255.0f / n), 255.0, MathFunctions.Rand(100.0f, 200.0f)), GoodWill = MathFunctions.Rand(-1, 1), InteractiveFaction = true }; return(fact); }
public void CreateMigration() { int tries = 0; float padding = 2.0f; while (tries < 10) { int side = MathFunctions.Random.Next(4); BoundingBox bounds = World.ChunkManager.Bounds; Vector3 pos = Vector3.Zero; switch (side) { case 0: pos = new Vector3(bounds.Min.X + padding, bounds.Max.Y - padding, MathFunctions.Rand(bounds.Min.Z + padding, bounds.Max.Z - padding)); break; case 1: pos = new Vector3(bounds.Max.X - padding, bounds.Max.Y - padding, MathFunctions.Rand(bounds.Min.Z + padding, bounds.Max.Z - padding)); break; case 2: pos = new Vector3(MathFunctions.Rand(bounds.Min.X + padding, bounds.Max.X - padding), bounds.Max.Y - padding, bounds.Min.Z + padding); break; case 3: pos = new Vector3(MathFunctions.Rand(bounds.Min.X + padding, bounds.Max.X - padding), bounds.Max.Y - padding, bounds.Max.Z - padding); break; } var biome = Overworld.GetBiomeAt(pos, World.WorldScale, World.WorldOrigin); if (biome.Fauna.Count == 0) { tries++; continue; } var randomFauna = Datastructures.SelectRandom(biome.Fauna); var testCreature = EntityFactory.CreateEntity <GameComponent>(randomFauna.Name, Vector3.Zero); if (testCreature == null) { tries++; continue; } var testCreatureAI = testCreature.GetRoot().GetComponent <CreatureAI>(); if (testCreatureAI == null || testCreatureAI.Movement.IsSessile) { testCreature.GetRoot().Delete(); tries++; continue; } var count = Creature.GetNumSpecies(testCreatureAI.Creature.Species); testCreature.GetRoot().Delete(); if (count < 30) { var randomNum = Math.Min(MathFunctions.RandInt(1, 3), 30 - count); for (int i = 0; i < randomNum; i++) { var randompos = MathFunctions.Clamp(pos + MathFunctions.RandVector3Cube() * 2, World.ChunkManager.Bounds); var vox = VoxelHelpers.FindFirstVoxelBelow(new VoxelHandle(World.ChunkManager.ChunkData, GlobalVoxelCoordinate.FromVector3(pos))); if (!vox.IsValid) { continue; } EntityFactory.CreateEntity <GameComponent>(randomFauna.Name, vox.GetBoundingBox().Center() + Vector3.Up * 1.5f); } } break; } }
public List <ResourceAmount> GenerateResources(WorldManager world) { Dictionary <ResourceType, ResourceAmount> toReturn = new Dictionary <ResourceType, ResourceAmount>(); Resource.ResourceTags[] blacklistTags = { Resource.ResourceTags.Money, Resource.ResourceTags.Corpse }; foreach (var tags in TradeGoods) { int num = MathFunctions.RandInt(tags.Value - 5, tags.Value + 5); IEnumerable <Resource> resources = ResourceLibrary.GetResourcesByTag(tags.Key); if (resources.Count() <= 0) { continue; } for (int i = 0; i < num; i++) { Resource randResource = Datastructures.SelectRandom(resources); if (randResource.Tags.Any(blacklistTags.Contains)) { continue; } if (tags.Key == Resource.ResourceTags.Craft) { Resource.ResourceTags craftTag = Datastructures.SelectRandom(Crafts); IEnumerable <Resource> availableCrafts = ResourceLibrary.GetResourcesByTag(craftTag); Resource trinket = ResourceLibrary.GenerateTrinket( Datastructures.SelectRandom(availableCrafts).Name, MathFunctions.Rand(0.1f, 3.0f)); if (MathFunctions.RandEvent(0.3f) && Encrustings.Count > 0) { IEnumerable <Resource> availableGems = ResourceLibrary.GetResourcesByTag(Datastructures.SelectRandom(Encrustings)); randResource = ResourceLibrary.EncrustTrinket(trinket.Name, Datastructures.SelectRandom(availableGems).Name); } else { randResource = trinket; } } if (!toReturn.ContainsKey(randResource.Name)) { toReturn[randResource.Name] = new ResourceAmount(randResource.Name, 1); } else { toReturn[randResource.Name].NumResources += 1; } } } for (int i = 0; i < NumFurniture; i++) { var randomObject = Datastructures.SelectRandom(CraftLibrary.EnumerateCraftables().Where(type => type.Type == CraftItem.CraftType.Object && type.RequiredResources.All((tags) => TradeGoods.Any(good => good.Key == tags.ResourceType)))); if (randomObject == null) { continue; } List <ResourceAmount> selectedResources = new List <ResourceAmount>(); foreach (var requirement in randomObject.RequiredResources) { IEnumerable <Resource> resources = ResourceLibrary.GetResourcesByTag(requirement.ResourceType); selectedResources.Add(new ResourceAmount(Datastructures.SelectRandom(resources), requirement.NumResources)); } var randResource = randomObject.ToResource(world, selectedResources, Posessive + " "); if (!toReturn.ContainsKey(randResource.Name)) { toReturn[randResource.Name] = new ResourceAmount(randResource.Name, 1); } else { toReturn[randResource.Name].NumResources += 1; } } List <ResourceAmount> resList = toReturn.Select(amount => amount.Value).ToList(); return(resList); }
public void Initialize(string blood) { 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, 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"; }