|
|
using LitJson;
|
using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
class HeroControler : ILModel<HeroControler>
|
{
|
RoleModel roleModel { get { return ModelCenter.Instance.GetModelEx<RoleModel>(); } }
|
VipModel vipModel { get { return ModelCenter.Instance.GetModelEx<VipModel>(); } }
|
|
Dictionary<int, List<string>> popWinDict = new Dictionary<int, List<string>>();
|
|
float popWinLastTime = 0; //充值界面推送,不做堆栈推送,如有同时多个只推送一个,推送间隔2秒
|
protected override void Init()
|
{
|
GameEvent.playerLoginOkEvent += OnPlayerLoginOk;
|
FuncOpen.Instance.OnFuncStateChangeEvent += OnFunctionStateChange;
|
MailAllModel.Instance.funcType = MailFuncType.Mail;//邮件不是继承模块导致未初始化问题,在这里初始化
|
PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
|
ParseConfig();
|
}
|
|
protected override void UnInit()
|
{
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFunctionStateChange;
|
GameEvent.playerLoginOkEvent -= OnPlayerLoginOk;
|
}
|
|
void ParseConfig()
|
{
|
var popStr = FuncConfigConfig.Get("RechargePop").Numerical1;
|
var dict = JsonMapper.ToObject<Dictionary<string, List<string>>>(popStr);
|
|
foreach (var key in dict.Keys)
|
{
|
popWinDict[int.Parse(key)] = dict[key];
|
}
|
}
|
|
|
public ulong GetMoneyCntIL(int moneyType)
|
{
|
return UIHelper.GetMoneyCnt(moneyType);
|
}
|
|
//货币类型对应的0418类型
|
public PlayerDataType GetMoneyPlayerDataType(int moneyType)
|
{
|
switch (moneyType)
|
{
|
|
case 1:
|
{
|
return PlayerDataType.Gold;
|
}
|
case 2:
|
{
|
return PlayerDataType.GoldPaper;
|
}
|
case 3:
|
{
|
return PlayerDataType.Silver;
|
}
|
case 32:
|
{
|
//环保值
|
return PlayerDataType.default4;
|
}
|
}
|
return 0;
|
}
|
|
|
private void OnFunctionStateChange(int id)
|
{
|
FuncPush(id);
|
}
|
|
//参考 RoleModel . OnFuncStateChangeEvent 0 未推送 1已推送
|
//功能:是否提醒过 1豪华首充 2无限货币 3 在线特惠 4 1元30倍 5 玩法前瞻 6 战场召集 7跨服64排位 8 跨服天梯
|
public void FuncPush(int id)
|
{
|
if (id == 203)
|
{
|
//var result = FuncAwardModel.Instance.TryGetAwardState(48);
|
//roleModel.funcInfo[5] = result == -1 ? 1 : result;
|
}
|
else if (id == 208)
|
{
|
if (ILCrossServerModel.Instance.IsOpen())
|
{
|
roleModel.funcInfo[6] = ILCrossServerModel.Instance.newCallMark == Int2.zero ? 1 : 0;
|
}
|
}
|
else if (id == 210)
|
{
|
if (FuncOpen.Instance.IsFuncOpen(210) && CrossServerQualifyingModel.Instance.nowGroupMark != 0)
|
{
|
roleModel.funcInfo[7] = 0;
|
}
|
}
|
else if (id == 157)
|
{
|
if (CrossServerOneVsOnePKSeason.Instance.isSatisfyMatch &&
|
CrossServerOneVsOnePlayerInfo.Instance.GetDayRemainNum() > 0)
|
{
|
roleModel.funcInfo[8] = 0;
|
}
|
}
|
}
|
|
List<int> funcPushIDS = new List<int>() { 157, 208, 210 };
|
|
void OnPlayerLoginOk()
|
{
|
popWinLastTime = 0;
|
for (int i = 0; i < funcPushIDS.Count; i++)
|
{
|
FuncPush(funcPushIDS[i]);
|
}
|
}
|
|
public void FuncPushGoto(int id)
|
{
|
if (id == 6)
|
{
|
if (ILCrossServerModel.Instance.newCallMark == Int2.zero)
|
{
|
WindowCenter.Instance.OpenEx<CrossServerWin>(false, 3);
|
return;
|
}
|
var callMark = new Int3(ILCrossServerModel.Instance.newCallMark.x, ILCrossServerModel.Instance.newCallMark.y, 1);
|
ILCrossServerModel.Instance.selectJumpIndex = ILCrossServerModel.Instance.crossBattleFieldOpenTimes.IndexOf(callMark) + 1;
|
WindowCenter.Instance.OpenEx<CrossServerWin>(false, 3);
|
}
|
else if (id == 7)
|
{
|
WindowCenter.Instance.OpenIL<CrossServerQualifyingWin>();
|
}
|
else if (id == 8)
|
{
|
WindowCenter.Instance.Open<CrossServerWin>(false, 0);
|
}
|
}
|
|
public void FuncPushClose(int id)
|
{
|
|
}
|
|
//性别 0男1女
|
public int GetGender(int job)
|
{
|
if (job == 2)
|
return 1;
|
|
return 0;
|
}
|
|
|
private void PlayerDataRefreshEvent(PlayerDataType dataType)
|
{
|
if (dataType == PlayerDataType.LV)
|
{
|
|
if (popWinDict.ContainsKey(PlayerDatas.Instance.baseData.LV))
|
{
|
VipModel.RechargeCount rechargeCount;
|
vipModel.TryGetRechargeCount(int.Parse(popWinDict[PlayerDatas.Instance.baseData.LV][0]), out rechargeCount);
|
if (rechargeCount.totalCount > 0) return;
|
|
if (Time.time - popWinLastTime < 2)
|
return;
|
|
//WindowCenter.Instance.Open(popWinDict[PlayerDatas.Instance.baseData.LV][1], false, int.Parse(popWinDict[PlayerDatas.Instance.baseData.LV][2]));
|
|
PopupWindowsProcessor.Instance.Add(popWinDict[PlayerDatas.Instance.baseData.LV][1], int.Parse(popWinDict[PlayerDatas.Instance.baseData.LV][2]));
|
popWinLastTime = Time.time;
|
}
|
}
|
}
|
|
|
//客户端坐标和服务端坐标 需要通过计算获得
|
//获取客户端坐标
|
public Vector2 GetClientPos(int posX, int posY)
|
{
|
return new Vector2((posX - GA_Hero.MapOffset.x) * .5f, (posY - GA_Hero.MapOffset.y) * .5f);
|
}
|
}
|