From e77f491d47e9890293a38d16f50848e80c7b102a Mon Sep 17 00:00:00 2001 From: Pasha Bibko <156938226+PashaBibko@users.noreply.github.com> Date: Thu, 15 Jan 2026 13:40:46 +0000 Subject: [PATCH] Adjusted spawning rules --- Assets/Scripts/CanvasManager.cs | 4 ++-- Assets/Scripts/WindowBase.cs | 2 +- Assets/Scripts/WindowSpawner.cs | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/CanvasManager.cs b/Assets/Scripts/CanvasManager.cs index f8fc7bd..b7c9fbf 100644 --- a/Assets/Scripts/CanvasManager.cs +++ b/Assets/Scripts/CanvasManager.cs @@ -24,8 +24,8 @@ namespace InterfaceOff { Rect rect = Instance.GameCanvas.pixelRect; - float x = Random.Range(rect.xMin + 150, rect.xMax - 150); - float y = Random.Range(rect.yMin + 150, rect.yMax - 150); + float x = Random.Range(rect.xMin, rect.xMax); + float y = Random.Range(rect.yMin, rect.yMax); return new Vector3(x, y, 0f); } diff --git a/Assets/Scripts/WindowBase.cs b/Assets/Scripts/WindowBase.cs index c743f3b..a208463 100644 --- a/Assets/Scripts/WindowBase.cs +++ b/Assets/Scripts/WindowBase.cs @@ -50,7 +50,7 @@ namespace InterfaceOff ); } - Components.RectTransform.anchoredPosition = position; // Updates position if it is supposed to] change + Components.RectTransform.anchoredPosition = position; // Updates position if it is supposed to change } public virtual void OnWindowInstantiation() { } diff --git a/Assets/Scripts/WindowSpawner.cs b/Assets/Scripts/WindowSpawner.cs index 1c72d52..b8916e8 100644 --- a/Assets/Scripts/WindowSpawner.cs +++ b/Assets/Scripts/WindowSpawner.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using Ext.B83.Unity.Attributes; using UnityEngine; using Random = UnityEngine.Random; @@ -23,6 +22,7 @@ namespace InterfaceOff private int TotalSpawnWeight { get; set; } [field: SerializeField] public bool AutoSpawn { get; private set; } = true; + private int SpawnCounter { get; set; } private void Awake() { @@ -87,10 +87,11 @@ namespace InterfaceOff { if (AutoSpawn) { - /* Checks if it should spawn a window */ - bool shouldSpawn = Random.Range(0, 60) == 0; - if (shouldSpawn) + /* Decreases the spawn counter and spawns if at 0 */ + SpawnCounter = Math.Max(0, SpawnCounter - 1); + if (SpawnCounter == 0) { + SpawnCounter = Random.Range(0, 4 * 20); SpawnNewRandomWindow(); } }