From 69f013755e206bf52348ad5e400df1461b0c7287 Mon Sep 17 00:00:00 2001 From: Piegames <14054505+piegamesde@users.noreply.github.com> Date: Tue, 24 Apr 2018 21:07:32 +0200 Subject: [PATCH] Randomized mob shooting And other balancing --- Assets/Scripts/Entities/Bug.cs | 4 ++-- Assets/Scripts/Entities/Enemy.cs | 10 +++++----- Assets/Scripts/Entities/Spider.cs | 4 ++-- Assets/Scripts/Generation/DungeonGenerator.cs | 8 +++++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/Entities/Bug.cs b/Assets/Scripts/Entities/Bug.cs index dc6bd49..fd8fec8 100644 --- a/Assets/Scripts/Entities/Bug.cs +++ b/Assets/Scripts/Entities/Bug.cs @@ -16,12 +16,12 @@ namespace Assets.Scripts.Entities { } protected override void Start() { - base.Start(); SingleShot s = new SingleShot(this.gameObject, 8, 3, 8 ); s.SetRange(3); s.SetPrefab(bullet); s.SetSpawn(bulletSpawn); - SetAttack(s); + SetAttack(s); + base.Start(); } } } diff --git a/Assets/Scripts/Entities/Enemy.cs b/Assets/Scripts/Entities/Enemy.cs index 829f816..43e139d 100644 --- a/Assets/Scripts/Entities/Enemy.cs +++ b/Assets/Scripts/Entities/Enemy.cs @@ -32,12 +32,12 @@ namespace Assets.Scripts.Entities { if ( ply != null ) victim = ply.gameObject; } - - + + if (attack != null) + nextAttackTime = Time.timeSinceLevelLoad + attack.GetCooldownTime() * (UnityEngine.Random.value + 0.5f); } void Update() { - if ( victim == null || attack == null ) { if ( objective != null ) { Player ply = objective.GetPlayer(); @@ -53,8 +53,8 @@ namespace Assets.Scripts.Entities { RaycastHit2D hit = rh.Find(x => x.fraction != 0); if ( hit.collider != null && hit.collider.gameObject == victim ) { Debug.Log("Attacking Player!!!"); - attack.Attack(); - nextAttackTime = Time.timeSinceLevelLoad + attack.GetCooldownTime(); + attack.Attack(); + nextAttackTime = Time.timeSinceLevelLoad + attack.GetCooldownTime() * (UnityEngine.Random.value + 0.25f); } } diff --git a/Assets/Scripts/Entities/Spider.cs b/Assets/Scripts/Entities/Spider.cs index 55d9b81..55f6d54 100644 --- a/Assets/Scripts/Entities/Spider.cs +++ b/Assets/Scripts/Entities/Spider.cs @@ -16,12 +16,12 @@ namespace Assets.Scripts.Entities { } protected override void Start() { - base.Start(); SingleShot s = new SingleShot(this.gameObject, 25, 4, 2); s.SetRange(10); s.SetPrefab(bullet); s.SetSpawn(bulletSpawn); - SetAttack(s); + SetAttack(s); + base.Start(); } } } diff --git a/Assets/Scripts/Generation/DungeonGenerator.cs b/Assets/Scripts/Generation/DungeonGenerator.cs index 033f62c..548c0bf 100644 --- a/Assets/Scripts/Generation/DungeonGenerator.cs +++ b/Assets/Scripts/Generation/DungeonGenerator.cs @@ -461,9 +461,11 @@ public class DungeonGenerator { Objective o = null; - int rand = UnityEngine.Random.Range(0, 7); + int rand = UnityEngine.Random.Range(0, 8); switch (rand) { - case 0: { + case 0: + case 7: + { // Scorpion Attack!!!!: List lg = new List(); int count = UnityEngine.Random.Range(1, ( int ) Math.Min(Mathf.Floor(r.GetSpawnpoints().Count), 4)); @@ -505,7 +507,7 @@ public class DungeonGenerator { { // Siders!!!!: List lg = new List(); - int count = Math.Min(UnityEngine.Random.Range(1, (int)Mathf.Floor(r.GetSpawnpoints().Count)), 3); + int count = Math.Min(UnityEngine.Random.Range(1, (int)Mathf.Floor(r.GetSpawnpoints().Count)), 5); for (int c = 0; c < count; c++) { lg.Add(enemyPrefabs[Entity.Entities.SPIDER]);