备份CatanBuilding瘦身独立工程
This commit is contained in:
133
Assets/Scripts/UI/Rod/RodBag/FishingRodUpSystem.cs
Normal file
133
Assets/Scripts/UI/Rod/RodBag/FishingRodUpSystem.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
public class FishingRodUpSystem
|
||||
{
|
||||
public IEventAggregator eventAggregator;
|
||||
|
||||
public List<RodItemData> rodItemDatas = new List<RodItemData>();
|
||||
public Dictionary<int, int> allCount = new Dictionary<int, int>();
|
||||
public Dictionary<int, List<int>> hasRodID;
|
||||
|
||||
PlayerFishData playerFishData;
|
||||
Tables _tables;
|
||||
public int SelectIndex = 0;
|
||||
public int StartQuality => 2;
|
||||
int EndQuality => 4;
|
||||
public AvatarEvent bagPanel;
|
||||
|
||||
public FishingRodUpSystem()
|
||||
{
|
||||
playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
eventAggregator = new EventAggregator();
|
||||
var dataList = _tables.TbRodData.DataList;
|
||||
|
||||
for (int i = StartQuality; i <= EndQuality; i++)
|
||||
{
|
||||
allCount[i] = dataList.Where(x => x.Quality == i).Count();
|
||||
}
|
||||
}
|
||||
public List<int> HasRodID(int quality)
|
||||
{
|
||||
return hasRodID.TryGetValue(quality, out List<int> rodIDs) ? rodIDs : new List<int>();
|
||||
}
|
||||
public void InitRodList()
|
||||
{
|
||||
rodItemDatas.Clear();
|
||||
hasRodID = new Dictionary<int, List<int>>();
|
||||
var dataList = _tables.TbRodData.DataList;
|
||||
int count = dataList.Count;
|
||||
RodData _rodData;
|
||||
RodAscend _rodAscend;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_rodData = dataList[i];
|
||||
bool isLock = playerFishData.NotRod(_rodData.ID);
|
||||
if (!isLock)
|
||||
{
|
||||
if (!hasRodID.TryGetValue(_rodData.Quality, out List<int> rodIDs))
|
||||
{
|
||||
hasRodID[_rodData.Quality] = rodIDs = new List<int>();
|
||||
}
|
||||
rodIDs.Add(_rodData.ID);
|
||||
}
|
||||
|
||||
_rodData = dataList[i];
|
||||
_rodAscend = _tables.TbRodAscend.GetOrDefault(_rodData.AscendID);
|
||||
|
||||
int level = playerFishData.GetRodLevel(_rodData.ID);
|
||||
int star = playerFishData.GetRodPiece(_rodData.ID);
|
||||
bool isMax = star >= _rodAscend.MaxAscent;
|
||||
RodItemData rodItemData = new RodItemData()
|
||||
{
|
||||
config = dataList[i],
|
||||
isLock = isLock,
|
||||
level = level + 1,
|
||||
star = star,
|
||||
isNew = GContext.container.Resolve<PlayerData>().IsNewRod(dataList[i].ID),
|
||||
isMax = isMax,
|
||||
isEquip = dataList[i].ID == GContext.container.Resolve<PlayerData>().equipRodID
|
||||
};
|
||||
if (!isLock)
|
||||
{
|
||||
GetDuelPerk(rodItemData);
|
||||
}
|
||||
int skindID = playerFishData.GetRodSkin(_rodData.ID);
|
||||
rodItemData.skin = _tables.TbRodSkinData.GetOrDefault(skindID);
|
||||
if (rodItemData.skin == null)
|
||||
{
|
||||
Debug.LogError($"No SkinID {skindID} in RodID {rodItemData.config.ID}");
|
||||
continue;
|
||||
}
|
||||
rodItemData.SetRodPower();
|
||||
rodItemDatas.Add(rodItemData);
|
||||
}
|
||||
rodItemDatas.Sort(RodItemData.Sort);
|
||||
}
|
||||
void GetDuelPerk(RodItemData rodItemData)
|
||||
{
|
||||
var playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
Dictionary<int, string> RodPerkList = playerFishData.GetRodDuelPerk(rodItemData.config.ID, rodItemData.star);
|
||||
//float power = rodItemData.config.DuelPower[rodItemData.level - 1];
|
||||
//float param = 1;
|
||||
foreach (var perk in RodPerkList)
|
||||
{
|
||||
//var rodEngancePerk = _tables.TbRodAscendPerk.GetOrDefault(perk.Key);
|
||||
rodItemData.traitIDs.Add(perk.Key);
|
||||
rodItemData.noactions.Add(true);
|
||||
//string value = perk.Value;
|
||||
//if (!string.IsNullOrEmpty(value) && !value.Contains('|'))
|
||||
//{
|
||||
// param += float.Parse(value) * _tables.TbRodAscendPerk.GetOrDefault(perk.Key)?.DuelPowerParam ?? 0;
|
||||
//}
|
||||
}
|
||||
//power *= param;
|
||||
//rodItemData.DuelPower = (int)power;
|
||||
}
|
||||
public RodItemData GetCurrentRodItemData()
|
||||
{
|
||||
return rodItemDatas[SelectIndex];
|
||||
}
|
||||
|
||||
public IDisposable Subscribe<T>(Action<T> eventAction)
|
||||
{
|
||||
return eventAggregator.GetEvent<T>().Subscribe(eventAction);
|
||||
}
|
||||
|
||||
public void Publish<T>(T evt)
|
||||
{
|
||||
if (eventAggregator != null)
|
||||
eventAggregator.Publish(evt);
|
||||
}
|
||||
}
|
||||
public struct RefreshRodBagEvent
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user