Files
forest/Assets/scripts/GameRules.cs
2022-09-04 11:34:51 +03:00

26 lines
693 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameRules : MonoBehaviour
{
public int MaxLevelSticks;
[HideInInspector] public GameObject[] SticksInWorld;
[HideInInspector] public GameObject[] stickSpawner;
StickSpawner bebra;
void Start()
{
stickSpawner = GameObject.FindGameObjectsWithTag("Spawner");
}
private void FixedUpdate()
{
SticksInWorld = GameObject.FindGameObjectsWithTag("stick");
if (MaxLevelSticks > SticksInWorld.Length)
{
stickSpawner[Random.Range(0, stickSpawner.Length)].GetComponent<StickSpawner>().CreateStick();
}
}
}