First off I am not sure if this is the right place for this question but when I tried unity answers the reCaptcha said: ERROR for site owner:
Invalid domain for site key
Okay so here is the code I have but I keep getting these 2 errors
Assets/Scripts/WaveSystem.cs(64,25): error CS1525: Unexpected symbol (', expecting
,‘, ;', or
=’
AND
Assets/Scripts/WaveSystem.cs(102,0): error CS1525: Unexpected symbol `}’
Can someone please help tell me what is wrong----
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WaveSystem : MonoBehaviour {
public enum SpawnState { SPAWNING, WAITING, COUNTING };
[System.Serializable]
public class Wave
{
public string name;
public Transform enemy;
public int count;
public float rate;
}
public Wave[] waves;
private int nextWave = 0;
public float timeBetweenWaves = 5f;
public float waveCountdown;
private float searchCountdown = 1f;
private SpawnState state = SpawnState.COUNTING;
void Start()
{
waveCountdown = timeBetweenWaves;
}
void Update()
{
if (state == SpawnState.WAITING)
{
if (!EnemyIsAlive())
{
Debug.Log("WaveComplete");
}
else
{
return;
}
}
if (waveCountdown <= 0)
{
if (state != SpawnState.SPAWNING)
{
StartCoroutine(SpawnWave(waves[nextWave]));
}
else
{
waveCountdown -= Time.deltaTime;
}
}
bool EnemyIsAlive()
{
searchCountdown -= Time.deltaTime;
if (searchCountdown <= 0f)
{
searchCountdown = 1f;
if (GameObject.FindGameObjectsWithTag("Enemy") == null)
{
return false;
}
}
return true;
}
IEnumerator SpawnWave(Wave _wave)
{
Debug.Log("Spawning Wave:" + _wave.name);
state = SpawnState.SPAWNING;
for (int i = 0; i < _wave.count; i++)
{
SpawnEnemy(_wave.enemy);
yield return new WaitForSeconds( 1f/_wave.rate);
}
state = SpawnState.WAITING;
yield break;
}
void SpawnEnemy(Transform _enemy)
{
Instantiate(_enemy, transform.position, transform.rotation);
Debug.Log("Spawing Enemy: " + _enemy.name);
}
}
}