Advertisement
Guest User

Vorspire

a guest
Jul 7th, 2009
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.59 KB | None | 0 0
  1. #define RUNUO_2 //Comment this out to enable RunUO 1.0 Mode
  2.  
  3. using System;
  4. using System.Collections;
  5.  
  6. #if(RUNUO_2)
  7. using System.Collections.Generic;
  8. #endif
  9.  
  10. using Server;
  11. using Server.Mobiles;
  12. using Server.Network;
  13.  
  14. namespace Server.Touring
  15. {
  16.     public static partial class Tour
  17.     {
  18. #if(RUNUO_2)
  19.         private static List<Destination> m_Destinations = new List<Destination>();
  20.         private static Dictionary<Mobile, int> m_Stages = new Dictionary<Mobile, int>();
  21.         private static Dictionary<Mobile, Destination> m_StartLocations = new Dictionary<Mobile, Destination>();
  22.         private static Dictionary<Destination, TourGuide> m_GuideLocations = new Dictionary<Destination, TourGuide>();
  23.  
  24.         public static List<Destination> Destinations { get { return m_Destinations; } }
  25.         public static Dictionary<Mobile, int> Stages { get { return m_Stages; } }
  26.         public static Dictionary<Mobile, Destination> StartLocations { get { return m_StartLocations; } }
  27.         public static Dictionary<Destination, TourGuide> GuideLocations { get { return m_GuideLocations; } }
  28. #else
  29.         private static ArrayList m_Destinations = new ArrayList();
  30.         private static Hashtable m_Stages = new Hashtable();
  31.         private static Hashtable m_StartLocations = new Hashtable();
  32.         private static Hashtable m_GuideLocations = new Hashtable();
  33.  
  34.         public static ArrayList Destinations { get { return m_Destinations; } }
  35.         public static Hashtable Stages { get { return m_Stages; } }
  36.         public static Hashtable StartLocations { get { return m_StartLocations; } }
  37.         public static Hashtable GuideLocations { get { return m_GuideLocations; } }
  38. #endif
  39.  
  40.         public static void Start(Mobile m)
  41.         {
  42.             if (m == null || m.Deleted)
  43.                 return;
  44.  
  45.             if (m_Stages.ContainsKey(m))
  46.                 m_Stages.Remove(m);
  47.  
  48.             if (m_StartLocations.ContainsKey(m))
  49.                 m_StartLocations.Remove(m);
  50.  
  51.             m_Stages.Add(m, 0);
  52.             m_StartLocations.Add(m, new Destination(m.Map, m.Location, m.Region == null ? "Home" : m.Region.Name, "You have been sent back to your original location.", TimeSpan.Zero));
  53.  
  54.             m.SendMessage(0x55, "Welcome to the tour, sit back, relax and enjoy the ride...");
  55.             m.SendMessage(0x55, "The tour will begin in 5 seconds.");
  56.  
  57.             Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerStateCallback(NextDestination), new object[] { m });
  58.         }
  59.  
  60.         public static void Finish(Mobile m)
  61.         {
  62.             if (m == null || m.Deleted)
  63.                 return;
  64.  
  65.             if (m_Stages.ContainsKey(m))
  66.                 m_Stages.Remove(m);
  67.  
  68.             if (m_StartLocations.ContainsKey(m))
  69.             {
  70.                 Destination startDest = (Destination)m_StartLocations[m];
  71.                 startDest.DoTeleport(m);
  72.  
  73.                 m_StartLocations.Remove(m);
  74.             }
  75.  
  76.             m.SendMessage(0x55, "We hope you enjoyed the tour!");
  77.  
  78.             m.Frozen = false;
  79.             m.Blessed = false;
  80.         }
  81.  
  82.         private static void NextDestination(object state)
  83.         {
  84.             object[] states = (object[])state;
  85.             Mobile m = (Mobile)states[0];
  86.  
  87.             if (m == null || m.Deleted)
  88.                 return;
  89.  
  90.             if (m_Stages.ContainsKey(m))
  91.             {
  92.                 int curStage = (int)m_Stages[m];
  93.  
  94.                 if (curStage >= m_Destinations.Count)
  95.                 {
  96.                     Tour.Finish(m);
  97.                     return;
  98.                 }
  99.  
  100.                 Destination dest = (Destination)m_Destinations[curStage];
  101.  
  102.                 if (dest.IsValid())
  103.                     dest.DoTeleport(m);
  104.  
  105.                 m_Stages[m] = (int)m_Stages[m] + 1;
  106.             }
  107.         }
  108.  
  109.         public static TourGuide FindTourGuide(Destination dest)
  110.         {
  111.             if (dest.IsValid())
  112.             {
  113.                 if (m_GuideLocations.ContainsKey(dest))
  114.                     return (TourGuide)m_GuideLocations[dest];
  115.             }
  116.  
  117.             TourGuide guide = new TourGuide(dest);
  118.  
  119.             if (guide != null && !guide.Deleted)
  120.             {
  121.                 m_GuideLocations.Add(dest, guide);
  122.                 return guide;
  123.             }
  124.  
  125.             return null;
  126.         }
  127.     }
  128. }
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement