using Snxxz.UI;
|
using System;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
public class RichTableEvent : TRichTextEvent
|
{
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel
|
{
|
get
|
{
|
return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
}
|
}
|
|
public RichTableEvent()
|
{
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.TABLE, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.SHOWITEM, this);
|
}
|
|
public override bool Execute(RichTextEventEnum type, RichTextMgr.HrefInfo href)
|
{
|
switch (type)
|
{
|
case RichTextEventEnum.SHOWITEM:
|
{
|
ItemConfig cfg = ItemConfig.Get(href.mSplits["showitem"]);
|
if (cfg != null)
|
{
|
OnSingleClickItemCell(cfg.ID, href);
|
}
|
}
|
break;
|
}
|
return false;
|
}
|
|
public override string GetDisplay(RichTextEventEnum type, Dictionary<string, string> _dict)
|
{
|
switch (type)
|
{
|
case RichTextEventEnum.TABLE:
|
{
|
if (_dict.ContainsKey("info"))
|
{
|
string info = _dict["info"];
|
switch (info)
|
{
|
case "richtextmsgreplace":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
return RichTextMsgReplaceConfig.GetRichReplace(_dict["name"], id);
|
}
|
}
|
break;
|
case "item":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
ItemConfig cfg = ItemConfig.Get(id);
|
if (cfg != null)
|
{
|
var _itemColor = cfg.ItemColor;
|
if (cfg.Type == 113)//翅膀
|
{
|
Dictionary<int, List<int>> userdatadic = null;
|
if (_dict.ContainsKey("userdata"))
|
{
|
string userdata = _dict["userdata"];
|
userdatadic = ConfigParse.Analysis(userdata);
|
_itemColor = ItemLogicUtility.Instance.GetItemQuality(cfg.ID, userdatadic);
|
}
|
}
|
var itemName = cfg.ItemName;
|
if (_dict != null && _dict.ContainsKey("chatsend"))
|
{
|
itemName = StringUtility.Contact("[", itemName, "]");
|
}
|
if (_dict != null && _dict.ContainsKey("count"))
|
{
|
var count = 0;
|
int.TryParse(_dict["count"], out count);
|
if (count > 0)
|
{
|
itemName = StringUtility.Contact(itemName, "x", count);
|
}
|
}
|
return GetTextColorByItemColor(itemName, _itemColor, _dict);
|
}
|
else
|
{
|
DebugEx.LogError(string.Format("物品表里没有ID{0}对应的物品", id));
|
}
|
}
|
}
|
break;
|
case "npc":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
NPCConfig cfg = NPCConfig.Get(id);
|
if (cfg != null)
|
{
|
return cfg.charName;
|
}
|
}
|
}
|
break;
|
case "map":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
MapConfig cfg = MapConfig.Get(id);
|
if (cfg != null)
|
{
|
return cfg.Name;
|
}
|
}
|
}
|
break;
|
case "skill":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
SkillConfig cfg = SkillConfig.Get(id);
|
if (cfg != null)
|
{
|
return cfg.SkillName;
|
}
|
}
|
}
|
break;
|
case "fairyquestion":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
QuestionBankConfig cfg = QuestionBankConfig.Get(id);
|
if (cfg != null)
|
{
|
return cfg.question;
|
}
|
}
|
}
|
break;
|
case "runetower":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
RuneTowerConfig cfg = RuneTowerConfig.Get(id);
|
if (cfg != null)
|
{
|
return cfg.TowerName;
|
}
|
}
|
}
|
break;
|
case "realm":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
RealmConfig _cfg = RealmConfig.Get(id);
|
if (_cfg != null)
|
{
|
var text = RichTextMgr.Inst.presentRichText;
|
int colorType = 0;
|
if (text != null)
|
{
|
colorType = text.colorType == RichText.ColorType.Dark ? 0 : 1;
|
}
|
return UIHelper.GetRealmName(id, colorType == 1);
|
}
|
}
|
}
|
break;
|
case "pet":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
PetInfoConfig _cfg = PetInfoConfig.Get(id);
|
if (_cfg != null)
|
{
|
return GetTextColorByItemColor(_cfg.Name, _cfg.Quality, _dict);
|
}
|
}
|
}
|
break;
|
case "alchemy":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
AlchemyConfig _cfg = AlchemyConfig.Get(id);
|
if (_cfg != null)
|
{
|
return _cfg.AlchemName;
|
}
|
}
|
}
|
break;
|
case "treasure":
|
{
|
int id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id))
|
{
|
TreasureConfig _cfg = TreasureConfig.Get(id);
|
if (_cfg != null)
|
{
|
return _cfg.Name;
|
}
|
}
|
}
|
break;
|
case "godweapon":
|
{
|
var _type = 0;
|
if (_dict.ContainsKey("type") && int.TryParse(_dict["type"], out _type))
|
{
|
var _cfg = GodWeaponConfig.GetConfig(_type, 1);
|
if (_cfg != null)
|
{
|
return _cfg.Name;
|
}
|
}
|
}
|
break;
|
case "buffdesc":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var _cfg = SkillConfig.Get(_id);
|
if (_cfg != null)
|
{
|
return _cfg.BuffDescription;
|
}
|
}
|
}
|
break;
|
case "property":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var _cfg = PlayerPropertyConfig.Get(_id);
|
if (_cfg != null)
|
{
|
return _cfg.Name;
|
}
|
}
|
}
|
break;
|
case "mount":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var _cfg = HorseConfig.Get(_id);
|
if (_cfg != null)
|
{
|
return GetTextColorByItemColor(_cfg.Name, _cfg.Quality, _dict);
|
}
|
}
|
}
|
break;
|
case "success":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var _cfg = SuccessConfig.Get(_id);
|
if (_cfg != null)
|
{
|
return _cfg.Describe;
|
}
|
}
|
}
|
break;
|
case "osredenvelope":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var _cfg = OSRedAchieveConfig.Get(_id);
|
if (_cfg != null)
|
{
|
return _cfg.typeName;
|
}
|
}
|
}
|
break;
|
case "treasureprivilege":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var _cfg = TreasurePrivilegeConfig.Get(_id);
|
if (_cfg != null)
|
{
|
return _cfg.Name;
|
}
|
}
|
}
|
break;
|
case "towernewrune":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var config = RuneTowerConfig.Get(_id + 1);
|
if (config != null)
|
{
|
var itemConfig = ItemConfig.Get(config.ProductRune);
|
return itemConfig.ItemName;
|
}
|
var towerFloor = RuneTowerFloorConfig.Get(_id * 100 + 8);
|
if (config != null)
|
{
|
var itemConfig = ItemConfig.Get(towerFloor.UnLockCompose);
|
return itemConfig.ItemName;
|
}
|
}
|
}
|
break;
|
case "runetowerfloor":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var config = RuneTowerFloorConfig.Get(_id);
|
if (config != null)
|
{
|
var towerConfig = RuneTowerConfig.Get(config.TowerId);
|
return StringUtility.Contact(towerConfig.TowerName, config.FloorName);
|
}
|
}
|
}
|
break;
|
case "coloritem":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var config = ItemConfig.Get(_id);
|
if (config != null)
|
{
|
return StringUtility.Contact(GetItemColorChs(config.ItemColor), GetTextColorByItemColor(config.ItemName, config.ItemColor, _dict));
|
}
|
}
|
}
|
break;
|
case "crossserverarena":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var text = RichTextMgr.Inst.presentRichText;
|
int colorType = 0;
|
if (text != null)
|
{
|
colorType = text.colorType == RichText.ColorType.Dark ? 0 : 1;
|
}
|
return UIHelper.AppendDanLVNameColor(_id, colorType == 1);
|
}
|
}
|
break;
|
case "jadedynastytower":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
var config = JadeDynastyTowerConfig.Get(_id);
|
if (config != null)
|
{
|
return config.floorName;
|
}
|
}
|
}
|
break;
|
case "equipsuitname":
|
{
|
var _id = 0;
|
if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id))
|
{
|
return EquipSuitConfig.GetEquipSuitName(_id);
|
}
|
}
|
break;
|
}
|
}
|
}
|
break;
|
}
|
return string.Empty;
|
}
|
|
private void OnSingleClickItemCell(int itemId, RichTextMgr.HrefInfo hrefInfo)
|
{
|
int[] stone = null;
|
if (hrefInfo.mSplits.ContainsKey("stone"))
|
{
|
try
|
{
|
stone = LitJson.JsonMapper.ToObject<int[]>(hrefInfo.mSplits["stone"]);
|
}
|
catch (Exception e)
|
{
|
DebugEx.Log(e.Message);
|
}
|
}
|
int itemCount = 0;
|
if (hrefInfo.mSplits.ContainsKey("itemcnt"))
|
{
|
itemCount = int.Parse(hrefInfo.mSplits["itemcnt"]);
|
}
|
int isBind = 0;
|
if (hrefInfo.mSplits.ContainsKey("isbind"))
|
{
|
isBind = int.Parse(hrefInfo.mSplits["isbind"]);
|
}
|
int strengthenLv = 0;
|
if (hrefInfo.mSplits.ContainsKey("strengthenlv"))
|
{
|
strengthenLv = int.Parse(hrefInfo.mSplits["strengthenlv"]);
|
}
|
int index = 0;
|
if (hrefInfo.mSplits.ContainsKey("place"))
|
{
|
index = int.Parse(hrefInfo.mSplits["place"]);
|
}
|
|
if (hrefInfo.mSplits.ContainsKey("equippartsuite")
|
&& hrefInfo.mSplits["equippartsuite"] != string.Empty)
|
{
|
LitJson.JsonData _json = null;
|
try
|
{
|
_json = LitJson.JsonMapper.ToObject(hrefInfo.mSplits["equippartsuite"]);
|
}
|
catch (Exception e)
|
{
|
DebugEx.Log(e.Message);
|
}
|
}
|
|
equipItems = null;
|
if (hrefInfo.mSplits.ContainsKey("equipitems")
|
&& hrefInfo.mSplits["equipitems"] != string.Empty)
|
{
|
try
|
{
|
equipItems = LitJson.JsonMapper.ToObject<int[][]>(hrefInfo.mSplits["equipitems"]);
|
}
|
catch (Exception e)
|
{
|
DebugEx.Log(e.Message);
|
}
|
}
|
|
RoleParticularModel.EquipWash _equipWash = default(RoleParticularModel.EquipWash);
|
if (hrefInfo.mSplits.ContainsKey("equipwash")
|
&& hrefInfo.mSplits["equipwash"] != string.Empty)
|
{
|
try
|
{
|
_equipWash = LitJson.JsonMapper.ToObject<RoleParticularModel.EquipWash>(hrefInfo.mSplits["equipwash"]);
|
}
|
catch (Exception e)
|
{
|
DebugEx.Log(e.Message);
|
}
|
}
|
|
Dictionary<int, List<int>> userdatadic = null;
|
if (hrefInfo.mSplits.ContainsKey("userdata"))
|
{
|
string userdata = hrefInfo.mSplits["userdata"];
|
userdatadic = ConfigParse.Analysis(userdata);
|
}
|
Dictionary<int, int> suitLvDict = null;
|
if (hrefInfo.mSplits.ContainsKey("suitlv"))
|
{
|
suitLvDict = new Dictionary<int, int>();
|
string suitLvData = hrefInfo.mSplits["suitlv"];
|
string[] split_data = suitLvData.Split('\'');
|
for (int i = 0; i < split_data.Length; i++)
|
{
|
string[] split_value = split_data[i].Split('_');
|
if (split_value.Length == 2)
|
{
|
int key = int.Parse(split_value[0]);
|
suitLvDict.Add(key, int.Parse(split_value[1]));
|
}
|
}
|
}
|
|
if (hrefInfo.mSplits.ContainsKey("chatsenditem"))
|
{
|
var chatSendItem = LitJson.JsonMapper.ToObject<ChatCtrl.ChatSendItem>(hrefInfo.mSplits["chatsenditem"]);
|
itemId = chatSendItem.itemId;
|
itemCount = chatSendItem.count;
|
stone = chatSendItem.equipGems;
|
if (!string.IsNullOrEmpty(chatSendItem.useData))
|
{
|
userdatadic = ConfigParse.Analysis(chatSendItem.useData);
|
}
|
}
|
|
ItemAttrData attrData = new ItemAttrData(itemId, true, (ulong)itemCount, -1, false, PackType.Deleted,
|
"", userdatadic);
|
attrData.SetGemModel(stone);
|
attrData.SetStrengthData(strengthenLv, GetStrengthenType(itemId));
|
itemTipsModel.SetItemTipsModel(attrData);
|
}
|
|
List<RoleParticularModel.EquipSuit> equipSuitList = new List<RoleParticularModel.EquipSuit>();
|
int[][] equipItems = null;
|
|
public int GetItem(int _index)
|
{
|
if (equipItems != null)
|
{
|
for (int i = 0; i < equipItems.Length; i++)
|
{
|
int[] _itemData = equipItems[i];
|
if (_itemData != null && _itemData.Length > 1)
|
{
|
if (_itemData[0] == _index)
|
{
|
return _itemData[1];
|
}
|
}
|
}
|
}
|
return 0;
|
}
|
|
public string GetItemColorChs(int _itemColor)
|
{
|
switch (_itemColor)
|
{
|
case 2:
|
return Language.Get("EquipSuitBlue");
|
case 3:
|
return Language.Get("EquipSuitPurple");
|
case 4:
|
return Language.Get("EquipSuitOrange");
|
case 5:
|
return Language.Get("EquipSuitRed");
|
default:
|
return Language.Get("EquipSuitWhite");
|
}
|
}
|
|
public static int GetStrengthenType(int _id)
|
{
|
var _type =1;
|
return _type;
|
}
|
|
private static string GetTextColorByItemColor(string info, int _itemColor, Dictionary<string, string> dic)
|
{
|
if (dic.ContainsKey("col"))
|
{
|
if (int.Parse(dic["col"]) == 0)
|
{
|
return info;
|
}
|
}
|
var text = RichTextMgr.Inst.presentRichText;
|
int colorType = 0;
|
if (text != null)
|
{
|
colorType = text.colorType == RichText.ColorType.Dark ? 0 : 1;
|
}
|
return UIHelper.AppendColor(_itemColor, info, colorType == 1);
|
}
|
}
|