先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
1465 lines
52 KiB
C#
1465 lines
52 KiB
C#
using System;
|
||
using System.Linq;
|
||
using UnityEngine;
|
||
using cfg;
|
||
using LitJson;
|
||
using System.Collections.Generic;
|
||
using asap.core;
|
||
using game;
|
||
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 string Serialize()
|
||
{
|
||
//return $"{Level}|{MaxG}|{TotalG}|{MaxPTS}|{TotalPTS}|{TotalCard}|{TotalNum}|{NewFish}|{fishRate}";
|
||
return $"{Level}|{MaxG}|{TotalCard}|{TotalNum}|{NewFish}";
|
||
}
|
||
public static FishWeightData Deserialize(string s)
|
||
{
|
||
string[] arr = s.Split('|');
|
||
FishWeightData data = new FishWeightData();
|
||
if (arr.Length == 9)
|
||
{
|
||
data.Level = int.Parse(arr[0]);
|
||
data.MaxG = float.Parse(arr[1]);
|
||
data.TotalCard = int.Parse(arr[5]);
|
||
data.TotalNum = int.Parse(arr[6]);
|
||
data.NewFish = bool.Parse(arr[7]);
|
||
}
|
||
else if (arr.Length == 5)
|
||
{
|
||
data.Level = int.Parse(arr[0]);
|
||
data.MaxG = float.Parse(arr[1]);
|
||
data.TotalCard = int.Parse(arr[2]);
|
||
data.TotalNum = int.Parse(arr[3]);
|
||
data.NewFish = bool.Parse(arr[4]);
|
||
}
|
||
return data;
|
||
}
|
||
}
|
||
public partial class PlayerFishData
|
||
{
|
||
private cfg.Tables _tables;
|
||
public PlayerFishData(cfg.Tables tables)
|
||
{
|
||
this._tables = tables;
|
||
}
|
||
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>();
|
||
|
||
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("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_5_{map.Key}", out data_value))
|
||
{
|
||
Dictionary<int, string> mapDataStr = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, string>>(data_value);
|
||
Dictionary<int, FishWeightData> mapData = new Dictionary<int, FishWeightData>();
|
||
foreach (var item in mapDataStr)
|
||
{
|
||
mapData[item.Key] = FishWeightData.Deserialize(item.Value);
|
||
}
|
||
SetFishAllData(map.Key, mapData);
|
||
}
|
||
else if (userDatas.TryGetValue($"Map_{map.Key}", out data_value))
|
||
{
|
||
//兼容老数据
|
||
Dictionary<int, FishWeightData> mapData = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, FishWeightData>>(data_value);
|
||
|
||
SetFishAllData(map.Key, mapData);
|
||
}
|
||
}
|
||
#if AGG
|
||
int lv = GetAllLevel();
|
||
GEvent.SetProp("fishcard_level", lv);
|
||
GEvent.SetUserProp("fishcard_level", lv);
|
||
#endif
|
||
}
|
||
|
||
float FishMaxG(FishData fishData, int level, float maxG)
|
||
{
|
||
var _fishWeight = fishData.BaseWeight * fishData.PointExtraParam * (1 + fishData.WeightRandom);
|
||
if (level > 0)
|
||
{
|
||
FishCard fishCard = _tables.TbFishCard.GetOrDefault(fishData.FishCardID);
|
||
if (fishCard == null)
|
||
{
|
||
return _fishWeight;
|
||
}
|
||
var weightIncEvent = fishCard.WeightMagList[level - 1];
|
||
_fishWeight *= (1 + weightIncEvent);
|
||
}
|
||
_fishWeight = Mathf.Round(_fishWeight * 100) / 100;
|
||
if (maxG > _fishWeight)
|
||
{
|
||
//Debug.LogWarning($"FishMaxG: fishID={fishData.ID}, level={level}, maxG={maxG}, _fishWeight={_fishWeight}");
|
||
return _fishWeight;
|
||
}
|
||
else
|
||
{
|
||
return maxG;
|
||
}
|
||
}
|
||
|
||
public int GetDiffFishCount()
|
||
{
|
||
return fishData.Count;
|
||
}
|
||
public int GetAnglingCount()
|
||
{
|
||
return GContext.container.Resolve<PlayerData>()._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;
|
||
GContext.container.Resolve<PlayerData>().SavePlayerData();
|
||
}
|
||
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].CashBonus;
|
||
}
|
||
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: true))
|
||
{
|
||
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(RodAscend _rodAscend)
|
||
{
|
||
int fragment = GetRodPiece(_rodAscend.FragmentID);
|
||
int requireNum = _rodAscend.AscentTransformed[0];
|
||
return fragment >= requireNum;
|
||
}
|
||
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.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;
|
||
}
|
||
|
||
MapNewUpdateUserDataValue(GContext.container.Resolve<PlayerData>().currentMapId, _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.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;
|
||
}
|
||
|
||
MapNewUpdateUserDataValue(map.Key, _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;
|
||
}
|
||
int mapID = GContext.container.Resolve<PlayerData>().currentMapId;
|
||
MapNewUpdateUserDataValue(mapID, mapFishData[mapID]);
|
||
}
|
||
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;
|
||
}
|
||
MapNewUpdateUserDataValue(map.Key, mapFishData[map.Key]);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
public bool NotRod(int id)
|
||
{
|
||
return !rodData.ContainsKey(id);
|
||
}
|
||
|
||
public void SetFishAllData(int key, Dictionary<int, FishWeightData> mapData)
|
||
{
|
||
Dictionary<int, FishWeightData> mapDataNew = new Dictionary<int, FishWeightData>();
|
||
foreach (var fishWeightData in mapData)
|
||
{
|
||
|
||
FishData _fish = _tables.TbFishData.GetOrDefault(fishWeightData.Key);
|
||
if (_fish != null)
|
||
{
|
||
if (_fish.AreaID != key)
|
||
{
|
||
Debug.Log("fishWeightData.AreaID " + fishWeightData.Key + " " + key);
|
||
|
||
continue;
|
||
}
|
||
FishWeightData newData = new FishWeightData
|
||
{
|
||
Level = fishWeightData.Value.Level,
|
||
MaxG = fishWeightData.Value.MaxG,
|
||
TotalCard = fishWeightData.Value.TotalCard,
|
||
TotalNum = fishWeightData.Value.TotalNum,
|
||
NewFish = fishWeightData.Value.NewFish
|
||
};
|
||
|
||
//修正最大重量,过一段时间删除
|
||
if (_fish.Quality <= 5)
|
||
{
|
||
newData.MaxG = FishMaxG(_fish, newData.Level, newData.MaxG);
|
||
}
|
||
//修正最大重量
|
||
|
||
mapDataNew.Add(_fish.ID, newData);
|
||
fishData[_fish.ID] = newData;
|
||
if (newData.Level > 0)
|
||
{
|
||
cfg.FishCard fishCard = _tables.TbFishCard[_fish.FishCardID];
|
||
if (newData.Level > fishCard.MaxLevel)
|
||
{
|
||
newData.Level = fishCard.MaxLevel;
|
||
}
|
||
int startWeight = fishCard.CardsRequiredList[newData.Level - 1];
|
||
if (startWeight > newData.TotalCard)
|
||
{
|
||
newData.TotalCard = startWeight;
|
||
}
|
||
}
|
||
fishCardData[_fish.FishCardID] = newData.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.container.Resolve<MiniBattlePassDataProvider>().UpdateTaskData(MiniBattlePassType.Fishcard, 1);
|
||
//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 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]);
|
||
}
|
||
GContext.Publish(new ConditionTypeEvent(ConditionType.GetFishID, fishId));
|
||
}
|
||
|
||
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, null);
|
||
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));
|
||
// GContext.container.Resolve<MiniBattlePassDataProvider>().UpdateTaskData(MiniBattlePassType.Fishcard, 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].MaxG < 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]);
|
||
}
|
||
|
||
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
|
||
};
|
||
}
|
||
MapNewUpdateUserDataValue(mapID, mapFishData[mapID]);
|
||
}
|
||
void MapNewUpdateUserDataValue(int mapID, Dictionary<int, FishWeightData> keyValuePairs)
|
||
{
|
||
Dictionary<int, string> mapData = keyValuePairs.ToDictionary(_ => _.Key, _ => _.Value.Serialize());
|
||
PlayFabMgr.Instance.UpdateUserDataValue($"Map_5_{mapID}", JsonMapper.ToJson(mapData));
|
||
}
|
||
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))
|
||
{
|
||
MapData mapData = _tables.TbMapData.GetOrDefault(mapID);
|
||
int AllPTS = GetAllPTSByMap(mapData.ID);
|
||
var pointsRequire = mapData.PointsRequire;
|
||
for (int i = 0; i < pointsRequire.Count; i++)
|
||
{
|
||
if (i >= progress)
|
||
{
|
||
break;
|
||
}
|
||
else if (AllPTS < pointsRequire[i])
|
||
{
|
||
mapProgress[mapID] = i;
|
||
return i;
|
||
}
|
||
}
|
||
return progress;
|
||
}
|
||
else
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
public void GetMapProgressReward(MapData mapData)
|
||
{
|
||
int mapID = mapData.ID;
|
||
int AllPTS = GetAllPTSByMap(mapData.ID);
|
||
var pointsRequires = mapData.PointsRequire;
|
||
mapProgress.TryGetValue(mapID, out int progress);
|
||
mapProgress[mapID] = pointsRequires.Count;
|
||
List<int> dorpList = new List<int>();
|
||
for (int i = progress; i < pointsRequires.Count; i++)
|
||
{
|
||
if (AllPTS < pointsRequires[i])
|
||
{
|
||
mapProgress[mapID] = i;
|
||
}
|
||
else
|
||
{
|
||
int dorpID = mapData.PointsReward[i];
|
||
int pointsRequire = mapData.PointsRequire[i];
|
||
dorpList.Add(dorpID);
|
||
#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
|
||
}
|
||
}
|
||
|
||
GContext.container.Resolve<PlayerItemData>().AddItemByDropList(dorpList, null);
|
||
PlayFabMgr.Instance.UpdateUserDataValue("MapProgress", Newtonsoft.Json.JsonConvert.SerializeObject(mapProgress));
|
||
}
|
||
|
||
public int GetAllPTSByMap(int mapID)
|
||
{
|
||
if (mapFishData.TryGetValue(mapID, out Dictionary<int, FishWeightData> weightData))
|
||
{
|
||
int allPts = 0;
|
||
foreach (var item in weightData)
|
||
{
|
||
int id = item.Key;
|
||
float MaxG = item.Value.MaxG;
|
||
FishData fishData = _tables.TbFishData.GetOrDefault(id);
|
||
if (fishData != null)
|
||
{
|
||
DropPackageList dropPackageList = _tables.TbDrop[fishData.DropID].DropList;
|
||
float proficiency = dropPackageList.DropCountList[0] * MaxG / fishData.BaseWeight;
|
||
allPts += (int)(proficiency);
|
||
}
|
||
}
|
||
return allPts;
|
||
}
|
||
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;
|
||
}
|