Skip to content

Commit

Permalink
Update Wave Manager To Spawn Waves OutSide The WorldBorder
Browse files Browse the repository at this point in the history
  • Loading branch information
LordEvil1 committed Apr 11, 2024
1 parent 22fd5d3 commit 6fbee3d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Assets/Code/Scripts/GameManagers/WaveManager/WaveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class WaveManager : MonoBehaviour
public FormationBase Formation {
get {
if (_formation == null) _formation = GetComponent<FormationBase>();
transform.position = GetRandomPosForSPawn();
transform.position = GetRandomPosForSpawn();
return _formation;
}
set => _formation = value;
Expand Down Expand Up @@ -76,11 +76,12 @@ private void Spawn(IEnumerable<Vector3> points) {
_spawnedUnits.Add(unit);
}
}

public Vector3 GetRandomPosForSPawn(){
var worldBorder = GameObject.Find("World Border");
var RandX = UnityEngine.Random.Range(worldBorder.transform.localScale.x * -1,worldBorder.transform.localScale.x);
var RandZ = UnityEngine.Random.Range( worldBorder.transform.localScale.z * -1,worldBorder.transform.localScale.z);
public Vector3 GetRandomPosForSpawn(){
var extensionFactor = 5.0f;
var wbLocalScale = WorldBorder.WorldBorderObj.transform.localScale;

var RandX = UnityEngine.Random.Range(wbLocalScale.x * -extensionFactor, wbLocalScale.x * extensionFactor);
var RandZ = UnityEngine.Random.Range(wbLocalScale.z * -extensionFactor, wbLocalScale.z * extensionFactor);

return new Vector3(RandX, 0.0f, RandZ);
}
Expand Down
8 changes: 8 additions & 0 deletions Assets/Code/Scripts/Objectives/WorldBorder.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Assets/Code/Scripts/Objectives/WorldBorder/WorldBorder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WorldBorder : MonoBehaviour
{
public static GameObject WorldBorderObj;
// Start is called before the first frame update
void Awake()
{
WorldBorderObj = this.gameObject;
}

// Update is called once per frame
void Update()
{

}
}
11 changes: 11 additions & 0 deletions Assets/Code/Scripts/Objectives/WorldBorder/WorldBorder.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6fbee3d

Please sign in to comment.