Esempio n. 1
0
        public void InitLevelData(int lvl)
        {
            Level    = lvl;
            FlyCount = 0;
            foreach (Transform child in _stageBubbParent)
            {
                Destroy(child.gameObject);
            }
            var tunning = GameCfg.LevelTunnings[lvl];

            StageAnchorData    = new StageAnchorData(tunning.StageType);
            _background.sprite = GameCfg.Backgrounds[UnityRandom.Range(0, GameCfg.Backgrounds.Length)];
            InitLevelStage();
        }
Esempio n. 2
0
        private void MoveBubbDown()
        {
            var count       = GameConstant.MoveDownRowNum;
            var lastMoveRow = GameConstant.StageRowCount - count;
            var emptyRows   = StageNodeData.GetRange(lastMoveRow, count);

            StageNodeData.RemoveRange(lastMoveRow, count);
            StageNodeData.InsertRange(0, emptyRows);

            // 更新锚点数据
            for (var row = 0; row < StageNodeData.Count; ++row)
            {
                var rowCount = StageAnchorData.GetRowAnchorsCount(row);
                for (var col = 0; col < rowCount; ++col)
                {
                    var node = StageNodeData[row][col];
                    node.Row       = row;
                    node.Col       = col;
                    node.AnchorPos = StageAnchorData[row, col];
                }
            }

            // 重设现有泡泡位置
            _stageBubbParent.GetComponentsInChildren(_bubbsCache);
            foreach (var bubble in _bubbsCache)
            {
                bubble.transform.position = bubble.StageNode.AnchorPos;
            }

            // 为空生成新的泡泡
            for (var row = count - 1; row >= 0; --row)
            {
                for (var col = 0; col < StageNodeData[row].Count; ++col)
                {
                    var node = StageNodeData[row][col];

                    var bubbType = GameCfg.LevelTunnings[Level].StageBubbWeights.SelectByWeight();
                    // 必需填充或者随机到填充,则填充
                    if (IsMustFillNode(node) || GameCfg.LevelTunnings[Level].UnNecessaryFillRatio >= UnityRandom.value)
                    {
                        node.BubbType = bubbType;
                        SpawnStageBubble(node);
                    }
                }
            }
        }
Esempio n. 3
0
        private void InitLevelStage()
        {
            // 数据
            foreach (var row in StageNodeData)
            {
                row.Clear();
            }
            var lvlTunning = GameCfg.LevelTunnings[Level];
            var initBubbs  = lvlTunning.InitBubles;

            for (var row = 0; row < StageNodeData.Count; ++row)
            {
                var rowCount = StageAnchorData.GetRowAnchorsCount(row);
                for (var col = 0; col < rowCount; ++col)
                {
                    var cfgClr = row < initBubbs.GetLength(0) ? initBubbs[row, col] : BubbType.Empty;
                    if (cfgClr == BubbType.Colorful)
                    {
                        cfgClr = BubbTypeUtil.GetRandomStageType();
                    }
                    var node = new StageNode {
                        Row = row, Col = col, BubbType = cfgClr, AnchorPos = StageAnchorData[row, col]
                    };
                    StageNodeData[row].Add(node);
                }
            }

            foreach (var rowNodes in StageNodeData)
            {
                foreach (var node in rowNodes)
                {
                    SpawnStageBubble(node);
                }
            }

            _gamePanel.Reset();
        }