IEnumerator SpawnCoroutine() { yield return(new WaitForSeconds(Settings.levelStartDelay)); Level currentLevel = levels.GetLevel(levelID); foreach (var wave in currentLevel.waves) { for (int i = 0; i < wave.mobs.Length; i++) { for (int k = 0; k < wave.mobs[i].count; k++) { PhotonNetwork.Instantiate(wave.mobs[i].mob, GetRandomPosition(), Quaternion.identity); } } yield return(new WaitForSeconds(wave.delay)); } yield return(new WaitUntil(() => EnemyMovement.enemyCount < 1)); yield return(new WaitForSeconds(Settings.levelStartDelay)); //player finished the level PlayerManager.localPlayer.currentLevel++; ReturnToTavern(); }
public void CreateLevelButtons() { if (levelButtonPrefab == null) { return; } for (int i = 0; i < LevelDatabase.GetLevelsLength(); i++) { GameObject levelButtonClone = Instantiate(levelButtonPrefab) as GameObject; levelButtonClone.transform.SetParent(levelPanelContent, false); LevelData levelData = LevelDatabase.GetLevel(i); Sprite sprite = Resources.Load(levelImagePath + levelData.title, typeof(Sprite)) as Sprite; Image image = levelButtonClone.GetComponent <Image> (); if (image != null) { image.sprite = sprite; } LevelButton levelButton = levelButtonClone.GetComponent <LevelButton> (); levelButton.SetLevelButton(levelData); } }
void PlayerReady() { totalPlayersReady++; UpdateText(); if (totalPlayersReady >= PhotonNetwork.CurrentRoom.PlayerCount) { if (PhotonNetwork.IsMasterClient) { var level = levelDatabase.GetLevel(PlayerManager.localPlayer.currentLevel); Debug.LogFormat("Switching to next scene: {0}", level.SceneName); PhotonNetwork.LoadLevel(level.SceneName); } } }