Adjusted spawning rules

This commit is contained in:
Pasha Bibko
2026-01-15 13:40:46 +00:00
parent c87947075d
commit e77f491d47
3 changed files with 8 additions and 7 deletions

View File

@@ -24,8 +24,8 @@ namespace InterfaceOff
{ {
Rect rect = Instance.GameCanvas.pixelRect; Rect rect = Instance.GameCanvas.pixelRect;
float x = Random.Range(rect.xMin + 150, rect.xMax - 150); float x = Random.Range(rect.xMin, rect.xMax);
float y = Random.Range(rect.yMin + 150, rect.yMax - 150); float y = Random.Range(rect.yMin, rect.yMax);
return new Vector3(x, y, 0f); return new Vector3(x, y, 0f);
} }

View File

@@ -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() { } public virtual void OnWindowInstantiation() { }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using Ext.B83.Unity.Attributes; using Ext.B83.Unity.Attributes;
using UnityEngine; using UnityEngine;
using Random = UnityEngine.Random; using Random = UnityEngine.Random;
@@ -23,6 +22,7 @@ namespace InterfaceOff
private int TotalSpawnWeight { get; set; } private int TotalSpawnWeight { get; set; }
[field: SerializeField] public bool AutoSpawn { get; private set; } = true; [field: SerializeField] public bool AutoSpawn { get; private set; } = true;
private int SpawnCounter { get; set; }
private void Awake() private void Awake()
{ {
@@ -87,10 +87,11 @@ namespace InterfaceOff
{ {
if (AutoSpawn) if (AutoSpawn)
{ {
/* Checks if it should spawn a window */ /* Decreases the spawn counter and spawns if at 0 */
bool shouldSpawn = Random.Range(0, 60) == 0; SpawnCounter = Math.Max(0, SpawnCounter - 1);
if (shouldSpawn) if (SpawnCounter == 0)
{ {
SpawnCounter = Random.Range(0, 4 * 20);
SpawnNewRandomWindow(); SpawnNewRandomWindow();
} }
} }