Add guards and implement basic cards
This commit is contained in:
parent
30beb96397
commit
08c395cf51
32 changed files with 803 additions and 24 deletions
|
|
@ -41,24 +41,43 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
void Awake() {
|
||||
HeroId[] heroIds = new HeroId[3] {
|
||||
HeroId.Brute,
|
||||
HeroId.Alchemist,
|
||||
HeroId.Shaman,
|
||||
HeroId.NPCGuard,
|
||||
HeroId.NPCGuard,
|
||||
};
|
||||
|
||||
HCardId[] cardIds = new HCardId[10] {
|
||||
HCardId.CrashingPunch,
|
||||
HCardId.LightningHatchet,
|
||||
HCardId.BlindFury,
|
||||
HCardId.Cover,
|
||||
HCardId.Cover,
|
||||
HCardId.Thunderstorm,
|
||||
HCardId.Scarring,
|
||||
HCardId.Scarring,
|
||||
HCardId.Meditate,
|
||||
HCardId.IronskinDraught,
|
||||
HCardId.LeadShot,
|
||||
HCardId.LeadShot,
|
||||
HCardId.SmokeBomb,
|
||||
HCardId.SwordSlash,
|
||||
HCardId.SwordSlash,
|
||||
HCardId.SwordSlash,
|
||||
HCardId.ShieldBlock,
|
||||
HCardId.SwordSlash,
|
||||
HCardId.ShieldBlock,
|
||||
};
|
||||
|
||||
// HeroId[] heroIds = new HeroId[3] {
|
||||
// HeroId.Brute,
|
||||
// HeroId.Alchemist,
|
||||
// HeroId.Shaman,
|
||||
// };
|
||||
|
||||
// HCardId[] cardIds = new HCardId[10] {
|
||||
// HCardId.CrashingPunch,
|
||||
// HCardId.LightningHatchet,
|
||||
// HCardId.BlindFury,
|
||||
// HCardId.Cover,
|
||||
// HCardId.Cover,
|
||||
// HCardId.Thunderstorm,
|
||||
// HCardId.Scarring,
|
||||
// HCardId.Scarring,
|
||||
// HCardId.Meditate,
|
||||
// HCardId.IronskinDraught,
|
||||
// };
|
||||
|
||||
MonsterId[] monsterIds = new MonsterId[3] {
|
||||
MonsterId.Golem,
|
||||
MonsterId.Bat,
|
||||
|
|
@ -309,8 +328,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
public IEnumerator UseHeroCard(HeroCard card) {
|
||||
this.heroEnergy.PayForCard(card);
|
||||
yield return card.Use(this, this, battlePlayerControls);
|
||||
this.heroDeck.RemoveCardFromHand(card);
|
||||
yield return card.Use(this, this, battlePlayerControls);
|
||||
if (card.IsPermanent()) {
|
||||
this.playArea.AddPlayedHeroPermanent(card);
|
||||
} else {
|
||||
|
|
@ -324,8 +343,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
public IEnumerator UseMonsterCard(MonsterCard card) {
|
||||
this.monsterEnergy.PayForCard(card);
|
||||
yield return card.Use(this, this);
|
||||
this.monsterDeck.RemoveCardFromHand(card);
|
||||
yield return card.Use(this, this);
|
||||
if (card.IsPermanent()) {
|
||||
this.playArea.AddPlayedMonsterPermanent(card);
|
||||
} else {
|
||||
|
|
@ -510,6 +529,13 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
effect.Target.AddBlock(effect.Amount);
|
||||
}
|
||||
|
||||
public void AddMassBlock(MassBlockEffect effect) {
|
||||
BattleParticipant[] affectedTeam = GetTeam(effect.Team);
|
||||
foreach (BattleParticipant bp in affectedTeam) {
|
||||
bp.AddBlock(effect.Amount);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddStatus(StatusEffect effect) {
|
||||
if (effect.Target == null) return;
|
||||
effect.Target.AddStatus(effect.Status, effect.Amount);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ public class BattleHero: BattleParticipant
|
|||
this.displayName = "Slug";
|
||||
this.maxHP = 10;
|
||||
break;
|
||||
case HeroId.NPCGuard:
|
||||
this.displayName = "Guard";
|
||||
this.maxHP = 8;
|
||||
break;
|
||||
default:
|
||||
throw new System.ArgumentException("HeroId unknown", "id");
|
||||
}
|
||||
|
|
|
|||
21
Assets/Battle/CardsHeroes/LeadShotHCard.cs
Normal file
21
Assets/Battle/CardsHeroes/LeadShotHCard.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LeadShotHCard : HeroCard
|
||||
{
|
||||
public LeadShotHCard(BattleParticipant owner)
|
||||
: base(owner, HCardId.LeadShot, "Lead Shot", 1, CardType.Attack,
|
||||
"Deals 2 damage to another target.") {
|
||||
}
|
||||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls) {
|
||||
SingleTargeting singleTargeting = new SingleTargeting(new OtherTargetPolicy(this.owner));
|
||||
yield return playerControls.StartCoroutine(playerControls.ChooseTarget(singleTargeting));
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
BattleParticipant target = singleTargeting.GetTarget();
|
||||
effectApplier.Apply(new DealDamageEffect(target, 2));
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/CardsHeroes/LeadShotHCard.cs.meta
Normal file
11
Assets/Battle/CardsHeroes/LeadShotHCard.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: db51b7fb04f794544b0cacc7555e0cce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/Battle/CardsHeroes/ShieldBlockHCard.cs
Normal file
22
Assets/Battle/CardsHeroes/ShieldBlockHCard.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ShieldBlockHCard : HeroCard
|
||||
{
|
||||
public ShieldBlockHCard(BattleParticipant owner)
|
||||
: base(owner, HCardId.ShieldBlock, "Shield Block", 1, CardType.Skill,
|
||||
"Block 2 damage on target ally.") {
|
||||
|
||||
}
|
||||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls) {
|
||||
SingleTargeting singleTargeting = new SingleTargeting(new AnyHeroTargetPolicy());
|
||||
yield return playerControls.StartCoroutine(playerControls.ChooseTarget(singleTargeting));
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
BattleParticipant target = singleTargeting.GetTarget();
|
||||
effectApplier.Apply(new BlockEffect(target, 2));
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/CardsHeroes/ShieldBlockHCard.cs.meta
Normal file
11
Assets/Battle/CardsHeroes/ShieldBlockHCard.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 79bfe10b9f0ac8d43b7c18cdc2896890
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Battle/CardsHeroes/SmokeBombHCard.cs
Normal file
19
Assets/Battle/CardsHeroes/SmokeBombHCard.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SmokeBombHCard : HeroCard
|
||||
{
|
||||
public SmokeBombHCard(BattleParticipant owner)
|
||||
: base(owner, HCardId.SmokeBomb, "Smoke Bomb", 2, CardType.Skill,
|
||||
"Blocks 2 damage on all allies.") {
|
||||
|
||||
}
|
||||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls) {
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
effectApplier.Apply(new MassBlockEffect(TeamChoice.Heroes, 2));
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/CardsHeroes/SmokeBombHCard.cs.meta
Normal file
11
Assets/Battle/CardsHeroes/SmokeBombHCard.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3bc5acd796238f146b9f9b0dc483fb85
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/Battle/CardsHeroes/SwordSlashHCard.cs
Normal file
21
Assets/Battle/CardsHeroes/SwordSlashHCard.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SwordSlashHCard : HeroCard
|
||||
{
|
||||
public SwordSlashHCard(BattleParticipant owner)
|
||||
: base(owner, HCardId.SwordSlash, "Sword Slash", 1, CardType.Attack,
|
||||
"Deals 1 damage to target.") {
|
||||
}
|
||||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls) {
|
||||
SingleTargeting singleTargeting = new SingleTargeting(new AnyTargetPolicy());
|
||||
yield return playerControls.StartCoroutine(playerControls.ChooseTarget(singleTargeting));
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
BattleParticipant target = singleTargeting.GetTarget();
|
||||
effectApplier.Apply(new DealDamageEffect(target, 1));
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/CardsHeroes/SwordSlashHCard.cs.meta
Normal file
11
Assets/Battle/CardsHeroes/SwordSlashHCard.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 463c0326672540c4082132cd46e9a6c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/Battle/Effects/MassBlockEffect.cs
Normal file
21
Assets/Battle/Effects/MassBlockEffect.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MassBlockEffect : IBattleEffect
|
||||
{
|
||||
private TeamChoice team;
|
||||
private int amount;
|
||||
|
||||
public MassBlockEffect(TeamChoice team, int amount) {
|
||||
this.team = team;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public void Apply(IBattleEffectResolver resolver) {
|
||||
resolver.AddMassBlock(this);
|
||||
}
|
||||
|
||||
public TeamChoice Team {get => this.team;}
|
||||
public int Amount {get => this.amount;}
|
||||
}
|
||||
11
Assets/Battle/Effects/MassBlockEffect.cs.meta
Normal file
11
Assets/Battle/Effects/MassBlockEffect.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a0c3290b12974bc4682c5abbcd529884
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -19,6 +19,10 @@ public enum HCardId {
|
|||
Fracking,
|
||||
CanisterBomb,
|
||||
IronskinDraught,
|
||||
SwordSlash,
|
||||
ShieldBlock,
|
||||
LeadShot,
|
||||
SmokeBomb,
|
||||
}
|
||||
|
||||
public class HeroCardDatabase : CardDatabase<HeroCard>
|
||||
|
|
@ -33,6 +37,10 @@ public class HeroCardDatabase : CardDatabase<HeroCard>
|
|||
{HCardId.Meditate, HeroId.Shaman},
|
||||
{HCardId.LightningHatchet, HeroId.Shaman},
|
||||
{HCardId.IronskinDraught, HeroId.Alchemist},
|
||||
{HCardId.SwordSlash, HeroId.NPCGuard},
|
||||
{HCardId.ShieldBlock, HeroId.NPCGuard},
|
||||
{HCardId.LeadShot, HeroId.Alchemist},
|
||||
{HCardId.SmokeBomb, HeroId.Alchemist},
|
||||
};
|
||||
|
||||
public override HeroCard CreateCard(int id, BattleParticipant owner) {
|
||||
|
|
@ -57,6 +65,14 @@ public class HeroCardDatabase : CardDatabase<HeroCard>
|
|||
return new LightningHatchetHCard(owner);
|
||||
case HCardId.IronskinDraught:
|
||||
return new IronskinDraughtHCard(owner);
|
||||
case HCardId.SwordSlash:
|
||||
return new SwordSlashHCard(owner);
|
||||
case HCardId.ShieldBlock:
|
||||
return new ShieldBlockHCard(owner);
|
||||
case HCardId.LeadShot:
|
||||
return new LeadShotHCard(owner);
|
||||
case HCardId.SmokeBomb:
|
||||
return new SmokeBombHCard(owner);
|
||||
default:
|
||||
throw new System.ArgumentException("HCardId unknown", "id");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,18 +6,14 @@ public enum HeroId {
|
|||
Alchemist,
|
||||
Brute,
|
||||
Shaman,
|
||||
NPCGuard,
|
||||
}
|
||||
|
||||
public class HeroDatabase
|
||||
{
|
||||
private static Dictionary<HeroId, string> SPRITE_NAMES = new Dictionary<HeroId, string> {
|
||||
{HeroId.Alchemist, "AlchemistSprite"},
|
||||
{HeroId.Brute, "BruteSprite"},
|
||||
{HeroId.Shaman, "ShamanSprite"},
|
||||
};
|
||||
|
||||
public static GameObject createHeroSprite(HeroId id) {
|
||||
GameObject spritePrefab = (GameObject) Resources.Load<GameObject>("HeroImages/" + SPRITE_NAMES[id]);
|
||||
GameObject spritePrefab = (GameObject) Resources.Load<GameObject>(
|
||||
"HeroImages/" + id.ToString() + "Sprite");
|
||||
if (spritePrefab == null) {
|
||||
throw new System.ArgumentException("No sprite for HeroId", "id");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ public interface IBattleEffectResolver {
|
|||
int DealMassDamage(MassDamageEffect effect);
|
||||
int Heal(HealEffect effect);
|
||||
void AddBlock(BlockEffect effect);
|
||||
void AddMassBlock(MassBlockEffect effect);
|
||||
void AddStatus(StatusEffect effect);
|
||||
void IncreaseHeroMaxEnergy(IncreaseMaxEnergyEffect delta);
|
||||
void IncreaseMaxHP(IncreaseMaxHPEffect effect);
|
||||
|
|
|
|||
16
Assets/Battle/Targeting/OtherTargetPolicy.cs
Normal file
16
Assets/Battle/Targeting/OtherTargetPolicy.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OtherTargetPolicy: TargetingPolicy
|
||||
{
|
||||
private BattleParticipant owner;
|
||||
|
||||
public OtherTargetPolicy(BattleParticipant owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public override bool CanTarget(BattleParticipant participant) {
|
||||
return participant != this.owner;
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/Targeting/OtherTargetPolicy.cs.meta
Normal file
11
Assets/Battle/Targeting/OtherTargetPolicy.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0c10bedfc510bfd4e8c787ae72424144
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue