i wanna scirptt for spawning and upograding bunkerr its sut have 3 stages of evolution…
- User
i wanna scirptt for spawning and upograding bunkerr
its sut have 3 stages of evolution
also there must be different paranetrs
and save bunker playe prefs system and load
save and load current nuker
bunkerr upgrading by disabling enabling obejct - stages
- Assistant
- User
thats look very very baad
// Updates the bunker appearance and parameters based on the current stage private void UpdateBunkerStage() { stage1.SetActive(currentStage == 1); stage2.SetActive(currentStage == 2); stage3.SetActive(currentStage == 3);
rewrite complite fully
i wanna roal serializebl class with proeprty stages
- Assistant
- User
i ahve that scriptt for spawnign items
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; public class eMainSpawnProcess : MonoBehaviour {
[Header("to get energy u must go to toxic lake cable")] public int level = 1; // Initial level public List<Transform> spawnPoints = new List<Transform>(); public List<GameObject> spawnableItems = new List<GameObject>(); private void OnEnable() { FindAllSpawnPoints(); } public void FindAllSpawnPoints() { spawnPoints.Clear(); foreach (eSpawnTransform spawnPoint in FindObjectsOfType<eSpawnTransform>()) { spawnPoints.Add(spawnPoint.transform); } } public void SpawnItem(GameObject item, Transform spawnPoint) { Instantiate(item, spawnPoint.position, spawnPoint.rotation); }}
and that hold tiemr and et
i wanna in second scriptt make abiltiy select spawn type
also all items spawn here with 100 chance
i wanna all spawn points was having random Vector2 range vairble to onenable get random spawn chance probability
so there can be not spawned items on point on random at all or maybe spawn but empty transform obejct
also i wanna use som random value randomization +
- Assistant
- User
why SpawnPoint spawns item>?
its doin eMainSpawnProcess
i ahve that scriptt for spawnign items
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; public class eMainSpawnProcess : MonoBehaviour {
[Header(“to get energy u must go to toxic lake cable”)]
public int level = 1; // Initial level
public List spawnPoints = new List(); public List spawnableItems = new List();
private void OnEnable() { FindAllSpawnPoints(); }
- Assistant
- User
okii, i wanna randomizaition type by default, not all
also i wanna have something like simila to timerr, but anothe vector2 random timee varaible that was counting in coorutine radnom seconddd between x and y secondd
also i wanna if item spawned on eSpawnTransform there is msut not spawns anythng
also i wanna eSpawnTransform was having bool - accesable by default true if false - no spawn availabele
- Assistant
- User
whats bette? leave all
public enum SpawnType { AllItems, RandomizedChance } public SpawnType spawnType = SpawnType.RandomizedChance;
[System.Serializable] public class SpawnProbability { public Transform spawnPoint; [Range(0, 100)] public float probability; }public void FindAllSpawnPoints() { spawnPoints.Clear(); spawnProbabilities.Clear();
foreach (var spawnTransform in FindObjectsOfType<eSpawnTransform>()) { if(spawnTransform.accessible) // Check if the spawn point is accessible { var spawnPoint = spawnTransform.transform; spawnPoints.Add(spawnPoint); SpawnProbability spawnProbability = new SpawnProbability() { spawnPoint = spawnPoint, probability = Random.Range(0, 100) // Assign a random spawn probability }; spawnProbabilities.Add(spawnProbability); } } }thtat things only for invoke scriptt that choosing like spawnsd items
and keep eMain scriptt - only for holding all items and points and instantiating them
or kepp mostly all stuff in eMain??
i need short answee
what bette on your freee choise?
- Assistant
Given the goal of maintaining code clarity and separation of concerns, it would be better to:
Keep the Spawn Logic in
eMainSpawnProcess- Responsibility:
eMainSpawnProcessshould be responsible for finding spawn points, determining probabilities, and spawning items. - Reasoning: This script should encapsulate all the logic related to item spawning since it keeps track of all spawnable items and spawn points.
Use
eInvokeSpawnProcessfor Triggering- Responsibility:
eInvokeSpawnProcessshould handle when and where to trigger the spawn process. - Reasoning: This script is concerned with when the spawning should occur based on conditions like player proximity and timers.
This separation ensures that each script is responsible for a specific aspect of the spawning system, making the code easier to maintain and extend.
Summary:
eMainSpawnProcess:
- Responsibility:
- User
okii, i wanna its eInvokeSpawnProcess handle all spawn probabilities, Triggers the spawn process based on timing and player proximity
eMainSpawnProcess was noly handles and spawning instantiating
rewrite it quicklyy
- Assistant
- User
what if item already spawnedd on point trnsform that spwan pointt and chance to spawn on that point bigge?
i wanna it not be overwriten
is it implemented?
i need shortt asnwe in 1 line
- Assistant
Yes, it's already implemented: an item won't spawn if the
accessibleflag isfalse. - User
i wanna rewrite eTransfrom script some part
tehre is eTransform Pointhave bool accesable i wanna there be also new bool - soemthing like named like there is already spawned obejct in here
- Assistant
- User
private IEnumerator SpawnItemCoroutine() { while (true) { TrySpawnRandomItem();
randomInterval = Random.Range(randomSpawnInterval.x, randomSpawnInterval.y); yield return new WaitForSeconds(randomInterval); } }what does it doin?
eInvokeSpawnProcess
TrySpawnRandomItem
sapwns only 1 item
i wanna go foreach mainSpawn sapwn point lsit
if accesable tryspan
- Assistant
- User
whats name i can select if e poitn transform occupied already and hasSpawnableObject?
i dont wanna use hasSpawnableObject name of bool
varibents that cool?
- Assistant
- User
how i can check if spawn poointt is accesable and not Ocuupied aagain?
- Assistant
- User
i wanna u replace public List spawnPoints = new List(); with eSpawnTransform and modify scriptts for easly acces and bo ability spawn if
- Assistant