Card爆改!

This commit is contained in:
SoulliesOfficial
2025-11-15 12:17:34 -05:00
parent 85bbe2431c
commit 5fe665d0ce
121 changed files with 838 additions and 783 deletions

View File

@@ -1,34 +1,55 @@
using System;
using System.Collections.Generic;
using Continentis.MainGame.Character;
using Continentis.MainGame.Combat;
using Continentis.MainGame.UI;
using Lean.Pool;
using NaughtyAttributes;
using SLSFramework.General;
using UniRx;
using UnityEngine;
namespace Continentis.MainGame.Card
{
public partial class CardInstance
public partial class CardInstance : IGameElement
{
public Guid elementID { get; set; }
[Header("References")]
public DeckSubmodule deck;
//public string currentPileName;
public CardLocation cardLocation;
public CardData cardData;
public CompositeDisposable disposables = new CompositeDisposable();
public ICardOwner owner;
public CharacterBase user;
public CombatTeam usingTeam;
public CardLogicBase cardLogic;
public CardLocation cardLocation;
public HandCardView handCardView;
public IntentionCardView intentionCardView;
public CardInstance(CardLogicBase cardLogic, ICardOwner owner, string initialPileName, int index = -1)
public int upgradeLevel;
[Header("Submodules")]
[ShowNativeProperty]
public AttributeSubmodule attributeSubmodule { get; private set; }
[ShowNativeProperty]
public WeightSubmodule weightSubmodule { get; private set; }
[ShowNativeProperty]
public CombatBuffSubmodule combatBuffSubmodule { get; private set; }
[ShowNativeProperty]
public EventSubmodule eventSubmodule { get; private set; }
[ShowNativeProperty]
public ContentSubmodule contentSubmodule { get; private set; }
[ShowNativeProperty]
public PlaySubmodule playSubmodule { get; private set; }
public CardInstance(CardData data, ICardOwner owner, string initialPileName, int index = -1)
{
cardLogic.cardInstance = this;
this.cardLogic = cardLogic;
(this as IGameElement).Initialize();
this.cardData = data;
this.owner = owner;
this.user = owner as CharacterBase;
if (this.owner is CombatTeam team)
{
this.usingTeam = team;
@@ -49,19 +70,30 @@ namespace Continentis.MainGame.Card
{
this.deck.Pile(cardLocation.pileName).Insert(index, this);
}
this.attributeSubmodule = new AttributeSubmodule(this);
this.weightSubmodule = new WeightSubmodule(this);
this.eventSubmodule = new EventSubmodule(this);
this.combatBuffSubmodule = new CombatBuffSubmodule(this);
this.contentSubmodule = new ContentSubmodule(this);
this.playSubmodule = new PlaySubmodule(this);
this.cardLogic = CardLogicBase.GenerateCardLogic(data);
this.cardLogic.Initialize(this);
this.cardLogic.SetUpLogicComponents();
}
/// <summary>
/// 根据CardLogic生成卡牌实例
/// </summary>
/// <param name="logic">卡牌逻辑实例</param>
/// <param name="template">卡牌实体实例</param>
/// <param name="owner">卡牌持有者</param>
/// <param name="pileName">初始卡堆名称"</param>
/// <param name="index">插入位置默认为0</param>
public static CardInstance GenerateCardInstance(CardLogicBase logic, ICardOwner owner, string pileName, int index = -1)
public static CardInstance GenerateCardInstance(CardInstance template, ICardOwner owner, string pileName, int index = -1)
{
CardInstance cardInstance = new CardInstance(logic, owner, pileName, index);
//cardInstance.cardLogic.Initialize();
CardInstance cardInstance = new CardInstance(template.cardData, owner, pileName, index);
//TODO: 复制template的属性到cardInstance
return cardInstance;
}
@@ -76,15 +108,27 @@ namespace Continentis.MainGame.Card
/// <returns></returns>
public static CardInstance GenerateCardInstance(CardData data, ICardOwner owner, string pileName, int index = -1)
{
CardInstance cardInstance = new CardInstance(CardLogicBase.GenerateCardLogic(data), owner, pileName, index);
cardInstance.cardLogic.Initialize();
CardInstance card = new CardInstance(data, owner, pileName, index);
if (owner == CombatMainManager.Instance.characterController.playerTeam)
{
CombatUIManager.Instance.combatMainPage.teamSwitchButton.UpdateTeamPileText(CombatMainManager.Instance.characterController.playerTeam);
CombatUIManager.Instance.combatMainPage.teamSwitchButton
.UpdateTeamPileText(CombatMainManager.Instance.characterController.playerTeam);
}
return cardInstance;
//下面的部分后续放入CardLogic的初始化函数中
card.RefreshCardAttributes();
if (card.HasKeyword("Instant")) //如果是“瞬发”牌,添加抽牌后立刻打出的事件
{
card.eventSubmodule.onDraw.InsertByPriority("Instant", new PrioritizedAction(() =>
{
card.DetectTargetsValidity(out List<CharacterBase> valid, out _, out _);
card.Play(card.SetRandomTargets(valid), card.user);
}, 99));
}
return card;
}
public HandCardView GenerateHandCardView(string pileName, int index = -1)
@@ -112,7 +156,7 @@ namespace Continentis.MainGame.Card
pile.AddCard(handCardView);
}
handCardView.cardInstance = this;
handCardView.card = this;
this.handCardView = handCardView;
handCardView.transform.localScale = pile is HandPile ? Vector3.one : Vector3.zero;
@@ -140,7 +184,7 @@ namespace Continentis.MainGame.Card
HUD_Intention intention = user.characterView.hudContainer.enablingHUDs["Intention"] as HUD_Intention;
IntentionCardView intentionCardView = LeanPool.Spawn(intentionCardObjectPrefab, intention.hudTransform).GetComponent<IntentionCardView>();
intention.AddCard(intentionCardView);
intentionCardView.cardInstance = this;
intentionCardView.card = this;
this.intentionCardView = intentionCardView;
intentionCardView.transform.localScale = Vector3.one;
intentionCardView.Setup(this);
@@ -157,6 +201,12 @@ namespace Continentis.MainGame.Card
}
}
}
public partial class CardInstance
{
public HandCardView handCardView;
public IntentionCardView intentionCardView;
}
public class CardLocation
{