public void CreateInitialEmbarkment(Generation.ChunkGeneratorSettings Settings) { // If no file exists, we have to create the balloon and balloon port. if (!string.IsNullOrEmpty(Settings.Overworld.InstanceSettings.ExistingFile)) { return; // Todo: Don't call in the first place?? } var port = GenerateInitialBalloonPort(Renderer.Camera.Position.X, Renderer.Camera.Position.Z, 1, Settings); PlayerFaction.Economy.Funds = Settings.Overworld.InstanceSettings.InitalEmbarkment.Funds; Settings.Overworld.PlayerCorporationFunds -= Settings.Overworld.InstanceSettings.InitalEmbarkment.Funds; Settings.Overworld.PlayerCorporationFunds -= Settings.Overworld.InstanceSettings.CalculateLandValue(); foreach (var res in Settings.Overworld.InstanceSettings.InitalEmbarkment.Resources.Enumerate()) { AddResources(res); Settings.Overworld.PlayerCorporationResources.Remove(res); } var portBox = port.GetBoundingBox(); ComponentManager.RootComponent.AddChild(Balloon.CreateBalloon( portBox.Center() + new Vector3(0, 100, 0), portBox.Center() + new Vector3(0, 10, 0), ComponentManager, PlayerFaction)); foreach (var applicant in Settings.Overworld.InstanceSettings.InitalEmbarkment.Employees) { Settings.Overworld.PlayerCorporationFunds -= applicant.SigningBonus; HireImmediately(applicant); } Renderer.Camera.Target = portBox.Center(); Renderer.Camera.Position = Renderer.Camera.Target + new Vector3(0, 15, -15); }
/// <summary> /// Creates the balloon, the dwarves, and the initial balloon port. /// </summary> public void CreateInitialEmbarkment() { // If no file exists, we have to create the balloon and balloon port. if (!string.IsNullOrEmpty(ExistingFile)) { return; } BalloonPort port = GenerateInitialBalloonPort(Master.Faction.RoomBuilder, ChunkManager, Camera.Position.X, Camera.Position.Z, 3); CreateInitialDwarves(); PlayerFaction.AddMoney(InitialEmbark.Money); foreach (var res in InitialEmbark.Resources) { PlayerFaction.AddResources(new ResourceAmount(res.Key, res.Value)); } var portBox = port.GetBoundingBox(); ComponentManager.RootComponent.AddChild(Balloon.CreateBalloon( portBox.Center() + new Vector3(0, 100, 0), portBox.Center() + new Vector3(0, 10, 0), ComponentManager, new ShipmentOrder(0, null), Master.Faction)); Camera.Target = portBox.Center(); Camera.Position = Camera.Target + new Vector3(0, 15, -15); GenerateInitialObjects(); }
public void CreateInitialEmbarkment(Generation.ChunkGeneratorSettings Settings) { PlayerFaction.Economy.Funds = Settings.Overworld.InstanceSettings.InitalEmbarkment.Funds; Settings.Overworld.PlayerCorporationFunds -= Settings.Overworld.InstanceSettings.InitalEmbarkment.Funds; Settings.Overworld.PlayerCorporationFunds -= Settings.Overworld.InstanceSettings.CalculateLandValue(); foreach (var res in Settings.Overworld.InstanceSettings.InitalEmbarkment.Resources.Enumerate()) { AddResources(res); Settings.Overworld.PlayerCorporationResources.Remove(res); } if (GenerateInitialBalloonPort(Renderer.Camera.Position.X, Renderer.Camera.Position.Z, 1, Settings).HasValue(out var port)) { var portBox = port.GetBoundingBox(); ComponentManager.RootComponent.AddChild(Balloon.CreateBalloon( // Bypassing the entity factory because we need to set the target. portBox.Center() + new Vector3(0, 10, 0), portBox.Center() + new Vector3(0, 10, 0), ComponentManager, PlayerFaction)); Renderer.Camera.Target = portBox.Center(); Renderer.Camera.Position = Renderer.Camera.Target + new Vector3(0, 15, -15); } foreach (var applicant in Settings.Overworld.InstanceSettings.InitalEmbarkment.Employees) { Settings.Overworld.PlayerCorporationFunds -= applicant.SigningBonus; HireImmediately(applicant); } }
public Body DispatchBalloon() { List <Room> rooms = GetRooms().Where(room => room.RoomData.Name == "Balloon Port").ToList(); if (rooms.Count == 0) { return(null); } Vector3 pos = rooms.First().GetBoundingBox().Center(); return(Balloon.CreateBalloon(pos + new Vector3(0, 1000, 0), pos + Vector3.UnitY * 15, World.ComponentManager, new ShipmentOrder(0, null), this)); }
public TradeEnvoy SendTradeEnvoy() { if (!World.EnumerateZones().Any(room => room is BalloonPort && room.IsBuilt)) { World.MakeAnnouncement(String.Format("Trade envoy from {0} left: No balloon port!", ParentFaction.Name)); SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_negative_generic, 0.15f); return(null); } TradeEnvoy envoy = null; var creatures = World.MonsterSpawner.Spawn(World.MonsterSpawner.GenerateSpawnEvent(this, World.PlayerFaction, MathFunctions.Random.Next(4) + 1, false)); envoy = new TradeEnvoy(World.Time.CurrentDate) { Creatures = creatures, OtherFaction = World.PlayerFaction, ShouldRemove = false, OwnerFaction = this, TradeGoods = Race.GenerateTradeItems(World), TradeMoney = new DwarfBux((decimal)MathFunctions.Rand(150.0f, 550.0f)) }; if (Race.IsNative) { if (Economy == null) { Economy = new Company(this, 1000.0m, new CompanyInformation() { Name = ParentFaction.Name }); } foreach (CreatureAI creature in envoy.Creatures) { creature.Physics.AddChild(new ResourcePack(World.ComponentManager)); creature.Physics.AddChild(new Flag(World.ComponentManager, Vector3.Up * 0.5f + Vector3.Backward * 0.25f, Economy.Information)); } } else { GameComponent balloon = null; var rooms = World.EnumerateZones().Where(room => room.Type.Name == "Balloon Port").ToList(); if (rooms.Count != 0) { Vector3 pos = rooms.First().GetBoundingBox().Center(); balloon = Balloon.CreateBalloon(pos + new Vector3(0, 1000, 0), pos + Vector3.UnitY * 15, World.ComponentManager, this); } if (balloon != null) { foreach (CreatureAI creature in creatures) { Matrix tf = creature.Physics.LocalTransform; tf.Translation = balloon.LocalTransform.Translation; creature.Physics.LocalTransform = tf; } } else { if (Economy == null) { Economy = new Company(this, 1000.0m, new CompanyInformation() { Name = ParentFaction.Name }); } foreach (CreatureAI creature in envoy.Creatures) { creature.Physics.AddChild(new ResourcePack(World.ComponentManager)); creature.Physics.AddChild(new Flag(World.ComponentManager, Vector3.Up * 0.5f + Vector3.Backward * 0.25f, Economy.Information)); } } } foreach (CreatureAI creature in envoy.Creatures) { creature.Physics.AddChild(new ResourcePack(World.ComponentManager)); } envoy.DistributeGoods(); TradeEnvoys.Add(envoy); World.MakeAnnouncement(new DwarfCorp.Gui.Widgets.QueuedAnnouncement { Text = String.Format("Trade envoy from {0} has arrived!", ParentFaction.Name), ClickAction = (gui, sender) => { if (envoy.Creatures.Count > 0) { envoy.Creatures.First().ZoomToMe(); World.UserInterface.MakeWorldPopup(String.Format("Traders from {0} ({1}) have entered our territory.\nThey will try to get to our balloon port to trade with us.", ParentFaction.Name, Race.Name), envoy.Creatures.First().Physics, -10); } }, ShouldKeep = () => { return(envoy.ExpiditionState == Expedition.State.Arriving); } }); SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_positive_generic, 0.15f); World.Tutorial("trade"); if (!String.IsNullOrEmpty(Race.TradeMusic)) { SoundManager.PlayMusic(Race.TradeMusic); } return(envoy); }