using Snxxz.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
using UnityEngine;
|
|
public class RichNormalEvent : TRichTextEvent
|
{
|
public RichNormalEvent()
|
{
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.APPLYFAIRY, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.INVITE, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.OPENUI, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.TIP, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.GetWay, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.JOINTEAM, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.AncientRobotName, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.AuctionBidding, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.RandomChat, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.TaskFeedback, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.MyFightPoint, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.MyReikiRoot, this);
|
RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.MyDefense, this);
|
}
|
|
public override bool Execute(RichTextEventEnum type, RichTextMgr.HrefInfo href)
|
{
|
switch (type)
|
{
|
case RichTextEventEnum.APPLYFAIRY:
|
{
|
uint id = 0;
|
if (uint.TryParse(href.mSplits["applyfairy"], out id))
|
{
|
ModelCenter.Instance.GetModel<FairyModel>().SendApplyFairy(id);
|
return true;
|
}
|
}
|
break;
|
case RichTextEventEnum.JOINTEAM:
|
{
|
uint id = 0;
|
if (uint.TryParse(href.mSplits["jointeam"], out id))
|
{
|
var teamModel = ModelCenter.Instance.GetModel<TeamModel>();
|
if (teamModel.myTeam.GetIndexOfMember((int)id) != -1)
|
{
|
SysNotifyMgr.Instance.ShowTip("AlreadyInTeam2");
|
return false;
|
}
|
teamModel.RequestInviteJoinTeam((int)id);
|
}
|
}
|
break;
|
case RichTextEventEnum.INVITE:
|
{
|
uint id = 0;
|
if (uint.TryParse(href.mSplits["invite"], out id))
|
{
|
var teamModel = ModelCenter.Instance.GetModel<TeamModel>();
|
if (teamModel.myTeam.GetIndexOfMember((int)id) != -1)
|
{
|
SysNotifyMgr.Instance.ShowTip("AlreadyInTeam");
|
return false;
|
}
|
if (teamModel.myTeam.inTeam)
|
{
|
ConfirmCancel.ShowPopConfirm(
|
"",
|
Language.Get("PlayerJoinTeam_1"),
|
(bool _ok) =>
|
{
|
if (_ok)
|
{
|
teamModel.RequestExitTeam();
|
teamModel.RequestApplyForJoin((int)id);
|
}
|
}
|
);
|
}
|
else
|
{
|
teamModel.RequestApplyForJoin((int)id);
|
}
|
|
}
|
}
|
break;
|
case RichTextEventEnum.OPENUI:
|
{
|
int id = 0;
|
if (int.TryParse(href.mSplits["openui"], out id))
|
{
|
WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)id);
|
}
|
}
|
break;
|
case RichTextEventEnum.TIP:
|
{
|
var _key = href.mSplits["tip"];
|
SysNotifyMgr.Instance.ShowTip(_key);
|
}
|
break;
|
case RichTextEventEnum.GetWay:
|
{
|
int _id = 0;
|
int.TryParse(href.mSplits["getway"], out _id);
|
ItemTipUtility.Show(_id);
|
}
|
break;
|
case RichTextEventEnum.AuctionBidding:
|
{
|
if (href.mSplits.ContainsKey("auctionbidding"))
|
{
|
var guid = href.mSplits["auctionbidding"];
|
guid = guid.Trim('\"');
|
ModelCenter.Instance.GetModel<AuctionModel>().LocationItemByGuid(guid);
|
}
|
}
|
break;
|
case RichTextEventEnum.RandomChat:
|
{
|
if (href.mSplits.ContainsKey("randomchat"))
|
{
|
var chatType = (ChatInfoType)int.Parse(href.mSplits["randomchat"]);
|
ChatCtrl.Inst.presentChatType = chatType;
|
ChatCtrl.Inst.openFromFairyTask = true;
|
WindowCenter.Instance.Open<ChatWin>();
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
}
|
}
|
break;
|
case RichTextEventEnum.TaskFeedback:
|
{
|
if (href.fromAutoTask)
|
{
|
return false;
|
}
|
if (href.mSplits.ContainsKey("taskfeedback"))
|
{
|
var taskId = 0;
|
int.TryParse(href.mSplits["taskfeedback"], out taskId);
|
|
TaskFeedback feedback;
|
var feedbackModel = ModelCenter.Instance.GetModel<TaskFeedbackModel>();
|
if (feedbackModel.TryGetTaskFeedback(taskId, out feedback))
|
{
|
feedbackModel.ExecuteTaskFeedback(taskId);
|
return true;
|
}
|
}
|
}
|
break;
|
}
|
return false;
|
}
|
|
public override string GetDisplay(RichTextEventEnum type, Dictionary<string, string> dic)
|
{
|
switch (type)
|
{
|
case RichTextEventEnum.AncientRobotName:
|
{
|
if (dic.ContainsKey("objid") && dic.ContainsKey("npcid"))
|
{
|
var objId = 0;
|
var npcId = 0;
|
if (int.TryParse(dic["objid"], out objId)
|
&& int.TryParse(dic["npcid"], out npcId))
|
{
|
var model = ModelCenter.Instance.GetModel<ActivityModel>();
|
return model.GetAncientRobotName(objId, npcId);
|
}
|
}
|
}
|
break;
|
case RichTextEventEnum.MyFightPoint:
|
{
|
var colorType = 0;
|
if (RichTextMgr.Inst.presentRichText != null)
|
{
|
colorType = RichTextMgr.Inst.presentRichText.colorType == RichText.ColorType.Dark ? 0 : 1;
|
}
|
var fightPoint = PlayerDatas.Instance.baseData.FightPoint;
|
var targetValue = 0;
|
var infoArray = dic["myfightpoint"].Split('_');
|
if (infoArray.Length > 1)
|
{
|
switch (infoArray[0])
|
{
|
case "skytower":
|
var config = SkyTowerConfig.Get(infoArray[1]);
|
if (config != null)
|
{
|
targetValue = config.fightPower;
|
}
|
break;
|
}
|
}
|
else
|
{
|
int.TryParse(dic["myfightpoint"], out targetValue);
|
}
|
|
if (fightPoint < targetValue)
|
{
|
var label = dic.ContainsKey("replacelabel1") ? dic["replacelabel1"] : string.Empty;
|
return UIHelper.AppendColor(TextColType.Red, StringUtility.Contact(label, fightPoint, "/", targetValue), colorType == 1);
|
}
|
else
|
{
|
var label = dic.ContainsKey("replacelabel2") ? dic["replacelabel2"] : string.Empty;
|
return UIHelper.AppendColor(TextColType.Green, label, colorType == 1);
|
}
|
}
|
case RichTextEventEnum.MyReikiRoot:
|
{
|
var colorType = 0;
|
if (RichTextMgr.Inst.presentRichText != null)
|
{
|
colorType = RichTextMgr.Inst.presentRichText.colorType == RichText.ColorType.Dark ? 0 : 1;
|
}
|
|
var reikiRootModel = ModelCenter.Instance.GetModel<ReikiRootModel>();
|
|
var satisfy = false;
|
var targetValue = 0;
|
var point = 0;
|
var property = 0;
|
|
if (int.TryParse(dic["myreikiroot"], out targetValue))
|
{
|
point = reikiRootModel.GetReikiRootTotalPoint();
|
satisfy = point >= targetValue;
|
}
|
else
|
{
|
var jsonArray = LitJson.JsonMapper.ToObject<int[][]>(dic["myreikiroot"]);
|
var job = PlayerDatas.Instance.baseData.Job;
|
for (int i = 0; i < jsonArray.Length; i++)
|
{
|
if (i == job - 1)
|
{
|
property = jsonArray[i][0];
|
point = reikiRootModel.GetReikiRootPoint(jsonArray[i][0]);
|
targetValue = jsonArray[i][1];
|
satisfy = point >= targetValue;
|
break;
|
}
|
}
|
}
|
|
if (!satisfy)
|
{
|
var label = dic.ContainsKey("replacelabel1") ? dic["replacelabel1"] : string.Empty;
|
if (property != 0)
|
{
|
var propertyConfig = PlayerPropertyConfig.Get(property);
|
label = StringUtility.Contact(propertyConfig.Name, ":");
|
}
|
return UIHelper.AppendColor(TextColType.Red, StringUtility.Contact(label, point, "/", targetValue), colorType == 1);
|
}
|
else
|
{
|
var label = dic.ContainsKey("replacelabel2") ? dic["replacelabel2"] : string.Empty;
|
return label;
|
}
|
}
|
case RichTextEventEnum.MyDefense:
|
{
|
var colorType = 0;
|
if (RichTextMgr.Inst.presentRichText != null)
|
{
|
colorType = RichTextMgr.Inst.presentRichText.colorType == RichText.ColorType.Dark ? 0 : 1;
|
}
|
|
var treasureModel = ModelCenter.Instance.GetModel<TreasureModel>();
|
|
var satisfy = false;
|
var targetValue = 0;
|
var point = 0;
|
|
var treasureId = 0;
|
if (int.TryParse(dic["mydefense"], out treasureId))
|
{
|
TreasureDungeon treasureDungeon;
|
if (treasureModel.TryGetTreasureDungeon(treasureId, out treasureDungeon))
|
{
|
var dungeonInfo = treasureDungeon.Get(treasureDungeon.currentLevel + 1);
|
if (!dungeonInfo.Equals(default(TreasureDungeonInfo)))
|
{
|
targetValue = dungeonInfo.defense;
|
}
|
}
|
point = UIHelper.GetPropertyValue(PropertyType.DEF);
|
satisfy = point >= targetValue;
|
}
|
|
if (!satisfy)
|
{
|
var label = dic.ContainsKey("replacelabel1") ? dic["replacelabel1"] : string.Empty;
|
return UIHelper.AppendColor(TextColType.Red, StringUtility.Contact(label, point, "/", targetValue), colorType == 1);
|
}
|
else
|
{
|
var label = dic.ContainsKey("replacelabel2") ? dic["replacelabel2"] : string.Empty;
|
return label;
|
}
|
}
|
}
|
return string.Empty;
|
}
|
}
|