public void SpawnAllObjects() { foreach (var obj in objects) { spawnCondition = obj.GetComponent <SpawnCondition>(); bool isDenied = true; bool isAccepted = false; int denyAttempt = 0, acceptAttempt = 0; Vector3 desiredPosition = new Vector3(); //Check priority spawn for X times. Only on first iteration. while (acceptAttempt < spawnCondition.acceptRetry) { desiredPosition = RandomisePos(); isAccepted = FieldIsAccepted(spawnCondition.acceptRange, desiredPosition); isDenied = FieldIsDenied(spawnCondition.denyRange, desiredPosition); //If field passed if (isAccepted && !isDenied) { acceptAttempt = spawnCondition.acceptRetry; } else { desiredPosition = RandomisePos(); acceptAttempt++; isDenied = true; isAccepted = false; } } //If priority spawn failed //true && 0 , [1] denied, 1, [2] denied, 2, [3] denied, 3 while (isDenied && denyAttempt != spawnCondition.denyRetry) { desiredPosition = RandomisePos(); isDenied = FieldIsDenied(spawnCondition.denyRange, desiredPosition); if (isDenied) { denyAttempt++; } } if (!isDenied) { SpawnObject(obj, desiredPosition); } //else //Debug.Log($"Couldn't spawn {obj.name}!"); } }
public virtual void Start() { condition = GetComponent<SpawnCondition>(); }
public BossData SetSlowChance(SpawnCondition condition, double chance) { ConditionSlow = condition; SlowChance = chance; return(this); }
public BossData SetFastChance(SpawnCondition condition, double chance) { ConditionFast = condition; FastChance = chance; return(this); }
public virtual void Start() { condition = GetComponent <SpawnCondition>(); }