Exemple #1
0
    /// <summary>
    /// 最下段のドロップがあるブロックを取得
    /// </summary>
    private MDDropBlock GetMostUnderFullBlock(int row, bool ignoreReserve = true)
    {
        MDDropBlock block = m_Lines[0][row];

        while (block != null && block.AttachedDrop == null && (ignoreReserve || block.ReservedDrop == null))
        {
            block = block.GetLink(PlayAreaBlock.Dir.Up) as MDDropBlock;
        }
        return(block);
    }
Exemple #2
0
    /// <summary>
    /// ドロップをプッシュ
    /// </summary>
    public void PushDrop(int row)
    {
        if (row < 0 || row >= Width || !IsValidPush())
        {
            return;
        }

        // 最下段のドロップがあるブロックの下のブロックを取得
        MDDropBlock block = GetMostUnderFullBlock(row, false);

        block = block == null ? m_Lines[m_Lines.Count - 1][row] : block.GetLink(PlayAreaBlock.Dir.Down) as MDDropBlock;

        for (int i = 0; i < m_PulledDrop.Count; i++)
        {
            // ターゲットブロックが無ければ空のラインを追加
            if (block == null)
            {
                AddEmptyLine(true);
                block = m_Lines[0][row];
            }

            // 消滅可能
            m_PulledDrop[i].IsValidVanish = true;
            // プッシュ登録
            m_PulledDrop[i].IsPushed = true;
            // 即座に消えるプッシュ
            m_PulledDrop[i].IsMatchPushed = m_PulledDrop.Count >= MDGame.Config.MinVanishMatchCount;

            // 予約
            block.Reserve(m_PulledDrop[i]);

            // プッシュ
            m_PushingDrops.Add(m_PulledDrop[i]);
            m_PulledDrop[i].BeginPush(Game.Player.transform.position + Vector3.down * i * BlockSize);

            block = block.GetLink(PlayAreaBlock.Dir.Down) as MDDropBlock;
        }
        m_PulledDrop.Clear();
    }
Exemple #3
0
    /// <summary>
    /// ドロップをプル
    /// </summary>
    public bool PullDrop(int row)
    {
        if (row < 0 || row >= Width || !IsValidPull(row))
        {
            return(false);
        }

        int count = 0;
        // 最下段のドロップがあるブロックを取得
        MDDropBlock block = GetMostUnderFullBlock(row, false);

        if (block != null)
        {
            MDDrop drop = null;
            while (block != null && block.IsAttachOrReserved)
            {
                bool reserveDrop = block.ReservedDrop != null;
                drop = reserveDrop ? block.ReservedDrop : block.AttachedDrop;
                if ((!drop.IsLocked() || reserveDrop) && (m_PulledDrop.Count == 0 || drop.DropType == m_PulledDrop[0].DropType))
                {
                    if (reserveDrop)
                    {
                        drop.CancelState();
                        block.CancelReserve();
                    }
                    else
                    {
                        block.Detach();
                    }

                    drop.BeginPull(Game.Player as MDPlayer);

                    m_PulledDrop.Add(drop);

                    block = block.GetLink(PlayAreaBlock.Dir.Up) as MDDropBlock;
                    ++count;
                }
                else
                {
                    break;
                }
            }
        }

        return(count > 0);
    }