//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, April 26, 2018
|
//--------------------------------------------------------
|
using System;
|
using System.Collections.Generic;
|
using TableConfig;
|
using Snxxz.UI;
|
using System.Linq;
|
//仙玉投资
|
public class FairyJadeInvestmentClass
|
{
|
public int ID;//ID
|
public int Type;//类型
|
public int NeedDay;//需要天数
|
public int NeedLv;//需要等级
|
public MonthlyInvestmentModel.MonthlyInvestmentItem FairyJadeInvestmentItem;//奖励
|
}
|
public class FairyJadeInvestmentModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
public Dictionary<int, FairyJadeInvestmentClass> FairyJadeInvestmentDic = new Dictionary<int, FairyJadeInvestmentClass>();//等级
|
public Dictionary<int, int> InfoSeriors = new Dictionary<int, int>();//奖励领取信息//key为索引,Value(0,未领,其他值未领的钱数)
|
public Dictionary<int, int> InvestmentAmountDic = new Dictionary<int, int>();//投资金额
|
public static Action FairyJadeInfoSeriorsUpdate;
|
public int InvestGold = 0; // 投资额度
|
public int InvestmentGrade = 0;//0未投,1档,2,档,3,档
|
public int SelectNumber = 0;//记录想要投资的钱数
|
public int RecordSelectNumberMax = 0;//用来标记最大可投资额度
|
public List<int> MultipleList = new List<int>();
|
VipInvestModel m_VipInvestModel;
|
VipInvestModel VipInvestModel { get { return m_VipInvestModel ?? (m_VipInvestModel = ModelCenter.Instance.GetModel<VipInvestModel>()); } }
|
private bool IsOk = false;
|
public bool IsRedpoint = false;
|
public override void Init()
|
{
|
int[] MultipleIntList = ConfigParse.GetMultipleStr<int>(ConfigManager.Instance.GetTemplate<FuncConfigConfig>("JadeInvest").Numerical1);
|
MultipleList.Clear();
|
for (int i = 0; i < MultipleIntList.Length; i++)
|
{
|
MultipleList.Add(MultipleIntList[i]);
|
}
|
Assignment();
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
IsOk = false;
|
IsRedpoint = false;
|
InvestGold = 0;
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
IsOk = true;
|
InvestmentAmount();
|
InvestmentRedPoint();
|
if (TimeUtility.CreateDays <= 3 && redPointStre1.state == RedPointState.None)
|
{
|
IsRedpoint = true;
|
if (PlayerDatas.Instance.baseData.LV >= 30)
|
{
|
RedPointSate();
|
}
|
}
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= Updatefighting;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent += Updatefighting;
|
FairyJadeInvestmentWin.FairyJadeInvestmentRedPointEvent -= FairyJadeInvestmentRedPoint;
|
FairyJadeInvestmentWin.FairyJadeInvestmentRedPointEvent += FairyJadeInvestmentRedPoint;
|
}
|
|
private void FairyJadeInvestmentRedPoint()
|
{
|
RedPointSate();
|
}
|
|
private void Updatefighting(PlayerDataRefresh _tCDBPlayerRefresh)
|
{
|
if (_tCDBPlayerRefresh == PlayerDataRefresh.LV && InvestGold > 0)
|
{
|
InvestmentRedPoint();
|
}
|
if (_tCDBPlayerRefresh == PlayerDataRefresh.LV)
|
{
|
if (TimeUtility.CreateDays <= 3 && redPointStre1.state == RedPointState.None && PlayerDatas.Instance.baseData.LV >= 30)
|
{
|
if (IsRedpoint)
|
{
|
RedPointSate();
|
}
|
}
|
}
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
public void Assignment()
|
{
|
var InvestConfig = ConfigManager.Instance.GetAllValues<InvestConfig>();
|
if (FairyJadeInvestmentDic.Count > 0)
|
{
|
return;
|
}
|
foreach (var value in InvestConfig)
|
{
|
if (value.type == 3 && !FairyJadeInvestmentDic.ContainsKey(value.needLV))
|
{
|
FairyJadeInvestmentClass fairyJadeInvestment = new FairyJadeInvestmentClass();
|
if (value.id >= 310)
|
{
|
fairyJadeInvestment.ID = value.id % 100;
|
}
|
else
|
{
|
fairyJadeInvestment.ID = value.id % 10;
|
}
|
if (!InfoSeriors.ContainsKey(fairyJadeInvestment.ID))
|
{
|
InfoSeriors.Add(fairyJadeInvestment.ID, 0);
|
}
|
fairyJadeInvestment.Type = value.type;
|
fairyJadeInvestment.NeedDay = value.needDay;
|
fairyJadeInvestment.NeedLv = value.needLV;
|
MonthlyInvestmentModel.MonthlyInvestmentItem FairyJadeItem = new MonthlyInvestmentModel.MonthlyInvestmentItem();
|
var _jsonData = LitJson.JsonMapper.ToObject(value.award);
|
foreach (string key in _jsonData.Keys)
|
{
|
var _job = int.Parse(key);
|
var _itemArray = LitJson.JsonMapper.ToObject<int[][]>(_jsonData[key].ToJson());
|
for (int j = 0; j < _itemArray.Length; j++)
|
{
|
FairyJadeItem.Add(_job, new AwardItem()
|
{
|
item = new Item(_itemArray[j][0], _itemArray[j][1]),
|
isBind = _itemArray[j][2],
|
});
|
}
|
}
|
fairyJadeInvestment.FairyJadeInvestmentItem = FairyJadeItem;
|
FairyJadeInvestmentDic.Add(value.needLV, fairyJadeInvestment);
|
}
|
}
|
}
|
public void GetInfoSeriors(HA337_tagMCGoldInvestInfo vNetData)//接受信息
|
{
|
if (vNetData.InvestType == 3)
|
{
|
InvestmentAmount();
|
InvestGold = (int)vNetData.InvestGold;
|
if (InvestmentAmountDic.ContainsKey(InvestGold))
|
{
|
InvestmentGrade = InvestmentAmountDic[InvestGold];
|
}
|
else
|
{
|
InvestmentGrade = 0;
|
}
|
for (int i = 0; i < vNetData.RewardRecordCnt; i++)
|
{
|
if (InfoSeriors.ContainsKey((int)vNetData.InvestRewardList[i].RewardIndex))
|
{
|
InfoSeriors[(int)vNetData.InvestRewardList[i].RewardIndex] = (int)vNetData.InvestRewardList[i].RewardValue;
|
}
|
}
|
if (FairyJadeInfoSeriorsUpdate != null)
|
{
|
FairyJadeInfoSeriorsUpdate();
|
}
|
if (IsOk)
|
{
|
InvestmentRedPoint();
|
}
|
}
|
}
|
|
public void SendInvestment(int InvestType, int RewardIndex)//领取奖励
|
{
|
CA541_tagCMGetInvestReward CA541 = new CA541_tagCMGetInvestReward();
|
CA541.InvestType = (byte)InvestType;
|
CA541.RewardIndex = (byte)RewardIndex;
|
GameNetSystem.Instance.SendInfo(CA541);
|
}
|
|
public void InvestmentMonthlyInvestment(int InvestType, int InvestGold)//仙玉投资
|
{
|
CA540_tagCMGoldInvest C540 = new CA540_tagCMGoldInvest();
|
C540.InvestType = (byte)InvestType;
|
C540.InvestGold = (uint)InvestGold;
|
GameNetSystem.Instance.SendInfo(C540);
|
}
|
|
public void InvestmentAmount()
|
{
|
if (InvestmentAmountDic.Count <= 0)
|
{
|
InvestmentAmountDic.Add(VipInvestModel.GetInvestGold(3, 0), 1);
|
InvestmentAmountDic.Add(VipInvestModel.GetInvestGold(3, 1), 2);
|
InvestmentAmountDic.Add(VipInvestModel.GetInvestGold(3, 2), 3);
|
RecordSelectNumberMax = VipInvestModel.GetInvestGold(3, 2);
|
}
|
}
|
|
private const int Redpoint_key1 = 3502;
|
public Redpoint redPointStre1 = new Redpoint(MainRedDot.RedPoint_VipDot, Redpoint_key1);//仙玉投资红点
|
public int JumpInedx = 0;
|
private void InvestmentRedPoint()//红点
|
{
|
JumpInedx = 0;
|
int type = -1;
|
redPointStre1.state = RedPointState.None;
|
int PlayerLV = PlayerDatas.Instance.baseData.LV;
|
foreach (var key in FairyJadeInvestmentDic.Keys)
|
{
|
type += 1;
|
if (PlayerLV >= key)
|
{
|
int indexID = FairyJadeInvestmentDic[key].ID;
|
if (InvestmentGrade != 0)
|
{
|
int IsReceive = InfoSeriors[indexID];
|
if (IsReceive == 0)
|
{
|
redPointStre1.state = RedPointState.Simple;
|
JumpInedx = type;
|
return;
|
}
|
else
|
{
|
List<AwardItem> fairyJadeInvestmentItem = FairyJadeInvestmentDic[key].FairyJadeInvestmentItem.GetAwardItem(InvestmentGrade);
|
int AtPresentNumber = 0;
|
if (IsReceive != 0)
|
{
|
List<AwardItem> fairyJadeInvestmentItemAdd = FairyJadeInvestmentDic[key].FairyJadeInvestmentItem.GetAwardItem(IsReceive);
|
AwardItem itemAdd = fairyJadeInvestmentItemAdd[0];
|
AtPresentNumber = itemAdd.item.count;
|
}
|
if (fairyJadeInvestmentItem[0].item.count > AtPresentNumber)
|
{
|
redPointStre1.state = RedPointState.Simple;
|
JumpInedx = type;
|
return;
|
}
|
}
|
}
|
|
}
|
|
}
|
int type1 = -1;
|
if (JumpInedx == 0 && InvestmentGrade != 0)
|
{
|
foreach (var key in FairyJadeInvestmentDic.Keys)
|
{
|
type1 += 1;
|
if (key > PlayerLV)
|
{
|
JumpInedx = type1;
|
return;
|
}
|
}
|
|
}
|
}
|
private void RedPointSate()//月卡投资创角前三天红点
|
{
|
if (InvestGold > 0)
|
{
|
return;
|
}
|
if (IsRedpoint)
|
{
|
redPointStre1.state = RedPointState.Simple;
|
}
|
else
|
{
|
InvestmentRedPoint();
|
}
|
}
|
}
|