From f78582aac8b4d73ac5bd2603f697f99ea31e1e49 Mon Sep 17 00:00:00 2001 From: Soulaha Balde Date: Sun, 3 Apr 2022 17:56:30 -0400 Subject: [PATCH 1/2] Different values for monsters --- Assets/Prefabs/Goblin Variant.prefab | 28 ++++++++++++++++++++++++++++ Assets/Prefabs/MainMenu.prefab | 6 +++--- Assets/Prefabs/Vampire.prefab | 2 +- Assets/Scripts/AIEntity.cs | 2 ++ Assets/Scripts/MinionThrower.cs | 15 +++++++-------- Assets/Scripts/Player Stats.asset | 2 ++ Assets/Scripts/PlayerStats.cs | 3 +++ Assets/Scripts/UI/MinionBar.cs | 8 ++++---- 8 files changed, 50 insertions(+), 16 deletions(-) diff --git a/Assets/Prefabs/Goblin Variant.prefab b/Assets/Prefabs/Goblin Variant.prefab index 6ed14bc..b155034 100644 --- a/Assets/Prefabs/Goblin Variant.prefab +++ b/Assets/Prefabs/Goblin Variant.prefab @@ -109,6 +109,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 160730869004340736, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3} + propertyPath: m_RootOrder + value: 3 + objectReference: {fileID: 0} - target: {fileID: 2399377275812995968, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3} propertyPath: m_RootOrder value: 0 @@ -153,10 +157,34 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 2399377275812995974, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3} + propertyPath: attackCooldown + value: 0.7 + objectReference: {fileID: 0} + - target: {fileID: 2399377275812995974, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3} + propertyPath: k__BackingField + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 2399377275812995974, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3} + propertyPath: k__BackingField + value: 30 + objectReference: {fileID: 0} - target: {fileID: 2399377275812995974, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3} propertyPath: k__BackingField value: objectReference: {fileID: 1205254930} + - target: {fileID: 2399377275812995974, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3} + propertyPath: k__BackingField + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 2399377275812995974, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3} + propertyPath: k__BackingField + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2399377275812995974, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3} + propertyPath: k__BackingField + value: 4 + objectReference: {fileID: 0} - target: {fileID: 2399377275812995980, guid: 5f633c05dee3f4b4784f5702b2365f02, type: 3} propertyPath: m_Name value: Goblin Variant diff --git a/Assets/Prefabs/MainMenu.prefab b/Assets/Prefabs/MainMenu.prefab index 45d3936..39e850d 100644 --- a/Assets/Prefabs/MainMenu.prefab +++ b/Assets/Prefabs/MainMenu.prefab @@ -853,9 +853,9 @@ MonoBehaviour: m_PersistentCalls: m_Calls: - m_Target: {fileID: 0} - m_TargetAssemblyTypeName: MainMenuManager, Assembly-CSharp - m_MethodName: GoToScene - m_Mode: 3 + m_TargetAssemblyTypeName: GameFlowManager, Assembly-CSharp + m_MethodName: ToStartFlowState + m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine diff --git a/Assets/Prefabs/Vampire.prefab b/Assets/Prefabs/Vampire.prefab index f79f76e..09dd778 100644 --- a/Assets/Prefabs/Vampire.prefab +++ b/Assets/Prefabs/Vampire.prefab @@ -103,8 +103,8 @@ MonoBehaviour: gameFlowManager: {fileID: 0} playerStats: {fileID: 11400000, guid: 12a626b5a296d934ba078d222ad6ba98, type: 2} minionPrefabs: - - {fileID: 2674681564269481473, guid: 6385a50f8549b2141a1daf3577c54d0a, type: 3} - {fileID: 4435383994544937624, guid: d6075d2fe32cab14082dfc6d5f5ebc59, type: 3} + - {fileID: 2674681564269481473, guid: 6385a50f8549b2141a1daf3577c54d0a, type: 3} aimArrow: {fileID: 5124059627794595469} --- !u!114 &7967951869135974023 MonoBehaviour: diff --git a/Assets/Scripts/AIEntity.cs b/Assets/Scripts/AIEntity.cs index 5b2a6d3..ee48eef 100644 --- a/Assets/Scripts/AIEntity.cs +++ b/Assets/Scripts/AIEntity.cs @@ -12,6 +12,7 @@ public class AIEntity : Entity { public bool facingRight { get; private set; } = true; protected Vector3 moatExtents; protected bool isAvoiding = false; + [field: SerializeField] public float cost{ get; private set; } = 10f; override protected void Start() { base.Start(); @@ -281,6 +282,7 @@ public class AIEntity : Entity { Entity targetEntity = entity.target.GetComponent(); if (targetEntity != null) { targetEntity.TakeDamage(entity.attackDmg, entity); + entity.rb.velocity = Vector3.zero; bool isTargetAlive = targetEntity.IsAlive(); if (!isTargetAlive) { return new FindTargetState(entity); diff --git a/Assets/Scripts/MinionThrower.cs b/Assets/Scripts/MinionThrower.cs index 8c14989..aaf0dc7 100644 --- a/Assets/Scripts/MinionThrower.cs +++ b/Assets/Scripts/MinionThrower.cs @@ -11,7 +11,7 @@ public class MinionThrower : MonoBehaviour { [SerializeField] [Required] PlayerStats playerStats = null!; - public Entity[] minionPrefabs = null!; + public AIEntity[] minionPrefabs = null!; public GameObject aimArrow = null!; bool isInThrowMode; @@ -21,7 +21,6 @@ public class MinionThrower : MonoBehaviour { PlayerMovement movement = null!; float currentCooldownTimer; - float currentInitialCooldown; void Awake() { vampireEntity = GetComponent(); @@ -31,7 +30,7 @@ public class MinionThrower : MonoBehaviour { } void Start() { - foreach (Entity minion in minionPrefabs) { + foreach (AIEntity minion in minionPrefabs) { minionBar.AddMinionType(minion); } minionBar.UpdateReload(0f); @@ -40,7 +39,7 @@ public class MinionThrower : MonoBehaviour { void FixedUpdate() { if (currentCooldownTimer > 0f) { currentCooldownTimer -= Time.fixedDeltaTime; - minionBar.UpdateReload(currentCooldownTimer / currentInitialCooldown); + minionBar.UpdateReload(currentCooldownTimer / playerStats.currentInitialCooldown); } } @@ -78,15 +77,15 @@ public class MinionThrower : MonoBehaviour { return; } - float minionHealthCost = 10f; // TODO + float minionHealthCost = minionBar.GetCurrentMinion().cost; if (minionHealthCost >= vampireEntity.Health) { return; } vampireEntity.TakeDamage(minionHealthCost, vampireEntity); - currentInitialCooldown = 2f; // TODO - currentCooldownTimer = currentInitialCooldown; - minionBar.UpdateReload(currentCooldownTimer / currentInitialCooldown); + + currentCooldownTimer = playerStats.currentInitialCooldown; + minionBar.UpdateReload(currentCooldownTimer / playerStats.currentInitialCooldown); var newMinion = Instantiate(minionBar.GetCurrentMinion().gameObject, arena.minionParent) .GetComponent(); diff --git a/Assets/Scripts/Player Stats.asset b/Assets/Scripts/Player Stats.asset index 54d8bf9..f4897ab 100644 --- a/Assets/Scripts/Player Stats.asset +++ b/Assets/Scripts/Player Stats.asset @@ -15,3 +15,5 @@ MonoBehaviour: movementSpeed: 4 suckSpeed: 1 bloodLossRate: 2 + k__BackingField: 0.4 + currentInitialCooldown: 0.5 diff --git a/Assets/Scripts/PlayerStats.cs b/Assets/Scripts/PlayerStats.cs index 82c69b0..ae891cf 100644 --- a/Assets/Scripts/PlayerStats.cs +++ b/Assets/Scripts/PlayerStats.cs @@ -13,4 +13,7 @@ public class PlayerStats : ScriptableObject { [field: SerializeField] [field: Range(0f, 1f)] public float MinJoystickValueForThrowing { get; private set; } = .4f; + + [field: SerializeField] [field: Min(0f)] + public float currentInitialCooldown = 0.5f; } \ No newline at end of file diff --git a/Assets/Scripts/UI/MinionBar.cs b/Assets/Scripts/UI/MinionBar.cs index 0d899de..46bbd5f 100644 --- a/Assets/Scripts/UI/MinionBar.cs +++ b/Assets/Scripts/UI/MinionBar.cs @@ -7,12 +7,12 @@ public class MinionBar : MonoBehaviour { public GameObject minionIconPrefab; - List minionTypes; + List minionTypes; List minionIcons; int currentIndex; void Awake() { - minionTypes = new List(); + minionTypes = new List(); minionIcons = new List(); } @@ -39,7 +39,7 @@ public class MinionBar : MonoBehaviour { // print("new selected minion type : " + currentIndex.ToString()); } - public void AddMinionType(Entity newMinionPrefab) { + public void AddMinionType(AIEntity newMinionPrefab) { minionTypes.Add(newMinionPrefab); MinionIcon newIcon = Instantiate(minionIconPrefab, transform) .GetComponent(); @@ -67,7 +67,7 @@ public class MinionBar : MonoBehaviour { } } - public Entity GetCurrentMinion() { + public AIEntity GetCurrentMinion() { return minionTypes[currentIndex]; } From 9d51ed4cfdf6066c5984339509059f36d3a3245b Mon Sep 17 00:00:00 2001 From: Soulaha Balde Date: Sun, 3 Apr 2022 18:33:50 -0400 Subject: [PATCH 2/2] Arena can spawn diff gladiators w/ x ratio each --- Assets/Prefabs/Arena.prefab | 5 ++++- Assets/Prefabs/Big Knight Variant.prefab | 24 ++++++++++++++++++++++++ Assets/Scripts/Arena Stats.asset | 7 ++++++- Assets/Scripts/Arena.cs | 24 ++++++++++++++++++++---- Assets/Scripts/ArenaStats.cs | 3 ++- 5 files changed, 56 insertions(+), 7 deletions(-) diff --git a/Assets/Prefabs/Arena.prefab b/Assets/Prefabs/Arena.prefab index 38322f7..6ef9a5c 100644 --- a/Assets/Prefabs/Arena.prefab +++ b/Assets/Prefabs/Arena.prefab @@ -62349,10 +62349,13 @@ MonoBehaviour: - position: {x: 10, y: -10} direction: {x: 0, y: 1} stats: {fileID: 11400000, guid: fe319ad8c9a37b84e8b45268c913d54c, type: 2} - entityPrefab: {fileID: 2004725698506461420, guid: f75821098c495cb43a0bff5d9ef0a671, type: 3} + lightGladiator: {fileID: 2004725698506461419, guid: f75821098c495cb43a0bff5d9ef0a671, type: 3} + regularGladiator: {fileID: 2004725698506461419, guid: f75821098c495cb43a0bff5d9ef0a671, type: 3} + heavyGladiator: {fileID: 1373848176550804357, guid: 99423d7c9a753554e87e6bb7e555018b, type: 3} k__BackingField: {fileID: 793317230} k__BackingField: {fileID: 1787272690} k__BackingField: {fileID: 1550580935} + currWaveSize: 0 --- !u!114 &1359990806 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Big Knight Variant.prefab b/Assets/Prefabs/Big Knight Variant.prefab index 50787e5..38407c6 100644 --- a/Assets/Prefabs/Big Knight Variant.prefab +++ b/Assets/Prefabs/Big Knight Variant.prefab @@ -113,6 +113,10 @@ PrefabInstance: propertyPath: m_Enabled value: 0 objectReference: {fileID: 0} + - target: {fileID: 161084746864990857, guid: b25a487d193f24049b6a791adf592b2e, type: 3} + propertyPath: m_RootOrder + value: 3 + objectReference: {fileID: 0} - target: {fileID: 197677485360569561, guid: b25a487d193f24049b6a791adf592b2e, type: 3} propertyPath: m_Name value: Big Knight Variant @@ -161,10 +165,30 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 197677485360569566, guid: b25a487d193f24049b6a791adf592b2e, type: 3} + propertyPath: attackCooldown + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 197677485360569566, guid: b25a487d193f24049b6a791adf592b2e, type: 3} + propertyPath: k__BackingField + value: 15 + objectReference: {fileID: 0} + - target: {fileID: 197677485360569566, guid: b25a487d193f24049b6a791adf592b2e, type: 3} + propertyPath: k__BackingField + value: 80 + objectReference: {fileID: 0} - target: {fileID: 197677485360569566, guid: b25a487d193f24049b6a791adf592b2e, type: 3} propertyPath: k__BackingField value: objectReference: {fileID: 1594628713} + - target: {fileID: 197677485360569566, guid: b25a487d193f24049b6a791adf592b2e, type: 3} + propertyPath: k__BackingField + value: 40 + objectReference: {fileID: 0} + - target: {fileID: 197677485360569566, guid: b25a487d193f24049b6a791adf592b2e, type: 3} + propertyPath: k__BackingField + value: 1 + objectReference: {fileID: 0} - target: {fileID: 1378753993384522801, guid: b25a487d193f24049b6a791adf592b2e, type: 3} propertyPath: m_AnchorMax.x value: 0 diff --git a/Assets/Scripts/Arena Stats.asset b/Assets/Scripts/Arena Stats.asset index fbce64e..74d2f77 100644 --- a/Assets/Scripts/Arena Stats.asset +++ b/Assets/Scripts/Arena Stats.asset @@ -14,4 +14,9 @@ MonoBehaviour: m_EditorClassIdentifier: secondsBetweenSpawners: 15 initWaitToSpawn: 3 - waveSize: 3 + initWaveSize: 3 + maxWaveSize: 10 + waveIncrease: 1 + increaseWaveStep: 3 + lightRatio: 0.25 + heavyRatio: 0.1 diff --git a/Assets/Scripts/Arena.cs b/Assets/Scripts/Arena.cs index d3140e2..de5a793 100644 --- a/Assets/Scripts/Arena.cs +++ b/Assets/Scripts/Arena.cs @@ -21,7 +21,11 @@ public class Arena : MonoBehaviour { [SerializeField] [Required] ArenaStats stats = null!; [SerializeField] [Required] - GameObject entityPrefab = null!; + public AIEntity lightGladiator = null!; + [SerializeField] [Required] + public AIEntity regularGladiator = null!; + [SerializeField] [Required] + public AIEntity heavyGladiator = null!; [field: SerializeField] [field: Required] public Transform gladiatorParent { get; private set; } = null!; @@ -39,7 +43,7 @@ public class Arena : MonoBehaviour { void Start() => StartCoroutine(SpawnEnemies()); - void SpawnEnemy(int spawnerIndex) { + void SpawnEnemy(int spawnerIndex, AIEntity entityPrefab) { if (!gameFlowManager.CanDoAction) return; @@ -56,18 +60,30 @@ public class Arena : MonoBehaviour { yield return new WaitForSeconds(stats.initWaitToSpawn); currWaveSize = stats.initWaveSize; int currentSpawner = 0; + int lightAmountSpawned = 0; + int heavyAmountSpawned = 0; int amountSpawned = 0; int wave = 1; while(true){ while (amountSpawned < currWaveSize) { currentSpawner = Random.Range(0, spawners.Length); - SpawnEnemy(currentSpawner); - amountSpawned++; + if(currWaveSize >= .5*stats.maxWaveSize && lightAmountSpawned <= stats.maxWaveSize * stats.lightRatio){ + SpawnEnemy(currentSpawner, lightGladiator); + lightAmountSpawned++; + }else if(currWaveSize >= .8*stats.maxWaveSize && heavyAmountSpawned <= stats.maxWaveSize * stats.heavyRatio){ + SpawnEnemy(currentSpawner, heavyGladiator); + heavyAmountSpawned++; + }else{ + SpawnEnemy(currentSpawner, regularGladiator); + } + amountSpawned++; } if(wave++ >= stats.increaseWaveStep){ if((currWaveSize += stats.waveIncrease) > stats.maxWaveSize) currWaveSize=stats.maxWaveSize; } amountSpawned = 0; + lightAmountSpawned = 0; + heavyAmountSpawned = 0; yield return new WaitForSeconds(stats.secondsBetweenSpawners); } diff --git a/Assets/Scripts/ArenaStats.cs b/Assets/Scripts/ArenaStats.cs index b92300d..b3ca5c3 100644 --- a/Assets/Scripts/ArenaStats.cs +++ b/Assets/Scripts/ArenaStats.cs @@ -8,5 +8,6 @@ public class ArenaStats : ScriptableObject { [Min(0f)] public int maxWaveSize = 10; [Min(0f), Tooltip("The amount of gladiator to add to wave")] public int waveIncrease = 1; [Min(0f), Tooltip("How many waves before we increase by WaveIncrease")] public int increaseWaveStep = 3; - + [Range(0f, 1f), Tooltip("Percentage of gladiator who are light")] public float lightRatio = 0.25f; + [Range(0f, 1f), Tooltip("Percentage of gladiator who are heavy")] public float heavyRatio = 0.1f; } \ No newline at end of file