意图初步

This commit is contained in:
SoulliesOfficial
2025-11-15 09:08:36 -05:00
parent 9a8eadef24
commit 85bbe2431c
33 changed files with 508 additions and 198 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Continentis.MainGame.Card;
using SLSFramework.General;
using UnityEngine;
using UnityEngine.Events;
@@ -8,6 +9,7 @@ namespace Continentis.MainGame.Character
{
public class IntentionSubmodule : SubmoduleBase<CharacterBase>
{
public List<IntentionBase> allIntentions;
public IntentionBase currentIntention;
public UnityAction getIntendedCards;
@@ -15,7 +17,8 @@ namespace Continentis.MainGame.Character
public IntentionSubmodule(CharacterBase owner) : base(owner)
{
currentIntention = new IntentionBase();
allIntentions = new List<IntentionBase>();
currentIntention = new IntentionBase(this);
getIntendedCards = owner.GetIntendedCards;
intendedCards = new List<IntendedCard>();
}
@@ -33,11 +36,30 @@ namespace Continentis.MainGame.Character
}
}
public class IntentionBase
public class IntentionBase : IPrioritized
{
public int guaranteedStamina = 0;
public int guaranteedMana = 0;
public int maxCardCount = 999;
public IntentionSubmodule intentionSubmodule;
public CharacterBase character => intentionSubmodule.owner;
public DeckSubmodule characterDeck => character.deckSubmodule;
public RecordSubmodule characterRecord => character.recordSubmodule;
public int Priority { get; protected set; }
public int guaranteedStamina;
public int guaranteedMana;
public int maxCardCount;
public IntentionBase(IntentionSubmodule intentionSubmodule)
{
this.intentionSubmodule = intentionSubmodule;
this.Priority = 0;
this.guaranteedStamina = 0;
this.guaranteedMana = 0;
this.maxCardCount = 999;
}
public virtual bool Condition()
{
return true;
}
public virtual void RefreshCardWeights()
{
@@ -48,5 +70,7 @@ namespace Continentis.MainGame.Character
{
}
}
}

View File

@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Continentis.MainGame.Card;
using UnityEngine;
namespace Continentis.MainGame.Character
{
public partial class RecordSubmodule : SubmoduleBase<CharacterBase>
{
public int currentRound;
public int currentAction;
public List<ActionRecord> actionRecords;
public RecordSubmodule(CharacterBase owner) : base(owner)
{
actionRecords = new List<ActionRecord>();
}
public void SetAction(int round, int actionIndex)
{
currentRound = round;
currentAction = actionIndex;
actionRecords.Add(new ActionRecord(round, actionIndex, new List<CardInstance>()));
}
}
public partial class RecordSubmodule
{
public void RecordCardPlay(CardInstance card)
{
if (actionRecords.Count == 0)
{
Debug.LogWarning("No action record to add card play to.");
return;
}
ActionRecord currentRecord = actionRecords[actionRecords.Count - 1];
currentRecord.cardsPlayed.Add(card);
Debug.Log($"在回合 {currentRecord.round} 行动 {currentRecord.actionIndex} 中记录了卡牌 {card.cardLogic.contentSubmodule.cardName} 的使用。");
}
}
public partial class RecordSubmodule
{
public ActionRecord GetRecord(int round, int actionIndex)
{
return actionRecords.FirstOrDefault(record => record.round == round && record.actionIndex == actionIndex);
}
public List<ActionRecord> GetLastActionsRecords(int count)
{
return actionRecords.Skip(Mathf.Max(0, actionRecords.Count - count)).ToList();
}
public List<ActionRecord> GetLastRoundsRecords(int roundCount)
{
int minRound = Mathf.Max(0, currentRound - roundCount + 1);
return actionRecords.Where(record => record.round >= minRound).ToList();
}
}
[Serializable]
public class ActionRecord
{
public int round;
public int actionIndex;
public List<CardInstance> cardsPlayed;
public ActionRecord(int round, int actionIndex, List<CardInstance> cardsPlayed)
{
this.round = round;
this.actionIndex = actionIndex;
this.cardsPlayed = cardsPlayed;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 95504a2d65ce1fa4d82cbdb23ef16892