半血双倍伤害&击杀钩子
This commit is contained in:
41
Assets/TcgEngine/Resources/Abilities/play/play_damage2.asset
Normal file
41
Assets/TcgEngine/Resources/Abilities/play/play_damage2.asset
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8ce5f81e5cc37f547af6923758602c8c, type: 3}
|
||||||
|
m_Name: play_damage2
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
id: play_deal_damage2
|
||||||
|
trigger: 5
|
||||||
|
conditions_trigger: []
|
||||||
|
target: 30
|
||||||
|
conditions_target:
|
||||||
|
- {fileID: 11400000, guid: 47221d412dc0a014b8a33abb0cbfc773, type: 2}
|
||||||
|
- {fileID: 11400000, guid: ef09540f94d8428408b69fea46ec3334, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a1fb3a7171663234280fdfb41c99ab0a, type: 2}
|
||||||
|
filters_target: []
|
||||||
|
effects:
|
||||||
|
- {fileID: 11400000, guid: 92cd231cc27774c149e82c59d3e72736, type: 2}
|
||||||
|
status: []
|
||||||
|
value: 3
|
||||||
|
duration: 0
|
||||||
|
chain_abilities: []
|
||||||
|
mana_cost: 0
|
||||||
|
exhaust: 0
|
||||||
|
board_fx: {fileID: 0}
|
||||||
|
caster_fx: {fileID: 0}
|
||||||
|
target_fx: {fileID: 9125387663047351618, guid: b66600b51774daa49964ead5c6a00c49,
|
||||||
|
type: 3}
|
||||||
|
projectile_fx: {fileID: 0}
|
||||||
|
cast_audio: {fileID: 0}
|
||||||
|
target_audio: {fileID: 0}
|
||||||
|
charge_target: 0
|
||||||
|
title: "\u6253\u51FA\u4F24\u5BB3"
|
||||||
|
desc: "damage_double \u4F24\u5BB3\u7FFB\u500D"
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f729004d1ece04092a037b6b6d40829e
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
41
Assets/TcgEngine/Resources/Abilities/play/play_damage3.asset
Normal file
41
Assets/TcgEngine/Resources/Abilities/play/play_damage3.asset
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8ce5f81e5cc37f547af6923758602c8c, type: 3}
|
||||||
|
m_Name: play_damage3
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
id: play_deal_damage3
|
||||||
|
trigger: 5
|
||||||
|
conditions_trigger: []
|
||||||
|
target: 30
|
||||||
|
conditions_target:
|
||||||
|
- {fileID: 11400000, guid: 47221d412dc0a014b8a33abb0cbfc773, type: 2}
|
||||||
|
- {fileID: 11400000, guid: ef09540f94d8428408b69fea46ec3334, type: 2}
|
||||||
|
- {fileID: 11400000, guid: a1fb3a7171663234280fdfb41c99ab0a, type: 2}
|
||||||
|
filters_target: []
|
||||||
|
effects:
|
||||||
|
- {fileID: 11400000, guid: 82aa37988fd69413b83d98dcd038982c, type: 2}
|
||||||
|
status: []
|
||||||
|
value: 10
|
||||||
|
duration: 0
|
||||||
|
chain_abilities: []
|
||||||
|
mana_cost: 0
|
||||||
|
exhaust: 0
|
||||||
|
board_fx: {fileID: 0}
|
||||||
|
caster_fx: {fileID: 0}
|
||||||
|
target_fx: {fileID: 9125387663047351618, guid: b66600b51774daa49964ead5c6a00c49,
|
||||||
|
type: 3}
|
||||||
|
projectile_fx: {fileID: 0}
|
||||||
|
cast_audio: {fileID: 0}
|
||||||
|
target_audio: {fileID: 0}
|
||||||
|
charge_target: 0
|
||||||
|
title: "\u6253\u51FA\u4F24\u5BB3"
|
||||||
|
desc: "damage_double \u4F24\u5BB3\u7FFB\u500D"
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e2cae01651c214277978e2e91d4cc0a2
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8ce5f81e5cc37f547af6923758602c8c, type: 3}
|
||||||
|
m_Name: spell_ally_hp_4
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
id: spell_ally_hp_4
|
||||||
|
trigger: 0
|
||||||
|
conditions_trigger: []
|
||||||
|
target: 10
|
||||||
|
conditions_target:
|
||||||
|
- {fileID: 11400000, guid: 7463bf87d3794e249b7610c9de9c5327, type: 2}
|
||||||
|
filters_target: []
|
||||||
|
effects:
|
||||||
|
- {fileID: 11400000, guid: fc8261ce93dbc924e859751e098513ad, type: 2}
|
||||||
|
status: []
|
||||||
|
value: 4
|
||||||
|
duration: 0
|
||||||
|
chain_abilities: []
|
||||||
|
mana_cost: 0
|
||||||
|
exhaust: 0
|
||||||
|
board_fx: {fileID: 0}
|
||||||
|
caster_fx: {fileID: 0}
|
||||||
|
target_fx: {fileID: 0}
|
||||||
|
projectile_fx: {fileID: 0}
|
||||||
|
cast_audio: {fileID: 0}
|
||||||
|
target_audio: {fileID: 0}
|
||||||
|
charge_target: 0
|
||||||
|
title: "\u76DF\u53CB\u751F\u547D\u503C"
|
||||||
|
desc: "\u76DF\u53CB\u751F\u547D\u503C\u3002"
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c7f9902097b1a41db9993a832dee3f16
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -23,13 +23,10 @@ MonoBehaviour:
|
|||||||
mana: 1
|
mana: 1
|
||||||
attack: 1
|
attack: 1
|
||||||
hp: 20
|
hp: 20
|
||||||
mana_fire: 0
|
|
||||||
mana_forest: 0
|
|
||||||
mana_water: 0
|
|
||||||
traits: []
|
traits: []
|
||||||
stats: []
|
stats: []
|
||||||
abilities:
|
abilities:
|
||||||
- {fileID: 11400000, guid: 91c599c9893ab47a69a039c0ed0215cc, type: 2}
|
- {fileID: 11400000, guid: d006aa7902864824d907d4aa6b62de09, type: 2}
|
||||||
text: "<b>\u65BD\u653E(2):</b> \u5C06\u4E00\u5F20\u6CD5\u672F\u724C\u9001\u56DE\u4F60\u7684\u624B\u724C\u3002"
|
text: "<b>\u65BD\u653E(2):</b> \u5C06\u4E00\u5F20\u6CD5\u672F\u724C\u9001\u56DE\u4F60\u7684\u624B\u724C\u3002"
|
||||||
desc:
|
desc:
|
||||||
spawn_fx: {fileID: 9125387663047351618, guid: bac685160af4aff46ae561a51da6f5f4,
|
spawn_fx: {fileID: 9125387663047351618, guid: bac685160af4aff46ae561a51da6f5f4,
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ MonoBehaviour:
|
|||||||
m_Name: imp
|
m_Name: imp
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
id: imp
|
id: imp
|
||||||
title: 小鬼
|
title: "\u5C0F\u9B3C"
|
||||||
art_full: {fileID: 21300000, guid: e74d128a608ae4c449e33aaf6449ee5e, type: 3}
|
art_full: {fileID: 21300000, guid: e74d128a608ae4c449e33aaf6449ee5e, type: 3}
|
||||||
art_board: {fileID: 21300000, guid: e4ceb28c84c0b8846a348abfad791085, type: 3}
|
art_board: {fileID: 21300000, guid: e4ceb28c84c0b8846a348abfad791085, type: 3}
|
||||||
type: 10
|
type: 10
|
||||||
|
camp: 0
|
||||||
team: {fileID: 11400000, guid: 6bbb96863ece0314fb318c0fce569afc, type: 2}
|
team: {fileID: 11400000, guid: 6bbb96863ece0314fb318c0fce569afc, type: 2}
|
||||||
rarity: {fileID: 11400000, guid: fab1a52f5a36cc942985dea95be18ac9, type: 2}
|
rarity: {fileID: 11400000, guid: fab1a52f5a36cc942985dea95be18ac9, type: 2}
|
||||||
mana: 2
|
mana: 2
|
||||||
@@ -25,8 +26,8 @@ MonoBehaviour:
|
|||||||
traits: []
|
traits: []
|
||||||
stats: []
|
stats: []
|
||||||
abilities:
|
abilities:
|
||||||
- {fileID: 11400000, guid: 4f4dd01a7c411ab408c5ca18edbef253, type: 2}
|
- {fileID: 11400000, guid: e2cae01651c214277978e2e91d4cc0a2, type: 2}
|
||||||
text: <b>打出:</b> 造成1点伤害。
|
text: "<b>\u6253\u51FA:</b> \u9020\u62101\u70B9\u4F24\u5BB3\u3002"
|
||||||
desc:
|
desc:
|
||||||
spawn_fx: {fileID: 9125387663047351618, guid: bac685160af4aff46ae561a51da6f5f4,
|
spawn_fx: {fileID: 9125387663047351618, guid: bac685160af4aff46ae561a51da6f5f4,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|||||||
@@ -13,20 +13,21 @@ MonoBehaviour:
|
|||||||
m_Name: tree_angry
|
m_Name: tree_angry
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
id: tree_angry
|
id: tree_angry
|
||||||
title: 愤怒之树
|
title: "\u6124\u6012\u4E4B\u6811"
|
||||||
art_full: {fileID: 21300000, guid: df4f7d3c3ffc18c42bdecfa498fa53da, type: 3}
|
art_full: {fileID: 21300000, guid: df4f7d3c3ffc18c42bdecfa498fa53da, type: 3}
|
||||||
art_board: {fileID: 21300000, guid: b4baa2ca665d5aa42be490f5a09ea949, type: 3}
|
art_board: {fileID: 21300000, guid: b4baa2ca665d5aa42be490f5a09ea949, type: 3}
|
||||||
type: 10
|
type: 10
|
||||||
|
camp: 0
|
||||||
team: {fileID: 11400000, guid: b80d8061c5bdb2e408e62a08e0e743ca, type: 2}
|
team: {fileID: 11400000, guid: b80d8061c5bdb2e408e62a08e0e743ca, type: 2}
|
||||||
rarity: {fileID: 11400000, guid: fab1a52f5a36cc942985dea95be18ac9, type: 2}
|
rarity: {fileID: 11400000, guid: fab1a52f5a36cc942985dea95be18ac9, type: 2}
|
||||||
mana: 3
|
mana: 3
|
||||||
attack: 3
|
attack: 3
|
||||||
hp: 5
|
hp: 30
|
||||||
traits: []
|
traits: []
|
||||||
stats: []
|
stats: []
|
||||||
abilities:
|
abilities:
|
||||||
- {fileID: 11400000, guid: 1bc895e873a2be145898a86a2fb9ca03, type: 2}
|
- {fileID: 11400000, guid: 1bc895e873a2be145898a86a2fb9ca03, type: 2}
|
||||||
text: 再生
|
text: "\u518D\u751F"
|
||||||
desc:
|
desc:
|
||||||
spawn_fx: {fileID: 5791330189299518109, guid: 1fa8fa11b2c6b9b4d976743e5bbb3956,
|
spawn_fx: {fileID: 5791330189299518109, guid: 1fa8fa11b2c6b9b4d976743e5bbb3956,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|||||||
18
Assets/TcgEngine/Resources/Effects/damage_double.asset
Normal file
18
Assets/TcgEngine/Resources/Effects/damage_double.asset
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 31aa9b0b846e37e47bb7896cc026a560, type: 3}
|
||||||
|
m_Name: damage_double
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
bonus_damage: {fileID: 11400000, guid: 50116f133bd899842ab1d2a5b71412ee, type: 2}
|
||||||
|
double_damage_on_half_hp: 1
|
||||||
|
enable_kill_hook: 0
|
||||||
|
kill_abilities: []
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 92cd231cc27774c149e82c59d3e72736
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 31aa9b0b846e37e47bb7896cc026a560, type: 3}
|
||||||
|
m_Name: damage_hook_add_all_hp_4
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
bonus_damage: {fileID: 11400000, guid: 50116f133bd899842ab1d2a5b71412ee, type: 2}
|
||||||
|
double_damage_on_half_hp: 0
|
||||||
|
enable_kill_hook: 1
|
||||||
|
kill_abilities:
|
||||||
|
- {fileID: 11400000, guid: c0cea65074408f8498948aeae58fac68, type: 2}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 82aa37988fd69413b83d98dcd038982c
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -12,8 +12,15 @@ namespace TcgEngine
|
|||||||
[CreateAssetMenu(fileName = "effect", menuName = "TcgEngine/Effect/Damage", order = 10)]
|
[CreateAssetMenu(fileName = "effect", menuName = "TcgEngine/Effect/Damage", order = 10)]
|
||||||
public class EffectDamage : EffectData
|
public class EffectDamage : EffectData
|
||||||
{
|
{
|
||||||
|
[Header("伤害设置")]
|
||||||
public TraitData bonus_damage;
|
public TraitData bonus_damage;
|
||||||
|
|
||||||
|
[Header("半血翻倍")]
|
||||||
|
public bool double_damage_on_half_hp = false; // 当目标生命值低于50%时伤害翻倍
|
||||||
|
|
||||||
|
[Header("击杀触发")]
|
||||||
|
public AbilityData kill_trigger_ability = null; // 击杀后触发的技能
|
||||||
|
|
||||||
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
|
||||||
{
|
{
|
||||||
int damage = GetDamage(logic.GameData, caster, ability.value);
|
int damage = GetDamage(logic.GameData, caster, ability.value);
|
||||||
@@ -22,8 +29,21 @@ namespace TcgEngine
|
|||||||
|
|
||||||
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
|
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
|
||||||
{
|
{
|
||||||
int damage = GetDamage(logic.GameData, caster, ability.value);
|
int damage = GetDamageWithHalfHpBonus(logic.GameData, caster, ability.value, target);
|
||||||
|
|
||||||
|
// 是否可以击杀
|
||||||
|
int target_hp_before = target != null ? target.GetHP() : 0;
|
||||||
|
bool will_kill = target != null && target_hp_before <= damage;
|
||||||
|
|
||||||
|
// 造成伤害
|
||||||
logic.DamageCard(caster, target, damage, true);
|
logic.DamageCard(caster, target, damage, true);
|
||||||
|
|
||||||
|
// 如果击杀了目标且配置了击杀触发技能,则触发技能
|
||||||
|
if (will_kill && target != null && kill_trigger_ability != null)
|
||||||
|
{
|
||||||
|
Debug.Log("满足击杀条件");
|
||||||
|
TriggerKillAbility(logic, caster, target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetDamage(Game data, Card caster, int value)
|
private int GetDamage(Game data, Card caster, int value)
|
||||||
@@ -33,5 +53,33 @@ namespace TcgEngine
|
|||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int GetDamageWithHalfHpBonus(Game data, Card caster, int value, Card target)
|
||||||
|
{
|
||||||
|
int damage = GetDamage(data, caster, value);
|
||||||
|
|
||||||
|
// 半血伤害翻倍
|
||||||
|
if (double_damage_on_half_hp && target != null)
|
||||||
|
{
|
||||||
|
int current_hp = target.GetHP();
|
||||||
|
int max_hp = target.CardData.hp;
|
||||||
|
float hp_percentage = (float)current_hp / max_hp;
|
||||||
|
|
||||||
|
if (hp_percentage <= 0.5f) // 生命值低于等于50%
|
||||||
|
{
|
||||||
|
damage *= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TriggerKillAbility(GameLogic logic, Card caster, Card killed_target)
|
||||||
|
{
|
||||||
|
if (kill_trigger_ability != null && caster != null)
|
||||||
|
{
|
||||||
|
Debug.Log("触发击杀钩子");
|
||||||
|
logic.TriggerAbilityDelayed(kill_trigger_ability, caster, killed_target);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user