public ForestState() : base("Forest") { #region Nav Mesh var p1 = new Polygon( new Vector2(111, 233), new Vector2(339, 304), new Vector2(316, 367), new Vector2(71, 259)); var p2 = new Polygon( new Vector2(316, 367), new Vector2(240, 449), new Vector2(160, 414), new Vector2(242, 336)); var p3 = new Polygon( new Vector2(293, 390), new Vector2(241, 446), new Vector2(492, 555), new Vector2(515, 490)); var p4 = new Polygon( new Vector2(515, 490), new Vector2(770, 488), new Vector2 (715, 558), new Vector2(492, 555)); var p5 = new Polygon ( new Vector2 (714, 560), new Vector2 (828, 380), new Vector2 (928, 380), new Vector2 (929, 542), new Vector2 (866, 653)); var p6 = new Polygon ( new Vector2 (928, 541), new Vector2 (2032, 502), new Vector2 (2026, 702), new Vector2 (866, 653)); var p1n = new PolyNode(p1); var p2n = new PolyNode(p2); var p3n = new PolyNode(p3); var p4n = new PolyNode(p4); var p5n = new PolyNode(p5); var p6n = new PolyNode(p6); PolyLink.AttachLinks(277, 350, ref p1n, ref p2n); PolyLink.AttachLinks(268, 414, ref p2n, ref p3n); PolyLink.AttachLinks(505, 521, ref p3n, ref p4n); PolyLink.AttachLinks (744, 514, ref p4n, ref p5n); PolyLink.AttachLinks (891, 581, ref p5n, ref p6n); Nav = new List<PolyNode> { p1n, p2n, p3n, p4n, p5n, p6n }; #endregion Background = G.C.Load<Texture2D> ("ForestArea/background"); Foreground = G.C.Load<Texture2D> ("ForestArea/foreground"); light = new RenderTarget2D(G.Graphics.GraphicsDevice, G.SCREEN_WIDTH, G.SCREEN_HEIGHT, false, SurfaceFormat.Color, DepthFormat.None); Flashlight = CreateSprite("ForestArea/flashlight_beam"); Lightmask = new Sprite { IsVisible = true, Texture = light, }; pixel = new Texture2D(G.Graphics.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); pixel.SetData<Color>(new Color[] {Color.White}); Shoe = CreateItem ("Sarah's Shoe", "", "ForestArea/shoe", "UI/Icons/shoe", 326, 467, new Rectagon (0, 0, 53, 35).Vertices.ToArray ()); Branch = CreateItem ("Bloody Broken Branch", "", "ForestArea/branch", "UI/Icons/branch", 784, 410, new Vector2 (815 - 784, 383 - 410), new Vector2 (761 - 784, 501 - 410), new Vector2 (814 - 784, 511 - 410), new Vector2 (916 - 784, 435 - 410)); ThornBush = CreateItem ("Bush of Thorns", "", "ForestArea/bush", "UI/Icons/papers", 830, 283, new Rectagon (0, 0, 53, 35).Vertices.ToArray ()); CoverBrush1 = CreateItem ("CB1", "", "ForestArea/coverbush", "UI/Icons/papers", 1230, 489, new Rectagon (0, 0, 53, 35).Vertices.ToArray ()); CoverBrush2 = CreateItem ("CB2", "", "ForestArea/coverbush", "UI/Icons/papers", 1463, 486, new Rectagon (0, 0, 53, 35).Vertices.ToArray ()); CoverBrush3 = CreateItem ("CB13", "", "ForestArea/coverbush", "UI/Icons/papers", 1666, 493, new Rectagon (0, 0, 53, 35).Vertices.ToArray ()); Branch.OnClick += s => SoundWrapper.PlayDialog ("Bloody Branch"); Shoe.IsActive = true; Shoe.CanPickup = true; Branch.IsActive = true; Branch.CanPickup = true; ThornBush.IsActive = false; ThornBush.CanPickup = false; ThornBush.IsMouseHover = false; CoverBrush1.IsActive = false; CoverBrush2.IsActive = false; CoverBrush3.IsActive = false; var exitidle = new Animation ("Idle", new[] { new Rectangle(0, 0, 200, 200), new Rectangle(200, 0, 200, 200), new Rectangle(400, 0, 200, 200), new Rectangle(600, 0, 200, 200), new Rectangle(800, 0, 200, 200) }, Looping: true); ExitLight = new AnimatedSprite (G.C.Load<Texture2D> ("ForestArea/exit_animation"), new[] { exitidle }); ExitLight._IHateRectangles = new Rectangle (0, 0, 200, 200); ExitLight.IsVisible = true; ExitLight.Location = new Vector2 (0, 0); ExitLight.AnimationManager.SetAnimation ("Idle"); ForestExit = new Hotspot ( "Tent Entrance", new Polygon ( new Vector2(4, 271), new Vector2(3, 4), new Vector2(330, 114), new Vector2(205, 258)), (t, i) => { G.LastScreen = "Forest"; G.FadeOut.Finished = () => { G.FadeOut.Reset (); G.StateManager.Set ("Camp"); G.FadeIn.TriggerStart(); }; G.FadeOut.TriggerStart(); }) { WalkLocation = new Vector2 (170, 279) }; SarahSpot = new Hotspot ( "Sarah's Body", new Polygon ( new Vector2(1545, 551), new Vector2(1839, 548), new Vector2(1871, 659), new Vector2(1552, 638)), (t, i) => { }); ShrubSpot = new Hotspot ( "Chop down thorny bushes", new Polygon ( new Vector2(938, 596), new Vector2(1021, 343), new Vector2(2046, 483), new Vector2(2036, 709)), (t, i) => { if (i != null && i.Name == "Machete") { CoverBrush1.IsVisible = false; CoverBrush2.IsVisible = false; CoverBrush3.IsVisible = false; ThornBush.IsVisible = false; ThornBush.IsActive = false; ThornBush.IsMouseHover = false; SarahSpot.IsUsable = true; ShrubSpot.IsUsable = false; G.DialogManager.PostMessage ("You chopped down the thorny bushes", TimeSpan.Zero, new TimeSpan (0, 0, 3)); foreach (var item in Items) { item.IsActive = true; } } else { G.DialogManager.PostMessage ("I need something to chop these bushes down", TimeSpan.Zero, new TimeSpan (0, 0, 3)); } }); SarahSpot.IsUsable = false; ShrubSpot.IsUsable = true; Items.Add (Shoe); Items.Add (Branch); Items.Add (ThornBush); Items.Add (CoverBrush1); Items.Add (CoverBrush2); Items.Add (CoverBrush3); Hotspots.Add (ForestExit); Hotspots.Add (ShrubSpot); Hotspots.Add (SarahSpot); }
public CampState() : base("Camp") { #region NavMesh var p1 = new Polygon ( new Vector2(151, 274), new Vector2(331, 257), new Vector2(435, 384), new Vector2(215, 392)); var p2 = new Polygon ( new Vector2(4, 416), new Vector2(215, 395), new Vector2(434, 388), new Vector2(871, 405), new Vector2(904, 714), new Vector2(2, 717)); var p3 = new Polygon ( new Vector2 (1090 - 225, 406), new Vector2 (1563 - 225, 414), new Vector2 (1573 - 225, 533), new Vector2 (1300 - 225, 715), new Vector2 (1128 - 225, 714)); var p4 = new Polygon ( new Vector2(936, 398), new Vector2(1113, 287), new Vector2(1219, 295), new Vector2(1267, 402)); var p1n = new PolyNode (p1); var p2n = new PolyNode (p2); var p3n = new PolyNode (p3); var p4n = new PolyNode (p4); PolyLink.AttachLinks (318, 391, ref p1n, ref p2n); PolyLink.AttachLinks (887, 555, ref p2n, ref p3n); PolyLink.AttachLinks (1119, 403, ref p3n, ref p4n); Nav = new List<PolyNode> { p1n, p2n, p3n, p4n, }; #endregion Background = G.C.Load<Texture2D>("CampArea/background"); Foreground = G.C.Load<Texture2D>("CampArea/foreground"); Backpack = CreateItem("Backpack", "A torn backpack", "CampArea/backpack", 734, 410, new Rectagon(0, 0, 111, 59).Vertices.ToArray()); Batteries = CreateItem("Batteries", "Your tongue hurts - they are supprisingly strong", "CampArea/batteries", "UI/Icons/batteries", 761, 480, new Rectagon(0, 0, 78, 32).Vertices.ToArray()); EmptyWineBottle = CreateItem("Empty Wine Bottle", "It's empty", "CampArea/wine1", "UI/Icons/bottle", 137, 574, new Rectagon(0, 0, 24, 81).Vertices.ToArray()); BrokenWineBottle = CreateItem("Broken Wine Bottle", "The neck of the bottle has been broken, likely due to a fall", "CampArea/wine2", "UI/Icons/bottle", 422, 615, new Rectagon(0, 0, 53, 35).Vertices.ToArray()); Papers = CreateItem("Shrededd paper", "[TODO]", "CampArea/papers", "UI/Icons/papers", 822, 457, new Rectagon(0, 0, 53, 35).Vertices.ToArray()); Boulder = CreateItem ("Boulder", "A heavy rock", "CampArea/boulder", "UI/Icons/papers", 480, 313); Machete = CreateItem ("Machete", "A knife used for cutting things down", "CampArea/machete", 560, 420, new Rectagon (0, 0, 150, 60).Vertices.ToArray()); var fireIdle = new Animation ("Idle", new[] { new Rectangle(0, 0, 450, 300), new Rectangle(450, 0, 450, 300), new Rectangle(900, 0, 450, 300), new Rectangle(1350, 0, 450, 300) }, Looping: true); FirepitAnimation = new AnimatedSprite (G.C.Load<Texture2D> ("CampArea/fire_animation"), new Animation[] { fireIdle }); FirepitAnimation._IHateRectangles = new Rectangle (0, 0, 450, 300); FirepitAnimation.IsVisible = false; FirepitAnimation.Location = new Vector2 (0, 350); FirepitAnimation.AnimationManager.SetAnimation ("Idle"); var fireflies_idle = new Animation ("Idle", new[] { new Rectangle(0, 0, 200, 200), new Rectangle(200, 0, 200, 200), new Rectangle(400, 0, 200, 200), new Rectangle(600, 0, 200, 200), new Rectangle(800, 0, 200, 200), new Rectangle(1000, 0, 200, 200), new Rectangle(1200, 0, 200, 200), new Rectangle(1400, 0, 200, 200) }, Looping: true); FliesAnimation = new AnimatedSprite (G.C.Load<Texture2D> ("CampArea/fireflies_animation"), new [] { fireflies_idle}); FliesAnimation._IHateRectangles = new Rectangle (0, 0, 200, 200); FliesAnimation.IsVisible = true; FliesAnimation.Location = new Vector2 (900, 325); FliesAnimation.AnimationManager.SetAnimation ("Idle"); Boulder.IsActive = false; Boulder.CanPickup = false; Boulder.IsMouseHover = false; Machete.IsActive = false; Machete.CanPickup = false; Machete.IsMouseHover = false; Backpack.IsActive = true; Backpack.CanPickup = false; Batteries.IsActive = false; Batteries.CanPickup = false; Batteries.IsVisible = false; Batteries.IsMouseHover = false; EmptyWineBottle.IsActive = false; EmptyWineBottle.CanPickup = true; BrokenWineBottle.IsActive = false; BrokenWineBottle.CanPickup = true; BrokenWineBottle.IsVisible= false; Papers.IsActive = false; Papers.CanPickup = false; Papers.IsVisible = false; Papers.IsMouseHover = false; FirepitLight = CreateSprite("CampArea/light map 1", 0, 0); FirepitLight.IsVisible = false; TentLight = CreateSprite("CampArea/light map 1", 0, 0); #region HotSpots TentEntrance = new Hotspot ( "Tent Entrance", new Polygon (new Vector2 (3, 277), new Vector2 (333, 247), new Vector2 (83, 107), new Vector2 (2, 107)), (t,i) => { G.LastScreen = "Camp"; G.FadeOut.Finished = () => { G.FadeOut.Reset (); G.StateManager.Set ("Tent"); G.FadeIn.TriggerStart (); }; G.C.Load<SoundEffect> ("sfx/Zipper").Play (); G.FadeOut.TriggerStart (); }) { WalkLocation = new Vector2 (170, 279) }; CampExit = new Hotspot( "Camp Exit", new Polygon( new Vector2(1087, 281), new Vector2(1075, 110), new Vector2(1277, 114), new Vector2(1268, 301)), (t,i) => { if (CanLeaveLevel) { G.FadeOut.Finished += () => { G.FadeOut.Reset (); G.StateManager.Set ("Forest"); G.FadeIn.TriggerStart (); }; G.FadeOut.TriggerStart (); } else { SoundWrapper.PlayDialog ("Too Dark"); G.DialogManager.PostQueuedMessage("It's too dark, maybe if I had a flashlight or something.", new TimeSpan (0, 0, 3)); } }) { WalkLocation = new Vector2 (1170, 298) }; Firepit = new Hotspot( "Light Fire Pit", new Polygon(new Vector2(57, 497), new Vector2(50, 465), new Vector2(184, 412), new Vector2 (307, 458), new Vector2 (290, 503), new Vector2(194, 526), new Vector2(97, 518)), (t,i) => { if (FirepitAnimation.IsVisible) return; if (i != null && i.Name == "Matches") { G.C.Load<SoundEffect> ("sfx/Match").Play(); TentLight.IsVisible = false; FirepitAnimation.IsVisible = true; G.DialogManager.PostMessage("You have used the matches", TimeSpan.Zero, new TimeSpan(0, 0, 3)); G.InventoryManager.CurrentItems.Remove("Matches"); foreach (var item in Items) { item.IsActive = true; } } else { G.DialogManager.PostMessage("I need matches to light this...", TimeSpan.Zero, new TimeSpan(0, 0, 3)); } }); BoulderSpot = new Hotspot ( "Pry Boulder up", new Polygon ( new Vector2 (485, 388), new Vector2 (555, 314), new Vector2 (626, 315), new Vector2 (676, 384), new Vector2 (673, 431), new Vector2 (589, 474), new Vector2 (484, 441)), (t, i) => { if (i != null && i.Name == "Bloody Broken Branch") { Boulder.Location.X -= 50; BoulderSpot.IsUsable = false; Machete.IsActive = true; Machete.IsMouseHover = true; Machete.CanPickup = true; G.DialogManager.PostMessage ("You pried up the boulder with the branch", TimeSpan.Zero, new TimeSpan (0, 0, 3)); G.InventoryManager.CurrentItems.Remove ("Bloody Broken Branch"); foreach (var item in Items) { item.IsActive = true; } } else { SoundWrapper.PlayDialog ("Rock"); G.DialogManager.PostMessage ("I need something strong to pry this up", TimeSpan.Zero, new TimeSpan (0, 0, 3)); } }) { WalkLocation = new Vector2(606, 470) }; #endregion Batteries.OnClick += s => SoundWrapper.PlayDialog ("Batteries"); Papers.OnClick += s => SoundWrapper.PlayDialog ("Letter"); Backpack.OnClick += state => { Batteries.IsActive = true; Batteries.CanPickup = true; Batteries.IsVisible = true; Batteries.IsMouseHover = true; Papers.IsActive = true; Papers.CanPickup = true; Papers.IsVisible = true; Papers.IsMouseHover = true; }; GameItem.AddCraftingRecipie("Flashlight", "Batteries", () => { GameItem.ItemDictionary["Flashlight"].Description = "A flashlight, it's batteries are fully charged"; GameItem.ItemDictionary["Flashlight"].InventoryIcon = G.C.Load<Texture2D>("UI/Icons/flashlight_on"); G.InventoryManager.CurrentItems.Remove("Batteries"); // Since we're doing this manually, we have to update it manually ItemsToLeave.Remove ("Flashlight_lit"); CanLeaveLevel = (ItemsToLeave.Count == 0); }); ItemsToLeave.Add("Flashlight_lit"); Items.AddRange(new[] { Batteries, EmptyWineBottle, BrokenWineBottle, Papers, Backpack, Machete, Boulder }); Lights.AddRange(new[] { FirepitLight, TentLight }); Hotspots.AddRange(new[] { Firepit, TentEntrance, CampExit, BoulderSpot }); return; //REMOVE TentLight.IsVisible = false; FirepitAnimation.IsVisible = true; G.DialogManager.PostMessage ("You have used the matches", TimeSpan.Zero, new TimeSpan (0, 0, 3)); G.InventoryManager.CurrentItems.Remove ("Matches"); foreach (var item in Items) { item.IsActive = true; } }
public MemoryState(string name) : base(name) { Player = G.Player; Items = new List<GameItem>(); Hotspots = new List<Hotspot>(); ItemsToLeave = new List<string>(); ItemsToRemember = new List<string>(); Lights = new List<Sprite>(); Camera = new CameraSingle (G.SCREEN_WIDTH, G.SCREEN_HEIGHT); InventoryButton = new Hotspot( "Open Inventory", new Rectagon(10, 5, 18, 55), (t,i) => { G.InventoryManager.IsShown = !G.InventoryManager.IsShown; InventoryButton.Rotation = G.InventoryManager.IsShown ? -MathHelper.PiOver2 : MathHelper.PiOver2; InventoryButton.Location.Y += G.InventoryManager.IsShown ? G.InventoryManager.Bounds.Bottom + 25 : -G.InventoryManager.Bounds.Bottom - 25; InventoryButton.Name = G.InventoryManager.IsShown ? "Close Inventory" : "Open Inventory"; }) {EnforceDistance = false}; Hotspots.Add (InventoryButton); }
public TentState() : base("Tent") { Background = G.C.Load<Texture2D> ("TentArea/background"); #region NavMesh var p1 = new Polygon ( new Vector2 (106, 469), new Vector2 (152, 442), new Vector2 (420, 433), new Vector2 (777, 429), new Vector2 (1000, 443), new Vector2 (997, 480), new Vector2 (896, 594), new Vector2 (627, 646), new Vector2 (345, 644), new Vector2 (159, 605)); var p1n = new PolyNode (p1); Nav = new List<PolyNode> { p1n }; #endregion Blanket = CreateItem ("Blanket", "A warm blanket", "TentArea/blanket", 200, 500, new Vector2 (0, 41), new Vector2 (256, -6), new Vector2 (419, 91), new Vector2 (296, 153)); Flash = CreateItem ("Flashlight", "A dead flashlight, it's missing batteries", "TentArea/flashlight","UI/Icons/flashlight_off", 587, 436, new Vector2 (568 - 587, 493 - 436), new Vector2 (575 - 587, 427 - 436), new Vector2 (630 - 587, 433 - 436), new Vector2 (634 - 587, 484 - 436)); Sweater = CreateItem("Sweater", "A Sweater", "TentArea/sweater", "UI/Icons/sweater", 390, 550, new Vector2 (426 - 500, 563 - 550), new Vector2 (513 - 500, 551 - 550), new Vector2 (653 - 500, 559 - 550), new Vector2 (639 - 500, 594 - 550), new Vector2 (566 - 500, 615 - 550), new Vector2 (496 - 500, 603 - 550)); Matches = CreateItem ("Matches", "A set of matches", "TentArea/matches", "UI/Icons/matches", 850, 500, new Vector2 (830 - 850, 505 - 500), new Vector2 (892 - 850, 491 - 500), new Vector2 (905 - 850, 516 - 500), new Vector2 (844 - 850, 532 - 500)); Blanket.OnClick += t => { Blanket.IsActive = false; Blanket.Texture = G.C.Load<Texture2D> ("TentArea/tossedblanket"); Sweater.IsActive = true; G.C.Load<SoundEffect> ("sfx/Blanket").Play(); }; Sweater.OnClick += s => G.C.Load<SoundEffect> ("sfx/Sweater").Play(); Matches.OnClick += s => SoundWrapper.PlayDialog ("Matches"); Flash.OnClick += s => SoundWrapper.PlayDialog ("Flashlight"); Matches.IsActive = false; Matches.IsVisible = false; Blanket.IsActive = true; Blanket.CanPickup = false; Sweater.CanPickup = true; Flash.IsActive = true; Flash.CanPickup = true; Bag = new Hotspot ( "Duffle Bag", new Polygon ( new Vector2 (757, 443), new Vector2 (883, 417), new Vector2 (902, 489), new Vector2 (776, 507), new Vector2 (745, 483) ), (t, i) => { if (BagOpened) return; Player.AnimationManager.SetAnimation ("Kick"); Matches.IsVisible = true; Matches.IsActive = true; Matches.CanPickup = true; BagOpened = true; }) { WalkLocation = new Vector2 (740, 482) }; Exit = new Hotspot( "Tent Exit", new Polygon( new Vector2(620 + 90, 250), new Vector2(607 + 90, 373), new Vector2(575 + 90, 459), new Vector2(650 + 90, 468), new Vector2(675 + 90, 374), new Vector2(657 + 90, 299)), (t,i) => { if (CanLeaveLevel) { G.C.Load<SoundEffect> ("sfx/Zipper").Play (); G.FadeOut.Finished = () => { G.FadeOut.Reset(); G.LastScreen = "Tent"; G.StateManager.Set ("Camp"); G.FadeIn.TriggerStart(); }; G.FadeOut.TriggerStart(); } else { SoundWrapper.PlayDialog ("Cold and Dark"); G.DialogManager.PostMessage ("I should put on some clothes... and grab my flashlight.", TimeSpan.Zero, new TimeSpan (0, 0, 5)); } }) { WalkLocation = new Vector2(706, 486)}; ItemsToLeave.Add("Sweater"); ItemsToLeave.Add("Flashlight"); lantern = CreateSprite ("TentArea/lantern", 510, 89); light1 = CreateSprite ("TentArea/light1"); light2 = CreateSprite ("TentArea/light2"); glow = CreateSprite ("TentArea/lanternGlow", 370, 140); border = CreateSprite ("TentArea/border"); LanternSpot = new Hotspot("Unlit Lantern", new Circlegon(545, 315, 64), (t,i) => { if (light2.IsVisible) return; G.C.Load<SoundEffect> ("sfx/Lantern").Play(); Player.AnimationManager.SetAnimation ("Wake Up"); LanternSpot.Name = "Lit Lantern"; light1.IsVisible = false; light2.IsVisible = true; //glow.IsVisible = true; }) { WalkLocation = new Vector2 (596, 546) }; light1.IsVisible = true; light2.IsVisible = false; glow.IsVisible = false; Items.Add (Flash); Items.Add (Sweater); Items.Add (Matches); Items.Add (Blanket); Lights.Add (lantern); Lights.Add (glow); Lights.Add (border); Lights.Add (light1); Lights.Add (light2); Hotspots.Add (Exit); Hotspots.Add (LanternSpot); Hotspots.Add (Bag); }