MOD!
This commit is contained in:
@@ -2,32 +2,32 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Continentis.MainGame.Character;
|
||||
using Continentis.MainGame.Combat;
|
||||
using Continentis.MainGame.Commands;
|
||||
using DamageNumbersPro;
|
||||
using SoulliesFramework.General;
|
||||
using UnityEngine;
|
||||
using SLSFramework.General;
|
||||
using SLSFramework.UModAssistance;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Continentis.MainGame.Card
|
||||
{
|
||||
public partial class CardLogicBase
|
||||
{
|
||||
public void Targeting(CharacterBase target)
|
||||
{
|
||||
TargetingEffect(target);
|
||||
}
|
||||
|
||||
public void Untargeting()
|
||||
{
|
||||
UntargetingEffect();
|
||||
}
|
||||
|
||||
protected virtual void TargetingEffect(CharacterBase target)
|
||||
/// <summary>
|
||||
/// 选中目标时触发的效果,效果在所有逻辑组件的Targeting之前执行(在SetUp函数生成EventSubmodule的时候)。
|
||||
/// 如果必须需要在逻辑组件之后执行,请重写Initialize函数。
|
||||
/// </summary>
|
||||
public virtual void TargetingEffect(CharacterBase target)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void UntargetingEffect()
|
||||
/// <summary>
|
||||
/// 取消选中目标时触发的效果,效果在所有逻辑组件的Untargeting之前执行(在SetUp函数生成EventSubmodule的时候)。
|
||||
/// 如果必须需要在逻辑组件之后执行,请重写Initialize函数。
|
||||
/// </summary>
|
||||
public virtual void UntargetingEffect()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -35,14 +35,23 @@ namespace Continentis.MainGame.Card
|
||||
|
||||
public partial class CardLogicBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 刷新卡牌属性
|
||||
/// </summary>
|
||||
public void RefreshCardAttributes()
|
||||
{
|
||||
if(user == null) return;
|
||||
|
||||
attributeSubmodule.RefreshAllAttributes();
|
||||
if(handCardView == null || !handCardView.isSelecting) Untargeting();
|
||||
if ((handCardView == null && intentionCardView == null) || !handCardView.isSelecting)
|
||||
{
|
||||
eventSubmodule.onUntargeting();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据卡牌内容应用属性变化
|
||||
/// </summary>
|
||||
public virtual void ApplyAttributeChangesByCard()
|
||||
{
|
||||
|
||||
@@ -51,28 +60,27 @@ namespace Continentis.MainGame.Card
|
||||
|
||||
public partial class CardLogicBase
|
||||
{
|
||||
public virtual void SetTargets(out List<CharacterBase> valid,
|
||||
out List<CharacterBase> conditionNotMet, out List<CharacterBase> invalid)
|
||||
public virtual void DetectTargetsValidity(out List<CharacterBase> valid, out List<CharacterBase> notMet, out List<CharacterBase> invalid)
|
||||
{
|
||||
List<CharacterBase> characters = CombatMainManager.Instance.characters;
|
||||
List<CharacterBase> characters = CombatMainManager.Instance.characterController.characters;
|
||||
invalid = new List<CharacterBase>();
|
||||
conditionNotMet = new List<CharacterBase>();
|
||||
notMet = new List<CharacterBase>();
|
||||
valid = new List<CharacterBase>();
|
||||
|
||||
int targetCount = attributeSubmodule.targetCount;
|
||||
|
||||
if (targetCount <= -2)
|
||||
{
|
||||
throw new Exception("Target count is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetCount == 0 || cardData.functionalTags.Contains("TargetSelf")) // 卡牌目标为自身
|
||||
if (targetCount == 0 || cardData.tags.Contains("TargetSelf")) // 卡牌目标为自身
|
||||
{
|
||||
valid.Add(user);
|
||||
invalid.AddRange(characters);
|
||||
invalid.Remove(user);
|
||||
}
|
||||
else if (cardData.functionalTags.Contains("TargetAllies")) // 卡牌目标为友方单位
|
||||
else if (cardData.tags.Contains("TargetAllies")) // 卡牌目标为友方单位
|
||||
{
|
||||
if(user.fraction is Fraction.Ally or Fraction.Player)
|
||||
{
|
||||
@@ -103,7 +111,7 @@ namespace Continentis.MainGame.Card
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cardData.functionalTags.Contains("TargetEnemies")) // 卡牌目标为敌人
|
||||
else if (cardData.tags.Contains("TargetEnemies")) // 卡牌目标为敌人
|
||||
{
|
||||
if (user.fraction is Fraction.Ally or Fraction.Player)
|
||||
{
|
||||
@@ -142,44 +150,58 @@ namespace Continentis.MainGame.Card
|
||||
.Where(target => !target.statusSubmodule.HasStatus(StatusType.Taunt))
|
||||
.ToList();
|
||||
|
||||
conditionNotMet.AddRange(protectedTargets);
|
||||
notMet.AddRange(protectedTargets);
|
||||
valid.RemoveAll(target => !target.statusSubmodule.HasStatus(StatusType.Taunt));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(cardData.functionalTags.Contains("TargetAll")) // 卡牌目标为全体
|
||||
else if(cardData.tags.Contains("TargetAll")) // 卡牌目标为全体
|
||||
{
|
||||
valid.AddRange(characters);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("No valid target found, please check the card data.");
|
||||
Debug.Log("No valid target found");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual List<CharacterBase> SetRandomTargets(List<CharacterBase> valid)
|
||||
{
|
||||
List<CharacterBase> targets = new List<CharacterBase>();
|
||||
int maximumTargets = attributeSubmodule.targetCount;
|
||||
if (maximumTargets == -1 || maximumTargets >= valid.Count)
|
||||
{
|
||||
targets.AddRange(valid);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (targets.Count < maximumTargets && valid.Count > 0)
|
||||
{
|
||||
CharacterBase target = valid[Random.Range(0, valid.Count)];
|
||||
valid.Remove(target);
|
||||
targets.Add(target);
|
||||
}
|
||||
}
|
||||
|
||||
return targets;
|
||||
}
|
||||
|
||||
public virtual bool CheckBeforePlay()
|
||||
{
|
||||
Vector3 userPosition = user.characterView.transform.position;
|
||||
|
||||
if (!CheckEnoughStamina())
|
||||
if (!user.CheckEnoughStamina(GetAttribute("StaminaCost")))
|
||||
{
|
||||
MainGameManager.Instance.basePrefabs.GenerateInfoText("Not Enough Stamina", userPosition);
|
||||
MainGameManager.Instance.basePrefabs.GenerateInfoText("Not Enough Stamina", user.characterView);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckEnoughMana())
|
||||
if (!user.CheckEnoughMana(GetAttribute("ManaCost")))
|
||||
{
|
||||
MainGameManager.Instance.basePrefabs.GenerateInfoText("Not Enough Mana", userPosition);
|
||||
MainGameManager.Instance.basePrefabs.GenerateInfoText("Not Enough Mana", user.characterView);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*public void Play(List<CharacterBase> targetList, CharacterBase user = null, bool willCheckBeforePlay = true)
|
||||
{
|
||||
CommandQueueManager.Instance.AddCommand(_Play(targetList, user, willCheckBeforePlay));
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// 打出卡牌
|
||||
@@ -199,19 +221,45 @@ namespace Continentis.MainGame.Card
|
||||
|
||||
handCardView.isDuringPlaying = true;
|
||||
}
|
||||
|
||||
|
||||
cardInstance.user = user ?? CombatMainManager.Instance.currentCharacter;
|
||||
|
||||
if (!willCheckBeforePlay || CheckBeforePlay())
|
||||
{
|
||||
eventSubmodule.onBeforePlay.Invoke(targetList);
|
||||
CommandQueueManager.Instance.AddCommand(PlayEffect(targetList));
|
||||
eventSubmodule.onAfterPlay.Invoke(targetList);
|
||||
AfterPlayEffect(targetList);
|
||||
combatBuffSubmodule.buffList.For(buff => buff.usageSubmodule?.UpdateModule());
|
||||
if (cardInstance.user is PlayerHero)
|
||||
CombatUIManager.Instance.deckPage.combatResourcesDisplayer.UpdateIcons();
|
||||
cardInstance.user.ModifyStamina(-GetAttribute("StaminaCost"));
|
||||
cardInstance.user.ModifyMana(-GetAttribute("ManaCost"));
|
||||
|
||||
if (cardInstance.user is PlayerHero)
|
||||
{
|
||||
CombatUIManager.Instance.combatMainPage.combatResourcesDisplayer.UpdateIcons();
|
||||
}
|
||||
|
||||
Debug.Log($"Starting to play card: {contentSubmodule.cardName}");
|
||||
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(() =>
|
||||
{
|
||||
playSubmodule.isDuringPlayEffect = true;
|
||||
eventSubmodule.onBeforePlay.Invoke(targetList);
|
||||
cardInstance.user.eventSubmodule?.onBeforePlayCard.Invoke(cardInstance, targetList);
|
||||
cardInstance.user.combatBuffSubmodule.buffList.For(buff =>
|
||||
{
|
||||
buff.eventSubmodule?.onBeforePlayCard.Invoke(cardInstance, targetList);
|
||||
});
|
||||
}));
|
||||
|
||||
CommandQueueManager.Instance.AddCommand(PlayEffect(targetList));
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(() =>
|
||||
{
|
||||
eventSubmodule.onAfterPlay.Invoke(targetList);
|
||||
combatBuffSubmodule.buffList.For(buff => buff.usageSubmodule?.UpdateModule());
|
||||
cardInstance.user.eventSubmodule.onAfterPlayCard.Invoke(cardInstance, targetList);
|
||||
cardInstance.user.combatBuffSubmodule.buffList.For(buff =>
|
||||
{
|
||||
buff.eventSubmodule?.onAfterPlayCard.Invoke(cardInstance, targetList);
|
||||
});
|
||||
AfterPlayEffect(targetList);
|
||||
playSubmodule.isDuringPlayEffect = false;
|
||||
}));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -227,9 +275,6 @@ namespace Continentis.MainGame.Card
|
||||
|
||||
protected virtual CommandBase PlayEffect(List<CharacterBase> targetList)
|
||||
{
|
||||
ConsumeStamina();
|
||||
ConsumeMana();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -237,14 +282,14 @@ namespace Continentis.MainGame.Card
|
||||
{
|
||||
if (user is PlayerHero playerHero)
|
||||
{
|
||||
if (HasTag("Exhaust"))
|
||||
if (HasKeyword("Exhaust"))
|
||||
{
|
||||
playerHero.deckSubmodule.ExhaustCard(cardInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerHero.deckSubmodule.DiscardCard(cardInstance);
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(0, () =>
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(() =>
|
||||
{
|
||||
if (handCardView != null)
|
||||
{
|
||||
@@ -255,7 +300,7 @@ namespace Continentis.MainGame.Card
|
||||
}
|
||||
else if (user is CombatNPC npc)
|
||||
{
|
||||
if (HasTag("Exhaust"))
|
||||
if (HasKeyword("Exhaust"))
|
||||
{
|
||||
npc.deckSubmodule.ExhaustCard(cardInstance);
|
||||
}
|
||||
@@ -265,34 +310,6 @@ namespace Continentis.MainGame.Card
|
||||
|
||||
public partial class CardLogicBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加格挡(格挡每回合结束后会清空)
|
||||
/// </summary>
|
||||
protected void AddBlock(int block, CharacterBase target = null)
|
||||
{
|
||||
target ??= user;
|
||||
target.attributeSubmodule.generalAttributeGroup.current["Block"] += block;
|
||||
target.characterView.hudContainer.UpdateAllHUD();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加闪避(闪避在回合结束后或被击中后清空)
|
||||
/// </summary>
|
||||
protected void AddDodge(int dodge, CharacterBase target = null)
|
||||
{
|
||||
target ??= user;
|
||||
target.attributeSubmodule.generalAttributeGroup.current["Dodge"] += dodge;
|
||||
target.characterView.hudContainer.UpdateAllHUD();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加护盾(护盾不会自动清空)
|
||||
/// </summary>
|
||||
protected void AddShield(int shield, CharacterBase target = null)
|
||||
{
|
||||
target ??= user;
|
||||
target.attributeSubmodule.generalAttributeGroup.current["Shield"] += shield;
|
||||
target.characterView.hudContainer.UpdateAllHUD();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user