public void PlayBack(WaypointsList waypointsList) { if (waypointsList.Waypoints.Count <= 0) { return; } PlayBackList = waypointsList; transform.localScale = Vector3.zero; MoveTo(PlayBackList.GetWayPoint(0).position); CurrentIndex = 0; }
IEnumerator SpawnAllWaves() { //checa qual a wave que começa e inicia a coroutine de spawn de todos os inimigos for (int waveIndex = startingWave; waveIndex < waypointsList.Count; waveIndex++) { currentWave = waypointsList[waveIndex]; //if (!GameController.instance.GameOver) { yield return(StartCoroutine(SpawnAllEnemiesInWave(currentWave))); } } }
private IEnumerator SpawnAllEnemiesInWave(WaypointsList waypointsLists) { //instancia cada inimigo de uma vez indicado no scriptable object e informa qual waypoint deve seguir for (int enemyNumber = 1; enemyNumber <= waypointsLists.GetEnemyNumber(); enemyNumber++) { var newEnemy = Instantiate(waypointsLists.GetEnemyPrefab(), waypointsLists.GetWaypoints()[0].transform.position, Quaternion.identity); newEnemy.GetComponent <EnemyPath>().SetWaveConfig(waypointsLists); yield return(new WaitForSeconds(waypointsLists.GetTimeBetweenSpawn() + waypointsLists.GetSpawnRandomFactor())); } yield return(new WaitForSeconds(waypointsLists.GetTimeNextWave())); RepeatWave(); }
//checa a ultima wave da lista para repetir a lista void RepeatWave() { int lastWave = waypointsList.Count; print(lastWave); if (currentWave == waypointsList[lastWave - 1]) { lastWave = 0; currentWave = waypointsList[0]; if (!GameController.instance.GameOver) { StartCoroutine(SpawnAllWaves()); } } }
// Start is called before the first frame update void Start() { persistentCoordinates.OnPersistentCoordinatesInitialized += OnPersistentCoordinatesInitialized; string json = null; try { json = System.IO.File.ReadAllText(@"/documents/C1/waypoints.json"); if (json.Length != 0) { WaypointsList = JsonUtility.FromJson <WaypointsList>(json); } } catch (Exception e) { Debug.LogError(e); } Debug.Log("Load JSON:" + json); }
void OnPersistentCoordinatesInitialized(Transform transform, string uid) { Debug.Log("Loaded PCF:" + uid); if (WaypointsList == null) { WaypointsList = new WaypointsList(transform); WaypointsList.pcfUid = uid; } else if (uid == WaypointsList.pcfUid) { WaypointsList.SetTransform(transform); for (int i = 0; i < WaypointsList.Waypoints.Count; i++) { Pose pose = WaypointsList.GetWayPoint(i); Instantiate(WaypointObjPrefab, pose.position, pose.rotation); } } if (!IsAdded) { MLInput.OnControllerButtonDown += OnButtonDown; IsAdded = true; } }
//coloca a configuração da wave com o waypoint public void SetWaveConfig(WaypointsList waveConfig) { this.waypointScriptableObject = waveConfig; }