Implement OilOfSharpness
This commit is contained in:
parent
2190070fee
commit
31cb8fe4c0
45 changed files with 604 additions and 21 deletions
|
|
@ -33,6 +33,8 @@ public abstract class BaseCard
|
|||
return "Skill";
|
||||
case CardType.Enchantment:
|
||||
return "Enchantment";
|
||||
case CardType.Default:
|
||||
return "Default";
|
||||
default:
|
||||
throw new System.ArgumentException("CardType unknown", "cardType");
|
||||
}
|
||||
|
|
@ -40,7 +42,7 @@ public abstract class BaseCard
|
|||
public string GetEffectText() {return this.effectText;}
|
||||
|
||||
public bool IsPermanent() {
|
||||
return this.type == CardType.Enchantment;
|
||||
return this.type == CardType.Enchantment || this.type == CardType.Default;
|
||||
}
|
||||
|
||||
public bool IsEphemeral() {
|
||||
|
|
|
|||
29
Assets/Battle/BattleClock.cs
Normal file
29
Assets/Battle/BattleClock.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
public class BattleClock {
|
||||
public delegate void TimeChangedAction(BattleTime timeNow);
|
||||
public event TimeChangedAction OnTimeChanged;
|
||||
|
||||
private int mRoundNumber;
|
||||
private RoundStep mStep;
|
||||
|
||||
public BattleClock() {
|
||||
mRoundNumber = 0;
|
||||
mStep = RoundStep.None;
|
||||
}
|
||||
|
||||
public void AdvanceRound() {
|
||||
mRoundNumber++;
|
||||
mStep = RoundStep.StartOfRound;
|
||||
TriggerOnTimeChanged();
|
||||
}
|
||||
|
||||
public void AdvanceToStep(RoundStep step) {
|
||||
mStep = step;
|
||||
TriggerOnTimeChanged();
|
||||
}
|
||||
|
||||
private void TriggerOnTimeChanged() {
|
||||
if (OnTimeChanged != null) OnTimeChanged(this.Now);
|
||||
}
|
||||
|
||||
public BattleTime Now {get => new BattleTime(mRoundNumber, mStep);}
|
||||
}
|
||||
11
Assets/Battle/BattleClock.cs.meta
Normal file
11
Assets/Battle/BattleClock.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 22aaeef7020f83f47a03c0b2d8186afa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -34,6 +34,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
private HandPlayability<HeroCard> heroHandPlayability;
|
||||
private HandPlayability<MonsterCard> monsterHandPlayability;
|
||||
private TurnIntentions<MonsterCard> monsterIntentions;
|
||||
private BattleClock clock;
|
||||
private BuffManager buffManager;
|
||||
private ParticipantActivity participantActivity;
|
||||
|
||||
private delegate void BattleStateChangedAction();
|
||||
private event BattleStateChangedAction OnBattleStateChanged;
|
||||
|
|
@ -93,6 +96,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
this.monsterDeck = new BattleDeck<MonsterCard>(
|
||||
this.monsterCardDatabase, parameters.MCardIds.Cast<int>().ToArray(), mCardOwners);
|
||||
|
||||
this.clock = new BattleClock();
|
||||
this.buffManager = new BuffManager(this.clock);
|
||||
this.participantActivity = new ParticipantActivity();
|
||||
this.playArea = new PlayArea();
|
||||
|
||||
this.heroHandPlayability = new HandPlayability<HeroCard>(
|
||||
|
|
@ -151,6 +157,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
|
||||
private IEnumerator RunBattleRound() {
|
||||
this.clock.AdvanceRound();
|
||||
this.state.AdvanceToTeamTurn(TeamChoice.Heroes);
|
||||
|
||||
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
||||
|
|
@ -172,10 +179,14 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
this.state.AdvanceToTeamTurn(TeamChoice.Monsters);
|
||||
yield return RunMonsterTurn();
|
||||
|
||||
this.clock.AdvanceToStep(RoundStep.EndOfRound);
|
||||
this.participantActivity.NextRound();
|
||||
}
|
||||
|
||||
private IEnumerator RunHeroTurn() {
|
||||
// Start of hero turn
|
||||
this.clock.AdvanceToStep(RoundStep.StartOfHeroTurn);
|
||||
OnBattleStateChanged();
|
||||
this.monsterIntentions.ResumeIntentions();
|
||||
|
||||
|
|
@ -200,6 +211,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
|
||||
// End of hero turn
|
||||
yield return this.playArea.UseHeroDefaults(this.heroes, this.participantActivity, UseHeroDefault);
|
||||
if (STABLE_HAND_STYLE) {
|
||||
this.heroDeck.DiscardInExcessOf(3);
|
||||
} else {
|
||||
|
|
@ -208,11 +220,15 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
foreach (BattleHero hero in this.heroes) {
|
||||
hero.TickStatuses();
|
||||
}
|
||||
|
||||
this.clock.AdvanceToStep(RoundStep.EndOfHeroTurn);
|
||||
|
||||
OnBattleStateChanged();
|
||||
this.monsterIntentions.PauseIntentions();
|
||||
}
|
||||
|
||||
private IEnumerator RunMonsterTurn() {
|
||||
this.clock.AdvanceToStep(RoundStep.StartOfMonsterTurn);
|
||||
OnBattleStateChanged();
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
|
|
@ -253,6 +269,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
foreach (BattleMonster monster in this.monsters) {
|
||||
monster.TickStatuses();
|
||||
}
|
||||
|
||||
this.clock.AdvanceToStep(RoundStep.EndOfMonsterTurn);
|
||||
OnBattleStateChanged();
|
||||
}
|
||||
|
||||
|
|
@ -275,8 +293,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
this.heroEnergy.PayForCard(card);
|
||||
this.heroDeck.RemoveCardFromHand(card);
|
||||
this.participantActivity.NotifyParticipantUsedCard(card.Owner, card);
|
||||
yield return card.Use(this, this, battlePlayerControls);
|
||||
if (card.IsPermanent()) {
|
||||
if (card.Type == CardType.Default) {
|
||||
// Already added to playArea by effect
|
||||
} else if (card.IsPermanent()) {
|
||||
this.playArea.AddPlayedHeroPermanent(card);
|
||||
} else if (card.IsEphemeral()) {
|
||||
this.heroDeck.MoveCardToOblivion(card);
|
||||
|
|
@ -288,6 +309,17 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
OnBattleStateChanged();
|
||||
}
|
||||
|
||||
public IEnumerator UseHeroDefault(DefaultHeroCard card) {
|
||||
if (!card.Owner.CanUseDefault()) {
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return card.UseDefault(this, this, battlePlayerControls);
|
||||
|
||||
CheckState();
|
||||
OnBattleStateChanged();
|
||||
}
|
||||
|
||||
public IEnumerator UseMonsterCard(MonsterCard card) {
|
||||
this.monsterEnergy.PayForCard(card);
|
||||
this.monsterDeck.RemoveCardFromHand(card);
|
||||
|
|
@ -444,7 +476,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
public int DealDamage(DealDamageEffect effect) {
|
||||
if (effect.Target == null) return 0;
|
||||
|
||||
int damageDealt = effect.Target.DealDamage(effect.Amount);
|
||||
int amount = effect.Amount;
|
||||
if (effect.Source != null) {
|
||||
amount += this.buffManager.GetTotalBuffAmountOfType(effect.Source, BuffType.Power);
|
||||
}
|
||||
int damageDealt = effect.Target.DealDamage(amount);
|
||||
foreach (DamageTrigger dt in this.damageTriggers) {
|
||||
if (dt.IsTriggeredBy(effect)) {
|
||||
EnqueueActivatedTrigger(dt);
|
||||
|
|
@ -499,6 +535,10 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
effect.Target.AddStatus(effect.Status, effect.Amount);
|
||||
}
|
||||
|
||||
public void BuffParticipant(BuffParticipantEffect effect) {
|
||||
this.buffManager.AddBuff(effect, this.clock.Now);
|
||||
}
|
||||
|
||||
public void Rotate(RotateEffect effect) {
|
||||
if (effect.Positions == 0) return;
|
||||
|
||||
|
|
@ -554,6 +594,13 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
}
|
||||
|
||||
public void SetupDefault(DefaultEffect effect) {
|
||||
DefaultHeroCard previousDefault = this.playArea.SetupDefault(effect);
|
||||
if (previousDefault != null) {
|
||||
this.heroDeck.MoveCardToDiscard(previousDefault);
|
||||
}
|
||||
}
|
||||
|
||||
public void ArmDamageTrigger(DamageTrigger damageTrigger) {
|
||||
this.damageTriggers.Add(damageTrigger);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,6 +164,10 @@ public class BattleParticipant
|
|||
return IsAlive() && !HasStatus(BattleStatus.Stun);
|
||||
}
|
||||
|
||||
public bool CanUseDefault() {
|
||||
return IsAlive() && !HasStatus(BattleStatus.Stun);
|
||||
}
|
||||
|
||||
public bool HasStatus(BattleStatus status) {
|
||||
return this.statuses.ContainsKey(status);
|
||||
}
|
||||
|
|
|
|||
24
Assets/Battle/BattleTime.cs
Normal file
24
Assets/Battle/BattleTime.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
public enum RoundStep {
|
||||
None,
|
||||
StartOfRound,
|
||||
StartOfHeroTurn,
|
||||
EndOfHeroTurn,
|
||||
StartOfMonsterTurn,
|
||||
EndOfMonsterTurn,
|
||||
EndOfRound,
|
||||
}
|
||||
|
||||
public class BattleTime {
|
||||
private int mRoundNumber;
|
||||
private RoundStep mRoundStep;
|
||||
|
||||
public BattleTime(int roundNumber, RoundStep roundStep) {
|
||||
mRoundNumber = roundNumber;
|
||||
mRoundStep = roundStep;
|
||||
}
|
||||
|
||||
public int RoundNumber {get => mRoundNumber;}
|
||||
public RoundStep RoundStep {get => mRoundStep;}
|
||||
|
||||
public int Int {get => mRoundNumber * 100 + (int) mRoundStep;}
|
||||
}
|
||||
11
Assets/Battle/BattleTime.cs.meta
Normal file
11
Assets/Battle/BattleTime.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c9c620593374fcf4c985eaf5041b1eff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3
Assets/Battle/BuffDuration.cs
Normal file
3
Assets/Battle/BuffDuration.cs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
public enum BuffDuration {
|
||||
UntilEndOfNextHeroTurn,
|
||||
}
|
||||
11
Assets/Battle/BuffDuration.cs.meta
Normal file
11
Assets/Battle/BuffDuration.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0b7d7799a49ca114481b8b4e0d1d3879
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Assets/Battle/BuffManager.cs
Normal file
64
Assets/Battle/BuffManager.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class Buff {
|
||||
private BuffType mType;
|
||||
private int mAmount;
|
||||
private BattleTime mEnd;
|
||||
|
||||
public Buff(BuffType type, int amount, BattleTime end) {
|
||||
mType = type;
|
||||
mAmount = amount;
|
||||
mEnd = end;
|
||||
}
|
||||
|
||||
public BuffType Type {get => mType;}
|
||||
public int Amount {get => mAmount;}
|
||||
public BattleTime End {get => mEnd;}
|
||||
}
|
||||
|
||||
public class BuffManager {
|
||||
|
||||
private Dictionary<BattleParticipant, List<Buff>> mBuffs = new Dictionary<BattleParticipant, List<Buff>>();
|
||||
|
||||
public BuffManager(BattleClock clock) {
|
||||
clock.OnTimeChanged += NotifyBattleTime;
|
||||
}
|
||||
|
||||
public void AddBuff(BuffParticipantEffect effect, BattleTime timeNow) {
|
||||
List<Buff> current = GetAllBuffsFor(effect.Participant);
|
||||
current.Add(new Buff(effect.Type, effect.Amount, CalculateEnd(timeNow, effect.Duration)));
|
||||
mBuffs[effect.Participant] = current;
|
||||
}
|
||||
|
||||
public int GetTotalBuffAmountOfType(BattleParticipant participant, BuffType type) {
|
||||
int total = 0;
|
||||
foreach (Buff buff in GetAllBuffsFor(participant)) {
|
||||
if (buff.Type == type) {
|
||||
total += buff.Amount;
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public List<Buff> GetAllBuffsFor(BattleParticipant participant) {
|
||||
if (mBuffs.ContainsKey(participant)) {
|
||||
return mBuffs[participant];
|
||||
} else {
|
||||
return new List<Buff>();
|
||||
}
|
||||
}
|
||||
|
||||
private void NotifyBattleTime(BattleTime timeNow) {
|
||||
foreach (List<Buff> buffs in mBuffs.Values) {
|
||||
buffs.RemoveAll(buff => timeNow.Int >= buff.End.Int);
|
||||
}
|
||||
}
|
||||
|
||||
private static BattleTime CalculateEnd(BattleTime timeNow, BuffDuration duration) {
|
||||
if (duration == BuffDuration.UntilEndOfNextHeroTurn) {
|
||||
return new BattleTime(timeNow.RoundNumber + 1, RoundStep.EndOfHeroTurn);
|
||||
}
|
||||
throw new System.Exception();
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/BuffManager.cs.meta
Normal file
11
Assets/Battle/BuffManager.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ef089e4327ee000469448b5357efc161
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3
Assets/Battle/BuffType.cs
Normal file
3
Assets/Battle/BuffType.cs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
public enum BuffType {
|
||||
Power,
|
||||
}
|
||||
11
Assets/Battle/BuffType.cs.meta
Normal file
11
Assets/Battle/BuffType.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c870b0605da509b42b5fb4284f6e04f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -3,4 +3,5 @@ public enum CardType {
|
|||
Attack,
|
||||
Skill,
|
||||
Enchantment,
|
||||
Default,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class BlindFuryHCard : HeroCard
|
|||
public override IEnumerator Use(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls) {
|
||||
BattleParticipant target = AIUtils.GetNearestMonster(viewpoint, this.owner);
|
||||
effectApplier.Apply(new DealDamageEffect(target, 5));
|
||||
effectApplier.Apply(new DealDamageEffect(Owner, target, 5));
|
||||
effectApplier.Apply(new ModifyInsightEffect(-1));
|
||||
yield break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ public class CrashingPunchHCard : HeroCard
|
|||
SingleTargeting singleTargeting = new SingleTargeting(new AnyTargetPolicy());
|
||||
yield return playerControls.StartCoroutine(playerControls.ChooseTarget(singleTargeting));
|
||||
BattleParticipant target = singleTargeting.GetTarget();
|
||||
effectApplier.Apply(new DealDamageEffect(target, 3));
|
||||
effectApplier.Apply(new DealDamageEffect(Owner, target, 3));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class LeadShotHCard : HeroCard
|
|||
yield return playerControls.StartCoroutine(playerControls.ChooseTarget(singleTargeting));
|
||||
yield return new WaitForSeconds(0.4f);
|
||||
BattleParticipant target = singleTargeting.GetTarget();
|
||||
effectApplier.Apply(new DealDamageEffect(target, 2));
|
||||
effectApplier.Apply(new DealDamageEffect(Owner, target, 2));
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ public class LightningHatchetHCard : HeroCard
|
|||
SingleTargeting singleTargeting = new SingleTargeting(new AnyMonsterTargetPolicy());
|
||||
yield return playerControls.StartCoroutine(playerControls.ChooseTarget(singleTargeting));
|
||||
BattleParticipant target = singleTargeting.GetTarget();
|
||||
effectApplier.Apply(new DealDamageEffect(target, 2));
|
||||
effectApplier.Apply(new DealDamageEffect(Owner, target, 2));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ public class LightningStrikeHCard : HeroCard
|
|||
SingleTargeting singleTargeting = new SingleTargeting(new AnyTargetPolicy());
|
||||
yield return playerControls.StartCoroutine(playerControls.ChooseTarget(singleTargeting));
|
||||
BattleParticipant target = singleTargeting.GetTarget();
|
||||
effectApplier.Apply(new DealDamageEffect(target, 3));
|
||||
effectApplier.Apply(new DealDamageEffect(Owner, target, 3));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
26
Assets/Battle/CardsHeroes/OilOfSharpnessHCard.cs
Normal file
26
Assets/Battle/CardsHeroes/OilOfSharpnessHCard.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OilOfSharpnessHCard : DefaultHeroCard
|
||||
{
|
||||
public OilOfSharpnessHCard(BattleParticipant owner)
|
||||
: base(owner, HCardId.OilOfSharpness, "Oil of Sharpness", 1, CardType.Default,
|
||||
"Target hero gets +1 power until end of next turn.") {
|
||||
}
|
||||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls) {
|
||||
effectApplier.Apply(new DefaultEffect(this));
|
||||
yield break;
|
||||
}
|
||||
|
||||
public override IEnumerator UseDefault(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls) {
|
||||
SingleTargeting targeting = new SingleTargeting(new AnyHeroTargetPolicy());
|
||||
yield return playerControls.ChooseTarget(targeting);
|
||||
BattleParticipant target = targeting.GetTarget();
|
||||
effectApplier.Apply(new BuffParticipantEffect(target, BuffType.Power, 1, BuffDuration.UntilEndOfNextHeroTurn));
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/CardsHeroes/OilOfSharpnessHCard.cs.meta
Normal file
11
Assets/Battle/CardsHeroes/OilOfSharpnessHCard.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ac807b0678a548a46a0f67b2a4f43fed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -15,7 +15,7 @@ public class SwordSlashHCard : HeroCard
|
|||
yield return playerControls.StartCoroutine(playerControls.ChooseTarget(singleTargeting));
|
||||
yield return new WaitForSeconds(0.4f);
|
||||
BattleParticipant target = singleTargeting.GetTarget();
|
||||
effectApplier.Apply(new DealDamageEffect(target, 1));
|
||||
effectApplier.Apply(new DealDamageEffect(Owner, target, 1));
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ public class GolemBerserkMCard : MonsterCard
|
|||
public override IEnumerator Use(IBattleEffectApplier effectApplier, MonsterViewpoint monsterViewpoint) {
|
||||
BattleParticipant target = AIUtils.GetNearestHero(monsterViewpoint, this.owner);
|
||||
|
||||
effectApplier.Apply(new DealDamageEffect(target, 8));
|
||||
effectApplier.Apply(new DealDamageEffect(Owner, target, 8));
|
||||
yield return new WaitForSeconds(1f);
|
||||
foreach (BattleHero hero in monsterViewpoint.Heroes) {
|
||||
if (hero != target) {
|
||||
effectApplier.Apply(new DealDamageEffect(hero, 4));
|
||||
effectApplier.Apply(new DealDamageEffect(Owner, hero, 4));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class GolemChargeMCard : MonsterCard
|
|||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
BattleParticipant target = AIUtils.GetFarthestHero(monsterViewpoint, this.owner);
|
||||
DealDamageEffect damageEffect = new DealDamageEffect(target, 4);
|
||||
DealDamageEffect damageEffect = new DealDamageEffect(Owner, target, 4);
|
||||
effectApplier.Apply(damageEffect);
|
||||
StatusEffect statusEffect = new StatusEffect(target, BattleStatus.Stun);
|
||||
effectApplier.Apply(statusEffect);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class GolemFistMCard : MonsterCard
|
|||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier, MonsterViewpoint monsterViewpoint) {
|
||||
BattleParticipant target = AIUtils.GetNearestHero(monsterViewpoint, this.owner);
|
||||
DealDamageEffect damageEffect = new DealDamageEffect(target, 3);
|
||||
DealDamageEffect damageEffect = new DealDamageEffect(Owner, target, 3);
|
||||
effectApplier.Apply(damageEffect);
|
||||
yield break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class QuickSwiftDeathMCard : MonsterCard
|
|||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier, MonsterViewpoint monsterViewpoint) {
|
||||
BattleParticipant target = AIUtils.GetNearestHero(monsterViewpoint, this.owner);
|
||||
DealDamageEffect damageEffect = new DealDamageEffect(target, 100);
|
||||
DealDamageEffect damageEffect = new DealDamageEffect(Owner, target, 100);
|
||||
effectApplier.Apply(damageEffect);
|
||||
yield break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public class VampireFangsMCard : MonsterCard
|
|||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier, MonsterViewpoint monsterViewpoint) {
|
||||
BattleParticipant target = AIUtils.GetHeroWithHighestHP(monsterViewpoint);
|
||||
DealDamageEffect damageEffect = new DealDamageEffect(target, 2);
|
||||
DealDamageEffect damageEffect = new DealDamageEffect(Owner, target, 2);
|
||||
effectApplier.Apply(damageEffect);
|
||||
if (damageEffect.AmountDealt > 0) {
|
||||
HealEffect healEffect = new HealEffect(this.owner, damageEffect.AmountDealt);
|
||||
|
|
|
|||
|
|
@ -20,20 +20,24 @@ public class CheatBattle: MonoBehaviour
|
|||
HCardId.Eagerness,
|
||||
|
||||
HCardId.CrashingPunch,
|
||||
HCardId.LightningHatchet,
|
||||
HCardId.BlindFury,
|
||||
HCardId.Cover,
|
||||
HCardId.Cover,
|
||||
HCardId.Thunderstorm,
|
||||
HCardId.Scarring,
|
||||
HCardId.Scarring,
|
||||
HCardId.Meditate,
|
||||
|
||||
HCardId.OilOfSharpness,
|
||||
HCardId.IronskinDraught,
|
||||
|
||||
HCardId.LightningHatchet,
|
||||
HCardId.Thunderstorm,
|
||||
HCardId.Meditate,
|
||||
};
|
||||
|
||||
int[] hCardOwnerIndexes = new int[16] {
|
||||
0, 0, 1, 1, 2, 2,
|
||||
0, 2, 0, 0, 0, 2, 0, 0, 2, 1,
|
||||
0, 0, 0, 0, 0,
|
||||
1, 1,
|
||||
2, 2, 2,
|
||||
};
|
||||
|
||||
MonsterId[] monsterIds = new MonsterId[3] {
|
||||
|
|
|
|||
13
Assets/Battle/DefaultHeroCard.cs
Normal file
13
Assets/Battle/DefaultHeroCard.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class DefaultHeroCard: HeroCard
|
||||
{
|
||||
public DefaultHeroCard(BattleParticipant owner, HCardId id, string displayName, int cost, CardType type,
|
||||
string effectText)
|
||||
: base(owner, id, displayName, cost, type, effectText) {}
|
||||
|
||||
public abstract IEnumerator UseDefault(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls);
|
||||
}
|
||||
11
Assets/Battle/DefaultHeroCard.cs.meta
Normal file
11
Assets/Battle/DefaultHeroCard.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6d2e07039087c844c863e1b155f4d983
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
42
Assets/Battle/DefaultsManager.cs
Normal file
42
Assets/Battle/DefaultsManager.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DefaultsManager
|
||||
{
|
||||
public delegate IEnumerator UseDefaultAction(DefaultHeroCard card);
|
||||
|
||||
private Dictionary<BattleHero, DefaultHeroCard> mHeroDefaults = new Dictionary<BattleHero, DefaultHeroCard>();
|
||||
|
||||
public DefaultsManager() {
|
||||
}
|
||||
|
||||
public DefaultHeroCard Setup(DefaultEffect effect) {
|
||||
DefaultHeroCard newCard = effect.Card;
|
||||
DefaultHeroCard previousCard = null;
|
||||
BattleHero heroOwner = (BattleHero) newCard.Owner;
|
||||
mHeroDefaults.TryGetValue(heroOwner, out previousCard);
|
||||
|
||||
mHeroDefaults[heroOwner] = newCard;
|
||||
|
||||
return previousCard;
|
||||
}
|
||||
|
||||
public IEnumerator UseHeroDefaults(
|
||||
BattleHero[] heroes, ParticipantActivity activity,
|
||||
UseDefaultAction usedDefaultAction) {
|
||||
foreach (BattleHero hero in heroes) {
|
||||
if (hero == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (activity.GetNonEmotionCardsUsedThisRound(hero) == 0) {
|
||||
DefaultHeroCard defaultCard;
|
||||
mHeroDefaults.TryGetValue(hero, out defaultCard);
|
||||
if (defaultCard != null) {
|
||||
yield return usedDefaultAction(defaultCard);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/DefaultsManager.cs.meta
Normal file
11
Assets/Battle/DefaultsManager.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9517ccf8137932d458bdd10b84540001
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Assets/Battle/Effects/BuffParticipantEffect.cs
Normal file
27
Assets/Battle/Effects/BuffParticipantEffect.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BuffParticipantEffect : IBattleEffect
|
||||
{
|
||||
private BattleParticipant mParticipant;
|
||||
private BuffType mType;
|
||||
private BuffDuration mDuration;
|
||||
private int mAmount;
|
||||
|
||||
public BuffParticipantEffect(BattleParticipant participant, BuffType type, int amount, BuffDuration duration) {
|
||||
mParticipant = participant;
|
||||
mType = type;
|
||||
mAmount = amount;
|
||||
mDuration = duration;
|
||||
}
|
||||
|
||||
public void Apply(IBattleEffectResolver resolver) {
|
||||
resolver.BuffParticipant(this);
|
||||
}
|
||||
|
||||
public BattleParticipant Participant {get => mParticipant;}
|
||||
public BuffType Type {get => mType;}
|
||||
public BuffDuration Duration {get => mDuration;}
|
||||
public int Amount {get => mAmount;}
|
||||
}
|
||||
11
Assets/Battle/Effects/BuffParticipantEffect.cs.meta
Normal file
11
Assets/Battle/Effects/BuffParticipantEffect.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 203a8da7e3f13cf478d850b47c3f762e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -4,11 +4,13 @@ using UnityEngine;
|
|||
|
||||
public class DealDamageEffect : IBattleEffect
|
||||
{
|
||||
private BattleParticipant source;
|
||||
private BattleParticipant target;
|
||||
private int amount;
|
||||
private int amountDealt;
|
||||
|
||||
public DealDamageEffect(BattleParticipant target, int amount) {
|
||||
public DealDamageEffect(BattleParticipant source, BattleParticipant target, int amount) {
|
||||
this.source = source;
|
||||
this.target = target;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
|
@ -17,6 +19,7 @@ public class DealDamageEffect : IBattleEffect
|
|||
this.amountDealt = resolver.DealDamage(this);
|
||||
}
|
||||
|
||||
public BattleParticipant Source {get => this.source;}
|
||||
public BattleParticipant Target {get => this.target;}
|
||||
public int Amount {get => this.amount;}
|
||||
public int AmountDealt {get => this.amountDealt;}
|
||||
|
|
|
|||
19
Assets/Battle/Effects/DefaultEffect.cs
Normal file
19
Assets/Battle/Effects/DefaultEffect.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class DefaultEffect : IBattleEffect
|
||||
{
|
||||
private DefaultHeroCard mCard;
|
||||
|
||||
public DefaultEffect(DefaultHeroCard card) {
|
||||
mCard = card;
|
||||
}
|
||||
|
||||
public void Apply(IBattleEffectResolver resolver) {
|
||||
resolver.SetupDefault(this);
|
||||
}
|
||||
|
||||
public DefaultHeroCard Card {get => mCard;}
|
||||
}
|
||||
11
Assets/Battle/Effects/DefaultEffect.cs.meta
Normal file
11
Assets/Battle/Effects/DefaultEffect.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c713bb4a53fb33249a23147f4f67114c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -24,6 +24,7 @@ public enum HCardId {
|
|||
LeadShot,
|
||||
SmokeBomb,
|
||||
Eagerness,
|
||||
OilOfSharpness,
|
||||
}
|
||||
|
||||
public class HeroCardDatabase : CardDatabase<HeroCard>
|
||||
|
|
@ -60,6 +61,8 @@ public class HeroCardDatabase : CardDatabase<HeroCard>
|
|||
return new SmokeBombHCard(owner);
|
||||
case HCardId.Eagerness:
|
||||
return new EagernessHCard(owner);
|
||||
case HCardId.OilOfSharpness:
|
||||
return new OilOfSharpnessHCard(owner);
|
||||
default:
|
||||
throw new System.ArgumentException("HCardId unknown", "id");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,11 @@ public interface IBattleEffectResolver {
|
|||
void IncreaseHeroMaxEnergy(IncreaseMaxEnergyEffect delta);
|
||||
void IncreaseMaxHP(IncreaseMaxHPEffect effect);
|
||||
void ModifyInsight(ModifyInsightEffect effect);
|
||||
void BuffParticipant(BuffParticipantEffect effect);
|
||||
void DrawCards(DrawCardsEffect effect);
|
||||
void AcquireCards(AcquireCardsEffect effect);
|
||||
void Rotate(RotateEffect effect);
|
||||
void SetupDefault(DefaultEffect effect);
|
||||
|
||||
void ArmDamageTrigger(DamageTrigger damageTrigger);
|
||||
}
|
||||
|
|
|
|||
30
Assets/Battle/ParticipantActivity.cs
Normal file
30
Assets/Battle/ParticipantActivity.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class ParticipantActivity {
|
||||
|
||||
private Dictionary<BattleParticipant, List<BaseCard>> mCardsUsedThisRound = new Dictionary<BattleParticipant, List<BaseCard>>();
|
||||
|
||||
public ParticipantActivity() {
|
||||
}
|
||||
|
||||
public void NotifyParticipantUsedCard(BattleParticipant participant, BaseCard card) {
|
||||
if (mCardsUsedThisRound.ContainsKey(participant)) {
|
||||
mCardsUsedThisRound[participant].Add(card);
|
||||
} else {
|
||||
mCardsUsedThisRound[participant] = new List<BaseCard>() {card};
|
||||
}
|
||||
}
|
||||
|
||||
public int GetNonEmotionCardsUsedThisRound(BattleParticipant participant) {
|
||||
if (mCardsUsedThisRound.ContainsKey(participant)) {
|
||||
return mCardsUsedThisRound[participant].Count(card => card.Type != CardType.Emotion);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void NextRound() {
|
||||
mCardsUsedThisRound.Clear();
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/ParticipantActivity.cs.meta
Normal file
11
Assets/Battle/ParticipantActivity.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: abe2bbff2aef9fc4388e4aad5eb0b1f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -10,10 +10,12 @@ public class PlayArea
|
|||
|
||||
private List<BaseCard> heroPermanents;
|
||||
private List<BaseCard> monsterPermanents;
|
||||
private DefaultsManager mDefaultsManager;
|
||||
|
||||
public PlayArea() {
|
||||
this.heroPermanents = new List<BaseCard>();
|
||||
this.monsterPermanents = new List<BaseCard>();
|
||||
mDefaultsManager = new DefaultsManager();
|
||||
}
|
||||
|
||||
public List<BaseCard> GetHeroPermanents() {
|
||||
|
|
@ -40,6 +42,24 @@ public class PlayArea
|
|||
TriggerPlayAreaChanged();
|
||||
}
|
||||
|
||||
public DefaultHeroCard SetupDefault(DefaultEffect effect) {
|
||||
DefaultHeroCard previousDefault = mDefaultsManager.Setup(effect);
|
||||
if (previousDefault != null) {
|
||||
RemoveHeroPermanent(previousDefault);
|
||||
}
|
||||
|
||||
AddPlayedHeroPermanent(effect.Card);
|
||||
|
||||
TriggerPlayAreaChanged();
|
||||
return previousDefault;
|
||||
}
|
||||
|
||||
public IEnumerator UseHeroDefaults(
|
||||
BattleHero[] heroes, ParticipantActivity activity,
|
||||
DefaultsManager.UseDefaultAction useDefaultAction) {
|
||||
yield return mDefaultsManager.UseHeroDefaults(heroes, activity, useDefaultAction);
|
||||
}
|
||||
|
||||
private void TriggerPlayAreaChanged() {
|
||||
if (OnPlayAreaChanged != null) OnPlayAreaChanged();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue