diff --git a/Assets/_Project/Definitions/BuilderSpells/SlowAreaSpell.asset b/Assets/_Project/Definitions/BuilderSpells/SlowAreaSpell.asset index 3439119..cb2746a 100644 --- a/Assets/_Project/Definitions/BuilderSpells/SlowAreaSpell.asset +++ b/Assets/_Project/Definitions/BuilderSpells/SlowAreaSpell.asset @@ -25,7 +25,7 @@ MonoBehaviour: areaSound: clip: {fileID: 8300000, guid: 038ff3eab9aa0034bac26ccb648ef2a1, type: 3} volume: 0.632 - minPitch: 1.14 + minPitch: 1.04 maxPitch: 0.96 SlowFactor: 0.5 EffectDuration: 8 diff --git a/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset b/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset new file mode 100644 index 0000000..0465991 --- /dev/null +++ b/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset @@ -0,0 +1,31 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 37cc60a4a6e53e24cb6d1c0be310868a, type: 3} + m_Name: SlowAreaUpgradedSpell + m_EditorClassIdentifier: Assembly-CSharp::TD.Gameplay.BuilderSpells.SlowAreaUpgradedSpellDefinition + DisplayName: Slow Area II + Description: Upgraded Slow Area. Slows for 50% longer. + Icon: {fileID: 0} + Cooldown: 10 + TargetType: 1 + Radius: 5 + enemyLayerMask: + serializedVersion: 2 + m_Bits: 1152 + areaVfxPrefab: {fileID: 1462673130280185047, guid: bf2f1f2a9a54e9162b80673e3f7eeaf6, type: 3} + areaSound: + clip: {fileID: 8300000, guid: 038ff3eab9aa0034bac26ccb648ef2a1, type: 3} + volume: 0.632 + minPitch: 1.04 + maxPitch: 0.96 + SlowFactor: 0.5 + EffectDuration: 12 diff --git a/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset.meta b/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset.meta new file mode 100644 index 0000000..16266b6 --- /dev/null +++ b/Assets/_Project/Definitions/BuilderSpells/SlowAreaUpgradedSpell.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 364edf6abc3c31e33b53d0a01142b8ab +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset b/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset new file mode 100644 index 0000000..743c46d --- /dev/null +++ b/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset @@ -0,0 +1,20 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7b1c5b562f39c72eea3bafd0165af078, type: 3} + m_Name: Draft_BuilderSpellOption_SlowAreaUpgrade + m_EditorClassIdentifier: Assembly-CSharp::TD.Gameplay.Draft.BuilderSpellUpgradeDraftOption + DisplayName: Slow Area II + Description: Slows enemies in the area for 50% longer than the default slow area. + Icon: {fileID: 0} + Weight: 1 + BaseKind: 1 + UpgradedKind: 2 diff --git a/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset.meta b/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset.meta new file mode 100644 index 0000000..13ca9fd --- /dev/null +++ b/Assets/_Project/Definitions/Draft/Draft_BuilderSpellOption_SlowAreaUpgrade.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d180030b68a9a5e1da497bf6f83451d4 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Project/Scenes/Levels/9Player.unity b/Assets/_Project/Scenes/Levels/9Player.unity index 684df64..9a4d028 100644 --- a/Assets/_Project/Scenes/Levels/9Player.unity +++ b/Assets/_Project/Scenes/Levels/9Player.unity @@ -13428,6 +13428,7 @@ MonoBehaviour: spells: - {fileID: 11400000, guid: 051c48f416e5366b59d49b0e062333ac, type: 2} - {fileID: 11400000, guid: d893f46b037536b4ba91307e184cecfe, type: 2} + - {fileID: 11400000, guid: 364edf6abc3c31e33b53d0a01142b8ab, type: 2} --- !u!4 &914832726 Transform: m_ObjectHideFlags: 0 @@ -28786,6 +28787,7 @@ MonoBehaviour: - {fileID: 11400000, guid: 65ff25c1c8a89f7df8e88f71968c1c98, type: 2} - {fileID: 11400000, guid: 5f390de69ba43b2a6a0d89cf09580320, type: 2} - {fileID: 11400000, guid: 29b35841f7e5db454903798cb5d83434, type: 2} + - {fileID: 11400000, guid: d180030b68a9a5e1da497bf6f83451d4, type: 2} --- !u!4 &2139601601 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/_Project/Scripts/Core/BuilderSpellKind.cs b/Assets/_Project/Scripts/Core/BuilderSpellKind.cs index 58fcb5d..91c56e9 100644 --- a/Assets/_Project/Scripts/Core/BuilderSpellKind.cs +++ b/Assets/_Project/Scripts/Core/BuilderSpellKind.cs @@ -11,5 +11,6 @@ namespace TD.Core { Fireball = 0, SlowArea = 1, + SlowAreaUpgraded = 2, } } diff --git a/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs b/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs new file mode 100644 index 0000000..dd339f7 --- /dev/null +++ b/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs @@ -0,0 +1,21 @@ +// Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs + +using TD.Core; +using UnityEngine; + +namespace TD.Gameplay.BuilderSpells +{ + /// + /// Draft upgrade for — identical behavior, just a + /// distinct so can replace the base spell + /// with this one in the player's loadout. All fields (SlowFactor, EffectDuration, etc.) + /// are inherited; author this asset with a longer EffectDuration than the base spell. + /// + [CreateAssetMenu(fileName = "SlowAreaUpgradedSpell", + menuName = "TD/Builder Spells/Slow Area (Upgraded)")] + public class SlowAreaUpgradedSpellDefinition : SlowAreaSpellDefinition + { + public override BuilderSpellKind Kind => BuilderSpellKind.SlowAreaUpgraded; + } +} diff --git a/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs.meta b/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs.meta new file mode 100644 index 0000000..af8991f --- /dev/null +++ b/Assets/_Project/Scripts/Gameplay/BuilderSpells/SlowAreaUpgradedSpellDefinition.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 37cc60a4a6e53e24cb6d1c0be310868a \ No newline at end of file diff --git a/Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs.meta b/Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs.meta new file mode 100644 index 0000000..393a4c1 --- /dev/null +++ b/Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 717648113e8090fc6856744d898ab375 \ No newline at end of file diff --git a/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs b/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs index 7582ea2..360a566 100644 --- a/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs +++ b/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs @@ -15,7 +15,9 @@ namespace TD.Gameplay.Draft /// and already key off of. /// also checks slot capacity — once /// is reached, no further spell options are - /// offered. + /// offered. Gates on rather than + /// current possession, so a base spell already upgraded past (see + /// ) is never re-offered. /// [CreateAssetMenu(fileName = "BuilderSpellOption", menuName = "TD/Draft/Builder Spell Option")] public class BuilderSpellDraftOption : DraftOption @@ -29,7 +31,7 @@ namespace TD.Gameplay.Draft var loadout = PlayerSpellLoadout.GetForClient(clientId); if (loadout == null) return false; if (loadout.SlotCount >= PlayerSpellLoadout.MaxSpellSlots) return false; - return !loadout.PlayerHasSpell(Kind); + return !loadout.PlayerHasEverGranted(Kind); } public override bool ServerApply(ulong clientId) diff --git a/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs.meta b/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs.meta new file mode 100644 index 0000000..2d6304f --- /dev/null +++ b/Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 7b1c5b562f39c72eea3bafd0165af078 \ No newline at end of file diff --git a/Assets/_Project/Scripts/Gameplay/PlayerSpellLoadout.cs b/Assets/_Project/Scripts/Gameplay/PlayerSpellLoadout.cs index 0d8bfb3..4782e9f 100644 --- a/Assets/_Project/Scripts/Gameplay/PlayerSpellLoadout.cs +++ b/Assets/_Project/Scripts/Gameplay/PlayerSpellLoadout.cs @@ -60,6 +60,10 @@ namespace TD.Gameplay private readonly NetworkList spells = new NetworkList(); + // Every kind ever granted this match, including ones since upgraded away. Unlike + // `spells`, entries here are never removed — see PlayerHasEverGranted. + private readonly NetworkList everGrantedKinds = new NetworkList(); + /// Fired on every peer when a spell is granted or a cooldown changes. public event System.Action OnLoadoutChanged; @@ -100,6 +104,14 @@ namespace TD.Gameplay public BuilderSpellKind? GetKind(int slot) => (slot >= 0 && slot < spells.Count) ? spells[slot].Kind : (BuilderSpellKind?)null; + /// + /// True if this player has ever been granted the given spell this match, whether or + /// not it's still occupying a slot (e.g. it may have since been upgraded away). Used + /// by so a base spell already + /// upgraded past is never re-offered. + /// + public bool PlayerHasEverGranted(BuilderSpellKind kind) => everGrantedKinds.Contains((byte)kind); + /// True if is out of range, empty, or still cooling down. public bool IsSlotOnCooldown(int slot) { @@ -136,6 +148,7 @@ namespace TD.Gameplay if (PlayerHasSpell(kind)) return false; spells.Add(SpellSlot.CreateReady(kind)); + if (!everGrantedKinds.Contains((byte)kind)) everGrantedKinds.Add((byte)kind); return true; } @@ -155,6 +168,7 @@ namespace TD.Gameplay if (spells[i].Kind == oldKind) { spells[i] = SpellSlot.CreateReady(newKind); + if (!everGrantedKinds.Contains((byte)newKind)) everGrantedKinds.Add((byte)newKind); return true; } }