//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, January 03, 2018
|
//--------------------------------------------------------
|
using LitJson;
|
using Spine;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
namespace vnxbqy.UI {
|
|
|
//新挂机功能 离线在线都有收益
|
public class OffLineOnHookModel : Model, IBeforePlayerDataInitialize
|
{
|
public MCTJGInfoClass mCTJGInfoClass = new MCTJGInfoClass(); //挂机累计收益
|
public int startSeconds; // 开始挂机时间戳
|
public event Action onHookTimeEvent;
|
public const int funcID = 228;
|
|
public int quickHours; // 快速挂机时间-小时
|
public int quickCostType; // 快速挂机消耗货币类型
|
public List<int> quickCostVaules = new List<int>(); // 快速挂机消耗货币数量, 随次数变化
|
public string formuleExp; //正常挂机经验公式
|
Dictionary<int, int> maxOnHookTimeWithRealm = new Dictionary<int, int>(); // 通过境界等级获取最大挂机时间
|
int orgMaxTime; //原始最大挂机时间
|
|
|
public int openWinState; //上线打开界面 1为上线 2为有经验 状态为2打开界面
|
public override void Init()
|
{
|
ParseConfig();
|
}
|
|
void ParseConfig()
|
{
|
var config = FuncConfigConfig.Get("GuajiQuick");
|
quickHours = int.Parse(config.Numerical1);
|
quickCostType = int.Parse(config.Numerical3);
|
quickCostVaules = JsonMapper.ToObject<List<int>>(config.Numerical4);
|
|
config = FuncConfigConfig.Get("GuajiAward");
|
formuleExp = config.Numerical1;
|
|
config = FuncConfigConfig.Get("GuajiTime");
|
orgMaxTime = int.Parse(config.Numerical2);
|
var json = JsonMapper.ToObject(config.Numerical3);
|
var keys = json.Keys.ToList();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
var key = keys[i];
|
maxOnHookTimeWithRealm[int.Parse(key)] = int.Parse(json[key].ToString());
|
}
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
mCTJGInfoClass = new MCTJGInfoClass();
|
mCTJGInfoClass.moneys = new Dictionary<int, int>();
|
mCTJGInfoClass.ItemList = new List<Int2>();
|
|
openWinState = 1;
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public void MCTJGInfo(HB109_tagMCGuajiInfo info)
|
{
|
mCTJGInfoClass.QuickAwardCount = info.QuickAwardCount;
|
if (info.AwardType == 1)
|
{
|
string showStr = string.Empty;
|
showStr += Language.Get("L2013", Language.Get("L2012"), info.Exp + (ulong)info.ExpPoint * 100000000) + "</r>";
|
for (int i = 0; i < info.MoneyLen; i++)
|
{
|
showStr += Language.Get("L2013", Language.Get("MoneyType_" + info.MoneyList[i].MoneyType), info.MoneyList[i].MoneyValue) + "</r>";
|
}
|
|
List<Item> itemList = new List<Item>();
|
for (int i = 0; i < info.ItemLen; i++)
|
{
|
itemList.Add(new Item((int)info.ItemList[i].ItemID, info.ItemList[i].Count));
|
}
|
|
ItemLogicUtility.Instance.ShowGetItemRichText(itemList, showStr, 8);
|
}
|
else
|
{
|
|
mCTJGInfoClass.AwardSeconds = (int)info.AwardSeconds;
|
mCTJGInfoClass.Exp = (ulong)info.Exp + (ulong)info.ExpPoint * 100000000;
|
mCTJGInfoClass.moneys = new Dictionary<int, int>();
|
for (int i = 0; i < info.MoneyLen; i++)
|
{
|
mCTJGInfoClass.moneys[info.MoneyList[i].MoneyType] = (int)info.MoneyList[i].MoneyValue;
|
}
|
|
mCTJGInfoClass.ItemList = new List<Int2>();
|
for (int i = 0; i < info.ItemLen; i++)
|
{
|
Int2 item = new Int2();
|
item.x = (int)info.ItemList[i].ItemID;
|
item.y = (int)info.ItemList[i].Count;
|
mCTJGInfoClass.ItemList.Add(item);
|
}
|
startSeconds = TimeUtility.AllSeconds;
|
if (openWinState == 1)
|
{
|
//累计时间低于120秒不弹界面
|
if (info.AwardSeconds > 120)
|
openWinState = 2;
|
else
|
openWinState = 0;
|
}
|
UpdateRedPoint();
|
}
|
onHookTimeEvent?.Invoke();
|
}
|
|
public int GetMaxQuickCount()
|
{
|
return VipPrivilegeConfig.GetVipPrivilegeData(47, PlayerDatas.Instance.baseData.VIPLv);
|
}
|
|
public int GetQuickCost()
|
{
|
int index = mCTJGInfoClass.QuickAwardCount;
|
if (index >= quickCostVaules.Count)
|
{
|
index = quickCostVaules.Count - 1;
|
}
|
return quickCostVaules[index];
|
}
|
|
|
// 是否领取快速收益,是发1
|
public void GetAward(int type)
|
{
|
var pack = new CA504_tagCMPlayerGetReward();
|
pack.RewardType = 73;
|
pack.DataEx = (uint)type;
|
GameNetSystem.Instance.SendInfo(pack);
|
}
|
|
// 获取境界对应的最大挂机时间 {10:2, 15:5, 20:8, 25:12, 30:15} 取接近的最小境界
|
public int GetMaxOnHookTimeWithRealm()
|
{
|
int realm = PlayerDatas.Instance.baseData.realmLevel;
|
int maxTime = 0;
|
var keys = maxOnHookTimeWithRealm.Keys.ToList();
|
keys.Sort();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
if (realm >= keys[i])
|
{
|
maxTime = maxOnHookTimeWithRealm[keys[i]];
|
}
|
}
|
return (maxTime + orgMaxTime);
|
}
|
|
// 获取哪个境界提升了最大挂机时间
|
public int GetAddMaxOnHookTime(int realm)
|
{
|
if (maxOnHookTimeWithRealm.ContainsKey(realm))
|
return maxOnHookTimeWithRealm[realm];
|
return 0;
|
}
|
|
Redpoint redpoint = new Redpoint(MainRedDot.OnHookRedpoint);
|
|
//红点提醒 大于10-60分钟, 上线为主动弹界面PopupWindowsProcessor
|
public void UpdateRedPoint()
|
{
|
redpoint.state = RedPointState.None;
|
if (!FuncOpen.Instance.IsFuncOpen(funcID))
|
return;
|
|
if (mCTJGInfoClass.AwardSeconds > 120 + PlayerDatas.Instance.baseData.LV * 5)
|
{
|
redpoint.state = RedPointState.Simple;
|
}
|
}
|
}
|
|
|
public class MCTJGInfoClass
|
{
|
public byte QuickAwardCount; // 今日已快速挂机收益次数
|
public int AwardSeconds; // 已累计收益时长,秒
|
public ulong Exp;
|
public Dictionary<int, int> moneys; // 已累计货币
|
public List<Int2> ItemList; // 已累计物品
|
}
|
|
}
|
|
|
|