Files
tcg-client/Assets/TcgEngine/Scripts/Effects/EffectMana.cs
2025-08-11 14:09:21 +08:00

49 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TcgEngine.Gameplay;
namespace TcgEngine
{
/// <summary>
/// Effect to gain/lose mana (player)
/// </summary>
[CreateAssetMenu(fileName = "effect", menuName = "TcgEngine/Effect/Mana", order = 10)]
public class EffectMana : EffectData
{
public bool increase_value;
public bool increase_max;
[Header("Team Mana")]
public string team_id = ""; // 指定影响的阵营空值表示影响通用mana
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
{
// 如果指定了阵营影响阵营mana否则影响通用mana
if (!string.IsNullOrEmpty(team_id))
{
// 影响阵营mana
int current_add = increase_value ? ability.value : 0;
int max_add = increase_max ? ability.value : 0;
target.AddTeamMana(team_id, current_add, max_add);
}
else
{
// 影响通用mana保持原有逻辑
if (increase_max)
{
target.mana_max += ability.value;
target.mana_max = Mathf.Clamp(target.mana_max, 0, GameplayData.Get().mana_max);
}
if(increase_value)
{
target.mana += ability.value;
target.mana = Mathf.Max(target.mana, 0);
}
}
}
}
}