Card爆改!
This commit is contained in:
@@ -60,12 +60,12 @@ namespace Continentis.MainGame.Character
|
||||
[ShowNativeProperty]
|
||||
public RecordSubmodule recordSubmodule { get; private set; }
|
||||
|
||||
public virtual void Initialize(Fraction fraction, CharacterData data)
|
||||
public CharacterBase(CharacterData data, Fraction fraction)
|
||||
{
|
||||
(this as IGameElement).Initialize();
|
||||
|
||||
this.fraction = fraction;
|
||||
this.data = data;
|
||||
this.fraction = fraction;
|
||||
|
||||
switch (fraction)
|
||||
{
|
||||
@@ -91,7 +91,6 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
this.logicBase = GenerateCharacterLogic(data);
|
||||
this.logicBase.Initialize(this);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -91,21 +91,21 @@ namespace Continentis.MainGame.Character
|
||||
attachedCharacter.combatBuffSubmodule.buffList.Exclude(this).For(buff => buff.eventSubmodule?.onOtherBuffApplied.Invoke(this));
|
||||
RefreshAttributes();
|
||||
iconSubmodule?.Update();
|
||||
attachedCharacter.deckSubmodule.GetAllCards().ForEach(card => card.cardLogic.RefreshCardAttributes());
|
||||
attachedCharacter.deckSubmodule.GetAllCards().ForEach(card => card.RefreshCardAttributes());
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
{
|
||||
OnBuffRemove();
|
||||
this.attachedCharacter.combatBuffSubmodule.buffList.Remove(this);
|
||||
attachedCharacter.deckSubmodule.GetAllCards().ForEach(card => card.cardLogic.RefreshCardAttributes());
|
||||
attachedCharacter.deckSubmodule.GetAllCards().ForEach(card => card.RefreshCardAttributes());
|
||||
attachedCharacter.combatBuffSubmodule.buffList.Exclude(this).For(buff => buff.eventSubmodule?.onOtherBuffRemoved.Invoke(this));
|
||||
}
|
||||
|
||||
public override void UntriggerRemove()
|
||||
{
|
||||
this.attachedCharacter.combatBuffSubmodule.buffList.Remove(this);
|
||||
attachedCharacter.deckSubmodule.GetAllCards().ForEach(card => card.cardLogic.RefreshCardAttributes());
|
||||
attachedCharacter.deckSubmodule.GetAllCards().ForEach(card => card.RefreshCardAttributes());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Continentis.MainGame.Character
|
||||
{
|
||||
public partial class CharacterLogicBase
|
||||
{
|
||||
protected CharacterBase character;
|
||||
protected CharacterBase character;
|
||||
public virtual void Initialize(CharacterBase character)
|
||||
{
|
||||
this.character = character;
|
||||
@@ -300,20 +300,20 @@ namespace Continentis.MainGame.Character
|
||||
{
|
||||
bool CanAfford(CardInstance card, int stamina, int mana)
|
||||
{
|
||||
return card.cardLogic.GetAttribute("StaminaCost") <= stamina &&
|
||||
card.cardLogic.GetAttribute("ManaCost") <= mana;
|
||||
return card.GetAttribute("StaminaCost") <= stamina &&
|
||||
card.GetAttribute("ManaCost") <= mana;
|
||||
}
|
||||
|
||||
bool CheckAvailabilityAndSetTargets(CardInstance card, out List<CharacterBase> targets)
|
||||
{
|
||||
card.cardLogic.DetectTargetsValidity(out List<CharacterBase> valid, out _, out _);
|
||||
if (valid.Count == 0 || !card.cardLogic.CheckBeforePlay())
|
||||
card.DetectTargetsValidity(out List<CharacterBase> valid, out _, out _);
|
||||
if (valid.Count == 0 || !card.CheckBeforePlay())
|
||||
{
|
||||
targets = null;
|
||||
return false; // 无有效目标或无法使用则跳过
|
||||
}
|
||||
|
||||
targets = card.cardLogic.SetRandomTargets(valid);
|
||||
targets = card.SetRandomTargets(valid);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -331,7 +331,7 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
foreach (CardInstance card in availableCards)
|
||||
{
|
||||
if (card.cardLogic.weightSubmodule.forceUse)
|
||||
if (card.weightSubmodule.forceUse)
|
||||
{
|
||||
forced.Add(card);
|
||||
}
|
||||
@@ -360,8 +360,8 @@ namespace Continentis.MainGame.Character
|
||||
}
|
||||
|
||||
intended.Add(new IntendedCard(card, targets));
|
||||
remainingStamina -= card.cardLogic.GetAttribute("StaminaCost");
|
||||
remainingMana -= card.cardLogic.GetAttribute("ManaCost");
|
||||
remainingStamina -= card.GetAttribute("StaminaCost");
|
||||
remainingMana -= card.GetAttribute("ManaCost");
|
||||
}
|
||||
// 行动力不足则跳过该卡
|
||||
}
|
||||
@@ -377,7 +377,7 @@ namespace Continentis.MainGame.Character
|
||||
break;
|
||||
}
|
||||
|
||||
float totalWeight = affordableCards.Sum(card => card.cardLogic.weightSubmodule.currentWeight);
|
||||
float totalWeight = affordableCards.Sum(card => card.weightSubmodule.currentWeight);
|
||||
if (totalWeight <= 0f) break;
|
||||
|
||||
float r = Random.value * totalWeight;
|
||||
@@ -385,7 +385,7 @@ namespace Continentis.MainGame.Character
|
||||
CardInstance chosen = null;
|
||||
foreach (CardInstance card in affordableCards)
|
||||
{
|
||||
accum += card.cardLogic.weightSubmodule.currentWeight;
|
||||
accum += card.weightSubmodule.currentWeight;
|
||||
if (r <= accum)
|
||||
{
|
||||
chosen = card;
|
||||
@@ -403,8 +403,8 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
intended.Add(new IntendedCard(chosen, targets));
|
||||
normal.Remove(chosen);
|
||||
remainingStamina -= chosen.cardLogic.GetAttribute("StaminaCost");
|
||||
remainingMana -= chosen.cardLogic.GetAttribute("ManaCost");
|
||||
remainingStamina -= chosen.GetAttribute("StaminaCost");
|
||||
remainingMana -= chosen.GetAttribute("ManaCost");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace Continentis.MainGame.Character
|
||||
{
|
||||
public void SetUpHandCardViews()
|
||||
{
|
||||
DrawPile.ForEach(c=> c.GenerateHandCardView(CombatUIManager.Instance.combatMainPage.drawPile));
|
||||
HandPile.ForEach(c=>
|
||||
DrawPile.ForEach(card=> card.GenerateHandCardView(CombatUIManager.Instance.combatMainPage.drawPile));
|
||||
HandPile.ForEach(card =>
|
||||
{
|
||||
if(!c.cardLogic.playSubmodule.isDuringPlayEffect)
|
||||
c.GenerateHandCardView(CombatUIManager.Instance.combatMainPage.handPile);
|
||||
if(!card.playSubmodule.isDuringPlayEffect)
|
||||
card.GenerateHandCardView(CombatUIManager.Instance.combatMainPage.handPile);
|
||||
});
|
||||
DiscardPile.ForEach(c=>c.GenerateHandCardView(CombatUIManager.Instance.combatMainPage.discardPile));
|
||||
ExhaustPile.ForEach(c=>c.GenerateHandCardView(CombatUIManager.Instance.combatMainPage.exhaustPile));
|
||||
@@ -83,7 +83,7 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
public void PlayCard(CardInstance card, List<CharacterBase> targetList)
|
||||
{
|
||||
card.cardLogic.Play(targetList, owner);
|
||||
card.Play(targetList, owner);
|
||||
}
|
||||
|
||||
public CommandGroup DiscardCard(CardInstance card, bool initiative, float interval = 0.1f)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Continentis.MainGame.Character
|
||||
}
|
||||
ActionRecord currentRecord = actionRecords[actionRecords.Count - 1];
|
||||
currentRecord.cardsPlayed.Add(card);
|
||||
Debug.Log($"在回合 {currentRecord.round} 行动 {currentRecord.actionIndex} 中记录了卡牌 {card.cardLogic.contentSubmodule.cardName} 的使用。");
|
||||
Debug.Log($"在回合 {currentRecord.round} 行动 {currentRecord.actionIndex} 中记录了卡牌 {card.contentSubmodule.cardName} 的使用。");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,17 +5,14 @@ namespace Continentis.MainGame.Character
|
||||
{
|
||||
public partial class CombatNPC : CharacterBase
|
||||
{
|
||||
|
||||
public CombatNPC(CharacterData data, Fraction fraction) : base(data, fraction)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CombatNPC
|
||||
{
|
||||
public static CombatNPC GenerateCharacter(CharacterData data, Fraction fraction)
|
||||
{
|
||||
CombatNPC combatNpc = new CombatNPC();
|
||||
combatNpc.Initialize(fraction, data);
|
||||
|
||||
return combatNpc;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,19 +8,13 @@ namespace Continentis.MainGame.Character
|
||||
{
|
||||
public partial class PlayerHero : CharacterBase
|
||||
{
|
||||
|
||||
public PlayerHero(CharacterData data, Fraction fraction) : base(data, fraction)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class PlayerHero
|
||||
{
|
||||
public static PlayerHero GenerateCharacter(CharacterData data)
|
||||
{
|
||||
PlayerHero playerHero = new PlayerHero();
|
||||
playerHero.Initialize(Fraction.Player, data);
|
||||
|
||||
return playerHero;
|
||||
}
|
||||
|
||||
public override void InitializeCards()
|
||||
{
|
||||
base.InitializeCards();
|
||||
@@ -30,13 +24,13 @@ namespace Continentis.MainGame.Character
|
||||
drawPile.Shuffle();
|
||||
|
||||
// 处理“固有”卡牌
|
||||
foreach (CardInstance card in drawPile.Where(card => card.cardLogic.HasKeyword("Innate")).ToList())
|
||||
foreach (CardInstance card in drawPile.Where(card => card.HasKeyword("Innate")).ToList())
|
||||
{
|
||||
deckSubmodule.TransferCard("Draw", 0, card);
|
||||
}
|
||||
|
||||
// 处理“迟钝”卡牌
|
||||
foreach (CardInstance card in drawPile.Where(card => card.cardLogic.HasKeyword("Tardy")).ToList())
|
||||
foreach (CardInstance card in drawPile.Where(card => card.HasKeyword("Tardy")).ToList())
|
||||
{
|
||||
deckSubmodule.TransferCard("Draw", "Discard", card);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user