1448 lines
51 KiB
C#
1448 lines
51 KiB
C#
using System;
|
||
using System.Linq;
|
||
using UnityEngine;
|
||
using cfg;
|
||
using LitJson;
|
||
using System.Collections.Generic;
|
||
using asap.core;
|
||
using game;
|
||
using tysdk;
|
||
using UnityEngine.UI;
|
||
|
||
namespace GameCore
|
||
{
|
||
public class FishWeightData
|
||
{
|
||
public int Level;
|
||
public float MaxG;
|
||
public float TotalG;
|
||
public int MaxPTS;
|
||
public long TotalPTS;
|
||
public int TotalCard;
|
||
public int TotalNum;
|
||
public bool NewFish = true;
|
||
public float fishRate;
|
||
}
|
||
|
||
public partial class PlayerFishData
|
||
{
|
||
private cfg.Tables _tables;
|
||
private ICustomServerMgr customServerMgr;
|
||
public PlayerFishData(cfg.Tables tables, ICustomServerMgr customServerMgr)
|
||
{
|
||
this._tables = tables;
|
||
this.customServerMgr = customServerMgr;
|
||
}
|
||
Dictionary<int, Dictionary<int, FishWeightData>> mapFishData = new Dictionary<int, Dictionary<int, FishWeightData>>();
|
||
Dictionary<int, int> mapProgress = new Dictionary<int, int>();
|
||
|
||
Dictionary<int, FishWeightData> fishData = new Dictionary<int, FishWeightData>();
|
||
Dictionary<int, int> fishCardData = new Dictionary<int, int>();
|
||
//鱼杆星级 和 鱼杆碎片数量
|
||
Dictionary<int, int> rodData = new Dictionary<int, int>();
|
||
Dictionary<int, int> rodLevelData = new Dictionary<int, int>();
|
||
//每个地图上的的游弋鱼 item map
|
||
Dictionary<int, int> fishSwimToMap = new Dictionary<int, int>();
|
||
Dictionary<int, int> fishSwimToMapCount = new Dictionary<int, int>();
|
||
int _fishingFrequency = 0;
|
||
int _allFishingFrequency = 0;
|
||
bool _isRedPoint_up;
|
||
bool RodCanUp = false;
|
||
bool RodCanUpLevel = false;
|
||
public int MapTipforUnlocked;
|
||
public bool IsOpenMap = false;
|
||
public bool IsOpenRod = false;
|
||
//public bool IsOpenAutoFish = false;
|
||
|
||
public float InitBotLuck;
|
||
public float InitFishLuck;
|
||
public int BotCount = 0;
|
||
public Dictionary<string, float> LuckDataDic = new Dictionary<string, float>();
|
||
public bool IsOpenPiercing = false;
|
||
public int RodSelectedInPack = 0;
|
||
public void InitData(Dictionary<string, string> userDatas)
|
||
{
|
||
string data_value;
|
||
if (userDatas.TryGetValue("RodData", out data_value))
|
||
{
|
||
rodData = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, int>>(data_value);
|
||
}
|
||
|
||
if (userDatas.TryGetValue("RodLevelData", out data_value))
|
||
{
|
||
rodLevelData = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, int>>(data_value);
|
||
}
|
||
|
||
if (userDatas.TryGetValue("FishingFrequency", out data_value))
|
||
{
|
||
_fishingFrequency = GlobalUtils.TryParseInt(data_value);
|
||
GContext.Publish(new ExchangeFishCount(_fishingFrequency));
|
||
}
|
||
|
||
if (userDatas.TryGetValue("AllFishingFrequency", out data_value))
|
||
{
|
||
_allFishingFrequency = (GlobalUtils.TryParseInt(data_value));
|
||
}
|
||
|
||
if (userDatas.TryGetValue("LuckDataDic", out data_value))
|
||
{
|
||
LuckDataDic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, float>>(data_value);
|
||
}
|
||
|
||
if (userDatas.TryGetValue("FishSwimToMap", out data_value))
|
||
{
|
||
fishSwimToMap = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, int>>(data_value);
|
||
}
|
||
|
||
if (userDatas.TryGetValue("FishSwimToMapCount", out data_value))
|
||
{
|
||
fishSwimToMapCount = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, int>>(data_value);
|
||
}
|
||
|
||
if (userDatas.TryGetValue("MapProgress", out data_value))
|
||
{
|
||
InitMapProgress(data_value);
|
||
}
|
||
|
||
if (userDatas.TryGetValue(InitRodAccessoriesDataKey, out data_value))
|
||
{
|
||
InitRodAccessoriesData(data_value);
|
||
}
|
||
if (userDatas.TryGetValue(HonorLevelDataKey, out data_value))
|
||
{
|
||
_honorlevel = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, int>>(data_value);
|
||
}
|
||
Dictionary<int, MapData> mapTBData = _tables.TbMapData.DataMap;
|
||
foreach (var map in mapTBData)
|
||
{
|
||
if (userDatas.TryGetValue($"Map_{map.Key}", out data_value))
|
||
{
|
||
SetFishAllData(map.Key, data_value);
|
||
}
|
||
}
|
||
#if AGG
|
||
int lv = GetAllLevel();
|
||
GEvent.SetProp("fishcard_level", lv);
|
||
GEvent.SetUserProp("fishcard_level", lv);
|
||
#endif
|
||
}
|
||
|
||
public void SaveFishingFrequency()
|
||
{
|
||
_fishingFrequency++;
|
||
GContext.Publish(new ExchangeFishCount(_fishingFrequency));
|
||
_allFishingFrequency += GContext.container.Resolve<PlayerData>().GetMagnification();
|
||
GContext.Publish(new ConditionTypeEvent(ConditionType.GetFishCount, 1));
|
||
PlayFabMgr.Instance.UpdateUserDataValue("FishingFrequency", _fishingFrequency.ToString());
|
||
PlayFabMgr.Instance.UpdateUserDataValue("AllFishingFrequency", _allFishingFrequency.ToString());
|
||
}
|
||
|
||
public int GetDiffFishCount()
|
||
{
|
||
return fishData.Count;
|
||
}
|
||
public int GetAnglingCount()
|
||
{
|
||
return _fishingFrequency;
|
||
}
|
||
//public int GetFishingCount()
|
||
//{
|
||
// SmallGameData smallGameData = GContext.container.Resolve<SmallGameData>();
|
||
// return _fishingFrequency - smallGameData.BombGameCount - smallGameData.HeistGameCount;
|
||
//}
|
||
|
||
public void Init()
|
||
{
|
||
InitRodAccessoriesData();
|
||
InitLuck();
|
||
InitRod();
|
||
}
|
||
void InitLuck()
|
||
{
|
||
var config = _tables.TbGlobalConfig;
|
||
if (!LuckDataDic.TryGetValue("InitBotLuck", out InitBotLuck))
|
||
{
|
||
InitBotLuck = config.InitBotLuck;
|
||
}
|
||
if (!LuckDataDic.TryGetValue("InitFishLuck", out InitFishLuck))
|
||
{
|
||
InitFishLuck = config.InitFishLuck;
|
||
}
|
||
float botCount;
|
||
if (!LuckDataDic.TryGetValue("BotCount", out botCount))
|
||
{
|
||
botCount = 0;
|
||
}
|
||
BotCount = (int)botCount;
|
||
}
|
||
/// <summary>
|
||
/// 修改幸运值
|
||
/// </summary>
|
||
/// <param name="value">鱼的品质 0=》漂流瓶</param>
|
||
public void SetBotCount(int value)
|
||
{
|
||
//添加幸运值
|
||
if (value > 5)
|
||
{
|
||
return;
|
||
}
|
||
float luck = GContext.container.Resolve<PlayerData>().GetLuckMultipier();
|
||
var config = _tables.TbGlobalConfig;
|
||
if (value == 0)
|
||
{
|
||
BotCount++;
|
||
InitBotLuck += config.ModifierToBotLuck[0] * luck;
|
||
}
|
||
else
|
||
{
|
||
InitBotLuck += config.ModifierToBotLuck[1] * luck;
|
||
MoreFish moreFish = GContext.container.Resolve<BuffDataCenter>().GetWeelyBuffTimeData<MoreFish>();
|
||
if (moreFish != null && moreFish.Quality == value)
|
||
{
|
||
InitFishLuck += moreFish.ModifierToFishLuck * luck;
|
||
}
|
||
else
|
||
{
|
||
InitFishLuck += config.ModifierToFishLuck[value - 1] * luck;
|
||
}
|
||
|
||
BotCount = 0;
|
||
}
|
||
if (InitFishLuck < 0)
|
||
{
|
||
InitFishLuck = 0;
|
||
}
|
||
if (InitBotLuck < 0)
|
||
{
|
||
InitBotLuck = 0;
|
||
}
|
||
GameDebug.Log("InitBotLuck:" + InitBotLuck + " InitFishLuck:" + InitFishLuck + " BotCount:" + BotCount);
|
||
LuckDataDic["InitFishLuck"] = InitFishLuck;
|
||
LuckDataDic["InitBotLuck"] = InitBotLuck;
|
||
LuckDataDic["BotCount"] = BotCount;
|
||
PlayFabMgr.Instance.UpdateUserDataValue("LuckDataDic", JsonMapper.ToJson(LuckDataDic));
|
||
}
|
||
void InitRod()
|
||
{
|
||
if (!rodData.ContainsKey(_tables.TbRodData.DataList[0].ID))
|
||
{
|
||
rodData[_tables.TbRodData.DataList[0].ID] = 0;
|
||
}
|
||
else
|
||
{
|
||
CheckRodRedPointUp();
|
||
CheckAllRodUpLevel();
|
||
}
|
||
}
|
||
public void CheckRodRedPointUp()
|
||
{
|
||
_isRedPoint_up = false;
|
||
RodCanUp = false;
|
||
List<RodData> rodDatas = _tables.TbRodData.DataList;
|
||
RodAscend rodAscend;
|
||
for (int i = 0; i < rodDatas.Count; i++)
|
||
{
|
||
rodAscend = _tables.TbRodAscend[rodDatas[i].AscendID];
|
||
if (rodData.TryGetValue(rodAscend.FragmentID, out int itemCount))
|
||
{
|
||
if (rodData.TryGetValue(rodDatas[i].ID, out int star))
|
||
{
|
||
if (rodAscend.MaxAscent > star && itemCount >= rodAscend.AscentTransformed[star + 1])
|
||
{
|
||
RodCanUp = true;
|
||
_isRedPoint_up = true;
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (itemCount >= rodAscend.AscentTransformed[0])
|
||
{
|
||
_isRedPoint_up = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
SetRedPoint();
|
||
}
|
||
public bool CheckRodUpLevelByID(int id)
|
||
{
|
||
RodData rodDataA = _tables.TbRodData.GetOrDefault(id);
|
||
bool isUp = CheckRodUpLevel(rodDataA);
|
||
return isUp;
|
||
}
|
||
public bool CheckRodUpLevel(RodData rodDataA)
|
||
{
|
||
bool isUp = false;
|
||
if (rodData.TryGetValue(rodDataA.ID, out int star))
|
||
{
|
||
RodLevelup rodLevelup = _tables.TbRodLevelup.GetOrDefault(rodDataA.LevelupID);
|
||
int level = GetRodLevel(rodDataA.ID) + 1;//数据从0开始,显示从1开始
|
||
bool isMax = rodLevelup.MaxLevel <= level;
|
||
if (!isMax)
|
||
{
|
||
var fragment = GContext.container.Resolve<PlayerData>().pearl;
|
||
var requireNum = rodLevelup.LevelupConsume[level];
|
||
|
||
List<int> Millestones = rodLevelup.Millestones;
|
||
int maxLevel = level + 1;
|
||
|
||
for (int i = 0; i < Millestones.Count; i++)
|
||
{
|
||
if (i == star)
|
||
{
|
||
maxLevel = Millestones[i];
|
||
break;
|
||
}
|
||
}
|
||
if (maxLevel > level && fragment >= requireNum)
|
||
{
|
||
isUp = true;
|
||
}
|
||
}
|
||
}
|
||
return isUp;
|
||
}
|
||
public void CheckAllRodUpLevel()
|
||
{
|
||
RodCanUpLevel = false;
|
||
List<RodData> rodDatas = _tables.TbRodData.DataList;
|
||
for (int j = 0; j < rodDatas.Count; j++)
|
||
{
|
||
RodData rodDataA = rodDatas[j];
|
||
|
||
RodCanUpLevel = CheckRodUpLevel(rodDataA);
|
||
if (RodCanUpLevel)
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
SetRedPoint();
|
||
}
|
||
public void SetRedPoint()
|
||
{
|
||
PlayerData playerData = GContext.container.Resolve<PlayerData>();
|
||
//bool isUp = CheckRodUpLevelByID(playerData.equipRodID);
|
||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Rod, RodCanUpLevel || _isRedPoint_up || playerData.newRodList.Count > 0);
|
||
}
|
||
public ExchangeItemData AddNewRod(int id, int count)
|
||
{
|
||
ExchangeItemData itemRodExchangePiece = new ExchangeItemData();
|
||
for (int i = 0; i < count; i++)
|
||
{
|
||
if (rodData.ContainsKey(id))
|
||
{
|
||
RodData _rodData = _tables.TbRodData.GetOrDefault(id);
|
||
if (_rodData != null)
|
||
{
|
||
RodAscend rodAscend = _tables.TbRodAscend.GetOrDefault(_rodData.AscendID);
|
||
if (rodAscend != null)
|
||
{
|
||
itemRodExchangePiece.exchangeId = rodAscend.FragmentID;
|
||
itemRodExchangePiece.exchangeCount += rodAscend.DuplicationTransformed;
|
||
AddRodPiece(rodAscend.FragmentID, rodAscend.DuplicationTransformed);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GContext.container.Resolve<PlayerData>().AddNewRod(id);
|
||
rodData.Add(id, 0);
|
||
PlayFabMgr.Instance.UpdateUserDataValue("RodData", JsonMapper.ToJson(rodData));
|
||
//鱼竿红点数据修改
|
||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Rod, true);
|
||
}
|
||
}
|
||
return itemRodExchangePiece;
|
||
}
|
||
public bool GetRodCanUp()
|
||
{
|
||
return RodCanUp;
|
||
}
|
||
public bool GetRodCanUpLevel()
|
||
{
|
||
return RodCanUpLevel;
|
||
}
|
||
public int GetRodAllCount()
|
||
{
|
||
int count = 0;
|
||
foreach (var item in rodData)
|
||
{
|
||
if (item.Key < 10000000)
|
||
{
|
||
count++;
|
||
}
|
||
}
|
||
return count;
|
||
}
|
||
public int GetRoodAllLevel()
|
||
{
|
||
int count = 0;
|
||
foreach (var item in rodLevelData)
|
||
{
|
||
count += item.Value;
|
||
}
|
||
return count;
|
||
}
|
||
int GetRodAllStar()
|
||
{
|
||
int count = 0;
|
||
foreach (var item in rodData)
|
||
{
|
||
if (item.Key < 10000000)
|
||
{
|
||
count += item.Value;
|
||
}
|
||
}
|
||
return count;
|
||
}
|
||
public int GetRodAllScore()
|
||
{
|
||
int points1 = _tables.TbRodEarnPoints[1].Points;
|
||
int points2 = _tables.TbRodEarnPoints[2].Points;
|
||
int allLevel = GetRoodAllLevel();
|
||
int allStar = GetRodAllStar();
|
||
int score = allStar * points2 + allLevel * points1;
|
||
return score;
|
||
}
|
||
|
||
public float GetRodAscendStats()
|
||
{
|
||
int allScore = GetRodAllScore();
|
||
var dataList = GContext.container.Resolve<Tables>().TbRodLevelupStats.DataList;
|
||
float PointBonus = 0;
|
||
for (int i = 0; i < dataList.Count; i++)
|
||
{
|
||
if (allScore < dataList[i].Count)
|
||
{
|
||
break;
|
||
}
|
||
PointBonus += dataList[i].PointBonus;
|
||
}
|
||
return PointBonus;
|
||
}
|
||
|
||
public void RodLevelUp(int id, int count)
|
||
{
|
||
GContext.Publish(new ConditionTypeEvent { type = ConditionType.UpgradeRodTimes, count = 1 });
|
||
if (rodLevelData.TryGetValue(id, out int level))
|
||
{
|
||
rodLevelData[id]++;
|
||
}
|
||
else
|
||
{
|
||
rodLevelData[id] = 1;
|
||
}
|
||
#if AGG
|
||
using (var e = GEvent.GameEvent("item_change", gaSend: false))
|
||
{
|
||
e.AddContent("item_id", 1003)
|
||
.AddContent("state_info", "cost")
|
||
.AddContent("change_num", count);
|
||
}
|
||
using (var e = GEvent.GameEvent("rod_upgrade"))
|
||
{
|
||
e.AddContent("rod_id", id)
|
||
.AddContent("rod_level", GetRodLevel(id))
|
||
.AddContent("resin_consume", count)
|
||
.AddContent("rod_star", rodData[id])
|
||
.AddContent("rod_chips_consume", 0);
|
||
}
|
||
#endif
|
||
PlayFabMgr.Instance.UpdateUserDataValue("RodLevelData", JsonMapper.ToJson(rodLevelData));
|
||
|
||
GContext.container.Resolve<PlayerData>().SetPearl(GContext.container.Resolve<PlayerData>().pearl - count);
|
||
}
|
||
public int GetRodLevel(int id)
|
||
{
|
||
return rodLevelData.TryGetValue(id, out int level) ? level : 0;
|
||
}
|
||
|
||
public bool CheckUpgrade(RodData data)
|
||
{
|
||
int rodId = data.ID;
|
||
RodAscend _rodAscend = _tables.TbRodAscend.GetOrDefault(data.AscendID);
|
||
bool isLock = NotRod(rodId);
|
||
int star = isLock ? -1 : GetRodPiece(rodId);
|
||
|
||
bool isMax = star >= _rodAscend.MaxAscent;
|
||
if (isLock || isMax)
|
||
{
|
||
return false;
|
||
}
|
||
int fragment = GetRodPiece(_rodAscend.FragmentID);
|
||
int requireNum = _rodAscend.AscentTransformed[star + 1];
|
||
if (fragment >= requireNum)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
///还有判断通用碎片
|
||
int rquiredFragments = requireNum - fragment;
|
||
fragment = 0;
|
||
RodFragmentExchange rodFragmentExchange = _tables.TbRodFragmentExchange.GetOrDefault(data.Quality);
|
||
if (rodFragmentExchange != null)
|
||
{
|
||
rquiredFragments *= rodFragmentExchange.ExchangeRate;
|
||
fragment = GetRodPiece(rodFragmentExchange.GeneralFragmentID);
|
||
}
|
||
return fragment >= rquiredFragments;
|
||
|
||
}
|
||
|
||
|
||
public void AddRodPiece(int id, int count)
|
||
{
|
||
if (rodData.ContainsKey(id))
|
||
{
|
||
rodData[id] += count;
|
||
}
|
||
else
|
||
{
|
||
rodData.Add(id, count);
|
||
}
|
||
//鱼竿红点数据修改
|
||
CheckRodRedPointUp();
|
||
PlayFabMgr.Instance.UpdateUserDataValue("RodData", JsonMapper.ToJson(rodData));
|
||
}
|
||
|
||
public int GetRodPiece(int id)
|
||
{
|
||
return rodData.ContainsKey(id) ? rodData[id] : 0;
|
||
}
|
||
|
||
public void GMSetLvAll(int lv)
|
||
{
|
||
if (lv <= 0)
|
||
{
|
||
return;
|
||
}
|
||
List<RodData> rodTBData = _tables.TbRodData.DataList;
|
||
for (int i = 0; i < rodTBData.Count; i++)
|
||
{
|
||
RodData rodData = rodTBData[i];
|
||
rodLevelData[rodData.ID] = lv;
|
||
RodLevelup rodLevelup = _tables.TbRodLevelup.GetOrDefault(rodData.LevelupID);
|
||
if (lv >= rodLevelup.MaxLevel)
|
||
{
|
||
rodLevelData[rodData.ID] = rodLevelup.MaxLevel - 1;
|
||
}
|
||
else
|
||
{
|
||
rodLevelData[rodData.ID] = lv;
|
||
}
|
||
}
|
||
|
||
PlayFabMgr.Instance.UpdateUserDataValue("RodData", JsonMapper.ToJson(rodData));
|
||
}
|
||
|
||
public void GMSetStarAll(int lv)
|
||
{
|
||
if (lv <= 0)
|
||
{
|
||
return;
|
||
}
|
||
List<RodData> rodTBData = _tables.TbRodData.DataList;
|
||
for (int i = 0; i < rodTBData.Count; i++)
|
||
{
|
||
RodData _rodData = rodTBData[i];
|
||
|
||
RodAscend rodAscend = _tables.TbRodAscend.GetOrDefault(_rodData.AscendID);
|
||
|
||
if (lv >= rodAscend.AscentTransformed.Count)
|
||
{
|
||
rodData[_rodData.ID] = rodAscend.AscentTransformed.Count - 1;
|
||
}
|
||
else
|
||
{
|
||
rodData[_rodData.ID] = lv;
|
||
}
|
||
}
|
||
|
||
PlayFabMgr.Instance.UpdateUserDataValue("RodData", JsonMapper.ToJson(rodData));
|
||
}
|
||
|
||
public void GMAddAllFishMastery(bool all = false)
|
||
{
|
||
FishData fishTBData;
|
||
cfg.FishCard cardTBData;
|
||
if (!all)
|
||
{
|
||
MapData mapTBData = _tables.TbMapData.DataMap[GContext.container.Resolve<PlayerData>().currentMapId];
|
||
List<int> fishList = mapTBData.FishList;
|
||
Dictionary<int, FishWeightData> _fishData =
|
||
mapFishData.TryGetValue(GContext.container.Resolve<PlayerData>().currentMapId, out var v)
|
||
? v
|
||
: new Dictionary<int, FishWeightData>();
|
||
foreach (var fish in fishList)
|
||
{
|
||
fishTBData = _tables.TbFishData.DataMap[fish];
|
||
cardTBData = _tables.TbFishCard.DataMap[fishTBData.FishCardID];
|
||
FishWeightData fishWeightData = new FishWeightData();
|
||
|
||
if (fishData.ContainsKey(fishTBData.ID))
|
||
{
|
||
fishWeightData = fishData[fishTBData.ID];
|
||
}
|
||
else
|
||
{
|
||
fishData[fishTBData.ID] = fishWeightData;
|
||
if (mapFishData.ContainsKey(mapTBData.ID))
|
||
{
|
||
mapFishData[mapTBData.ID][fishTBData.ID] = fishWeightData;
|
||
}
|
||
else
|
||
{
|
||
mapFishData[mapTBData.ID] = new Dictionary<int, FishWeightData>
|
||
{
|
||
[fishTBData.ID] = fishWeightData
|
||
};
|
||
}
|
||
|
||
}
|
||
if (fishWeightData.MaxPTS == 0)
|
||
{
|
||
fishWeightData.MaxPTS = 1;
|
||
}
|
||
if (fishWeightData.MaxG <= 0)
|
||
{
|
||
fishWeightData.MaxG = 1;
|
||
}
|
||
if (fishWeightData.Level < cardTBData.MaxLevel)
|
||
{
|
||
fishWeightData.Level += 1;
|
||
}
|
||
|
||
fishWeightData.TotalCard =
|
||
Math.Max(cardTBData.CardsRequiredList[fishWeightData.Level - 1],
|
||
fishWeightData.TotalCard);
|
||
fishCardData[fishTBData.FishCardID] = fishWeightData.TotalCard;
|
||
}
|
||
|
||
PlayFabMgr.Instance.UpdateUserDataValue($"Map_{GContext.container.Resolve<PlayerData>().currentMapId}",
|
||
JsonMapper.ToJson(_fishData));
|
||
}
|
||
else
|
||
{
|
||
Dictionary<int, MapData> mapTBData = _tables.TbMapData.DataMap;
|
||
foreach (var map in mapTBData)
|
||
{
|
||
List<int> fishList = map.Value.FishList;
|
||
Dictionary<int, FishWeightData> _fishData = mapFishData.TryGetValue(map.Key, out var v)
|
||
? v
|
||
: new Dictionary<int, FishWeightData>();
|
||
foreach (var fish in fishList)
|
||
{
|
||
fishTBData = _tables.TbFishData.DataMap[fish];
|
||
cardTBData = _tables.TbFishCard.DataMap[fishTBData.FishCardID];
|
||
FishWeightData fishWeightData = new FishWeightData();
|
||
if (fishData.ContainsKey(fishTBData.ID))
|
||
{
|
||
fishWeightData = fishData[fishTBData.ID];
|
||
}
|
||
else
|
||
{
|
||
fishData[fishTBData.ID] = fishWeightData;
|
||
if (mapFishData.ContainsKey(map.Key))
|
||
{
|
||
mapFishData[map.Key][fishTBData.ID] = fishWeightData;
|
||
}
|
||
else
|
||
{
|
||
mapFishData[map.Key] = new Dictionary<int, FishWeightData>
|
||
{
|
||
[fishTBData.ID] = fishWeightData
|
||
};
|
||
}
|
||
|
||
}
|
||
if (fishWeightData.MaxPTS == 0)
|
||
{
|
||
fishWeightData.MaxPTS = 1;
|
||
}
|
||
if (fishWeightData.MaxG <= 0)
|
||
{
|
||
fishWeightData.MaxG = 1;
|
||
}
|
||
if (fishWeightData.Level < cardTBData.MaxLevel)
|
||
{
|
||
fishWeightData.Level += 1;
|
||
}
|
||
|
||
fishWeightData.TotalCard =
|
||
Math.Max(cardTBData.CardsRequiredList[fishWeightData.Level - 1],
|
||
fishWeightData.TotalCard);
|
||
fishCardData[fishTBData.FishCardID] = fishWeightData.TotalCard;
|
||
}
|
||
|
||
PlayFabMgr.Instance.UpdateUserDataValue($"Map_{map.Key}", JsonMapper.ToJson(_fishData));
|
||
}
|
||
}
|
||
}
|
||
|
||
public void GMAddAllFishMastery1(bool all = false)
|
||
{
|
||
FishData fishTBData;
|
||
cfg.FishCard masteryTBData;
|
||
|
||
if (!all)
|
||
{
|
||
MapData mapTBData = _tables.TbMapData.DataMap[GContext.container.Resolve<PlayerData>().currentMapId];
|
||
List<int> fishList = mapTBData.FishList;
|
||
|
||
foreach (var fish in fishList)
|
||
{
|
||
fishTBData = _tables.TbFishData.DataMap[fish];
|
||
masteryTBData = _tables.TbFishCard.DataMap[fishTBData.FishCardID];
|
||
FishWeightData fishWeightData = new FishWeightData();
|
||
if (fishData.ContainsKey(fishTBData.ID))
|
||
{
|
||
fishWeightData = fishData[fishTBData.ID];
|
||
}
|
||
else
|
||
{
|
||
fishData[fishTBData.ID] = fishWeightData;
|
||
if (mapFishData.ContainsKey(mapTBData.ID))
|
||
{
|
||
mapFishData[mapTBData.ID][fishTBData.ID] = fishWeightData;
|
||
}
|
||
else
|
||
{
|
||
mapFishData[mapTBData.ID] = new Dictionary<int, FishWeightData>
|
||
{
|
||
[fishTBData.ID] = fishWeightData
|
||
};
|
||
}
|
||
|
||
}
|
||
fishWeightData.TotalCard = masteryTBData.CardsRequiredList[masteryTBData.MaxLevel - 1];
|
||
fishWeightData.Level = masteryTBData.MaxLevel;
|
||
fishCardData[fishTBData.FishCardID] = fishWeightData.TotalCard;
|
||
}
|
||
|
||
PlayFabMgr.Instance.UpdateUserDataValue($"Map_{GContext.container.Resolve<PlayerData>().currentMapId}",
|
||
JsonMapper.ToJson(mapFishData[GContext.container.Resolve<PlayerData>().currentMapId]));
|
||
}
|
||
else
|
||
{
|
||
Dictionary<int, MapData> mapTBData = _tables.TbMapData.DataMap;
|
||
foreach (var map in mapTBData)
|
||
{
|
||
List<int> fishList = map.Value.FishList;
|
||
|
||
foreach (var fish in fishList)
|
||
{
|
||
fishTBData = _tables.TbFishData.DataMap[fish];
|
||
masteryTBData = _tables.TbFishCard.DataMap[fishTBData.FishCardID];
|
||
FishWeightData fishWeightData = new FishWeightData();
|
||
if (fishData.ContainsKey(fishTBData.ID))
|
||
{
|
||
fishWeightData = fishData[fishTBData.ID];
|
||
}
|
||
else
|
||
{
|
||
fishData[fishTBData.ID] = fishWeightData;
|
||
if (mapFishData.ContainsKey(map.Key))
|
||
{
|
||
mapFishData[map.Key][fishTBData.ID] = fishWeightData;
|
||
}
|
||
else
|
||
{
|
||
mapFishData[map.Key] = new Dictionary<int, FishWeightData>
|
||
{
|
||
[fishTBData.ID] = fishWeightData
|
||
};
|
||
}
|
||
|
||
}
|
||
|
||
fishWeightData.TotalCard = masteryTBData.CardsRequiredList[masteryTBData.MaxLevel - 1];
|
||
fishWeightData.Level = masteryTBData.MaxLevel;
|
||
fishCardData[fishTBData.FishCardID] = fishWeightData.TotalCard;
|
||
}
|
||
|
||
PlayFabMgr.Instance.UpdateUserDataValue($"Map_{map.Key}",
|
||
JsonMapper.ToJson(mapFishData[map.Key]));
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
public bool NotRod(int id)
|
||
{
|
||
return !rodData.ContainsKey(id);
|
||
}
|
||
|
||
public void SetFishAllData(int key, string data)
|
||
{
|
||
Dictionary<int, FishWeightData> mapData = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, FishWeightData>>(data);
|
||
Dictionary<int, FishWeightData> mapDataNew = new Dictionary<int, FishWeightData>();
|
||
foreach (var fishWeightData in mapData)
|
||
{
|
||
var _fish = _tables.TbFishData.GetOrDefault(fishWeightData.Key);
|
||
if (_fish != null)
|
||
{
|
||
if (_fish.AreaID != key)
|
||
{
|
||
Debug.Log("fishWeightData.AreaID " + fishWeightData.Key + " " + key);
|
||
|
||
continue;
|
||
}
|
||
mapDataNew.Add(_fish.ID, fishWeightData.Value);
|
||
fishData[_fish.ID] = fishWeightData.Value;
|
||
if (fishWeightData.Value.Level > 0)
|
||
{
|
||
cfg.FishCard fishCard = _tables.TbFishCard[_fish.FishCardID];
|
||
if (fishWeightData.Value.Level > fishCard.MaxLevel)
|
||
{
|
||
fishWeightData.Value.Level = fishCard.MaxLevel;
|
||
}
|
||
int startWeight = fishCard.CardsRequiredList[fishWeightData.Value.Level - 1];
|
||
if (startWeight > fishWeightData.Value.TotalCard)
|
||
{
|
||
fishWeightData.Value.TotalCard = startWeight;
|
||
}
|
||
}
|
||
fishCardData[_fish.FishCardID] = fishWeightData.Value.TotalCard;
|
||
}
|
||
}
|
||
mapFishData[key] = mapDataNew;
|
||
}
|
||
|
||
public void SetDataLevel(int id)
|
||
{
|
||
if (fishData.ContainsKey(id))
|
||
{
|
||
fishData[id].Level++;
|
||
SetFishData(id, fishData[id]);
|
||
}
|
||
}
|
||
public void SetDataLevel(int id, int lv)
|
||
{
|
||
if (fishData.ContainsKey(id))
|
||
{
|
||
fishData[id].Level = lv;
|
||
SetFishData(id, fishData[id]);
|
||
}
|
||
}
|
||
public void UpDateLevel(int id)
|
||
{
|
||
SetDataLevel(id);
|
||
|
||
//鱼卡战令
|
||
GContext.Publish(new ConditionTypeEvent(ConditionType.FishCardLevelUp, 1));
|
||
#if AGG
|
||
int allLv = GetAllLevel();
|
||
GEvent.SetProp("fishcard_level", allLv);
|
||
GEvent.SetUserProp("fishcard_level", allLv);
|
||
using (var e = GEvent.GameEvent("fishcard_upgrade"))
|
||
{
|
||
e.AddContent("level_count", 1);
|
||
}
|
||
|
||
#endif
|
||
}
|
||
|
||
//仅排行榜上传使用
|
||
public void SetRate(int fishId, float value)
|
||
{
|
||
CheckFishData(fishId);
|
||
if (fishData[fishId].fishRate < value)
|
||
{
|
||
fishData[fishId].fishRate = value;
|
||
SetFishData(fishId, fishData[fishId]);
|
||
}
|
||
}
|
||
|
||
public void SetWeight(int fishId, float weight)
|
||
{
|
||
//获取鱼重量记录为g
|
||
GContext.Publish(new ConditionTypeEvent(ConditionType.GetFishWeight, (int)(weight * 1000)));
|
||
CheckFishData(fishId);
|
||
if (fishData[fishId].MaxG < weight)
|
||
{
|
||
fishData[fishId].MaxG = weight;
|
||
SetFishData(fishId, fishData[fishId]);
|
||
}
|
||
}
|
||
public void AddTotalWeight(int fishId, float weight)
|
||
{
|
||
CheckFishData(fishId);
|
||
fishData[fishId].TotalG += weight;
|
||
//获取鱼重量记录为g
|
||
SetFishData(fishId, fishData[fishId]);
|
||
GContext.Publish(new ConditionTypeEvent(ConditionType.GetFishID, fishId));
|
||
}
|
||
public void SetMaxMastery(int fishId, int mastery)
|
||
{
|
||
CheckFishData(fishId);
|
||
if (fishData[fishId].MaxPTS < mastery)
|
||
{
|
||
fishData[fishId].MaxPTS = mastery;
|
||
SetFishData(fishId, fishData[fishId]);
|
||
}
|
||
}
|
||
public int GetMaxMastery(int fishId)
|
||
{
|
||
if (fishData.ContainsKey(fishId))
|
||
{
|
||
return fishData[fishId].MaxPTS;
|
||
}
|
||
else
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
public void AddTotalMastery(int fishId, int totalMastery)
|
||
{
|
||
CheckFishData(fishId);
|
||
fishData[fishId].TotalPTS = 0;// += totalMastery;
|
||
SetFishData(fishId, fishData[fishId]);
|
||
}
|
||
public long GetTotalMastery(int fishId)
|
||
{
|
||
CheckFishData(fishId);
|
||
return fishData[fishId].TotalPTS;
|
||
}
|
||
|
||
public void UpdateFishRank(int fishId)
|
||
{
|
||
int mapID = _tables.TbFishData.GetOrDefault(fishId).AreaID;
|
||
Dictionary<string, float> extra = new Dictionary<string, float>
|
||
{
|
||
["rating"] = fishData[fishId].fishRate,
|
||
["weight"] = fishData[fishId].TotalG,
|
||
};
|
||
//GContext.container.Resolve<LeadboardData>().UpdateFishRank(mapID, fishId, fishData[fishId].TotalMastery, extra);
|
||
}
|
||
public ExchangeItemData AddTotalCard(int id, int totalCard)
|
||
{
|
||
ExchangeItemData exchangeItemData = null;
|
||
GContext.Publish(new ConditionTypeEvent { type = ConditionType.CollectFishCardCount, count = totalCard });
|
||
if (fishCardData.ContainsKey(id))
|
||
{
|
||
fishCardData[id] += totalCard;
|
||
}
|
||
else
|
||
{
|
||
fishCardData[id] = totalCard;
|
||
}
|
||
|
||
var cardData = _tables.TbFishCard.DataMap[id];
|
||
int fishId = cardData.FishID;
|
||
CheckFishData(fishId);
|
||
fishData[fishId].TotalCard += totalCard;
|
||
|
||
int cardCount = fishCardData[id];
|
||
int allCount = cardData.CardsRequiredList[^1];
|
||
if (cardCount > allCount)
|
||
{
|
||
int extra = cardCount - allCount;
|
||
fishCardData[id] = allCount;
|
||
fishData[fishId].TotalCard = allCount;
|
||
//鱼卡转换道具
|
||
var dropExchange = _tables.TbFishCardExchange.GetOrDefault(cardData.Quality);
|
||
if (dropExchange != null)
|
||
{
|
||
var itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(dropExchange.DropID);
|
||
itemData.count *= extra;
|
||
GContext.container.Resolve<PlayerItemData>().AddItemCount(itemData.id, itemData.count);
|
||
exchangeItemData = new ExchangeItemData
|
||
{
|
||
exchangeId = itemData.id,
|
||
curCount = itemData.curCount,
|
||
exchangeCount = Mathf.RoundToInt(itemData.count)
|
||
};
|
||
}
|
||
}
|
||
SetFishData(fishId, fishData[fishId]);
|
||
return exchangeItemData;
|
||
}
|
||
void CheckFishData(int fishId)
|
||
{
|
||
if (!fishData.ContainsKey(fishId))
|
||
{
|
||
fishData.Add(fishId, new FishWeightData() { NewFish = true });
|
||
}
|
||
}
|
||
public void SetGetFishCount(int fishId)
|
||
{
|
||
int count = GContext.container.Resolve<PlayerData>().GetMagnification();
|
||
CheckFishData(fishId);
|
||
fishData[fishId].TotalNum += count;
|
||
}
|
||
public int GetCardDataProficiency(int id)
|
||
{
|
||
if (fishCardData.ContainsKey(id))
|
||
{
|
||
return fishCardData[id];
|
||
}
|
||
else
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
public bool GetFishCanLevel()
|
||
{
|
||
var dataList = _tables.TbMapData.DataList;
|
||
int count = dataList.Count;
|
||
int levelRequired = 0;
|
||
for (int i = 0; i < count; i++)
|
||
{
|
||
if (i > 0)
|
||
{
|
||
levelRequired = dataList[i - 1].LevelRequired;
|
||
}
|
||
if (GContext.container.Resolve<PlayerData>().lv >= levelRequired)
|
||
{
|
||
if (GetMapRedCount(dataList[i].FishList) > 0)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
public List<int> GetFishCardIdsCanLevelUpAll()
|
||
{
|
||
var dataList = _tables.TbMapData.DataList;
|
||
int count = dataList.Count;
|
||
int levelRequired = 0;
|
||
var fishCardIds = new List<int>();
|
||
for (int i = 0; i < count; i++)
|
||
{
|
||
if (i > 0)
|
||
{
|
||
levelRequired = dataList[i - 1].LevelRequired;
|
||
}
|
||
if (GContext.container.Resolve<PlayerData>().lv >= levelRequired)
|
||
{
|
||
var fishIds = dataList[i].FishList;
|
||
foreach (var id in fishIds)
|
||
{
|
||
var fishCard = _tables.TbFishCard[_tables.TbFishData.DataMap[id].FishCardID];
|
||
int level = GetDataLevel(id);
|
||
if (level < fishCard.MaxLevel && GetCardDataProficiency(fishCard.ID) >= fishCard.CardsRequiredList[level])
|
||
{
|
||
fishCardIds.Add(fishCard.ID);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
return fishCardIds;
|
||
}
|
||
public void AutoUpgradeFishCardAll()
|
||
{
|
||
int level;
|
||
int fishId;
|
||
Dictionary<int, int> cardData = new Dictionary<int, int>(fishCardData);
|
||
int allUpLevel = 0;
|
||
foreach (var fishData in cardData)
|
||
{
|
||
var fishCard = _tables.TbFishCard.GetOrDefault(fishData.Key);
|
||
if (fishCard == null)
|
||
{
|
||
Debug.LogError($"FishCard not found for ID: {fishData.Key}");
|
||
continue;
|
||
}
|
||
fishId = fishCard.FishID;
|
||
level = GetDataLevel(fishId);
|
||
var cardsRequiredList = fishCard.CardsRequiredList;
|
||
var proficiency = GetCardDataProficiency(fishCard.ID);
|
||
int newLevel = level;
|
||
for (int i = level; i < cardsRequiredList.Count; i++)
|
||
{
|
||
if (proficiency >= cardsRequiredList[i])
|
||
{
|
||
newLevel = i + 1;
|
||
}
|
||
else
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
if (newLevel > level)
|
||
{
|
||
SetDataLevel(fishId, newLevel);
|
||
allUpLevel += newLevel - level;
|
||
}
|
||
}
|
||
GContext.Publish(new ConditionTypeEvent(ConditionType.FishCardLevelUp, allUpLevel));
|
||
|
||
#if AGG
|
||
int lv = GetAllLevel();
|
||
GEvent.SetProp("fishcard_level", lv);
|
||
GEvent.SetUserProp("fishcard_level", lv);
|
||
using (var e = GEvent.GameEvent("fishcard_upgrade"))
|
||
{
|
||
e.AddContent("level_count", allUpLevel);
|
||
}
|
||
|
||
#endif
|
||
}
|
||
|
||
|
||
public bool IsNewFish(int id)
|
||
{
|
||
if (fishData.ContainsKey(id))
|
||
{
|
||
return fishData[id].MaxPTS < 0.001f;
|
||
}
|
||
else
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
public int GetDataLevel(int id)
|
||
{
|
||
if (fishData.ContainsKey(id))
|
||
{
|
||
return fishData[id].Level;
|
||
}
|
||
else
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
public int GetAllLevel()
|
||
{
|
||
int level = 0;
|
||
foreach (var fish in fishData)
|
||
{
|
||
level += fish.Value.Level;
|
||
}
|
||
|
||
return level;
|
||
}
|
||
|
||
public float GetDataMaxWeight(int id)
|
||
{
|
||
if (fishData.ContainsKey(id))
|
||
{
|
||
return fishData[id].MaxG;
|
||
}
|
||
else
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
public bool GetDataNewFish(int id)
|
||
{
|
||
if (fishData.ContainsKey(id))
|
||
{
|
||
return fishData[id].NewFish;
|
||
}
|
||
else
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
public void SetDataNewFish(int id)
|
||
{
|
||
if (!fishData.ContainsKey(id) || !fishData[id].NewFish)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (fishData.ContainsKey(id))
|
||
{
|
||
fishData[id].NewFish = false;
|
||
}
|
||
|
||
SetFishData(id, fishData[id]);
|
||
}
|
||
public FishWeightData GetFishWeightData(int mapId, int fishID)
|
||
{
|
||
if (mapFishData.ContainsKey(mapId))
|
||
{
|
||
var mapFish = mapFishData[mapId];
|
||
if (mapFish.ContainsKey(fishID))
|
||
{
|
||
return mapFish[fishID];
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
void SetFishData(int id, FishWeightData data)
|
||
{
|
||
int mapID = _tables.TbFishData.GetOrDefault(id).AreaID;
|
||
if (mapFishData.ContainsKey(mapID))
|
||
{
|
||
mapFishData[mapID][id] = data;
|
||
}
|
||
else
|
||
{
|
||
mapFishData[mapID] = new Dictionary<int, FishWeightData>
|
||
{
|
||
[id] = data
|
||
};
|
||
}
|
||
PlayFabMgr.Instance.UpdateUserDataValue($"Map_{mapID}", JsonMapper.ToJson(mapFishData[mapID]));
|
||
}
|
||
public int GetFishLevelByMap(int mapId)
|
||
{
|
||
int level = 0;
|
||
if (mapFishData.ContainsKey(mapId))
|
||
{
|
||
Dictionary<int, FishWeightData> keyValuePairs = mapFishData[mapId];
|
||
foreach (var fish in keyValuePairs)
|
||
{
|
||
level += fish.Value.Level;
|
||
}
|
||
}
|
||
return level;
|
||
}
|
||
public void SetMapRed()
|
||
{
|
||
if (!IsOpenMap)
|
||
{
|
||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Map, false);
|
||
return;
|
||
}
|
||
int allCount = 0;
|
||
var dataList = _tables.TbMapData.DataList;
|
||
int count = dataList.Count;
|
||
int levelRequired = 0;
|
||
for (int i = 0; i < count; i++)
|
||
{
|
||
if (i > 0)
|
||
{
|
||
levelRequired = dataList[i - 1].LevelRequired;
|
||
}
|
||
if (GContext.container.Resolve<PlayerData>().lv >= levelRequired)
|
||
{
|
||
allCount += GetMapRedCount(dataList[i].FishList);
|
||
if (allCount > 99)
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Map, allCount > 0, allCount);
|
||
}
|
||
int GetMapRedCount(List<int> fishList)
|
||
{
|
||
int count = 0;
|
||
for (int i = 0; i < fishList.Count; i++)
|
||
{
|
||
var data = _tables.TbFishData.GetOrDefault(fishList[i]);
|
||
if (data == null)
|
||
{
|
||
continue;
|
||
}
|
||
var fishCard = _tables.TbFishCard.GetOrDefault(data.FishCardID);
|
||
if (fishCard == null)
|
||
{
|
||
continue;
|
||
}
|
||
var curProficiency = GetCardDataProficiency(data.FishCardID);
|
||
var level = GetDataLevel(data.ID);
|
||
for (int j = level; j < fishCard.MaxLevel; j++)
|
||
{
|
||
if (curProficiency >= fishCard.CardsRequiredList[j])
|
||
{
|
||
count++;
|
||
}
|
||
else
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
return count;
|
||
}
|
||
public bool GetMapRed(List<int> fishList)
|
||
{
|
||
for (int i = 0; i < fishList.Count; i++)
|
||
{
|
||
var data = _tables.TbFishData.GetOrDefault(fishList[i]);
|
||
if (data == null)
|
||
{
|
||
continue;
|
||
}
|
||
int curProficiency = GetCardDataProficiency(data.FishCardID);
|
||
var level = GetDataLevel(data.ID);
|
||
var fishCard = _tables.TbFishCard.GetOrDefault(data.FishCardID);
|
||
if (fishCard == null)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
if (level < fishCard.MaxLevel)
|
||
{
|
||
int endWeight = fishCard.CardsRequiredList[level];
|
||
if (curProficiency >= endWeight)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
//实际数值
|
||
public float GetAscendValue(float _rodDataValue, List<float> _valueRange)
|
||
{
|
||
if (_valueRange.Count == 1)
|
||
{
|
||
return _rodDataValue * _valueRange[0];
|
||
}
|
||
_rodDataValue = Mathf.Clamp(_rodDataValue, _valueRange[2], _valueRange[3]);
|
||
return (_rodDataValue - _valueRange[2]) / (_valueRange[3] - _valueRange[2]) * (_valueRange[1] - _valueRange[0]) + _valueRange[0];
|
||
}
|
||
|
||
//游弋鱼
|
||
public int GetFishSwimToMap(int id)
|
||
{
|
||
if (fishSwimToMap.TryGetValue(id, out var fishId))
|
||
{
|
||
return fishId;
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
public void SetFishSwimToMap(int id, int fishId)
|
||
{
|
||
if (fishId != 0)
|
||
{
|
||
fishSwimToMapCount[id] = 0;
|
||
PlayFabMgr.Instance.UpdateUserDataValue("FishSwimToMapCount", JsonMapper.ToJson(fishSwimToMapCount));
|
||
}
|
||
fishSwimToMap[id] = fishId;
|
||
PlayFabMgr.Instance.UpdateUserDataValue("FishSwimToMap", JsonMapper.ToJson(fishSwimToMap));
|
||
}
|
||
public void SetFishSwimToMapCount(int id, int count)
|
||
{
|
||
if (fishSwimToMapCount.ContainsKey(id))
|
||
{
|
||
fishSwimToMapCount[id]++;
|
||
if (fishSwimToMapCount[id] >= count)
|
||
{
|
||
SetFishSwimToMap(id, 0);
|
||
}
|
||
PlayFabMgr.Instance.UpdateUserDataValue("FishSwimToMapCount", JsonMapper.ToJson(fishSwimToMapCount));
|
||
}
|
||
}
|
||
//===========================鱼图鉴===========================
|
||
#region 鱼图鉴相关
|
||
public void InitMapProgress(string value)
|
||
{
|
||
mapProgress = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, int>>(value);
|
||
}
|
||
public int GetMapProgress(int mapID)
|
||
{
|
||
if (mapProgress.TryGetValue(mapID, out int progress))
|
||
{
|
||
return progress;
|
||
}
|
||
else
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
public void GetMapProgressReward(MapData mapData)
|
||
{
|
||
int mapID = mapData.ID;
|
||
if (mapProgress.TryGetValue(mapID, out int progress))
|
||
{
|
||
mapProgress[mapID] = progress + 1;
|
||
}
|
||
else
|
||
{
|
||
mapProgress[mapID] = 1;
|
||
}
|
||
int dorpID = mapData.PointsReward[progress];
|
||
int pointsRequire = mapData.PointsRequire[progress];
|
||
GContext.container.Resolve<PlayerItemData>().AddItemByDrop(dorpID, false);
|
||
#if AGG
|
||
using (var e = GEvent.GameEvent("map_points_reward"))
|
||
{
|
||
float averageLevel = GetFishLevelByMap(mapID);
|
||
averageLevel /= mapData.FishList.Count;
|
||
e.AddContent("map_id", mapID)
|
||
.AddContent("points", pointsRequire)
|
||
.AddContent("drop_id", dorpID)
|
||
.AddContent("current_map_fishcard_lv", averageLevel)
|
||
;
|
||
}
|
||
#endif
|
||
|
||
PlayFabMgr.Instance.UpdateUserDataValue("MapProgress", Newtonsoft.Json.JsonConvert.SerializeObject(mapProgress));
|
||
}
|
||
|
||
public int GetAllPTSByMap(int mapID)
|
||
{
|
||
if (mapFishData.TryGetValue(mapID, out Dictionary<int, FishWeightData> weightData))
|
||
{
|
||
return weightData.Sum(i => i.Value.MaxPTS);
|
||
}
|
||
else
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
public bool PTSRed()
|
||
{
|
||
if (GContext.container.Resolve<PlayerData>().OpenGrade)
|
||
{
|
||
var DataMap = GContext.container.Resolve<Tables>().TbMapData.DataMap;
|
||
foreach (var mapData in DataMap.Values)
|
||
{
|
||
int progress = GetMapProgress(mapData.ID);
|
||
var pointsRequire = mapData.PointsRequire;
|
||
if (progress < pointsRequire.Count && GetAllPTSByMap(mapData.ID) >= pointsRequire[progress])
|
||
{
|
||
RedPointManager.Instance.SetRedPointState("menu.achieve", true);
|
||
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
RedPointManager.Instance.SetRedPointState("menu.achieve", false);
|
||
return false;
|
||
}
|
||
#endregion
|
||
//===========================鱼图鉴===========================
|
||
public static void SetFishIcon(Image icon_fish, Item item)
|
||
{
|
||
IUIService uIService = GContext.container.Resolve<IUIService>();
|
||
string spriteName = "fishicon_empty_02";
|
||
if (item.Quality < 3)
|
||
{
|
||
spriteName = "fishicon_empty_01";
|
||
}
|
||
else if (item.Quality > 3)
|
||
{
|
||
spriteName = "fishicon_empty_03";
|
||
}
|
||
icon_fish.sprite = uIService.GetSprite(spriteName);
|
||
uIService.SetImageSprite(icon_fish, item.Icon);//鱼头像
|
||
}
|
||
}
|
||
}
|
||
|
||
public struct ExchangeFishCount
|
||
{
|
||
public ExchangeFishCount(int fishCount)
|
||
{
|
||
FishCount = fishCount;
|
||
}
|
||
public int FishCount;
|
||
}
|