Implement GolemFist
This commit is contained in:
parent
4ca7b7537a
commit
d1af817bc6
11 changed files with 106 additions and 19 deletions
18
Assets/Battle/CardsMonsters/GolemFistMCard.cs
Normal file
18
Assets/Battle/CardsMonsters/GolemFistMCard.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GolemFistMCard : MonsterCard
|
||||
{
|
||||
public GolemFistMCard(BattleParticipant owner)
|
||||
: base(owner, MCardId.GolemFist, "Golem Fist", 2, CardType.Attack,
|
||||
"Deals 3 damage to target. Target: nearest hero.") {
|
||||
}
|
||||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier, MonsterViewpoint monsterViewpoint) {
|
||||
BattleParticipant target = AIUtils.GetNearestHero(monsterViewpoint, this.owner);
|
||||
DealDamageEffect damageEffect = new DealDamageEffect(target, 3);
|
||||
effectApplier.Apply(damageEffect);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/CardsMonsters/GolemFistMCard.cs.meta
Normal file
11
Assets/Battle/CardsMonsters/GolemFistMCard.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f42a2de2b37632b489b9f6aebbf55b54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -5,12 +5,12 @@ using UnityEngine;
|
|||
public class VampireFangsMCard : MonsterCard
|
||||
{
|
||||
public VampireFangsMCard(BattleParticipant owner)
|
||||
: base(owner, MCardId.VampireFangs, "VampireFangs", 2, CardType.Attack,
|
||||
: base(owner, MCardId.VampireFangs, "Vampire Fangs", 2, CardType.Attack,
|
||||
"Steals 2 HP from target. Target: highest HP hero.") {
|
||||
}
|
||||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier, MonsterViewpoint monsterViewpoint) {
|
||||
BattleParticipant target = DetermineTarget(monsterViewpoint);
|
||||
BattleParticipant target = AIUtils.GetHeroWithHighestHP(monsterViewpoint);
|
||||
DealDamageEffect damageEffect = new DealDamageEffect(target, 2);
|
||||
effectApplier.Apply(damageEffect);
|
||||
if (damageEffect.AmountDealt > 0) {
|
||||
|
|
@ -19,21 +19,4 @@ public class VampireFangsMCard : MonsterCard
|
|||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
private BattleParticipant DetermineTarget(MonsterViewpoint monsterViewpoint) {
|
||||
return GetHeroWithHighestHP(monsterViewpoint);
|
||||
}
|
||||
|
||||
private BattleHero GetHeroWithHighestHP(MonsterViewpoint monsterViewpoint) {
|
||||
int highestHPHeroIndex = -1;
|
||||
int highestHP = -1;
|
||||
for (int i = 0; i < monsterViewpoint.Heroes.Length; i++) {
|
||||
int heroHP = monsterViewpoint.Heroes[i].GetHP();
|
||||
if (heroHP > highestHP) {
|
||||
highestHPHeroIndex = i;
|
||||
highestHP = heroHP;
|
||||
}
|
||||
}
|
||||
return monsterViewpoint.Heroes[highestHPHeroIndex];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue