public void GenerateBrick() { this.RemainingBricks = new List <Brick>(); int[,] currentLevelMatrix = this.levels[this.currentLevel]; float currentX = _firstBrickX; float currentY = _firstBrickY; for (int i = 0; i < this._maxRows; i++) { for (int j = 0; j < this._maxCols; j++) { int brickType = currentLevelMatrix[i, j]; if (brickType > 0) { Brick newBrick = Instantiate(_brickPrefab, new Vector3(currentX, currentY, -6), Quaternion.identity); newBrick.Init(_bricksContainer.transform, this.mats[brickType - 1], this.colors[brickType - 1], brickType); this.RemainingBricks.Add(newBrick); } currentX += _shiftX; if (j + 1 == this._maxCols) { currentX = _firstBrickX; } } currentY -= _shiftY; } this.initialBrickNo = this.RemainingBricks.Count; LevelLoaded?.Invoke(); }
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) { if (Instance == this) { LevelLoaded?.Invoke(arg0.buildIndex); } }
private void OnRequestNewLevel(int levelNum) { PlayAreaController.Instance.playAreaHolder.rotation = Quaternion.identity; if (currentLevelObject != null) { Destroy(currentLevelObject); } if (levelNum == -1) { currentLevel++; } else { currentLevel = levelNum; } if (currentLevel >= levelsList.allLevels.Count) { currentLevel = 0; } currentLevelDefine = levelsList.allLevels[currentLevel]; if (overrideLevelList) { currentLevelDefine = overrideDefine; } currentLevelObject = Instantiate(currentLevelDefine.level, playAreaHolder); Level _newLevel = currentLevelObject.GetComponent <Level>(); _newLevel.Init(); levelLoaded.Invoke(_newLevel); }
private void OnLevelLoadComplete(AsyncOperationHandle <SceneInstance> handle) { if (handle.Status != AsyncOperationStatus.Succeeded) { return; } _loaded = true; _sceneHandle = handle; LevelLoaded?.Invoke(); }
public void LoadLevel(LevelType levelType) { if (_currentLevel != null) { GameObject.Destroy(_currentLevel); LevelUnloaded?.Invoke(); } _currentLevel = GameObject.Instantiate(Data.Instance.LevelData.GetPrefab(levelType)); Services.Instance.LevelService.CurrentLevel = levelType; Time.timeScale = 1; LevelLoaded?.Invoke(); }
private void Start() { if (instance != null && instance != this) { Destroy(this.gameObject); } else { instance = this; } if (LevelLoaded.GetPersistentEventCount() > 0) { LevelLoaded.Invoke(); } }
private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (scene == gameObject.scene) { return; } if (!scene.IsValid()) { return; } var isCommon = scene.path == gameScene.ScenePath; var isMainMenu = scene.path == mainMenuScene.ScenePath; if (!isCommon) { loadingScreen.Show(false, true); } // Start network things when game scene is loaded. if (isCommon) { var nm = FindObjectOfType <NetworkManager>(); nm.ServerConfig = serverConfig; nm.StartNet(this, NetworkMode, ServerAddress); if (nm.Client is NetworkClient nc) { nc.StatusChanged += OnNetworkStatus; } return; } // Set last loaded level as active scene. SceneManager.SetActiveScene(scene); if (isMainMenu) { FindObjectOfType <MainMenu>().Preferences = Preferences; return; } LevelLoaded?.Invoke(this, scene.name); }
public void SetMap(LevelStats levelStats) { _levelStats = levelStats; LevelLoaded?.Invoke(this, new LevelLoadedArgs(_levelStats)); }
public void ResetLevel() { Utils.ScoreCounter.ResetScore(); Utils.PickupSpawner.ResetState(); LevelLoaded?.Invoke(); }
private void Start() { LevelLoaded?.Invoke(); }
protected virtual void OnLevelLoaded(string level) { LevelLoaded?.Invoke(this, level); }