Example #1
0
    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}!");
        }
    }
Example #2
0
	public virtual void Start()
	{
        condition = GetComponent<SpawnCondition>();
    }
Example #3
0
 public BossData SetSlowChance(SpawnCondition condition, double chance)
 {
     ConditionSlow = condition;
     SlowChance    = chance;
     return(this);
 }
Example #4
0
 public BossData SetFastChance(SpawnCondition condition, double chance)
 {
     ConditionFast = condition;
     FastChance    = chance;
     return(this);
 }
Example #5
0
 public virtual void Start()
 {
     condition = GetComponent <SpawnCondition>();
 }