public Dialog(List<Conversation> conversations, Entity owner, int cooldown = 2000) : base() { _enter = new EventHandler(OnEnter); _conversations = new List<Conversation>(); foreach(Conversation con in conversations) { _conversations.Add(con.Clone()); } _dm = DialogManager.Instance; _cm = owner.CM; _cm.AddCounter(_cShutdown); _cm.Bang += new EventHandler<BangEventArgs>(OnBang); _currentCon = _conversations.First().GetIterator(); this._owner = owner; Cooldown = cooldown; foreach (Conversation con in _conversations) { try { con.Add(new ComboBreaker()); } catch (ConversationAlreadyFinalisedException e) { } con.SetOwner(owner); } }
public Dialog(DataRow data) { string dialogID = data["Dialog"].ToString() + "_Dialog.xml"; string path = Game1.Instance.Content.RootDirectory + "/Data"; IEnumerable<string> files = Directory.EnumerateFiles(path, dialogID, SearchOption.AllDirectories); DataSet dialogData = null; foreach (string file in files) { if (dialogData == null) { dialogData = new DataSet(); dialogData.ReadXml(file); } else { throw new Exception("More than one dialog file found for ID " + data["Dialog"].ToString()); } } List<Conversation> conversations = ReadConversations(dialogData); _enter = new EventHandler(OnEnter); _conversations = new List<Conversation>(); foreach (Conversation con in conversations) { _conversations.Add(con.Clone()); } _dm = DialogManager.Instance; _currentCon = _conversations.First().GetIterator(); Cooldown = 2000; }
/// <summary> /// Sets the new default conversation. See @class ComboBreaker for more information. /// This method should only be called by ConversationItems /// </summary> /// <param name="newDefaultID">The new default ID.</param> public void SetNewDefault(string newDefaultID, string calledByID) { Active = false; foreach (Conversation con in _conversations) { if (con.ID.Equals(newDefaultID)) { _currentCon = con.GetIterator(); return; } } throw new ConversationNotFoundException(newDefaultID, calledByID); }
public override void SetOwner(Entity owner) { _cm = owner.CM; _cm.AddCounter(_cShutdown); _cm.Bang += new EventHandler<BangEventArgs>(OnBang); _currentCon = _conversations.First().GetIterator(); this._owner = owner; foreach (Conversation con in _conversations) { try { con.Add(new ComboBreaker()); } catch (ConversationAlreadyFinalisedException e) { } con.SetOwner(owner); } }