Esempio n. 1
0
 /// <summary>
 /// 开始记录
 /// </summary>
 public static void BeginCache <T>(ulong _markID = 0, int _eCombatType = 0, ulong[] _userIds = null) where T : CacheFile, new()
 {
     curCacheFile = new T
     {
         BattleID    = _markID,
         eCombatType = _eCombatType,
         UserIDs     = _userIds,
         dateTime    = DateTime.Now.ToString(CultureInfo.CurrentCulture),
         //recList = new List<CacheRec>()
     };
 }
Esempio n. 2
0
        public static void SaveCache2File(CacheFile _cache)
        {
#if UNITY_EDITOR
            string savePath = Application.streamingAssetsPath + "/rec.btf";
#else
            string savePath = Application.StartupPath + "/rec.btf";;
#endif
            using (var _fs = new FileStream(savePath, FileMode.Create))
            {
                BoisSerializer.Initialize <CacheFile>();
                var _serializer = new BoisSerializer();
                _serializer.Serialize <CacheFile>(_cache, _fs);
                _fs.Close();
            }
        }
Esempio n. 3
0
        public static string ShowRec(CacheFile _recFile)
        {
            StringBuilder _sBuilder = new StringBuilder();

            _sBuilder.AppendLine($"战场ID:{_recFile.BattleID}");
            _sBuilder.AppendLine($"战场类型:{_recFile.eCombatType}");
            _sBuilder.AppendLine($"时间:{_recFile.dateTime}");
            if (_recFile.UserIDs != null && _recFile.UserIDs.Length > 1)
            {
                _sBuilder.AppendLine($"发起者ID:{_recFile.UserIDs[0]}, 被攻击者:{_recFile.UserIDs[1]}");
            }

            for (offsetIdx = 0; offsetIdx < _recFile.recList.Count; offsetIdx++)
            {
                CacheRec _rec = _recFile.recList[offsetIdx];
                if (rule.MsgTypes.Count <= _rec.actionType)
                {
                    continue;
                }
                //先识别消息类型
                var _name = rule.MsgTypes[_rec.actionType];
                _sBuilder.Append("【bFps:").Append(_rec.bFps).Append("->");
                _sBuilder.Append("eFps:").Append(_rec.eFps).Append("】  ");
                if (rule.rules.TryGetValue(_name, out var _ruleUnit))
                {
                    var _dic = new Dictionary <string, object>();
                    for (var i = 0; i < _rec.recUnits.Count; i++)
                    {
                        if (i >= _ruleUnit.units.Count)
                        {
                            continue;
                        }
                        //var _value = _rec.recUnits[i].value;

                        var _value = _rec.recUnits[i];
                        if (_ruleUnit.units[i].StartsWith("E_"))
                        {
                            //认为是枚举
                            if (rule.enumDescribes.TryGetValue(_ruleUnit.units[i], out var _list))
                            {
                                if (int.TryParse(_value.ToString(), out var _enumIdx) && _list.Count > _enumIdx)
                                {
                                    if (_dic.ContainsKey(_ruleUnit.units[i]))
                                    {
                                        throw new System.Exception($"{_name}消息中已存在{_ruleUnit.units[i]}key,同一key不可以使用多次!");
                                    }
                                    _dic.Add(_ruleUnit.units[i], _list[_enumIdx]);
                                    continue;
                                }
                            }
                        }
                        if (_dic.ContainsKey(_ruleUnit.units[i]))
                        {
                            throw new System.Exception($"{_name}消息中已存在{_ruleUnit.units[i]}key,同一key不可以使用多次!");
                        }
                        _dic.Add(_ruleUnit.units[i], _value);
                    }

                    var _describe = _ruleUnit.describe;
                    int _idx      = 0;
                    foreach (var _d in _dic)
                    {
                        var _colStr = "#FF0000";
                        if (colorList.Count > _idx)
                        {
                            _colStr = colorList[_idx];
                        }
                        //_describe = _describe.Replace($"[{_d.Key}]", $"<color={_colStr}>{_d.Value}</color>");
                        _describe = _describe.Replace($"[{_d.Key}]", $"{_d.Value}");
                        _idx++;
                    }

                    _sBuilder.AppendLine(_describe);
                }
            }

            return(_sBuilder.ToString());
        }