Example #1
0
        protected override void OnUpdate()
        {
            if (boardModel == null || gameStateModel.State != Match3State.MatchesFall)
            {
                return;
            }

            for (int x = 0; x < boardModel.BoardWidth; x++)
            {
                if (boardModel.HasEntityAt(new int2(x, boardModel.BoardHeight - 1)) == false)
                {
                    var levelConfig   = gameStateModel.GetCurrentLevelConfig();
                    var boardPosition = new int2(x, boardModel.BoardHeight);
                    var spawnPosition = BoardCalculator.ConvertBoardPositionToTransformPosition(boardPosition);
                    if (HasGemInProximityInColumn(x, spawnPosition))
                    {
                        continue;
                    }

                    var entity = EntitiesHelper.CreateGem(EntitiesHelper.GetRandomColor(levelConfig.availableColors),
                                                          BoardCalculator.ConvertBoardPositionToTransformPosition(boardPosition), boardPosition);

                    signalBus.Fire(new Match3Signals.GemCreatedSignal(entity, BoardCalculator.ConvertBoardPositionToTransformPosition(boardPosition)));
                    EntityManager.AddComponent <IsFallingComponent>(entity);
                }
            }
        }
Example #2
0
        public void Execute(ChangeLevelSignal changeLevelSignal)
        {
            gameStateModel.CurrentLevelIndex = changeLevelSignal.Level;
            swarmModel.Create(gameStateModel.GetCurrentLevelConfig());
            playerShipModel.Reset();

            signalBus.Fire <StartLevelSignal>();
        }
Example #3
0
        public void Execute(Match3Signals.CreateBoardSignal createBoardSignal)
        {
            Debug.Log("Create board -> " + gameStateModel.State);
            var levelConfig = gameStateModel.GetCurrentLevelConfig();

            playerScoreModel.Reset();
            playerScoreModel.Turns = levelConfig.Turns;
            boardModel.ResetBoard(levelConfig);
            BoardCalculator.InitBoardSize(boardModel.BoardWidth, boardModel.BoardHeight);
            CreateGems(levelConfig);
            signalBus.Fire <Match3Signals.OnBoardCreatedSignal>();
        }