Implement acquiring cards. Thunderstorm acquires Lightning Strikes.
This commit is contained in:
parent
60afd791dd
commit
1e8d3bb068
12 changed files with 121 additions and 5 deletions
|
|
@ -194,7 +194,24 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
|
||||
// IBattleEffectResolver
|
||||
public void IncreaseMaxEnergy(int delta) {
|
||||
public void IncreaseHeroMaxEnergy(int delta) {
|
||||
this.maxEnergy += delta;
|
||||
}
|
||||
|
||||
public void AcquireHeroCards(CardId[] cardIds, BattleZone zone, BattleHero owner) {
|
||||
foreach (CardId cardId in cardIds) {
|
||||
BaseCard acquiredCard = CardDatabase.CreateCard(cardId, owner);
|
||||
switch (zone) {
|
||||
case BattleZone.DrawPile:
|
||||
this.GetHeroDeck().PutCardOnTopOfDrawPile(acquiredCard);
|
||||
break;
|
||||
default:
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
if (zone == BattleZone.DrawPile) {
|
||||
this.GetHeroDeck().ShuffleDrawPile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
7
Assets/Battle/BattleZone.cs
Normal file
7
Assets/Battle/BattleZone.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
public enum BattleZone {
|
||||
DrawPile,
|
||||
Hand,
|
||||
DiscardPile,
|
||||
HeroPlayArea,
|
||||
MonsterPlayArea,
|
||||
}
|
||||
11
Assets/Battle/BattleZone.cs.meta
Normal file
11
Assets/Battle/BattleZone.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6713790a4eefea84183d074f59de689c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -5,6 +5,7 @@ using UnityEngine;
|
|||
public enum CardId {
|
||||
CrashingPunch,
|
||||
Cover,
|
||||
LightningStrike,
|
||||
Thunderstorm,
|
||||
}
|
||||
|
||||
|
|
@ -13,6 +14,7 @@ public class CardDatabase
|
|||
private static Dictionary<CardId, HeroId> CARD_TO_HERO = new Dictionary<CardId, HeroId>() {
|
||||
{CardId.CrashingPunch, HeroId.Brute},
|
||||
{CardId.Cover, HeroId.Brute},
|
||||
{CardId.LightningStrike, HeroId.Shaman},
|
||||
{CardId.Thunderstorm, HeroId.Shaman},
|
||||
};
|
||||
|
||||
|
|
@ -23,6 +25,8 @@ public class CardDatabase
|
|||
return new CardCrashingPunch(owner);
|
||||
case CardId.Cover:
|
||||
return new CardCover(owner);
|
||||
case CardId.LightningStrike:
|
||||
return new CardLightningStrike(owner);
|
||||
case CardId.Thunderstorm:
|
||||
return new CardThunderstorm(owner);
|
||||
default:
|
||||
|
|
|
|||
19
Assets/Battle/Cards/CardLightningStrike.cs
Normal file
19
Assets/Battle/Cards/CardLightningStrike.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CardLightningStrike : BaseCard
|
||||
{
|
||||
public CardLightningStrike(BattleParticipant owner)
|
||||
: base(owner, CardId.LightningStrike, "Lightning Strike", 2, CardType.Action,
|
||||
"Deals 3 damage to target.") {
|
||||
}
|
||||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier, BattlePlayerControls playerControls) {
|
||||
SingleTargeting singleTargeting = new SingleTargeting(new AnyTargetPolicy());
|
||||
yield return playerControls.StartCoroutine(playerControls.ChooseTarget(singleTargeting));
|
||||
BattleParticipant target = singleTargeting.GetTarget();
|
||||
Debug.Log("Striking " + target + " with lightning.");
|
||||
target.DealDamage(3);
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/Cards/CardLightningStrike.cs.meta
Normal file
11
Assets/Battle/Cards/CardLightningStrike.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 11d435c247746fa4b91e5808379f51f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -6,12 +6,13 @@ public class CardThunderstorm : BaseCard
|
|||
{
|
||||
public CardThunderstorm(BattleParticipant owner)
|
||||
: base(owner, CardId.Thunderstorm, "Thunderstorm", 3, CardType.Enchantment,
|
||||
"Adds 1 energy.") {
|
||||
"Add 1 max energy. Acquire 2 Lightning Strike into draw pile.") {
|
||||
}
|
||||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier, BattlePlayerControls playerControls) {
|
||||
Debug.Log("A storm is brewing.");
|
||||
effectApplier.Apply(new IncreaseMaxEnergyEffect(1));
|
||||
effectApplier.Apply(new AcquireCardsEffect(new CardId[] {CardId.LightningStrike, CardId.LightningStrike}, BattleZone.DrawPile, this.owner));
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
24
Assets/Battle/Effects/AcquireCardsEffect.cs
Normal file
24
Assets/Battle/Effects/AcquireCardsEffect.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AcquireCardsEffect : IBattleEffect
|
||||
{
|
||||
private CardId[] cardIds;
|
||||
private BattleZone zone;
|
||||
private BattleParticipant participant;
|
||||
|
||||
public AcquireCardsEffect(CardId[] cardIds, BattleZone zone, BattleParticipant participant) {
|
||||
this.cardIds = cardIds;
|
||||
this.zone = zone;
|
||||
this.participant = participant;
|
||||
}
|
||||
|
||||
public void Apply(IBattleEffectResolver resolver) {
|
||||
if (this.participant.IsHero()) {
|
||||
resolver.AcquireHeroCards(this.cardIds, this.zone, (BattleHero) this.participant);
|
||||
} else {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/Effects/AcquireCardsEffect.cs.meta
Normal file
11
Assets/Battle/Effects/AcquireCardsEffect.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5af4ea0aedc362d428d86ff87d50d648
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -10,7 +10,7 @@ public class IncreaseMaxEnergyEffect : IBattleEffect
|
|||
this.delta = delta;
|
||||
}
|
||||
|
||||
public void Apply(IBattleEffectResolver bc) {
|
||||
bc.IncreaseMaxEnergy(this.delta);
|
||||
public void Apply(IBattleEffectResolver resolver) {
|
||||
resolver.IncreaseHeroMaxEnergy(this.delta);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,16 @@ public class HeroDeck
|
|||
TriggerDiscardPileChanged();
|
||||
}
|
||||
|
||||
public void PutCardOnTopOfDrawPile(BaseCard card) {
|
||||
this.drawPile.Insert(0, card);
|
||||
TriggerDrawPileChanged();
|
||||
}
|
||||
|
||||
public void ShuffleDrawPile() {
|
||||
this.drawPile.Shuffle();
|
||||
TriggerDrawPileChanged();
|
||||
}
|
||||
|
||||
private void RemakeDrawPile() {
|
||||
this.drawPile.AddRange(this.discardPile);
|
||||
this.discardPile.Clear();
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
|
||||
public interface IBattleEffectResolver {
|
||||
void IncreaseMaxEnergy(int delta);
|
||||
void IncreaseHeroMaxEnergy(int delta);
|
||||
void AcquireHeroCards(CardId[] cardIds, BattleZone zone, BattleHero owner);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue