using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using LitJson;
|
|
class WeddingModel : ILModel<WeddingModel>
|
{
|
|
Dictionary<uint, uint> couples = new Dictionary<uint, uint>(); //所有伴侣信息
|
|
//自己的伴侣信息
|
public uint m_CoupleID; // 伴侣玩家ID,一定是好友,社交信息从好友系统中获取
|
public string m_CoupleName;
|
public uint m_NewMarryTime; // 新婚时间戳, 秒,计算结婚天数按该时间计算
|
public uint m_MarryTime; // 最近一次提亲成功时间戳, 秒,计算可离婚时间按该时间计算
|
public List<int> m_BridePriceState = new List<int>(); // 聘礼状态,按位存储已购买次数,如205代表ID1买了5次,ID2买了0次,ID3买了2次,最高9次
|
public uint m_BreakRequestID; // 当前请求中的和离时间戳 - 请求方ID,0代表没人发起请求
|
public uint m_BreakRequestTime; // 当前请求中的和离时间戳, 秒,用于计算和离回应有效期
|
public uint m_PlayerBreakRequestTime; // 玩家最近一次和离请求时间戳, 秒,用于计算自身的请求和离CD
|
|
public int waitTime = 10;
|
public int marryCloseCnt; //结婚所需亲密度
|
public int freeCandyCnt; //表 喜糖免费次数
|
public int candyMoneyType;
|
public int candyMoneyValue;
|
public int maxEatCandyCount;
|
public int onceFireCandyCnt; //表 购买烟花赠送喜糖次数
|
public int serverBuyFireTimes; //全服可购买次数
|
public int fireMoneyType;
|
public int fireMoneyValue;
|
|
public int divorceCD; //提亲成功后多久可离婚
|
public int divorceReqCD; //可再次提离婚的时间
|
public int autoDivorceCD; //自动强制离婚的时间
|
public int forceDivorceMoney;
|
public int forceDivorceMoneyType;
|
|
public const int FuncID = 205;
|
public int qyLimitLV = 0;
|
|
PackModel packModel { get { return ModelCenter.Instance.GetModelEx<PackModel>(); } }
|
FriendsModel friendsModel { get { return ModelCenter.Instance.GetModelEx<FriendsModel>(); } }
|
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
RoleParticularModel rolePModel { get { return ModelCenter.Instance.GetModel<RoleParticularModel>(); } }
|
DungeonModel fbModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
|
public event Action OnSelectPlayer; //选择提前对象
|
SelectPlayer m_SelectPlayer;
|
public SelectPlayer selectPlayer
|
{
|
get
|
{
|
return m_SelectPlayer;
|
}
|
set
|
{
|
m_SelectPlayer = value;
|
OnSelectPlayer?.Invoke();
|
}
|
}
|
|
protected override void Init()
|
{
|
GameEvent.afterPlayerDataInitializeEvent += OnAfterPlayerDataInitializeEvent;
|
GameEvent.playerLoginOkEvent += OnPlayerLoginOk;
|
WindowCenter.Instance.windowAfterOpenEvent += OnAfterWindowOpen;
|
packModel.refreshItemCountEvent += RefreshItemCount;
|
fbModel.updateDungeonBuyCnt += UpdateDungeonTimes;
|
fbModel.dungeonRecordChangeEvent += OnDungeonRecordUpdate;
|
ParseConfig();
|
}
|
|
protected override void UnInit()
|
{
|
GameEvent.afterPlayerDataInitializeEvent -= OnAfterPlayerDataInitializeEvent;
|
WindowCenter.Instance.windowAfterOpenEvent += OnAfterWindowOpen;
|
packModel.refreshItemCountEvent -= RefreshItemCount;
|
GameEvent.playerLoginOkEvent -= OnPlayerLoginOk;
|
fbModel.updateDungeonBuyCnt += UpdateDungeonTimes;
|
fbModel.dungeonRecordChangeEvent += OnDungeonRecordUpdate;
|
}
|
|
void ParseConfig()
|
{
|
var loveMarry = FuncConfigConfig.Get("LoveMarry");
|
waitTime = int.Parse(loveMarry.Numerical1);
|
marryCloseCnt = int.Parse(loveMarry.Numerical2);
|
|
var loveCandy = FuncConfigConfig.Get("LoveCandy");
|
freeCandyCnt = int.Parse(loveCandy.Numerical1);
|
maxEatCandyCount = int.Parse(loveCandy.Numerical4);
|
var arr = loveCandy.Numerical2.Split('|');
|
candyMoneyType = int.Parse(arr[0]);
|
candyMoneyValue = int.Parse(arr[1]);
|
var loveFire = FuncConfigConfig.Get("LoveCandyFire");
|
serverBuyFireTimes = int.Parse(loveFire.Numerical1);
|
arr = loveFire.Numerical2.Split('|');
|
fireMoneyType = int.Parse(arr[0]);
|
fireMoneyValue = int.Parse(arr[1]);
|
onceFireCandyCnt = int.Parse(loveFire.Numerical3);
|
var divorceConfig = FuncConfigConfig.Get("LoveMarryBreak");
|
divorceCD = int.Parse(divorceConfig.Numerical1);
|
divorceReqCD = int.Parse(divorceConfig.Numerical2);
|
arr = divorceConfig.Numerical3.Split('|');
|
forceDivorceMoneyType = int.Parse(arr[0]);
|
forceDivorceMoney = int.Parse(arr[1]);
|
autoDivorceCD = int.Parse(divorceConfig.Numerical5);
|
|
var ringConfig = FuncConfigConfig.Get("LoveRing");
|
unLockRingItemID = int.Parse(ringConfig.Numerical1);
|
ringLVUPItemID = int.Parse(ringConfig.Numerical2);
|
|
var loveFB = FuncConfigConfig.Get("LoveFB");
|
isTeamTwo = int.Parse(loveFB.Numerical1);
|
fbShowItems = JsonMapper.ToObject<int[][]>(loveFB.Numerical4);
|
|
qyLimitLV = FuncOpenLVConfig.Get(FuncID).LimitLV;
|
}
|
|
void OnAfterPlayerDataInitializeEvent()
|
{
|
couples.Clear();
|
candyInfoList.Clear();
|
if (marryPlayerID != PlayerDatas.Instance.baseData.PlayerID)
|
{
|
//换号清除
|
MarryReqDict.Clear();
|
}
|
}
|
|
public void UpdateCouples(IL_HB314_tagGCSocialCouples netPack)
|
{
|
for (int i = 0; i < netPack.Count; i++)
|
{
|
if (netPack.Player[i].CoupleID == 0 && couples.ContainsKey(netPack.Player[i].PlayerID))
|
{
|
//离婚
|
couples.Remove(netPack.Player[i].PlayerID);
|
}
|
else
|
{
|
couples[netPack.Player[i].PlayerID] = netPack.Player[i].CoupleID;
|
}
|
}
|
}
|
|
public event Action OnCoupleInfo; //收到结婚信息
|
|
public void UpdateMyCouple(IL_HB326_tagGCCoupleInfo netPack)
|
{
|
if (m_CoupleID > 0 && LocalSave.GetInt("PlayerCouple" + PlayerDatas.Instance.baseData.PlayerID) == 0)
|
{
|
ynmbxxjUtil.Instance.TraceEvent("getmarried", "", false);
|
LocalSave.SetInt("PlayerCouple" + PlayerDatas.Instance.baseData.PlayerID, 1);
|
}
|
m_CoupleID = netPack.CoupleID;
|
m_CoupleName = netPack.CoupleName.Trim().Replace("\0", "");
|
m_NewMarryTime = netPack.NewMarryTime;
|
m_MarryTime = netPack.MarryTime;
|
m_BreakRequestID = netPack.BreakRequestID;
|
m_BreakRequestTime = netPack.BreakRequestTime;
|
m_PlayerBreakRequestTime = netPack.PlayerBreakRequestTime;
|
m_BridePriceState.Clear();
|
m_BridePriceState.Add((int)netPack.BridePriceState % 10);
|
m_BridePriceState.Add((int)netPack.BridePriceState / 10 % 10);
|
m_BridePriceState.Add((int)netPack.BridePriceState / 100 % 10);
|
OnCoupleInfo?.Invoke();
|
}
|
|
//显示自己的模型
|
public void ShowPlayer(RawImage rawImage)
|
{
|
var apperance = equipModel.GetAppearance();
|
var data = new UI3DPlayerExhibitionData
|
{
|
job = PlayerDatas.Instance.baseData.Job,
|
fashionClothesId = apperance.fashionClothes,
|
fashionWeaponId = apperance.fashionWeapon,
|
fashionSecondaryId = apperance.fashionSecondary,
|
clothesId = apperance.clothes,
|
weaponId = apperance.weapon,
|
secondaryId = apperance.secondary,
|
wingsId = 0,
|
suitLevel = apperance.isSuit ? 1 : 0,
|
reikiRootEffectId = 0,
|
isDialogue = false,
|
equipLevel = PlayerDatas.Instance.baseData.suitLevel,
|
titleID = PlayerDatas.Instance.baseData.TitleID,
|
};
|
UI3DModelExhibition.Instance.ShowPlayer(rawImage, data);
|
rawImage.raycastTarget = false;
|
}
|
|
//显示情侣模型
|
public void ShowCouple(RawImage rawImage)
|
{
|
var viewPlayerData = rolePModel.GetViewPlayerData((int)m_CoupleID);
|
|
if (viewPlayerData != null)
|
{
|
|
int _suitLevel = (int)(viewPlayerData.rolePropData.EquipShowSwitch % 10);
|
int clothes = viewPlayerData.GetItemId(RoleEquipType.Clothes);
|
int weapon = viewPlayerData.GetItemId(RoleEquipType.Weapon);
|
int weapon2 = viewPlayerData.GetItemId(RoleEquipType.Weapon2);
|
int fashionClothes = viewPlayerData.GetItemId(RoleEquipType.FashionClothes);
|
int fashionWeapon = viewPlayerData.GetItemId(RoleEquipType.FashionWeapon);
|
int fashionWeapon2 = viewPlayerData.GetItemId(RoleEquipType.FashionWeapon2);
|
|
var data = new UI3DPlayerExhibitionData
|
{
|
job = viewPlayerData.rolePropData.Job,
|
fashionClothesId = fashionClothes,
|
fashionWeaponId = fashionWeapon,
|
fashionSecondaryId = fashionWeapon2,
|
clothesId = clothes,
|
suitLevel = _suitLevel,
|
weaponId = weapon,
|
wingsId = 0,
|
secondaryId = weapon2,
|
reikiRootEffectId = 0,
|
isDialogue = false,
|
equipLevel = (int)viewPlayerData.rolePropData.EquipShowSwitch / 10 % 100,
|
titleID = viewPlayerData.rolePropData.TitleID,
|
};
|
|
rawImage.SetActiveIL(true);
|
UI3DModelExhibition.InstanceClone1.ShowPlayer(rawImage, data);
|
rawImage.raycastTarget = false;
|
}
|
}
|
|
#region 提亲
|
|
public List<SelectPlayer> playerList = new List<SelectPlayer>();
|
public void GetPlayerList()
|
{
|
playerList.Clear();
|
var friendDict = friendsModel.GetFriendDictByType(2);
|
if (friendDict != null)
|
{
|
var keyList = friendDict.Keys.ToList();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
uint playerID = keyList[i];
|
var playerInfo = friendsModel.GetFirendInfo(playerID, 2);
|
if (playerInfo == null)
|
continue;
|
if (couples.ContainsKey(playerID))
|
continue;
|
if (playerInfo.OnlineType != 1)
|
continue;
|
if (playerInfo.LV < qyLimitLV)
|
continue;
|
|
var player = new SelectPlayer
|
{
|
playerID = (int)playerID,
|
name = playerInfo.PlayerName.Trim().Replace("\0", ""),
|
closeCnt = FlowerGiftModel.Instance.GetCloseCnt((int)playerID),
|
job = playerInfo.Job,
|
online = playerInfo.OnlineType == 1 ? 1 : 0,
|
face = playerInfo.Face,
|
facePic = playerInfo.FacePic,
|
};
|
playerList.Add(player);
|
}
|
}
|
|
var fairy = PlayerDatas.Instance.fairyData.fairy;
|
if (fairy != null)
|
{
|
for (int i = 0; i < fairy.Member.Count; i++)
|
{
|
if (fairy.Member[i].PlayerID == PlayerDatas.Instance.baseData.PlayerID)
|
continue;
|
if (couples.ContainsKey(fairy.Member[i].PlayerID))
|
continue;
|
if (fairy.Member[i].LV < qyLimitLV)
|
continue;
|
|
var player = new SelectPlayer
|
{
|
playerID = (int)fairy.Member[i].PlayerID,
|
name = fairy.Member[i].Name.Trim().Replace("\0", ""),
|
closeCnt = FlowerGiftModel.Instance.GetCloseCnt((int)fairy.Member[i].PlayerID),
|
job = fairy.Member[i].Job,
|
online = fairy.Member[i].Exattr2 == 0 ? 1 : 0,
|
face = (int)fairy.Member[i].Face,
|
facePic = (int)fairy.Member[i].FacePic,
|
};
|
playerList.Add(player);
|
}
|
|
}
|
playerList.Sort(SortPlayer);
|
}
|
|
int SortPlayer(SelectPlayer friendA, SelectPlayer friendB)
|
{
|
if (friendA.online != friendB.online)
|
{
|
return friendB.online.CompareTo(friendA.online);
|
}
|
return friendB.closeCnt.CompareTo(friendA.closeCnt);
|
}
|
|
public struct SelectPlayer
|
{
|
public int playerID;
|
public string name;
|
public int closeCnt; //亲密度
|
public int job;
|
public int online; //0 不在线,1在线
|
public int face;
|
public int facePic;
|
}
|
|
public event Action OnMarryReqOKEvent;
|
public float marryReqOkTime;
|
//提亲发送成功,等待对方响应
|
public void UpdateMarryReqOK(IL_HB321_tagGCMarryReqOK netPack)
|
{
|
marryReqOkTime = Time.time;
|
OnMarryReqOKEvent?.Invoke();
|
}
|
|
public uint marryPlayerID = 0; //记录提亲玩家ID,为了区分重连还是切换角色,同角色重连不清数据
|
//===接收方收到数据
|
public Dictionary<int, MarryReqInfo> MarryReqDict = new Dictionary<int, MarryReqInfo>();
|
public int requestID = 0;
|
//===请求方收到数据
|
public string resultName;
|
public int result;
|
|
|
public void UpdateMarryReqInfo(IL_HB322_tagGCMarryReqInfo netPack)
|
{
|
marryPlayerID = PlayerDatas.Instance.baseData.PlayerID;
|
MarryReqDict[(int)netPack.PlayerID] = new MarryReqInfo()
|
{
|
name = netPack.PlayerName.Trim().Replace("\0", ""),
|
BridePriceID = netPack.BridePriceID,
|
startTime = Time.time,
|
};
|
|
if (WindowCenter.Instance.IsOpen("WeddingAnswerWin"))
|
WindowCenter.Instance.CloseImmediately("WeddingAnswerWin");
|
|
GetMarryReqPlayerID();
|
//立即打开,取当前封包
|
requestID = (int)netPack.PlayerID;
|
WindowCenter.Instance.OpenIL<WeddingAnswerWin>();
|
|
}
|
|
public struct MarryReqInfo
|
{
|
public string name;
|
public int BridePriceID;
|
public float startTime;
|
}
|
|
public void AnswerMarry(int isOK)
|
{
|
var pack = new IL_CB312_tagCGMarryResponse();
|
pack.ReqPlayerID = (uint)requestID;
|
pack.IsOK = (byte)isOK;
|
|
GameNetSystem.Instance.SendInfo(pack);
|
MarryReqDict.Remove(requestID);
|
}
|
|
public int GetMarryReqPlayerID()
|
{
|
List<int> removeIDs = new List<int>();
|
var keyList = MarryReqDict.Keys.ToList();
|
int getPlayerID = 0;
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
if (Time.time - MarryReqDict[keyList[i]].startTime > waitTime)
|
{
|
removeIDs.Add(keyList[i]);
|
}
|
if (getPlayerID == 0)
|
{
|
getPlayerID = keyList[i];
|
}
|
}
|
|
for (int i = 0; i < removeIDs.Count; i++)
|
{
|
if (MarryReqDict.ContainsKey(removeIDs[i]))
|
{
|
MarryReqDict.Remove(removeIDs[i]);
|
}
|
}
|
return getPlayerID;
|
}
|
|
//提亲回复
|
public void UpdateMarryResponseRet(IL_HB323_tagGCMarryResponseRet netPack)
|
{
|
if (netPack.PlayerIDA != PlayerDatas.Instance.baseData.PlayerID)
|
return;
|
resultName = netPack.PlayerNameB.Trim().Replace("\0", "");
|
result = netPack.IsOK;
|
WindowCenter.Instance.OpenIL<WeddingAnswerWin>(false, 3);
|
marryReqOkTime = 0;
|
}
|
|
private void OnAfterWindowOpen(Window _window)
|
{
|
if (_window.name == "MainInterfaceWin")
|
{
|
requestID = GetMarryReqPlayerID();
|
if (requestID == 0) return;
|
|
WindowCenter.Instance.OpenIL<WeddingAnswerWin>();
|
}
|
}
|
#endregion
|
|
#region 喜宴
|
public event Action OnSelectCandyBanquet; //选择喜宴
|
CandyInfo m_SelectCandyBanquet;
|
public CandyInfo selectCandyBanquet
|
{
|
get
|
{
|
return m_SelectCandyBanquet;
|
}
|
set
|
{
|
m_SelectCandyBanquet = value;
|
OnSelectCandyBanquet?.Invoke();
|
}
|
}
|
|
public Redpoint sugarRedPoint = new Redpoint(MainRedPoint.SugarRedPoint);
|
public bool candyToggle = false;
|
public bool fireToggle = false;
|
|
public bool isClickCandyList = false;
|
|
public event Action<int, int> OnUpdateCandy;
|
public List<CandyInfo> candyInfoList = new List<CandyInfo>();
|
uint playerAID;
|
uint playerBID;
|
//喜糖
|
public void UpdateCandyList(IL_HB324_tagGCCandyList netPack)
|
{
|
for (int i = 0; i < netPack.CandyCount; i++)
|
{
|
playerAID = netPack.CandyInfoList[i].PlayerIDA;
|
playerBID = netPack.CandyInfoList[i].PlayerIDB;
|
int index = candyInfoList.FindIndex(FindCandyOwner); //FindCandyOwner(playerAID, playerBID);
|
var candy = new CandyInfo() {
|
PlayerIDA = playerAID,
|
PlayerNameA = netPack.CandyInfoList[i].PlayerNameA,
|
PlayerIDB = playerBID,
|
PlayerNameB = netPack.CandyInfoList[i].PlayerNameB,
|
BridePriceID = netPack.CandyInfoList[i].BridePriceID,
|
EndTime = netPack.CandyInfoList[i].EndTime,
|
Prosperity = netPack.CandyInfoList[i].Prosperity,
|
FireworksPlayerBuyCount = netPack.CandyInfoList[i].FireworksPlayerBuyCount,
|
FireworksTotalBuyCount = netPack.CandyInfoList[i].FireworksTotalBuyCount,
|
FreeEatCandyCount = (byte)(freeCandyCnt + onceFireCandyCnt* netPack.CandyInfoList[i].FireworksPlayerBuyCount - netPack.CandyInfoList[i].PlayerFreeEatCandyCount),
|
};
|
|
if (index == -1)
|
{
|
candyInfoList.Add(candy);
|
}
|
else
|
{
|
candyInfoList[index] = candy;
|
}
|
RefreshCandyList(false);
|
OnUpdateCandy?.Invoke((int)playerAID, (int)playerBID);
|
UpdateSugarRedpoint();
|
}
|
|
}
|
|
//AB 和BA 可能是同一对仙侣,每对仙侣只能同时存在一个喜宴,在查找前需要过滤过期
|
//int FindCandyOwner(uint playerAID, uint playerBID)
|
//{
|
// for (int i = 0; i < candyInfoList.Count; i++)
|
// {
|
// if (candyInfoList[i].PlayerIDA == playerAID && candyInfoList[i].PlayerIDB == playerBID)
|
// {
|
// return i;
|
// }
|
// }
|
// return -1;
|
//}
|
bool FindCandyOwner(CandyInfo candy)
|
{
|
if (candy.PlayerIDA == playerAID && candy.PlayerIDB == playerBID)
|
return true;
|
|
return false;
|
}
|
|
public struct CandyInfo
|
{
|
public uint PlayerIDA; // 玩家ID - 请求方
|
public string PlayerNameA;
|
public uint PlayerIDB; // 玩家ID - 接受方
|
public string PlayerNameB;
|
public byte BridePriceID; // 聘礼ID
|
public uint EndTime; // 结束时间戳,秒
|
public uint Prosperity; // 当前繁荣度
|
public byte FireworksTotalBuyCount; // 烟花总已购买次数
|
public byte FireworksPlayerBuyCount; // 烟花玩家已购买次数
|
public byte FreeEatCandyCount; // 还剩免费次数
|
}
|
|
public void RefreshCandyList(bool needSort = true)
|
{
|
List<int> delIndexs = new List<int>();
|
int nowTime = TimeUtility.AllSeconds;
|
for (int i = 0; i < candyInfoList.Count; i++)
|
{
|
int id = candyInfoList[i].BridePriceID;
|
if (candyInfoList[i].EndTime <= nowTime)
|
{
|
delIndexs.Add(i);
|
}
|
}
|
|
delIndexs.Reverse();
|
for (int i = 0; i < delIndexs.Count; i++)
|
{
|
candyInfoList.RemoveAt(delIndexs[i]);
|
}
|
|
if (needSort)
|
{
|
candyInfoList.Sort(SortCandyList);
|
}
|
}
|
|
// 有免费次数>高级类别>结束时间
|
public int SortCandyList(CandyInfo candyA, CandyInfo candyB)
|
{
|
bool hasFreeCntA = candyA.FreeEatCandyCount > 0;
|
bool hasFreeCntB = candyB.FreeEatCandyCount > 0;
|
|
if (hasFreeCntA != hasFreeCntB)
|
{
|
return hasFreeCntB.CompareTo(hasFreeCntA);
|
}
|
|
if (candyA.BridePriceID != candyB.BridePriceID)
|
{
|
return candyB.BridePriceID.CompareTo(candyA.BridePriceID);
|
}
|
|
return candyA.EndTime.CompareTo(candyB.EndTime);
|
|
}
|
|
void UpdateSugarRedpoint()
|
{
|
sugarRedPoint.state = RedPointState.None;
|
for (int i = 0; i < candyInfoList.Count; i++)
|
{
|
if (candyInfoList[i].FreeEatCandyCount > 0)
|
{
|
sugarRedPoint.state = RedPointState.Simple;
|
return;
|
}
|
}
|
}
|
|
public CandyInfo GetCandyInfoByPlayerID(uint playerIDA, uint playerIDB)
|
{
|
for (int i = 0; i < candyInfoList.Count; i++)
|
{
|
if (candyInfoList[i].PlayerIDA == playerIDA && candyInfoList[i].PlayerIDB == playerIDB)
|
{
|
return candyInfoList[i];
|
}
|
}
|
return new CandyInfo();
|
}
|
|
public int eatCandyToday;
|
public event Action EatCandyTodayEvent;
|
public void UpdateLoveInfo(IL_HB330_tagMCLoveInfo netPack)
|
{
|
eatCandyToday = (int)netPack.EatCandyToday;
|
EatCandyTodayEvent?.Invoke();
|
}
|
|
#endregion
|
|
#region 情戒
|
public byte m_ClassLV; // 阶
|
public byte m_StarLV; // 星
|
public uint m_EatCount; // 本星已淬炼道具数
|
public event Action OnLoveRingEvent;
|
public event Action OnLoveRingStarUPEvent;
|
|
public int unLockRingItemID;
|
public int ringLVUPItemID;
|
public Dictionary<int, int> ringLVUPAttr = new Dictionary<int, int>();
|
|
public void UpdateLoveRing(IL_HB327_tagMCLoveRingInfo netPack)
|
{
|
bool islvup = false;
|
if (m_StarLV != netPack.StarLV)
|
{
|
islvup = true;
|
}
|
m_ClassLV = netPack.ClassLV;
|
m_StarLV = netPack.StarLV;
|
m_EatCount = netPack.EatCount;
|
|
OnLoveRingEvent?.Invoke();
|
if (islvup) OnLoveRingStarUPEvent?.Invoke();
|
}
|
|
public void RefreshRingUPAttr()
|
{
|
ringLVUPAttr.Clear();
|
int index = ILLoveRingConfig.GetIndex(m_ClassLV, m_StarLV);
|
//丹经验属性
|
for (int i = 1; i <= index; i++)
|
{
|
var config = ILLoveRingConfig.Get(i);
|
AddLVUPAttr(config);
|
var eatCnt = 0;
|
if (config.useCnt == 0)
|
{
|
//最高级不计算
|
continue;
|
}
|
else if (i == index)
|
{
|
//当前等级取封包数量
|
eatCnt = (int)m_EatCount / config.useCnt;
|
}
|
else
|
{
|
eatCnt = config.NeedEatCount / config.useCnt;
|
}
|
|
for (int j = 0; j < config.UpItemAttrType.Length; j++)
|
{
|
var upKey = config.UpItemAttrType[j];
|
if (!ringLVUPAttr.ContainsKey(upKey))
|
{
|
ringLVUPAttr[upKey] = 0;
|
}
|
|
ringLVUPAttr[upKey] = ringLVUPAttr[upKey] + eatCnt * config.UpItemAttrValue[j];
|
}
|
}
|
}
|
|
//升阶属性
|
void AddLVUPAttr(ILLoveRingConfig config)
|
{
|
for (int i = 0; i < config.StarAttrType.Length; i++)
|
{
|
var upKey = config.StarAttrType[i];
|
if (!ringLVUPAttr.ContainsKey(upKey))
|
{
|
ringLVUPAttr[upKey] = 0;
|
}
|
|
ringLVUPAttr[upKey] = ringLVUPAttr[upKey] + config.StarAttrValue[i];
|
}
|
|
if (m_CoupleID != 0)
|
{
|
for (int i = 0; i < config.CoupleAttrType.Length; i++)
|
{
|
var upKey = config.CoupleAttrType[i];
|
if (!ringLVUPAttr.ContainsKey(upKey))
|
{
|
ringLVUPAttr[upKey] = 0;
|
}
|
|
ringLVUPAttr[upKey] = ringLVUPAttr[upKey] + config.CoupleAttrValue[i];
|
}
|
}
|
}
|
|
//增加属性预览
|
public Dictionary<int, int> GetNextTrainAttr()
|
{
|
int index = ILLoveRingConfig.GetIndex(m_ClassLV, m_StarLV);
|
Dictionary<int, int> nextTrainAttr = new Dictionary<int, int>();
|
var config = ILLoveRingConfig.Get(index);
|
var NextTrainCount = config == null ? 1 : config.useCnt;
|
var NeedEatCount = config == null ? 1 : config.NeedEatCount;
|
if (NextTrainCount == 0)
|
{
|
return nextTrainAttr;
|
}
|
if (index != 0)
|
{
|
for (int i = 0; i < config.UpItemAttrType.Length; i++)
|
{
|
nextTrainAttr[config.UpItemAttrType[i]] = config.UpItemAttrValue[i];
|
}
|
}
|
|
if (m_EatCount + NextTrainCount >= NeedEatCount)
|
{
|
//有升阶的情况
|
var Nextconfig = ILLoveRingConfig.Get(index + 1);
|
|
for (int i = 0; i < Nextconfig.StarAttrType.Length; i++)
|
{
|
if (!nextTrainAttr.ContainsKey(Nextconfig.StarAttrType[i]))
|
{
|
nextTrainAttr[Nextconfig.StarAttrType[i]] = 0;
|
}
|
nextTrainAttr[Nextconfig.StarAttrType[i]] = nextTrainAttr[Nextconfig.StarAttrType[i]] + Nextconfig.StarAttrValue[i];
|
}
|
|
if (m_CoupleID != 0)
|
{
|
for (int i = 0; i < Nextconfig.CoupleAttrType.Length; i++)
|
{
|
if (!nextTrainAttr.ContainsKey(Nextconfig.CoupleAttrType[i]))
|
{
|
nextTrainAttr[Nextconfig.CoupleAttrType[i]] = 0;
|
}
|
nextTrainAttr[Nextconfig.CoupleAttrType[i]] = nextTrainAttr[Nextconfig.CoupleAttrType[i]] + Nextconfig.CoupleAttrValue[i];
|
}
|
}
|
}
|
|
return nextTrainAttr;
|
}
|
|
public int GetTrainCount()
|
{
|
var config = ILLoveRingConfig.GetRingConfigByLVStar(m_ClassLV, m_StarLV);
|
if (config == null)
|
{
|
return 0;
|
}
|
|
return config.useCnt;
|
}
|
|
public Redpoint weddingRedPoint = new Redpoint(MainRedDot.RedPoint_key, MainRedPoint.QYRedPoint);
|
public Redpoint ringRedPoint = new Redpoint(MainRedPoint.QYRedPoint, MainRedPoint.QYRedPoint * 100 + 1);
|
|
void UpdateRingRedPoint()
|
{
|
ringRedPoint.state = RedPointState.None;
|
var count = packModel.GetItemCountByID(PackType.Item, ringLVUPItemID);
|
var useCnt = GetTrainCount();
|
if (useCnt != 0 && count >= GetTrainCount())
|
{
|
ringRedPoint.state = RedPointState.Simple;
|
}
|
}
|
|
private void RefreshItemCount(PackType type, int index, int id)
|
{
|
if (id == ringLVUPItemID)
|
{
|
UpdateRingRedPoint();
|
}
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
UpdateRingRedPoint();
|
}
|
#endregion
|
|
#region 情缘副本
|
public const int qyFBID = 31300;
|
public int isTeamTwo = 0;
|
public int[][] fbShowItems;
|
//日常修行,此处不关联外层
|
public Redpoint fbRedPoint = new Redpoint(MainRedPoint.QYRedPoint * 100 + 2);
|
void UpdateFBRedpoint()
|
{
|
fbRedPoint.state = RedPointState.None;
|
var enterTimes = fbModel.GetEnterTimes(qyFBID);
|
var totalTimes = fbModel.GetTotalTimes(qyFBID);
|
if (enterTimes < totalTimes)
|
{
|
fbRedPoint.state = RedPointState.Simple;
|
}
|
}
|
|
private void UpdateDungeonTimes()
|
{
|
UpdateFBRedpoint();
|
}
|
|
private void OnDungeonRecordUpdate(int _dataMapId)
|
{
|
UpdateDungeonTimes();
|
}
|
|
#endregion
|
}
|