50 lines
2.0 KiB
Plaintext
50 lines
2.0 KiB
Plaintext
using System; using System.Collections.Generic; using System.Linq;
|
|
public class ActualFish { public Dictionary<int,FishWeightData> fishData=new(); public Dictionary<int,Dictionary<int,FishWeightData>> mapFishData=new(); public Tables _tables=new();
|
|
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 void SetGetFishCount(int fishId)
|
|
{
|
|
int count = GContext.container.Resolve<PlayerData>().GetMagnification();
|
|
CheckFishData(fishId);
|
|
fishData[fishId].TotalNum += count;
|
|
}
|
|
void CheckFishData(int fishId)
|
|
{
|
|
if (!fishData.ContainsKey(fishId))
|
|
{
|
|
fishData.Add(fishId, new FishWeightData() { NewFish = true });
|
|
}
|
|
}
|
|
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));
|
|
}
|
|
}
|