Update
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using SLSFramework.General;
|
||||
using SLSFramework.UModAssistance;
|
||||
using UnityEngine;
|
||||
@@ -7,7 +8,12 @@ namespace Continentis.MainGame
|
||||
public partial class AudioManager : Singleton<AudioManager>
|
||||
{
|
||||
public AudioSource musicAudioSource;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
PlayBGM("BGM_Basic_MagicalAdventures");
|
||||
}
|
||||
|
||||
public static AudioClip GetAudio(string audioID)
|
||||
{
|
||||
return ModManager.GetAsset<AudioClip>(audioID);
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Continentis.MainGame
|
||||
|
||||
string expressionToEvaluate = template.Substring(startIndex, endIndex - startIndex + 1);
|
||||
string cleanExpression = expressionToEvaluate.Substring(1);
|
||||
Debug.Log($"Evaluating expression: {cleanExpression}");
|
||||
//Debug.Log($"Evaluating expression: {cleanExpression}");
|
||||
object result = interpreter.Eval(cleanExpression);
|
||||
string resultAsLiteral = result.ToString();
|
||||
template = template.Substring(0, startIndex) + resultAsLiteral + template.Substring(endIndex + 1);
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace Continentis.MainGame
|
||||
|
||||
public partial class BuffBase<T>
|
||||
{
|
||||
protected bool FindExistingSameBuff<T1, T2>(out T2 existingBuff, List<T1> buffList) where T1 : BuffBase<T> where T2 : BuffBase<T>
|
||||
protected bool FindExistingSameBuffs<T1, T2>(out List<T2> existingBuffs, List<T1> buffList) where T1 : BuffBase<T> where T2 : BuffBase<T>
|
||||
{
|
||||
existingBuff = null;
|
||||
existingBuffs = new List<T2>();
|
||||
//Debug.Log($"Searching for existing buff of type: {this.GetType()} in buff list of count: {buffList.Count}");
|
||||
foreach (T1 buff in buffList)
|
||||
{
|
||||
@@ -55,9 +55,8 @@ namespace Continentis.MainGame
|
||||
if (buff.GetType() == this.GetType())
|
||||
{
|
||||
//Debug.Log("Found existing buff of the same type.");
|
||||
existingBuff = buff as T2;
|
||||
existingBuffs.Add(buff as T2);
|
||||
//Debug.Log(existingBuff == null);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -65,7 +64,7 @@ namespace Continentis.MainGame
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return existingBuffs.Count > 0;
|
||||
}
|
||||
|
||||
public abstract void Apply(T attached);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Continentis.MainGame.Card;
|
||||
using Continentis.MainGame.Character;
|
||||
@@ -67,7 +68,9 @@ namespace Continentis.MainGame.Card
|
||||
{
|
||||
protected bool FindExistingSameBuff<T>(out T existingBuff) where T : CardBuffBase
|
||||
{
|
||||
return base.FindExistingSameBuff(out existingBuff, attachedCard.combatBuffSubmodule.buffList);
|
||||
bool result = FindExistingSameBuffs(out List<T> existingBuffs, attachedCard.combatBuffSubmodule.buffList);
|
||||
existingBuff = result ? existingBuffs[0] : null;
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void Apply(CardInstance attachedCard, CharacterBase sourceCharacter = null)
|
||||
|
||||
@@ -170,8 +170,10 @@ namespace Continentis.MainGame.Card
|
||||
/// </summary>
|
||||
/// <param name="targetList">目标列表</param>
|
||||
/// <param name="user">使用者</param>
|
||||
/// <param name="noConsumption">是否不消耗资源</param>
|
||||
/// <param name="willCheckBeforePlay">打出之前是否进行可用性检测</param>
|
||||
public bool Play(List<CharacterBase> targetList, CharacterBase user = null, bool willCheckBeforePlay = true)
|
||||
public bool Play(List<CharacterBase> targetList, CharacterBase user = null,
|
||||
bool willCheckBeforePlay = true, bool noConsumption = false)
|
||||
{
|
||||
if (handCardView != null)
|
||||
{
|
||||
@@ -188,9 +190,12 @@ namespace Continentis.MainGame.Card
|
||||
|
||||
if (!willCheckBeforePlay || CheckBeforePlay())
|
||||
{
|
||||
this.user.ModifyStamina(-GetAttribute("StaminaCost"));
|
||||
this.user.ModifyMana(-GetAttribute("ManaCost"));
|
||||
|
||||
if (!noConsumption)
|
||||
{
|
||||
this.user.ModifyStamina(-GetAttribute("StaminaCost"));
|
||||
this.user.ModifyMana(-GetAttribute("ManaCost"));
|
||||
}
|
||||
|
||||
Debug.Log($"Starting to play card: {contentSubmodule.cardName}");
|
||||
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(() =>
|
||||
|
||||
@@ -26,6 +26,11 @@ namespace Continentis.MainGame.Card
|
||||
{
|
||||
card.SetVariableAttribute("Damage", damageOffset, additive, originalDamage);
|
||||
}
|
||||
|
||||
public void SetDamage_Default()
|
||||
{
|
||||
SetDamage(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 斩击伤害计算,伤害=基础伤害+(力量加成+敏捷加成)/2
|
||||
|
||||
@@ -57,7 +57,15 @@ namespace Continentis.MainGame.Character
|
||||
{
|
||||
protected bool FindExistingSameBuff<T>(out T existingBuff) where T : CharacterBuffBase
|
||||
{
|
||||
return FindExistingSameBuff(out existingBuff, attachedCharacter.combatBuffSubmodule.buffList);
|
||||
bool result = FindExistingSameBuffs(out List<T> existingBuffs, attachedCharacter.combatBuffSubmodule.buffList);
|
||||
existingBuff = result ? existingBuffs[0] : null;
|
||||
return result;
|
||||
}
|
||||
|
||||
protected bool FindExistingSameBuffs<T>(out List<T> existingBuffs) where T : CharacterBuffBase
|
||||
{
|
||||
bool result = FindExistingSameBuffs(out existingBuffs, attachedCharacter.combatBuffSubmodule.buffList);
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void Apply(CharacterBase attachedCharacter, CharacterBase sourceCharacter = null)
|
||||
|
||||
@@ -313,26 +313,6 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
public virtual void GetIntendedCards()
|
||||
{
|
||||
bool CanAfford(CardInstance card, int stamina, int mana)
|
||||
{
|
||||
return card.GetAttribute("StaminaCost") <= stamina &&
|
||||
card.GetAttribute("ManaCost") <= mana;
|
||||
}
|
||||
|
||||
bool CheckAvailabilityAndSetTargets(CardInstance card, out List<CharacterBase> targets)
|
||||
{
|
||||
card.DetectTargetsValidity(out List<CharacterBase> valid, out _, out _);
|
||||
if (valid.Count == 0)
|
||||
{
|
||||
targets = null;
|
||||
return false; // 无有效目标或无法使用则跳过
|
||||
}
|
||||
|
||||
targets = card.SetRandomTargets(valid);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
IntentionBase currentIntention = intentionSubmodule.currentIntention;
|
||||
List<CardInstance> availableCards = deckSubmodule.PoolPile;
|
||||
List<IntendedCard> intended = new List<IntendedCard>();
|
||||
@@ -425,5 +405,25 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
intentionSubmodule.intendedCards.AddRange(intended);
|
||||
}
|
||||
|
||||
bool CanAfford(CardInstance card, int stamina, int mana)
|
||||
{
|
||||
return card.GetAttribute("StaminaCost") <= stamina &&
|
||||
card.GetAttribute("ManaCost") <= mana;
|
||||
}
|
||||
|
||||
public bool CheckAvailabilityAndSetTargets(CardInstance card, out List<CharacterBase> targets)
|
||||
{
|
||||
card.DetectTargetsValidity(out List<CharacterBase> valid, out _, out _);
|
||||
if (valid.Count == 0)
|
||||
{
|
||||
targets = null;
|
||||
return false; // 无有效目标或无法使用则跳过
|
||||
}
|
||||
|
||||
targets = card.SetRandomTargets(valid);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,9 +73,15 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
public void ActionStart()
|
||||
{
|
||||
Debug.Log($"{owner.data.displayName} is starting an action. Current action count this round: {owner.actionCountThisRound}");
|
||||
if (owner.actionCountThisRound == 0)
|
||||
{
|
||||
buffList.For(buff => buff.roundFirstActionCountSubmodule?.Update());
|
||||
Debug.Log($"{owner.data.displayName} is starting their first action this round. Buff count of {buffList.Count} will update their round first action counts.");
|
||||
buffList.For(buff =>
|
||||
{
|
||||
Debug.Log($"Updating round first action count for buff: {buff.contentSubmodule.displayName}");
|
||||
buff.roundFirstActionCountSubmodule?.Update();
|
||||
});
|
||||
}
|
||||
|
||||
buffList.For(buff => buff.actionCountSubmodule?.Update());
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Continentis.MainGame.Character;
|
||||
using DG.Tweening;
|
||||
using Lean.Pool;
|
||||
using SLSFramework.UModAssistance;
|
||||
using UnityEngine;
|
||||
@@ -67,8 +68,7 @@ namespace Continentis.MainGame.Combat
|
||||
combatCharacterViews.Add(view);
|
||||
}
|
||||
|
||||
SetViewPositions();
|
||||
SetViewHUDs();
|
||||
SetViewPositions(0);
|
||||
|
||||
//ModManager.CreateInstance<CharacterCombatBuffBase>("Basic.Buffs.Weak", 2).Apply(enemies[0]);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ namespace Continentis.MainGame.Combat
|
||||
npc.InitializeCards();
|
||||
|
||||
Vector3 eulerAngles = fraction == Fraction.Enemy ? new Vector3(0, 180, 0) : Vector3.zero;
|
||||
CombatCharacterViewBase view = npc.GenerateCharacterView(new Vector3(0, -2, 0));
|
||||
CombatCharacterViewBase view = npc.GenerateCharacterView(new Vector3(0, -1, 0));
|
||||
view.mainView.transform.localEulerAngles = eulerAngles;
|
||||
|
||||
npcs[fraction].Add(npc);
|
||||
@@ -99,10 +99,9 @@ namespace Continentis.MainGame.Combat
|
||||
}
|
||||
|
||||
SetViewPositions();
|
||||
SetViewHUDs();
|
||||
}
|
||||
|
||||
public void SetViewPositions()
|
||||
public void SetViewPositions(float transitionDuration = 0.25f)
|
||||
{
|
||||
float playerSideLeftBound = -7.5f;
|
||||
float playerSideRightBound = -1.5f;
|
||||
@@ -118,7 +117,19 @@ namespace Continentis.MainGame.Combat
|
||||
{
|
||||
float xPos = playerSideLeftBound + index * playerBaseInterval;
|
||||
Vector3 position = new Vector3(xPos, -1, 0);
|
||||
playerHeroes[index].characterView.transform.position = position;
|
||||
|
||||
if (transitionDuration > 0f)
|
||||
{
|
||||
playerHeroes[index].characterView.transform.DOMove(position, transitionDuration)
|
||||
.SetEase(Ease.InOutSine)
|
||||
.OnComplete(SetViewHUDs)
|
||||
.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
playerHeroes[index].characterView.transform.position = position;
|
||||
SetViewHUDs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +147,18 @@ namespace Continentis.MainGame.Combat
|
||||
{
|
||||
float xPos = enemySideLeftBound + index * enemyBaseInterval;
|
||||
Vector3 position = new Vector3(xPos, -1, 0);
|
||||
enemies[index].characterView.transform.position = position;
|
||||
if (transitionDuration > 0f)
|
||||
{
|
||||
enemies[index].characterView.transform.DOMove(position, transitionDuration)
|
||||
.SetEase(Ease.InOutSine)
|
||||
.OnComplete(SetViewHUDs)
|
||||
.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
enemies[index].characterView.transform.position = position;
|
||||
SetViewHUDs();
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"Enemy are sorted: {string.Join(", ", enemies.Select(e => e.data.displayName))}");
|
||||
@@ -207,7 +229,6 @@ namespace Continentis.MainGame.Combat
|
||||
Object.Destroy(character.characterView.gameObject);
|
||||
|
||||
SetViewPositions();
|
||||
SetViewHUDs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,14 +149,14 @@ namespace Continentis.MainGame.Combat
|
||||
currentCharacter = characterController.actionOrderList[0];
|
||||
|
||||
currentCharacter.eventSubmodule.onActionStart.Invoke();
|
||||
currentCharacter.combatBuffSubmodule.ActionStart();
|
||||
currentCharacter.recordSubmodule.SetAction(currentRound, ++currentActionIndex);
|
||||
|
||||
|
||||
if (currentCharacter is PlayerHero playerHero)
|
||||
{
|
||||
CombatMainPage combatMainPage = CombatUIManager.Instance.combatMainPage;
|
||||
|
||||
playerHero.deckSubmodule.SetUpHandCardViews();
|
||||
playerHero.combatBuffSubmodule.ActionStart();
|
||||
|
||||
combatMainPage.handPile.isUpdatingLayout = false;
|
||||
CommandQueueManager.Instance.AddCommand(playerHero.deckSubmodule.DrawCards(playerHero.GetAttribute("DrawCardAmountPerAction")));
|
||||
@@ -191,8 +191,14 @@ namespace Continentis.MainGame.Combat
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(0.25f, null));
|
||||
foreach (IntendedCard intendedCard in currentCharacter.intentionSubmodule.intendedCards)
|
||||
{
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(0.25f, () => intendedCard.cardInstance.DestroyIntentionCardView()));
|
||||
intendedCard.cardInstance.Play(intendedCard.targets, currentCharacter, false);
|
||||
//TODO: 临时的,刷新一次意图目标
|
||||
currentCharacter.CheckAvailabilityAndSetTargets(intendedCard.cardInstance, out intendedCard.targets);
|
||||
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(0.25f, () =>
|
||||
{
|
||||
intendedCard.cardInstance.Play(intendedCard.targets, currentCharacter);
|
||||
intendedCard.cardInstance.DestroyIntentionCardView();
|
||||
}));
|
||||
}
|
||||
CommandQueueManager.Instance.AddCommand(new Cmd_Function(0f, EndAction));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Continentis.MainGame.Commands
|
||||
private readonly bool isCustomDraw;
|
||||
private readonly int drawCount;
|
||||
private readonly float interval;
|
||||
private readonly float singleCardAnimationDuration = 0.5f; // 单张卡牌的动画时长
|
||||
private readonly float singleCardAnimationDuration = 0.4f; // 单张卡牌的动画时长
|
||||
|
||||
private readonly List<CardInstance> customDrawCards;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Continentis.MainGame.UI
|
||||
@@ -13,6 +14,10 @@ namespace Continentis.MainGame.UI
|
||||
public float cardSpacingFactor = 500f; // 手牌间距调整因子
|
||||
public float maxVerticalOffset = 50f; // 控制最外侧卡牌的垂直偏移
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
private float cardSpacing;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (isUpdatingLayout)
|
||||
@@ -26,7 +31,7 @@ namespace Continentis.MainGame.UI
|
||||
if (count == 0 || index < 0)
|
||||
return Vector2.zero;
|
||||
|
||||
float cardSpacing = cardSpacingBase + Mathf.Max((cardSpacingFactor - (count * 20)), -200) / count;
|
||||
cardSpacing = cardSpacingBase + Mathf.Max((cardSpacingFactor - (count * 40)), -200) / count;
|
||||
|
||||
// 计算中间索引,保证手牌居中排列
|
||||
float midIndex = (count - 1) / 2f;
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Continentis.MainGame.UI
|
||||
{
|
||||
base.Awake();
|
||||
cardViews = new List<CardViewBase>();
|
||||
UpdateCountText();
|
||||
}
|
||||
|
||||
public virtual void AddCard(CardViewBase cardObject)
|
||||
|
||||
@@ -10,12 +10,20 @@ namespace SLSFramework.General
|
||||
{
|
||||
/// <summary>
|
||||
/// 对列表中的每个元素执行指定的操作
|
||||
/// 可以处理在迭代过程中移除元素的情况
|
||||
/// </summary>
|
||||
public static void For<T>(this IList<T> list, System.Action<T> action)
|
||||
public static void For<T>(this IList<T> list, Action<T> action)
|
||||
{
|
||||
for (var index = 0; index < list.Count; index++)
|
||||
{
|
||||
int initialCount = list.Count;
|
||||
|
||||
action(list[index]);
|
||||
|
||||
if (list.Count < initialCount)
|
||||
{
|
||||
index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user