diff --git a/Assets/Scripts/GameState/BaseController.cs b/Assets/Scripts/GameState/BaseController.cs index f3b5b217..cbe913e3 100644 --- a/Assets/Scripts/GameState/BaseController.cs +++ b/Assets/Scripts/GameState/BaseController.cs @@ -71,10 +71,8 @@ void Awake() GetComponent().onDeath += Die; anim = GetComponent(); - if(mainCrystal == null) - { + if (mainCrystal == null) Debug.LogError("Main Crystal not set."); - } } void OnDestroy() @@ -131,9 +129,7 @@ private void Die() StartCoroutine("Explode"); // Start Distortions - //distortionField.enabled = true; - - + //distortionField.enabled = true; } dead = true; @@ -184,19 +180,18 @@ public int GetIdVFX(Transform t) IEnumerator Explode() { // Get a list of all transforms (lighning targets) - Transform[] transforms = GameObject.FindObjectsOfType(); + Transform[] transforms = FindObjectsOfType(); // Create lightning as the crystal charges for (int _ = 0; _ >= explosionLightningCount; _++) { - int i = Random.Range(0, transforms.Length); - - Transform ray = Instantiate(drainRay, transform.position + new Vector3(Random.Range(-1, 1), 5f, Random.Range(-1, 1)), transform.rotation).transform; - ray.SetParent(transform); + Vector3 rayPos = transform.position + new Vector3(Random.Range(-1, 1), 5f, Random.Range(-1, 1)); + Transform ray = Instantiate(drainRay, rayPos, transform.rotation, transform).transform; // 1 is the index of the first child (after the parent itself) Transform target = ray.GetComponentsInChildren()[1]; - target.SetParent(transforms[i]); + Transform randomLightningTarget = transforms[Random.Range(0, transforms.Length)]; + target.SetParent(randomLightningTarget); target.localPosition = Vector3.zero; // Ensure correct camera focus @@ -209,7 +204,7 @@ IEnumerator Explode() GameObject deadBase = Instantiate(destroyedBase, transform.position, Quaternion.identity); // Add an explosion force on the base - foreach(Rigidbody rb in deadBase.GetComponentsInChildren()) + foreach (Rigidbody rb in deadBase.GetComponentsInChildren()) { rb.AddForce(new Vector3(Random.Range(-250f, 250f), Random.Range(500f, 800f), Random.Range(-250f, 250f))); } @@ -221,7 +216,7 @@ IEnumerator Explode() Instantiate(gameOverScreen); // Add particle system - Instantiate(deathParticles, transform.position + new Vector3(0,3,0), transform.rotation); + Instantiate(deathParticles, transform.position + new Vector3(0, 3, 0), transform.rotation); // Clean up Destroy(gameObject); diff --git a/Assets/Scripts/Player/CameraFocusController.cs b/Assets/Scripts/Player/CameraFocusController.cs index 91762652..9a4d5398 100644 --- a/Assets/Scripts/Player/CameraFocusController.cs +++ b/Assets/Scripts/Player/CameraFocusController.cs @@ -77,13 +77,10 @@ private Vector3 boundingBoxCenter() //Taking the mean sqare avg of the mindistance and box distance if (!overview) - { distance = Mathf.Sqrt(radialDist * radialDist + minDistance * minDistance); - } else - { distance = Mathf.Sqrt(radialDist * radialDist + overviewDistance * overviewDistance); - } + return center + distance * viewDir; } @@ -109,7 +106,6 @@ public void Focus(Transform obj) // Switch to overview mode EnableOverview(); - } public void EnableOverview() @@ -117,7 +113,7 @@ public void EnableOverview() if (!overview) { overview = true; - smoothing = smoothing / 10; + smoothing /= 10; } } } diff --git a/Assets/Scripts/Player/PlayerUi.cs b/Assets/Scripts/Player/PlayerUi.cs index 8b58a897..ead506b4 100644 --- a/Assets/Scripts/Player/PlayerUi.cs +++ b/Assets/Scripts/Player/PlayerUi.cs @@ -55,8 +55,7 @@ public void Select() if (inventory.ResourceAmount - GetSelectedCost() < 0) { state.SetState(PlayerStates.FREE); - } - else + } else { inventory.ResourceAmount -= GetSelectedCost(); GameObject spawnedTower = Instantiate(GetSelectedSegment());