//--------------------------------------------------------
|
// [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, IOpenServerActivity
|
{
|
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,档,4档
|
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>()); } }
|
|
public event Action<int> onStateUpate;
|
public bool IsOpen
|
{
|
get
|
{
|
return IsOpenFeatures();
|
}
|
}
|
|
public bool priorityOpen
|
{
|
get
|
{
|
return IsRedPoint();
|
}
|
}
|
|
public bool IsAdvance
|
{
|
get
|
{
|
return false;
|
}
|
}
|
|
private bool IsRedPoint()//红点
|
{
|
|
if (redPointStre1.state == RedPointState.None)
|
{
|
return false;
|
}
|
else
|
{
|
return true;
|
}
|
}
|
private bool IsOpenFeatures()//功能是否开启
|
{
|
bool isOpen = false;
|
if (InvestmentGrade > 0 && InvestmentGrade < 4)
|
{
|
isOpen = true;
|
}
|
else
|
{
|
if (InvestmentGrade == 4)
|
{
|
foreach (int key in InfoSeriors.Keys)
|
{
|
if (InfoSeriors[key] != 4)
|
{
|
isOpen = true;
|
}
|
}
|
}
|
}
|
if (PlayerDatas.Instance.baseData.LV >= 300 && !isOpen)
|
{
|
return false;
|
}
|
else
|
{
|
return true;
|
}
|
}
|
|
private bool IsOk = false;
|
public bool IsRedpoint = false;
|
|
private int DisplayLevel = 0;//显示等级
|
private int DisplayDays = 0;//显示天数
|
public override void Init()
|
{
|
OpenServerActivityCenter.Instance.Register(10, this);
|
var InvestRedPoint = Config.Instance.Get<FuncConfigConfig>("InvestRedPoint");
|
DisplayLevel = int.Parse(InvestRedPoint.Numerical2);
|
DisplayDays = int.Parse(InvestRedPoint.Numerical3);
|
|
int[] MultipleIntList = ConfigParse.GetMultipleStr<int>(Config.Instance.Get<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;
|
InvestmentGrade = 0;
|
SelectNumber = 0;
|
RecordSelectNumberMax = 0;
|
FairyJadeInvestmentDic.Clear();
|
InvestmentAmountDic.Clear();
|
InfoSeriors.Clear();
|
Assignment();
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
IsOk = true;
|
InvestmentAmount();
|
InvestmentRedPoint();
|
IsShowRedPointSimple();
|
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)
|
{
|
IsShowRedPointSimple();
|
}
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
public void Assignment()
|
{
|
var InvestConfig = Config.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);
|
InvestmentAmountDic.Add(VipInvestModel.GetInvestGold(3, 3), 4);
|
RecordSelectNumberMax = VipInvestModel.GetInvestGold(3, 3);
|
}
|
}
|
|
private const int Redpoint_key1 = 20910;
|
public Redpoint redPointStre1 = new Redpoint(209, 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.GetReward;
|
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.GetReward;
|
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();
|
}
|
}
|
|
private void IsShowRedPointSimple()
|
{
|
int GetDayOfYear = DateTime.Now.DayOfYear;
|
string strKey = "IsOpenFiaryJadeRedPoint" + PlayerDatas.Instance.baseData.PlayerID;
|
int day = LocalSave.GetInt(strKey);
|
if (day != GetDayOfYear)
|
{
|
if (TimeUtility.CreateDays <= DisplayDays && redPointStre1.state == RedPointState.None
|
&& PlayerDatas.Instance.baseData.LV >= DisplayLevel)
|
{
|
LocalSave.SetInt(strKey, GetDayOfYear);
|
IsRedpoint = true;
|
RedPointSate();
|
}
|
|
}
|
}
|
|
public void MessageNotification()
|
{
|
var _funcOrder = 0;
|
if (!OpenServerActivityCenter.Instance.IsAnyActivityOpen(out _funcOrder))
|
{
|
SysNotifyMgr.Instance.ShowTip("JadeInvestmentLimit1");//信息提示
|
return;
|
}
|
else if (InvestmentGrade <= 0 && PlayerDatas.Instance.baseData.LV >= 300)
|
{
|
SysNotifyMgr.Instance.ShowTip("JadeInvestmentLimit2");//信息提示
|
return;
|
}
|
else
|
{
|
bool isOpen = false;
|
if (InvestmentGrade == 4)
|
{
|
foreach (int key in InfoSeriors.Keys)
|
{
|
if (InfoSeriors[key] != 4)
|
{
|
isOpen = true;
|
}
|
}
|
}
|
if (!isOpen && PlayerDatas.Instance.baseData.LV >= 300)
|
{
|
SysNotifyMgr.Instance.ShowTip("JadeInvestmentLimit3");//信息提示
|
return;
|
}
|
}
|
|
}
|
|
}
|
|
|
|
|