Implement Molotov Cocktail
This commit is contained in:
parent
938a56231a
commit
a37adf2972
17 changed files with 255 additions and 20 deletions
|
|
@ -97,6 +97,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier
|
|||
|
||||
private IEnumerator RunBattleRound() {
|
||||
this.state.Clock.AdvanceRound();
|
||||
yield return this.RunActivatedTriggers();
|
||||
|
||||
this.state.HeroEnergy.Replenish();
|
||||
this.state.MonsterEnergy.Replenish();
|
||||
|
|
@ -116,6 +117,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier
|
|||
yield return RunMonsterTurn();
|
||||
|
||||
this.state.Clock.AdvanceToStep(RoundStep.EndOfRound);
|
||||
yield return this.RunActivatedTriggers();
|
||||
}
|
||||
|
||||
private IEnumerator RunHeroTurn() {
|
||||
|
|
@ -129,6 +131,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier
|
|||
hero.ResetBlock();
|
||||
}
|
||||
OnBattleStateChanged();
|
||||
yield return this.RunActivatedTriggers();
|
||||
|
||||
// Heroes act until they pass
|
||||
while (true) {
|
||||
|
|
@ -142,7 +145,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier
|
|||
|
||||
// TODO: Implement a stack/queue to resolve triggers in order.
|
||||
// Do this after the card resolution is over to avoid reentraint effects.
|
||||
this.state.TriggerManager.RunActivatedTriggers(this);
|
||||
yield return this.RunActivatedTriggers();
|
||||
CheckState();
|
||||
OnBattleStateChanged();
|
||||
}
|
||||
|
|
@ -155,7 +158,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier
|
|||
yield return this.state.PlayArea.UseHeroDefaults(this.state.Heroes, this.state.ParticipantActivity, UseHeroDefault);
|
||||
// TODO: Implement a stack/queue to resolve triggers in order.
|
||||
// Do this after the card resolution is over to avoid reentraint effects.
|
||||
this.state.TriggerManager.RunActivatedTriggers(this);
|
||||
yield return this.RunActivatedTriggers();
|
||||
CheckState();
|
||||
OnBattleStateChanged();
|
||||
|
||||
|
|
@ -169,6 +172,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier
|
|||
}
|
||||
|
||||
this.state.Clock.AdvanceToStep(RoundStep.EndOfHeroTurn);
|
||||
yield return this.RunActivatedTriggers();
|
||||
|
||||
OnBattleStateChanged();
|
||||
this.monsterIntentions.PauseIntentions();
|
||||
|
|
@ -184,6 +188,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier
|
|||
monster.ResetBlock();
|
||||
}
|
||||
OnBattleStateChanged();
|
||||
yield return this.RunActivatedTriggers();
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
// Monsters play an emotion
|
||||
|
|
@ -195,7 +200,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier
|
|||
|
||||
// TODO: Implement a stack/queue to resolve triggers in order.
|
||||
// Do this after the card resolution is over to avoid reentraint effects.
|
||||
this.state.TriggerManager.RunActivatedTriggers(this);
|
||||
yield return this.RunActivatedTriggers();
|
||||
CheckState();
|
||||
OnBattleStateChanged();
|
||||
}
|
||||
|
|
@ -213,7 +218,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier
|
|||
|
||||
// TODO: Implement a stack/queue to resolve triggers in order.
|
||||
// Do this after the card resolution is over to avoid reentraint effects.
|
||||
this.state.TriggerManager.RunActivatedTriggers(this);
|
||||
yield return this.RunActivatedTriggers();
|
||||
CheckState();
|
||||
OnBattleStateChanged();
|
||||
}
|
||||
|
|
@ -231,6 +236,12 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier
|
|||
|
||||
this.state.Clock.AdvanceToStep(RoundStep.EndOfMonsterTurn);
|
||||
OnBattleStateChanged();
|
||||
yield return this.RunActivatedTriggers();
|
||||
}
|
||||
|
||||
private IEnumerator RunActivatedTriggers() {
|
||||
yield return this.state.TriggerManager.RunActivatedTriggers(
|
||||
this, this.state, this.battlePlayerControls);
|
||||
}
|
||||
|
||||
private MonsterCard FirstMonsterActionToPlay() {
|
||||
|
|
|
|||
30
Assets/Battle/CardsHeroes/MolotovCocktailHCard.cs
Normal file
30
Assets/Battle/CardsHeroes/MolotovCocktailHCard.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MolotovCocktailHCard : HeroCard
|
||||
{
|
||||
public MolotovCocktailHCard(BattleParticipant owner)
|
||||
: base(owner, HCardId.MolotovCocktail, "Molotov Cocktail", 3, CardType.Enchantment,
|
||||
"At start of hero turn, deal 1 damage to all enemies.") {
|
||||
}
|
||||
|
||||
public override IEnumerator Use(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls) {
|
||||
StepTrigger trigger = new StepTrigger(
|
||||
RoundStep.StartOfHeroTurn,
|
||||
this.AtStartOfHeroTurn,
|
||||
TriggerExpiration.Never,
|
||||
TriggerRepetition.Multiple);
|
||||
effectApplier.Apply(new ArmStepTriggerEffect(trigger));
|
||||
yield break;
|
||||
}
|
||||
|
||||
private IEnumerator AtStartOfHeroTurn(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls) {
|
||||
yield return new WaitForSeconds(0.3f);
|
||||
MassDamageEffect damageEffect = new MassDamageEffect(TeamChoice.Monsters, 1);
|
||||
effectApplier.Apply(damageEffect);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/CardsHeroes/MolotovCocktailHCard.cs.meta
Normal file
11
Assets/Battle/CardsHeroes/MolotovCocktailHCard.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e7662730dc6ed8643813c916a0f0372f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -14,15 +14,18 @@ public class ScarringHCard : HeroCard
|
|||
effectApplier.Apply(new BlockEffect(this.owner, 4));
|
||||
DamageTrigger trigger = new DamageTrigger(
|
||||
new List<BattleParticipant>() {this.owner},
|
||||
this.NotifyDamageDealt,
|
||||
this.WhenDamageDealt,
|
||||
TriggerExpiration.StartOfNextHeroTurn,
|
||||
TriggerRepetition.Once);
|
||||
effectApplier.Apply(new ArmDamageTriggerEffect(trigger));
|
||||
yield break;
|
||||
}
|
||||
|
||||
public void NotifyDamageDealt(IBattleEffectApplier effectApplier) {
|
||||
public IEnumerator WhenDamageDealt(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint, BattlePlayerControls playerControls) {
|
||||
yield return new WaitForSeconds(0.3f);
|
||||
IncreaseMaxHPEffect effect = new IncreaseMaxHPEffect(this.owner, 1);
|
||||
effectApplier.Apply(effect);
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ public class CheatBattle: MonoBehaviour
|
|||
HCardId.CrashingPunch,
|
||||
HCardId.BlindFury,
|
||||
HCardId.Cover,
|
||||
HCardId.Cover,
|
||||
HCardId.Scarring,
|
||||
|
||||
HCardId.OilOfSharpness,
|
||||
HCardId.IronskinDraught,
|
||||
HCardId.MolotovCocktail,
|
||||
|
||||
HCardId.LightningHatchet,
|
||||
HCardId.Thunderstorm,
|
||||
|
|
@ -35,8 +35,8 @@ public class CheatBattle: MonoBehaviour
|
|||
|
||||
int[] hCardOwnerIndexes = new int[16] {
|
||||
0, 0, 1, 1, 2, 2,
|
||||
0, 0, 0, 0, 0,
|
||||
1, 1,
|
||||
0, 0, 0, 0,
|
||||
1, 1, 1,
|
||||
2, 2, 2,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,11 @@ public class EffectResolver : IBattleEffectResolver
|
|||
}
|
||||
}
|
||||
|
||||
public void ArmDamageTrigger(DamageTrigger damageTrigger) {
|
||||
this.state.TriggerManager.ArmDamageTrigger(damageTrigger);
|
||||
public void ArmDamageTrigger(DamageTrigger trigger) {
|
||||
this.state.TriggerManager.ArmDamageTrigger(trigger);
|
||||
}
|
||||
|
||||
public void ArmStepTrigger(StepTrigger trigger) {
|
||||
this.state.TriggerManager.ArmStepTrigger(trigger);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16
Assets/Battle/Effects/ArmStepTriggerEffect.cs
Normal file
16
Assets/Battle/Effects/ArmStepTriggerEffect.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ArmStepTriggerEffect : IBattleEffect
|
||||
{
|
||||
private StepTrigger trigger;
|
||||
|
||||
public ArmStepTriggerEffect(StepTrigger trigger) {
|
||||
this.trigger = trigger;
|
||||
}
|
||||
|
||||
public void Apply(IBattleEffectResolver resolver) {
|
||||
resolver.ArmStepTrigger(this.trigger);
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/Effects/ArmStepTriggerEffect.cs.meta
Normal file
11
Assets/Battle/Effects/ArmStepTriggerEffect.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b25e3128bcc255146b46c32c41bd7a2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -48,6 +48,8 @@ public class HeroCardDatabase : CardDatabase<HeroCard>
|
|||
return typeof(MeditateHCard);
|
||||
case HCardId.LightningHatchet:
|
||||
return typeof(LightningHatchetHCard);
|
||||
case HCardId.MolotovCocktail:
|
||||
return typeof(MolotovCocktailHCard);
|
||||
case HCardId.IronskinDraught:
|
||||
return typeof(IronskinDraughtHCard);
|
||||
case HCardId.SwordSlash:
|
||||
|
|
|
|||
|
|
@ -19,5 +19,6 @@ public interface IBattleEffectResolver {
|
|||
void Rotate(RotateEffect effect);
|
||||
void SetupDefault(DefaultEffect effect);
|
||||
|
||||
void ArmDamageTrigger(DamageTrigger damageTrigger);
|
||||
void ArmDamageTrigger(DamageTrigger trigger);
|
||||
void ArmStepTrigger(StepTrigger trigger);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using System.Collections;
|
||||
|
||||
public enum TriggerExpiration {
|
||||
Never,
|
||||
StartOfNextHeroTurn,
|
||||
|
|
@ -22,9 +24,15 @@ public class Trigger {
|
|||
this.repetition = repetition;
|
||||
}
|
||||
|
||||
public void Run(IBattleEffectApplier effectApplier) {
|
||||
if (this.expired) return;
|
||||
callback(effectApplier);
|
||||
public IEnumerator Run(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint,
|
||||
BattlePlayerControls playerControls) {
|
||||
if (this.expired) {
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return callback(effectApplier, viewpoint, playerControls);
|
||||
|
||||
if (this.repetition == TriggerRepetition.Once) {
|
||||
this.expired = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ public class TriggerManager
|
|||
{
|
||||
private List<Trigger> activatedTriggers = new List<Trigger>();
|
||||
private List<DamageTrigger> damageTriggers = new List<DamageTrigger>();
|
||||
private List<StepTrigger> stepTriggers = new List<StepTrigger>();
|
||||
|
||||
public TriggerManager(BattleClock clock) {
|
||||
clock.OnTimeChanged += this.NotifyTimeChanged;
|
||||
|
|
@ -14,6 +15,13 @@ public class TriggerManager
|
|||
private void NotifyTimeChanged(BattleTime now) {
|
||||
if (now.RoundStep == RoundStep.StartOfHeroTurn) {
|
||||
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
||||
this.stepTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
||||
}
|
||||
|
||||
foreach (StepTrigger st in this.stepTriggers) {
|
||||
if (st.IsTriggeredBy(now)) {
|
||||
EnqueueActivatedTrigger(st);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -33,17 +41,23 @@ public class TriggerManager
|
|||
}
|
||||
}
|
||||
|
||||
public void ArmDamageTrigger(DamageTrigger damageTrigger) {
|
||||
this.damageTriggers.Add(damageTrigger);
|
||||
public void ArmDamageTrigger(DamageTrigger trigger) {
|
||||
this.damageTriggers.Add(trigger);
|
||||
}
|
||||
|
||||
public void ArmStepTrigger(StepTrigger trigger) {
|
||||
this.stepTriggers.Add(trigger);
|
||||
}
|
||||
|
||||
private void EnqueueActivatedTrigger(Trigger trigger) {
|
||||
this.activatedTriggers.Add(trigger);
|
||||
}
|
||||
|
||||
public void RunActivatedTriggers(IBattleEffectApplier effectApplier) {
|
||||
public IEnumerator RunActivatedTriggers(IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint,
|
||||
BattlePlayerControls playerControls) {
|
||||
foreach (Trigger t in this.activatedTriggers) {
|
||||
t.Run(effectApplier);
|
||||
yield return t.Run(effectApplier, viewpoint, playerControls);
|
||||
}
|
||||
this.activatedTriggers.Clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1,6 @@
|
|||
public delegate void TriggeredEffect(IBattleEffectApplier effectApplier);
|
||||
using System.Collections;
|
||||
|
||||
public delegate IEnumerator TriggeredEffect(
|
||||
IBattleEffectApplier effectApplier,
|
||||
MonsterViewpoint viewpoint,
|
||||
BattlePlayerControls playerControls);
|
||||
16
Assets/Battle/Triggers/StepTrigger.cs
Normal file
16
Assets/Battle/Triggers/StepTrigger.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
public class StepTrigger : Trigger {
|
||||
|
||||
private RoundStep step;
|
||||
|
||||
public StepTrigger(RoundStep step, TriggeredEffect callback,
|
||||
TriggerExpiration expiration, TriggerRepetition repetition)
|
||||
: base(callback, expiration, repetition) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public bool IsTriggeredBy(BattleTime time) {
|
||||
return time.RoundStep == this.step;
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/Triggers/StepTrigger.cs.meta
Normal file
11
Assets/Battle/Triggers/StepTrigger.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f369bcd44b59b1345a33d76373db6a21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Resources/CardArt/HeroMolotovCocktail.jpg
Normal file
BIN
Assets/Resources/CardArt/HeroMolotovCocktail.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
92
Assets/Resources/CardArt/HeroMolotovCocktail.jpg.meta
Normal file
92
Assets/Resources/CardArt/HeroMolotovCocktail.jpg.meta
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 58b4b0ee9283648499d9b692031c0953
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue