public static void BuildAllComponents(List <Body> components, Room room, ParticleManager particles) { foreach (Body createdComponent in components) { Vector3 endPos = createdComponent.LocalTransform.Translation; Matrix offsetTransform = createdComponent.LocalTransform; offsetTransform.Translation += new Vector3(0, -1, 0); createdComponent.LocalTransform = offsetTransform; createdComponent.AnimationQueue.Add(new EaseMotion(0.8f, offsetTransform, endPos)); room.AddBody(createdComponent); particles.Trigger("puff", endPos + new Vector3(0.5f, 0.5f, 0.5f), Color.White, 10); createdComponent.SetFlagRecursive(GameComponent.Flag.Active, true); } }
public void HireImmediately(Applicant currentApplicant) { var rooms = EnumerateZones().Where(room => room.Type.Name == "Balloon Port").ToList(); if (rooms.Count == 0) // No balloon port - okay, just... pick a damn room. { rooms = EnumerateZones().ToList(); } Vector3 spawnLoc = Renderer.Camera.Position; if (rooms.Count > 0) { spawnLoc = rooms.First().GetBoundingBox().Center() + Vector3.UnitY; } var spawnOffset = MathFunctions.RandVector2Circle(); spawnLoc += new Vector3(spawnOffset.X, 0.0f, spawnOffset.Y); var dwarfPhysics = DwarfFactory.GenerateDwarf( spawnLoc, ComponentManager, currentApplicant.ClassName, currentApplicant.LevelIndex, currentApplicant.Gender, currentApplicant.RandomSeed); ComponentManager.RootComponent.AddChild(dwarfPhysics); var newMinion = dwarfPhysics.EnumerateAll().OfType <Dwarf>().FirstOrDefault(); Debug.Assert(newMinion != null); newMinion.Stats.AllowedTasks = currentApplicant.Class.Actions; newMinion.Stats.LevelIndex = currentApplicant.LevelIndex - 1; newMinion.Stats.LevelUp(newMinion); newMinion.Stats.FullName = currentApplicant.Name; newMinion.AI.AddMoney(currentApplicant.Level.Pay * 4m); newMinion.AI.Biography = currentApplicant.Biography; MakeAnnouncement( new Gui.Widgets.QueuedAnnouncement { Text = String.Format("{0} was hired as a {1}.", currentApplicant.Name, currentApplicant.Level.Name), ClickAction = (gui, sender) => newMinion.AI.ZoomToMe() }); ParticleManager.Trigger("dwarf_puff", spawnLoc, Color.DarkViolet, 90); SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_positive_generic, 0.15f); }