public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); //Version 0 if (version >= 0) { Charges = reader.ReadInt(); LastSearchMode = (SearchModeType)reader.ReadInt(); LastSearchLength = (SearchLengthType)reader.ReadInt(); } }
public void StartSearch(PlayerMobile player, SearchModeType searchMode, SearchLengthType searchLength) { player.SendMessage("You begin searching."); int searchIntervals = 1; double intervalDuration = 5; player.BeginAction(typeof(Spyglass)); switch (searchLength) { case SearchLengthType.Short: NextUsageAllowed = DateTime.UtcNow + TimeSpan.FromSeconds(5); searchIntervals = 1; break; case SearchLengthType.Medium: NextUsageAllowed = DateTime.UtcNow + TimeSpan.FromSeconds(15); searchIntervals = 3; break; case SearchLengthType.Long: NextUsageAllowed = DateTime.UtcNow + TimeSpan.FromSeconds(30); searchIntervals = 6; break; } for (int a = 0; a < searchIntervals; a++) { if (a == 0) { if (player.NetState != null) { player.PrivateOverheadMessage(MessageType.Regular, player.SpeechHue, false, "*begins scanning the horizon*", player.NetState); } } else { Timer.DelayCall(TimeSpan.FromSeconds(a * intervalDuration), delegate { if (player != null) { if (player.NetState != null) { player.PrivateOverheadMessage(MessageType.Regular, player.SpeechHue, false, "*continues scanning*", player.NetState); } } }); } } Timer.DelayCall(TimeSpan.FromSeconds(searchIntervals * intervalDuration), delegate { if (player == null) { return; } player.EndAction(typeof(Spyglass)); switch (searchMode) { case SearchModeType.Ships: player.Say("Ships"); break; case SearchModeType.Shipwrecks: player.Say("Shipwrecks"); break; case SearchModeType.SchoolsOfFish: player.Say("SchoolsOfFish"); break; } }); Charges--; if (Charges <= 0) { Delete(); } }