/// <summary> /// Set the index of a current dialog session. This dialog should be either the previous or next dialog /// from the last one (index wise) and the player must be in a dialog. /// </summary> /// /// <param name="target">The target merchant.</param> /// <param name="pursuitId">A dialog sequence (pursuit) ID.</param> /// <param name="newIndex">The index to which we are navigating.</param> /// <returns></returns> public bool SetDialogIndex(VisibleObject target, int pursuitId, int newIndex) { // Sanity checking if (target != Associate || pursuitId != CurrentPursuitId || target.Map.Id != User.Map.Id || !InDialog) { Logger.DebugFormat("{0}: Failed check", User.Name); return(false); } if (newIndex == (ActiveDialog.Index + 1) && newIndex != ActiveDialogSequence.Dialogs.Count() && newIndex < (ActiveDialogSequence.Dialogs.Count())) { // Next Logger.DebugFormat("Advancing one dialog"); ActiveDialog = ActiveDialogSequence.Dialogs[ActiveDialog.Index + 1]; Logger.DebugFormat("Active dialog is type {0}", ActiveDialog.GetType()); return(true); } else if (newIndex == (ActiveDialog.Index - 1) && newIndex >= 0) { // Previous Logger.DebugFormat("Rewinding one dialog"); ActiveDialog = ActiveDialogSequence.Dialogs[ActiveDialog.Index - 1]; return(true); } return(false); }
/// <summary> /// Set the index of a current dialog session. This dialog should be either the previous or next dialog /// from the last one (index wise) and the player must be in a dialog. /// </summary> /// /// <param name="target">The target merchant.</param> /// <param name="pursuitId">A dialog sequence (pursuit) ID.</param> /// <param name="newIndex">The index to which we are navigating.</param> /// <returns></returns> public bool SetDialogIndex(VisibleObject target, int pursuitId, int newIndex) { // Sanity checking if (target != null && (target != Associate || pursuitId != CurrentPursuitId || target.Map.Id != User.Map.Id || !InDialog)) { Log.Error("{Username}: Failed dialog sanity check: target {target}, current pursuit {cpid}, pursuit {pid}, index {index}, target map {targetmap}, user map {usermap}, indialog {dialog}", User.Name, target.Name, CurrentPursuitId, pursuitId, newIndex, target.Map.Id, User.Map.Id, InDialog); return(false); } if (target == null && pursuitId > Constants.DIALOG_SEQUENCE_SHARED) { Log.Error("{Username}: dialog associate is null but pursuitId is associate-specific"); return(false); } if (newIndex == (ActiveDialog.Index + 1) && newIndex != ActiveDialogSequence.Dialogs.Count() && newIndex < (ActiveDialogSequence.Dialogs.Count())) { // Next Log.Debug("Advancing one dialog"); ActiveDialog = ActiveDialogSequence.Dialogs[ActiveDialog.Index + 1]; Log.Debug("Active dialog is type {Type}", ActiveDialog.GetType()); return(true); } else if (newIndex == (ActiveDialog.Index - 1) && newIndex >= 0) { // Previous Log.Debug("Rewinding one dialog"); ActiveDialog = ActiveDialogSequence.Dialogs[ActiveDialog.Index - 1]; return(true); } return(false); }