public static void AddDiscovery(ConstellationInfo info) { if (!DiscoveredConstellations.Contains(info.Identifier)) { DiscoveredConstellations.Add(info.Identifier); } }
public override bool OnDragDrop(Mobile m, Item dropped) { if (dropped is StarChart) { StarChart chart = (StarChart)dropped; if (chart.Constellation >= 0 && chart.Constellation < AstronomySystem.MaxConstellations) { if (String.IsNullOrEmpty(chart.ConstellationName)) { m.SendLocalizedMessage(1158751); // You must name your constellation before submitting it. } else { ConstellationInfo info = AstronomySystem.GetConstellation(chart.Constellation); if (info != null) { Gump gump = new Gump(100, 100); gump.AddBackground(0, 0, 720, 270, 0x2454); gump.AddImage(0, 0, 0x69D); gump.AddHtmlLocalized(290, 14, 418, 18, 1114513, "#1158517", 0xC63, false, false); // Willebrord the Astronomer if (info.HasBeenDiscovered) { m.SendLocalizedMessage(1158764); // That constellation name has already been chosen, please choose another and resubmit your star chart. gump.AddHtmlLocalized(290, 51, 418, 209, 1158530, 0xC63, false, true); // Sorry to say that constellation has already been discovered! Fix your eyes to the heavens and keep up the searc } else { gump.AddHtmlLocalized(290, 51, 418, 209, 1158519, 0xC63, false, true); // Wow! Would you look at that! Always amazes me how even an amateur can make such profound discoveries! // I've recorded your discovery in the ledger. Here's some items I think you have more than earned! Well done! info.DiscoveredBy = chart.ChartedBy; info.Name = chart.ConstellationName; info.DiscoveredOn = chart.ChartedOn; AstronomySystem.AddDiscovery(info); m.AddToBackpack(new RecipeScroll(465)); m.AddToBackpack(new AstronomerTitleDeed()); } m.SendGump(gump); } } } } else { SayTo(m, 1158529, 1163); // What's this? I haven't time for this! Star Charts only please! } return(false); }
private static void CreateConstellations(int amount) { var next = TimeCoordinate.FiveToEight; if (LoadedConstellations > 0) { if (Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.FiveToEight).Count() > Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.NineToEleven).Count()) { next = TimeCoordinate.NineToEleven; } else if (Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.NineToEleven).Count() > Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.Midnight).Count()) { next = TimeCoordinate.Midnight; } else if (Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.Midnight).Count() > Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.OneToFour).Count()) { next = TimeCoordinate.OneToFour; } } for (int i = 0; i < amount; i++) { int ra = 0; double dec = 0.0; do { ra = Utility.RandomMinMax(0, MaxRA); dec = Utility.RandomMinMax(0, (int)MaxDEC) + Utility.RandomList(.2, .4, .6, .8, .0); }while (CheckExists(next, ra, dec)); var info = new ConstellationInfo(next, ra, dec, ConstellationInfo.RandomStarPositions()); Constellations.Add(info); info.Identifier = Constellations.Count - 1; switch (next) { case TimeCoordinate.FiveToEight: next = TimeCoordinate.NineToEleven; break; case TimeCoordinate.NineToEleven: next = TimeCoordinate.Midnight; break; case TimeCoordinate.Midnight: next = TimeCoordinate.OneToFour; break; case TimeCoordinate.OneToFour: next = TimeCoordinate.FiveToEight; break; } } }
public static void OnSave(WorldSaveEventArgs e) { Persistence.Serialize( FilePath, writer => { writer.Write(0); writer.Write(Constellations.Count); for (var index = 0; index < Constellations.Count; index++) { ConstellationInfo info = Constellations[index]; info.Serialize(writer); } }); }
public override void AddGumpLayout() { AddPage(0); AddBackground(0, 0, 820, 620, 0x2454); AddHtmlLocalized(10, 28, 800, 18, 1114513, "#1158520", 0x0, false, false); // Constellation Ledger AddHtmlLocalized(295, 55, 515, 36, 1158521, String.Format("{0}\t{1}", AstronomySystem.DiscoveredConstellations.Count, AstronomySystem.MaxConstellations), 0x0, false, false); // Constellations Discovered: ~1_VAL~ / ~2_VAL~ AddHtmlLocalized(55, 100, 100, 36, 1114513, "#1158522", 0x0, false, false); // Constellation Name AddHtmlLocalized(245, 100, 80, 36, 1114513, "#1158523", 0x0, false, false); // Astronomer AddHtmlLocalized(375, 100, 80, 36, 1114513, "#1158524", 0x0, false, false); // Discovery Date AddHtmlLocalized(505, 100, 80, 36, 1114513, "#1158525", 0x0, false, false); // Night Period AddHtmlLocalized(635, 100, 80, 36, 1114513, "#1158526", 0x0, false, false); // Coordinates int start = Page * 20; int y = 145; for (int i = start; i < AstronomySystem.DiscoveredConstellations.Count && i <= start + 20; i++) { ConstellationInfo info = AstronomySystem.GetConstellation(AstronomySystem.DiscoveredConstellations[i]); AddHtml(15, y, 200, 18, Color("#0040FF", info.Name), false, false); AddHtml(240, y, 112, 18, Color("#0040FF", info.DiscoveredBy != null ? info.DiscoveredBy.Name : "Unknown"), false, false); AddHtml(380, y, 112, 18, Color("#0040FF", info.DiscoveredOn.ToShortDateString()), false, false); AddHtmlLocalized(492, y, 130, 18, AstronomySystem.TimeCoordinateLocalization(info.TimeCoordinate), 0x1F, false, false); AddHtmlLocalized(632, y, 150, 18, 1158527, String.Format("{0}\t{1}", info.CoordRA, info.CoordDEC), 0x1F, false, false); // RA ~1_VAL~ DEC ~2_VAL~ y += 18; } AddButton(340, 540, 0x605, 0x606, 1, GumpButtonType.Reply, 0); AddButton(370, 540, 0x609, 0x60A, 2, GumpButtonType.Reply, 0); AddButton(460, 540, 0x607, 0x608, 3, GumpButtonType.Reply, 0); AddButton(484, 540, 0x603, 0x604, 4, GumpButtonType.Reply, 0); AddLabel(415, 570, 0, String.Format("{0}/{1}", Page + 1, Pages.ToString())); }
private static void CreateConstellations(int amount) { TimeCoordinate next = TimeCoordinate.FiveToEight; if (LoadedConstellations > 0) { int count = 0; for (var index = 0; index < Constellations.Count; index++) { var c = Constellations[index]; if (c.TimeCoordinate == TimeCoordinate.NineToEleven) { count++; } } int count1 = 0; for (var index = 0; index < Constellations.Count; index++) { var c = Constellations[index]; if (c.TimeCoordinate == TimeCoordinate.FiveToEight) { count1++; } } if (count1 > count) { next = TimeCoordinate.NineToEleven; } else { int count2 = 0; for (var index = 0; index < Constellations.Count; index++) { var c = Constellations[index]; if (c.TimeCoordinate == TimeCoordinate.Midnight) { count2++; } } int count3 = 0; for (var index = 0; index < Constellations.Count; index++) { var c = Constellations[index]; if (c.TimeCoordinate == TimeCoordinate.NineToEleven) { count3++; } } if (count3 > count2) { next = TimeCoordinate.Midnight; } else { int count4 = 0; for (var index = 0; index < Constellations.Count; index++) { var c = Constellations[index]; if (c.TimeCoordinate == TimeCoordinate.OneToFour) { count4++; } } int count5 = 0; for (var index = 0; index < Constellations.Count; index++) { var c = Constellations[index]; if (c.TimeCoordinate == TimeCoordinate.Midnight) { count5++; } } if (count5 > count4) { next = TimeCoordinate.OneToFour; } } } } for (int i = 0; i < amount; i++) { int ra = 0; double dec = 0.0; do { ra = Utility.RandomMinMax(0, MaxRA); dec = Utility.RandomMinMax(0, (int)MaxDEC) + Utility.RandomList(.2, .4, .6, .8, .0); }while (CheckExists(next, ra, dec)); ConstellationInfo info = new ConstellationInfo(next, ra, dec, ConstellationInfo.RandomStarPositions()); Constellations.Add(info); info.Identifier = Constellations.Count - 1; switch (next) { case TimeCoordinate.FiveToEight: next = TimeCoordinate.NineToEleven; break; case TimeCoordinate.NineToEleven: next = TimeCoordinate.Midnight; break; case TimeCoordinate.Midnight: next = TimeCoordinate.OneToFour; break; case TimeCoordinate.OneToFour: next = TimeCoordinate.FiveToEight; break; } } }