123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using System.Text.RegularExpressions;
- using System.Collections;
- using System;
- using FairyGUI;
- using UnityEngine;
- namespace GFGGame
- {
- public class StoryUtil
- {
- public static ArrayList GetLettersList(string words)
- {
- Regex regex = new Regex("\\u005Bcolor.*?/color]");
- MatchCollection mc = regex.Matches(words);
- string[] splitResult = regex.Split(words);
- ArrayList colorList = HandleColorTextList(mc);
- ArrayList result = new ArrayList();
- for(int i = 0; i < splitResult.Length; i++)
- {
- string text = splitResult[i];
- char[] charArr = text.ToCharArray();
- foreach(char a in charArr)
- {
- result.Add(a.ToString());
- }
- if(i < colorList.Count)
- {
- string[] colorTextArr = (string[])colorList[i];
- foreach(string b in colorTextArr)
- {
- result.Add(b);
- }
- }
- }
- return result;
- }
-
- private static ArrayList HandleColorTextList(MatchCollection mc)
- {
- ArrayList colorList = new ArrayList();
- for(int i = 0; i < mc.Count; i++)
- {
- Match m = mc[i];
- string[] result = HandleColorText(m);
- colorList.Add(result);
- }
- return colorList;
- }
- private static string[] HandleColorText(Match m)
- {
- string value = m.Value;
- Regex regexColor = new Regex("\\u005B.*?]");
- string text = regexColor.Replace(value, "");
- string[] result = new string[text.Length];
- Regex regexText = new Regex(text);
- string colorTemp = regexText.Replace(value, "xx");
- Regex regexLetter = new Regex("xx");
- for(int i = 0; i < text.Length; i++)
- {
- string letter = text.Substring(i, 1);
- string colorLetter = regexLetter.Replace(colorTemp, letter);
- result[i] = colorLetter;
- }
- return result;
- }
- public static string GetChapterOrderText(int chapterID)
- {
- int order = GetNormalChapterId(chapterID);
- return "第" + NumberUtil.GetChiniseNumberText(order) + "章";
- }
- /// <summary>
- /// 获得章节显示的序号
- /// </summary>
- /// <param name="chapterId"></param>
- /// <returns></returns>
- public static int GetNormalChapterId(int chapterId)
- {
- if(CalculateHelper.CheckChapterIsHard(chapterId))
- {
- return chapterId - GameConst.START_ID_OF_HARD;
- }
- return chapterId;
- }
- public static void UpdateStar(int starCount, GComponent component)
- {
- if(component != null)
- {
- int num = component.numChildren;
- for(int i = 1; i <= 3; i++)
- {
- GObject obj = component.GetChild("f" +i);
- if(obj != null)
- {
- obj.visible = i <= starCount;
- }
- }
- }
- }
- }
- }
|