You've already forked taptap2024_GJ_chidouren
88 lines
3.5 KiB
C#
88 lines
3.5 KiB
C#
using System.Collections.Generic;
|
|
using System.RandomPool;
|
|
using FJson.Core;
|
|
using UnityEngine;
|
|
using Views;
|
|
|
|
namespace Game.Data
|
|
{
|
|
/// <summary>
|
|
/// 基于此配置表扩展该通用随机池
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
public class CommonPoolConfig<T> where T : class
|
|
{
|
|
internal Dictionary<int, List<RandomNode<T>>> poolContents;
|
|
internal Dictionary<int, int> poolLevelWeight;
|
|
|
|
public CommonPoolConfig ()
|
|
{
|
|
this.poolContents = new Dictionary<int, List<RandomNode<T>>> ();
|
|
this.poolLevelWeight = new Dictionary<int, int> ();
|
|
}
|
|
|
|
public CommonPoolConfig (Dictionary<int, List<RandomNode<T>>> poolContents, Dictionary<int, int> poolLevelWeight)
|
|
{
|
|
this.poolContents = poolContents;
|
|
this.poolLevelWeight = poolLevelWeight;
|
|
}
|
|
|
|
public void PutPools (int level, RandomNode<T> node)
|
|
{
|
|
if (this.poolContents.ContainsKey (level))
|
|
{
|
|
this.poolContents[level].Add (node);
|
|
}
|
|
else
|
|
{
|
|
this.poolContents[level] = new List<RandomNode<T>> () { node };
|
|
}
|
|
}
|
|
|
|
internal virtual CommonRandomGroup<T> CreateGroup (int poolId)
|
|
{
|
|
return new CommonRandomGroup<T> (poolId);
|
|
}
|
|
|
|
// /// <summary>
|
|
// /// 用于创建怪物池对应配置表
|
|
// /// </summary>
|
|
// /// <param name="poolRow"></param>
|
|
// /// <returns></returns>
|
|
// public static CommonPoolConfig<RofEnemyRow> CreateEnemyPoolConfig(RofEnemyPoolRow poolRow)
|
|
// {
|
|
// var poolConfig = new CommonPoolConfig<RofEnemyRow>();
|
|
// var poolValue = KeywordUtils.DecodeRangeNum(poolRow.EnemyIDs);
|
|
// if (!string.IsNullOrWhiteSpace(poolValue))
|
|
// {
|
|
// poolValue = poolValue.Replace(" ", "");
|
|
// var enemyIds = poolValue.Split(',');
|
|
//
|
|
// foreach (var enemyId in enemyIds)
|
|
// {
|
|
// if (int.TryParse(enemyId, out var id))
|
|
// {
|
|
// var rofEnemyRow = EnemyManager.Instance.GetEnemy(id);
|
|
// var level = (ItemQuality) rofEnemyRow.quality;
|
|
// RandomNode<RofEnemyRow> node = new RandomNode<RofEnemyRow>(rofEnemyRow.ID, rofEnemyRow,
|
|
// -1, rofEnemyRow.weight, rofEnemyRow.exploreCondition);
|
|
// poolConfig.PutPools(level, node);
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// if (poolConfig.poolContents.ContainsKey(ItemQuality.Normal))
|
|
// poolConfig.poolLevelWeight[ItemQuality.Normal] = poolRow.NormalWeight;
|
|
// if (poolConfig.poolContents.ContainsKey(ItemQuality.Rare))
|
|
// poolConfig.poolLevelWeight[ItemQuality.Rare] = poolRow.RareWeight;
|
|
// if (poolConfig.poolContents.ContainsKey(ItemQuality.Epic))
|
|
// poolConfig.poolLevelWeight[ItemQuality.Epic] = poolRow.EpicWeight;
|
|
// if (poolConfig.poolContents.ContainsKey(ItemQuality.Legend))
|
|
// poolConfig.poolLevelWeight[ItemQuality.Legend] = poolRow.LegendWeight;
|
|
// if (poolConfig.poolContents.ContainsKey(ItemQuality.Hide))
|
|
// poolConfig.poolLevelWeight[ItemQuality.Hide] = poolRow.HideWeight;
|
|
// return poolConfig;
|
|
// }
|
|
|
|
}
|
|
} |