| using System; | 
| using System.Collections; | 
| using System.Collections.Generic; | 
| using System.Text.RegularExpressions; | 
| using UnityEngine; | 
| public class WordAnalysis : TRichAnalysis<WordAnalysis> | 
| { | 
|     public static Regex Word_Regex = new Regex(@"<Word (.*?)/>", RegexOptions.Singleline); | 
|   | 
|     public static Regex Color_Start_Regex = new Regex(@"<color=#[0-9a-zA-Z]+>", RegexOptions.Singleline); | 
|     public static Regex Color_End_Regex = new Regex(@"</color>", RegexOptions.Singleline); | 
|     public static Regex Space_Regex = new Regex(@"<Space=([0-9]*)>", RegexOptions.Singleline); | 
|     public static Regex Size_Start_Regex = new Regex(@"<[Ss]ize=([0-9]+)>", RegexOptions.Singleline); | 
|     public static Regex Size_End_Regex = new Regex(@"</[Ss]ize>", RegexOptions.Singleline); | 
|   | 
|     private static RichTextEventEnum eventType = RichTextEventEnum.TABLE; | 
|   | 
|     private static int presentColor = 0; | 
|     private static bool hasColor = false; | 
|   | 
|     public override string Analysis(string val, bool IsRich) | 
|     { | 
|         if (!Word_Regex.IsMatch(val)) | 
|         { | 
|             return val; | 
|         } | 
|         int index = 0; | 
|         m_StringBuilder.Length = 0; | 
|         foreach (Match match in Word_Regex.Matches(val)) | 
|         { | 
|             m_StringBuilder.Append(val.Substring(index, match.Index - index)); | 
|             AnalysisSplitEvent(match.Groups[1].Value); | 
|             index = match.Index + match.Length; | 
|         } | 
|         m_StringBuilder.Append(val.Substring(index, val.Length - index)); | 
|         return m_StringBuilder.ToString(); | 
|     } | 
|   | 
|     public override string CalculateTextIndex(string val, int index) | 
|     { | 
|         return string.Empty; | 
|     } | 
|   | 
|     private void AnalysisSplitEvent(string val) | 
|     { | 
|         string[] array = GetSplitEvent(val); | 
|         if (array.Length > 0) | 
|         { | 
|             foreach (var split_event in array) | 
|             { | 
|                 AnalysisSplitData(split_event); | 
|             } | 
|         } | 
|     } | 
|   | 
|     private void AnalysisSplitData(string val) | 
|     { | 
|   | 
|         string[] array = GetSplitData(val); | 
|         if (array.Length > 0) | 
|         { | 
|             bool hasAnalysis = true; | 
|             hasColor = false; | 
|             displayDic.Clear(); | 
|             string result = string.Empty; | 
|             foreach (var split_data in array) | 
|             { | 
|                 hasAnalysis = AnalysisSplitValue(split_data, ref result) && hasAnalysis; | 
|             } | 
|             if (hasAnalysis) | 
|             { | 
|                 result = RichTextMgr.Inst.GetDisplay(eventType, displayDic); | 
|             } | 
|             if (hasColor) | 
|             { | 
|                 var text = RichTextMgr.Inst.presentRichText; | 
|                 int colorType = 0; | 
|                 if (text != null) | 
|                 { | 
|                     colorType = text.colorType == RichText.ColorType.Dark ? 0 : 1; | 
|                 } | 
|                 result = Color_Start_Regex.Replace(result, string.Empty); | 
|                 result = Color_End_Regex.Replace(result, string.Empty); | 
|                 result = UIHelper.AppendColor(presentColor, result, colorType == 1); | 
|             } | 
|             m_StringBuilder.Append(result); | 
|         } | 
|   | 
|     } | 
|   | 
|     private bool AnalysisSplitValue(string val, ref string result) | 
|     { | 
|         string[] array = GetSplitValue(val); | 
|         if (array.Length == 2) | 
|         { | 
|             string split_value = array[0].ToLower(); | 
|             switch (split_value) | 
|             { | 
|                 case "info": | 
|                     { | 
|                         eventType = RichTextEventEnum.TABLE; | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                     } | 
|                     break; | 
|                 case "show": | 
|                     { | 
|                         if (array[1].ToLower() == "null") | 
|                         { | 
|                             result = Language.Get("Market_Text_33"); | 
|                         } | 
|                         else | 
|                         { | 
|                             result = array[1]; | 
|                         } | 
|                         return false; | 
|                     } | 
|                 case "color": | 
|                     { | 
|                         presentColor = int.Parse(array[1]); | 
|                         hasColor = true; | 
|                     } | 
|                     break; | 
|                 case "exp": | 
|                     { | 
|                         ulong _exp = 0; | 
|                         ulong.TryParse(array[1], out _exp); | 
|                         result = UIHelper.ReplaceLargeNum(_exp); | 
|                         return false; | 
|                     } | 
|                 case "time": | 
|                     { | 
|                         int _time = 0; | 
|                         int.TryParse(array[1], out _time); | 
|                         result = TimeUtility.SecondsToDHMSCHS(_time / 1000); | 
|                         return false; | 
|                     } | 
|                 case "chatsend": | 
|                     { | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                     } | 
|                     break; | 
|                 case "count": | 
|                     { | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                     } | 
|                     break; | 
|                 case "ancientrobotname": | 
|                     { | 
|                         eventType = RichTextEventEnum.AncientRobotName; | 
|                     } | 
|                     break; | 
|                 case "myfightpoint": | 
|                     { | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                         eventType = RichTextEventEnum.MyFightPoint; | 
|                     } | 
|                     break; | 
|                 case "myreikiroot": | 
|                     { | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                         eventType = RichTextEventEnum.MyReikiRoot; | 
|                     } | 
|                     break; | 
|                 case "mydefense": | 
|                     { | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                         eventType = RichTextEventEnum.MyDefense; | 
|                     } | 
|                     break; | 
|                 case "joblabel": | 
|                     { | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                         eventType = RichTextEventEnum.JobLabel; | 
|                     } | 
|                     break; | 
|                 case "blsos": | 
|                     { | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                         eventType = RichTextEventEnum.BLSOS; | 
|                     } | 
|                     break; | 
|                 case "gszd": | 
|                     { | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                         eventType = RichTextEventEnum.GSZD; | 
|                     } | 
|                     break; | 
|                 case "copy": | 
|                     { | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                         eventType = RichTextEventEnum.COPY; | 
|                     } | 
|                     break; | 
|                 case "serveridrangeinfo": | 
|                     { | 
|                         displayDic.Add(split_value, array[1].ToLower()); | 
|                         eventType = RichTextEventEnum.XJDHServerIDRangeInfo; | 
|                     } | 
|                     break; | 
|                 default: | 
|                     { | 
|                         displayDic.Add(split_value, array[1]); | 
|                     } | 
|                     break; | 
|             } | 
|             return true; | 
|         } | 
|         else | 
|         { | 
|             m_StringBuilder.Append(array[0]); | 
|             return false; | 
|         } | 
|     } | 
|   | 
|     public string ReplaceSpace(string val) | 
|     { | 
|         m_StringBuilder.Length = 0; | 
|         if (!Space_Regex.IsMatch(val)) | 
|         { | 
|             return val; | 
|         } | 
|         int index = 0; | 
|         foreach (Match match in Space_Regex.Matches(val)) | 
|         { | 
|             m_StringBuilder.Append(val.Substring(index, match.Index - index)); | 
|             int spaceCnt = 0; | 
|             if (int.TryParse(match.Groups[1].Value, out spaceCnt)) | 
|             { | 
|                 if (spaceCnt != 0) | 
|                 { | 
|                     for (int i = 0; i < spaceCnt; i++) | 
|                     { | 
|                         m_StringBuilder.Append(UIHelper.no_breaking_space); | 
|                     } | 
|                 } | 
|             } | 
|             index = match.Index + match.Length; | 
|         } | 
|         m_StringBuilder.Append(val.Substring(index, val.Length - index)); | 
|         return m_StringBuilder.ToString(); | 
|     } | 
| } |