继续
This commit is contained in:
@@ -66,7 +66,7 @@ namespace Continentis.MainGame.Character
|
||||
this.team = null;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
attributeSubmodule = new AttributeSubmodule(this);
|
||||
equipmentSubmodule = new EquipmentSubmodule(this);
|
||||
eventSubmodule = new EventSubmodule(this);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Continentis.MainGame.Card;
|
||||
using Continentis.MainGame.UI;
|
||||
using SLSFramework.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Continentis.MainGame.Character
|
||||
{
|
||||
public abstract partial class CombatBuffBase : CharacterBuffBase
|
||||
public abstract partial class CharacterCombatBuffBase : CharacterBuffBase
|
||||
{
|
||||
public CardLogicBase sourceCard;
|
||||
|
||||
@@ -19,31 +21,32 @@ namespace Continentis.MainGame.Character
|
||||
public StatusSubmodule statusSubmodule;
|
||||
}
|
||||
|
||||
public partial class CombatBuffBase
|
||||
public partial class CharacterCombatBuffBase
|
||||
{
|
||||
public sealed override bool OnBuffApply(out BuffBase<CharacterBase> existingBuff)
|
||||
{
|
||||
throw new System.NotImplementedException("请使用类型约束更强的OnBuffApply方法");
|
||||
}
|
||||
|
||||
public virtual bool OnBuffApply(out CombatBuffBase existingBuff)
|
||||
public virtual bool OnBuffApply(out CharacterCombatBuffBase existingBuff)
|
||||
{
|
||||
throw new System.NotImplementedException(); //需要在子类中实现
|
||||
}
|
||||
|
||||
public override void OnAfterFirstApply()
|
||||
{
|
||||
|
||||
statusSubmodule?.AddStatus();
|
||||
}
|
||||
|
||||
public override void OnBuffRemove()
|
||||
{
|
||||
RefreshAttributes();
|
||||
statusSubmodule?.RemoveStatus();
|
||||
iconSubmodule?.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CombatBuffBase
|
||||
public partial class CharacterCombatBuffBase
|
||||
{
|
||||
protected bool FindExistingSameBuff<T>(out T existingBuff) where T : CharacterBuffBase
|
||||
{
|
||||
@@ -61,9 +64,9 @@ namespace Continentis.MainGame.Character
|
||||
this.sourceCharacter = sourceCharacter;
|
||||
this.sourceCard = sourceCard;
|
||||
|
||||
if (OnBuffApply(out CombatBuffBase existingBuff))
|
||||
if (OnBuffApply(out CharacterCombatBuffBase existingBuff))
|
||||
{
|
||||
this.attachedCharacter.combatBuffSubmodule.buffList.Add(this);
|
||||
this.attachedCharacter.combatBuffSubmodule.buffList.AddByPriority(this);
|
||||
|
||||
OnAfterFirstApply();
|
||||
|
||||
@@ -92,9 +95,44 @@ namespace Continentis.MainGame.Character
|
||||
{
|
||||
this.attachedCharacter.combatBuffSubmodule.buffList.Remove(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查并处理专注类Buff的添加逻辑。
|
||||
/// 如果已有相同Buff存在,则返回true,并通过out参数返回该Buff。
|
||||
/// 如果没有相同Buff存在,则返回false,并在必要时移除优先级最低的专注类Buff以腾出空间。
|
||||
/// </summary>
|
||||
/// <param name="existingBuff"></param>
|
||||
/// <returns></returns>
|
||||
public bool FocusingCheck(out CharacterCombatBuffBase existingBuff)
|
||||
{
|
||||
// 移除超出上限的专注类Buff
|
||||
List<CharacterCombatBuffBase> focusingBuffs =
|
||||
attachedCharacter.combatBuffSubmodule.buffList.Where(buff => buff.buffType == BuffType.Focusing).ToList();
|
||||
focusingBuffs.Sort();
|
||||
int maximumFocusingBuffAmount = attachedCharacter.GetAttribute("MaximumFocusingBuffAmount", 1);
|
||||
for (int i = maximumFocusingBuffAmount; i < focusingBuffs.Count; i++)
|
||||
{
|
||||
focusingBuffs[i].Remove();
|
||||
}
|
||||
|
||||
// 检查是否已有相同Buff存在
|
||||
if (FindExistingSameBuff(out existingBuff))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 如果没有相同Buff存在但已达上限,则移除优先级最低的专注类Buff(将由新Buff替代)
|
||||
if(focusingBuffs.Count >= maximumFocusingBuffAmount)
|
||||
{
|
||||
CharacterCombatBuffBase lowestPriorityBuff = focusingBuffs[focusingBuffs.Count - 1];
|
||||
lowestPriorityBuff.Remove();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CombatBuffBase
|
||||
public partial class CharacterCombatBuffBase
|
||||
{
|
||||
private void RefreshAttributes()
|
||||
{
|
||||
@@ -15,14 +15,14 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
foreach (string cardDataID in data.initialDeckRef)
|
||||
{
|
||||
ModManager.GetData<CardData>(cardDataID).GenerateCardInstance(this, initialPile);
|
||||
CardInstance.GenerateCardInstance(ModManager.GetData<CardData>(cardDataID), this, initialPile);
|
||||
}
|
||||
|
||||
foreach (EquipmentBase equipment in equipmentSubmodule.currentEquipments)
|
||||
{
|
||||
foreach (string cardDataID in equipment.equipmentData.belongingCardDataRefs)
|
||||
{
|
||||
ModManager.GetData<CardData>(cardDataID).GenerateCardInstance(this, initialPile);
|
||||
CardInstance.GenerateCardInstance(ModManager.GetData<CardData>(cardDataID), this, initialPile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -224,16 +224,24 @@ namespace Continentis.MainGame.Character
|
||||
/// <summary>
|
||||
/// 添加格挡(格挡每回合结束后会清空)
|
||||
/// </summary>
|
||||
public void AddBlock(int baseBlock, CharacterBase target = null)
|
||||
public void AddBlock(int baseBlock, bool applyOffsetAndModifier = true, CharacterBase target = null)
|
||||
{
|
||||
int baseBlockAfterOffset = baseBlock + GetAttribute("BlockGainOffset");
|
||||
int finalBlock = Mathf.RoundToInt(baseBlockAfterOffset * GetRawAttribute("BlockGainMultiplier", 1));
|
||||
|
||||
target ??= this;
|
||||
target.ModifyAttribute("Block", finalBlock);
|
||||
|
||||
if (!applyOffsetAndModifier)
|
||||
{
|
||||
target.ModifyAttribute("Block", baseBlock);
|
||||
}
|
||||
else
|
||||
{
|
||||
int baseBlockAfterOffset = baseBlock + GetAttribute("BlockGainOffset");
|
||||
int finalBlock = Mathf.RoundToInt(baseBlockAfterOffset * GetRawAttribute("BlockGainMultiplier", 1));
|
||||
target.ModifyAttribute("Block", finalBlock);
|
||||
}
|
||||
|
||||
target.characterView.hudContainer.UpdateAllHUD();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加闪避(闪避在回合结束后或被击中后清空)
|
||||
/// </summary>
|
||||
|
||||
@@ -8,22 +8,22 @@ namespace Continentis.MainGame.Character
|
||||
{
|
||||
public partial class CombatBuffSubmodule : SubmoduleBase<CharacterBase>
|
||||
{
|
||||
public List<CombatBuffBase> buffList;
|
||||
public List<CharacterCombatBuffBase> buffList;
|
||||
|
||||
public CombatBuffSubmodule(CharacterBase character) : base(character)
|
||||
{
|
||||
buffList = new List<CombatBuffBase>();
|
||||
buffList = new List<CharacterCombatBuffBase>();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CombatBuffSubmodule
|
||||
{
|
||||
public T GetBuff<T>() where T : CombatBuffBase
|
||||
public T GetBuff<T>() where T : CharacterCombatBuffBase
|
||||
{
|
||||
return (T)buffList.Find(x => x.GetType() == typeof(T));
|
||||
}
|
||||
|
||||
public bool HasBuff<T>() where T : CombatBuffBase
|
||||
public bool HasBuff<T>() where T : CharacterCombatBuffBase
|
||||
{
|
||||
return buffList.Exists(x => x.GetType() == typeof(T));
|
||||
}
|
||||
|
||||
@@ -41,8 +41,17 @@ namespace Continentis.MainGame.Character
|
||||
ExhaustPile.ForEach(c=>c.GenerateHandCardView(CombatUIManager.Instance.combatMainPage.exhaustPile));
|
||||
}
|
||||
|
||||
public void DrawCards(int cardCount, float interval)
|
||||
/// <summary>
|
||||
/// 抽取指定数量的卡牌,返回一个包含抽牌指令的指令组。
|
||||
/// </summary>
|
||||
public CommandGroup DrawCards(int cardCount, float interval = 0.1f)
|
||||
{
|
||||
if (owner.statusSubmodule.HasStatus(StatusType.Heavy)) //沉重状态无法抽牌
|
||||
{
|
||||
MainGameManager.GenerateInfoText("Heavy: Can not draw cards", owner.characterView);
|
||||
return new CommandGroup(ExecutionMode.Sequential);
|
||||
}
|
||||
|
||||
if (cardCount > DrawPile.Count && DiscardPile.Count > 0)
|
||||
{
|
||||
Debug.Log("抽牌堆牌数不足,且弃牌堆有牌,正在洗牌...");
|
||||
@@ -52,12 +61,23 @@ namespace Continentis.MainGame.Character
|
||||
Debug.Log($"准备抽取 {cardCount} 张卡牌。");
|
||||
|
||||
CommandContext context = new CommandContext();
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_DrawCards(this, cardCount, interval), context);
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(0, () =>
|
||||
{
|
||||
//Debug.Log((context.sharedInfo["DrawnCards"] as List<CardInstance>).Count); //TODO: 抽牌后的处理
|
||||
}));
|
||||
//return context.sharedInfo["DrawnCards"] as List<CardBase>;
|
||||
CommandGroup drawCardsGroup = new CommandGroup(ExecutionMode.Sequential, context,
|
||||
new Cmd_DrawCards(this, cardCount, interval),
|
||||
new Cmd_Function(0, () =>
|
||||
{
|
||||
//Debug.Log((context.sharedInfo["DrawnCards"] as List<CardInstance>).Count); //TODO: 抽牌后的处理
|
||||
}));
|
||||
|
||||
return drawCardsGroup;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从指令组的上下文中获取抽到的卡牌列表。
|
||||
/// </summary>
|
||||
public List<CardInstance> GetDrawnCards(CommandGroup drawCardsGroup)
|
||||
{
|
||||
CommandContext context = drawCardsGroup.groupContext;
|
||||
return context.GetInfo<List<CardInstance>>("DrawnCards");
|
||||
}
|
||||
|
||||
public void PlayCard(CardInstance card, List<CharacterBase> targetList)
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Continentis.MainGame.Character
|
||||
Silence = 1, //沉默,无法使用魔法牌 (Magic)
|
||||
Disarm = 2, //缴械,无法使用攻击牌 (Attack)
|
||||
Inhibition = 3, //抑制,无法使用能力牌 (Ability)
|
||||
Heavy = 4, //沉重,无法再抽牌
|
||||
|
||||
//正面状态
|
||||
Invincible = 1000, //无敌
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Continentis.MainGame.Character
|
||||
if (_haveCustomClassProp.boolValue)
|
||||
{
|
||||
// 如果勾选,则显示class选择器
|
||||
DrawTypeSelectorGUI(_classFullNameProp, "Character Class", typeof(CharacterBase), "Continentis.Mods", ".Characters");
|
||||
DrawTypeSelectorGUI(_classFullNameProp, "Character Class", typeof(CharacterBase), out _, "Continentis.Mods", ".Characters");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user