You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.3 KiB
118 lines
3.3 KiB
3 years ago
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
public partial class SynthesisConfigCategory
|
||
|
{
|
||
|
public List<int> GetSynthesisListWithBuildingId(int buildingId)
|
||
|
{
|
||
|
var result = new List<int>();
|
||
|
foreach (var config in this.list)
|
||
|
{
|
||
|
var include = config.StructureID.ToList();
|
||
|
if (include.Contains(buildingId))
|
||
|
{
|
||
|
result.Add(config.Id);
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
public SynthesisConfig GetSynthesisConfigByItemId(int[] itemIds, int type)
|
||
|
{
|
||
|
foreach (var config in this.list)
|
||
|
{
|
||
|
|
||
|
if (config.MixtureTpye == type && compareArr(config.ItemId, itemIds))
|
||
|
{
|
||
|
return config;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public static bool compareArr(int[] arr1, int[] arr2)
|
||
|
{
|
||
|
var flag = true;
|
||
|
|
||
|
var a1Len = arr1.Length;
|
||
|
var a2Len = arr2.Length;
|
||
|
for (int i = 0; i < a1Len; i++)
|
||
|
{
|
||
|
var a = arr1[i];
|
||
|
if (!arr2.Contains(a))
|
||
|
{
|
||
|
if (a == 1003)
|
||
|
{
|
||
|
a2Len++;
|
||
|
continue;
|
||
|
}
|
||
|
flag = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (a1Len != a2Len)
|
||
|
{
|
||
|
flag = false;
|
||
|
}
|
||
|
|
||
|
return flag; //内容相同返回true,反之返回false。
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据菜品ID找到对应的菜谱ID;
|
||
|
/// </summary>
|
||
|
/// <param name="mixtureId"></param>
|
||
|
/// <returns></returns>
|
||
|
public int GetSynthesisIDByMixtureID(int mixtureId)
|
||
|
{
|
||
|
int result = 0;
|
||
|
if (mixtureId == 0) return result;
|
||
|
foreach (var config in this.list)
|
||
|
{
|
||
|
if(config.MixtureID == mixtureId || config.QualityMixtureID == mixtureId)
|
||
|
{
|
||
|
result = config.Id;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取所有对应规模等级的建筑
|
||
|
/// </summary>
|
||
|
public List<int> GetAllBuildingsWithScaleLimit(int scaleID)
|
||
|
{
|
||
|
var result = new List<int>();
|
||
|
foreach(var config in this.list)
|
||
|
{
|
||
|
if(config.MixtureTpye == (int)SynthesisMixtureTpyeEnum.STRUCTURE &&
|
||
|
config.UnlockCondition == (int)SynthesisUnlockConditionEnum.SCALECONFIG &&
|
||
|
config.Parameter2 == scaleID)
|
||
|
{
|
||
|
result.Add(config.MixtureID);
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
public SynthesisConfig GetSynthesisByMixture(SynthesisMixtureTpyeEnum type, int mixtureID)
|
||
|
{
|
||
|
foreach (var config in this.list)
|
||
|
{
|
||
|
if(config.MixtureID == mixtureID && config.MixtureTpye == (int)type)
|
||
|
{
|
||
|
return config;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
}
|