少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
 
public class RewardAnalysis:TRichAnalysis<RewardAnalysis>
{
    public static Regex Reward_Regex = new Regex(@"<reward (.*?)/>", RegexOptions.Singleline);
 
    private static RewardInfo presentReward = null;
 
    public void GetReward(string val,ref List<RewardInfo> rewardList)
    {
        rewardList.Clear();
        if (!Reward_Regex.IsMatch(val)) {
            return;
        }
        else {
            foreach (Match match in Reward_Regex.Matches(val)) {
                RewardInfo reward = new RewardInfo();
                presentReward = reward;
                rewardList.Add(reward);
                AnalysisSplitEvent(match.Value);
                if (presentReward.info == "item") {
                    presentReward.itemCfg = ItemConfig.Get(presentReward.id);
                }
            }
        }
    }
 
    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) {
            foreach (var split_data in array) {
                AnalysisSplitValue(split_data);
            }
        }
    }
 
    private void AnalysisSplitValue(string split_data)
    {
        string[] array = GetSplitValue(split_data);
        if (array.Length == 2) {
            switch (array[0].ToLower()) {
                case "info": {
                        presentReward.info = array[1];
                    }
                    break;
                case "id": {
                        int.TryParse(array[1],out presentReward.id);
                    }
                    break;
                case "exppoint":
                    {
                        int.TryParse(array[1], out presentReward.expPoint);
                    }
                    break;
                case "num": {
                        int.TryParse(array[1], out presentReward.num);
                    }
                    break;
                case "word": {
                        presentReward.showtype = RewardShowType.Word;
                    }
                    break;
                case "image": {
                        presentReward.showtype = RewardShowType.Image;
                    }
                    break;
            }
        }
    }
 
    public override string Analysis(string val, bool IsRich)
    {
        return string.Empty;
    }
 
    public override string CalculateTextIndex(string val, int index)
    {
        return string.Empty;
    }
 
    public class RewardInfo
    {
        public string info;
        public int id=0;
        public int num=0;
        public int expPoint = 0;
 
        public ItemConfig itemCfg = null;
 
        public RewardShowType showtype = RewardShowType.Image;
    }
 
    public enum RewardShowType
    {
        Word,
        Image,
    }
}