Exemple #1
0
        private void SetBlock(int x, int y, PanelData data)
        {
            BlockBase blockBase = null;

            switch (data.type)
            {
            case Enums.EPanelType.WALL:
                var wall = Wall.CreateInstance();
                wall.SetPattern(data.adjacentWallPattern);
                blockBase = wall;
                break;

            case Enums.EPanelType.JEWEL:
                var jewel = ShapeBlock.CreateInstance();
                jewel.MoveShapeBlockObservable.Subscribe(t => MoveShapeBlock(t.Item1, t.Item2));
                jewel.CheckClearObservable.Subscribe(unit => CheckLevelComplete());
                blockBase = jewel;
                break;

            case Enums.EPanelType.GOAL:
                break;
            }
            if (blockBase == null)
            {
                return;
            }

            blockBase.transform.SetParent(blockLayer);
            blockBase.transform.localScale = Vector3.one;
            blockBase.SetBoardPosition(x, y);
            blockBase.SetColor(data.color);
            blockBase.SetFootType(this.floorList[x, y]);
            this.blockList[x, y] = blockBase;
        }
Exemple #2
0
        private void MoveShapeBlock(ShapeBlock target, Enums.EDirection direction)
        {
            if (IsBlockMoving)
            {
                return;
            }

            var targetPos = blockList.GetPosition(target);
            var pos       = targetPos;
            var stageSize = this.blockList.size;

            switch (direction)
            {
            case Enums.EDirection.UP:
                do
                {
                    var next = pos.Up();
                    if (!this.blockList[next].IsEmpty())
                    {
                        break;
                    }
                    pos = next;
                } while (pos.y > 0);
                break;

            case Enums.EDirection.DOWN:
                do
                {
                    var next = pos.Down();
                    if (!this.blockList[next].IsEmpty())
                    {
                        break;
                    }
                    pos = next;
                } while (pos.y < stageSize.y - 1);
                break;

            case Enums.EDirection.LEFT:
                do
                {
                    var next = pos.Left();
                    if (!this.blockList[next].IsEmpty())
                    {
                        break;
                    }
                    pos = next;
                } while (pos.x > 0);
                break;

            case Enums.EDirection.RIGHT:
                do
                {
                    var next = pos.Right();
                    if (!this.blockList[next].IsEmpty())
                    {
                        break;
                    }
                    pos = next;
                } while (pos.x < stageSize.x - 1);
                break;
            }
            if (targetPos == pos)
            {
                return;
            }
            target.MoveBoardPosition(pos);
            this.blockList.Exchange(targetPos, pos);
            target.SetFootType(this.floorList[pos]);
        }