You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
3.2 KiB
C#
100 lines
3.2 KiB
C#
|
2 years ago
|
using Entitas;
|
||
|
|
using Game;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using Articy.Unity;
|
||
|
|
using Articy.Touhou;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 局内背包,局内掉落物品/货币/祝福 都在此管理
|
||
|
|
/// </summary>
|
||
|
|
|
||
|
|
[Game]
|
||
|
|
public class BagComponent : IComponent
|
||
|
|
{
|
||
|
|
public MetaDictionary<string, int> AllBless = new MetaDictionary<string, int>(); //所有祝福
|
||
|
|
public List<string> ChooseBless = new List<string>(); //祝福选择界面备选项
|
||
|
|
}
|
||
|
|
|
||
|
|
namespace Game
|
||
|
|
{
|
||
|
|
public abstract partial class Util
|
||
|
|
{
|
||
|
|
//添加祝福
|
||
|
|
public static void AddBless(GameEntity entity, string blessId, int level = 1)
|
||
|
|
{
|
||
|
|
var bag = entity.bag;
|
||
|
|
var cfg = Util.GetBlessConfig(blessId);
|
||
|
|
bag.AllBless[blessId] = level;
|
||
|
|
}
|
||
|
|
//移除祝福
|
||
|
|
public static void RemoveBless(GameEntity entity, string blessId)
|
||
|
|
{
|
||
|
|
var bag = entity.bag;
|
||
|
|
var cfg = Util.GetBlessConfig(blessId);
|
||
|
|
}
|
||
|
|
//是否拥有祝福
|
||
|
|
public static bool HasBless(GameEntity entity, string blessId)
|
||
|
|
{
|
||
|
|
var bag = entity.bag;
|
||
|
|
return bag.AllBless.ContainsKey(blessId);
|
||
|
|
}
|
||
|
|
//获取次级祝福数量
|
||
|
|
public static int GetSubBlessNum(GameEntity entity)
|
||
|
|
{
|
||
|
|
var bag = entity.bag;
|
||
|
|
return bag.AllBless.Count;
|
||
|
|
}
|
||
|
|
//移除所有祝福
|
||
|
|
public static void RemoveAllBless(GameEntity entity)
|
||
|
|
{
|
||
|
|
var bag = entity.bag;
|
||
|
|
bag.AllBless.Clear();
|
||
|
|
}
|
||
|
|
//打开祝福选择UI
|
||
|
|
public static void OpenBlessUI(EElementType elementType)
|
||
|
|
{
|
||
|
|
UIManager.Instance.Open(EuiPage.BlessChoose, elementType);
|
||
|
|
}
|
||
|
|
//获取祝福选择备选项
|
||
|
|
public static List<string> GetBlessChooseList(GameEntity entity, EElementType elementType)
|
||
|
|
{
|
||
|
|
var bag = entity.bag;
|
||
|
|
bag.ChooseBless.Clear();
|
||
|
|
|
||
|
|
var blessCfgList = Util.GetBlessConfigDataAll();
|
||
|
|
foreach (var blessCfgData in blessCfgList)
|
||
|
|
{
|
||
|
|
var blessId = blessCfgData.TechnicalName;
|
||
|
|
var blessCfg = blessCfgData.Template;
|
||
|
|
var blessCfgSkill = blessCfg.Bless;
|
||
|
|
if (Util.HasBless(entity, blessId))
|
||
|
|
{
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
if (CheckBlessGroup(entity, blessCfgSkill.BlessPreCheck) && CheckBlessGroup(entity, blessCfgSkill.BlessPreCheck2))
|
||
|
|
{
|
||
|
|
bag.ChooseBless.Add(blessId);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return bag.ChooseBless;
|
||
|
|
}
|
||
|
|
private static bool CheckBlessGroup(GameEntity entity, ArticyObject groupObj)
|
||
|
|
{
|
||
|
|
if (groupObj == null)
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
var blessGroup = (groupObj as IObjectWithFeatureBlessGroup).GetFeatureBlessGroup();
|
||
|
|
foreach (var blessObj in blessGroup.BlessGroup)
|
||
|
|
{
|
||
|
|
if (Util.HasBless(entity, blessObj.TechnicalName))
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|