Exemple #1
0
    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();
    }
Exemple #2
0
 private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
 {
     if (Instance == this)
     {
         LevelLoaded?.Invoke(arg0.buildIndex);
     }
 }
Exemple #3
0
    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();
 }
Exemple #5
0
 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();
 }
Exemple #6
0
 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);
    }
Exemple #8
0
 public void SetMap(LevelStats levelStats)
 {
     _levelStats = levelStats;
     LevelLoaded?.Invoke(this, new LevelLoadedArgs(_levelStats));
 }
Exemple #9
0
 public void ResetLevel()
 {
     Utils.ScoreCounter.ResetScore();
     Utils.PickupSpawner.ResetState();
     LevelLoaded?.Invoke();
 }
Exemple #10
0
 private void Start()
 {
     LevelLoaded?.Invoke();
 }
Exemple #11
0
 protected virtual void OnLevelLoaded(string level)
 {
     LevelLoaded?.Invoke(this, level);
 }