Ejemplo n.º 1
0
    /// <summary>
    /// 落下可能?
    /// </summary>
    public bool IsValidFall()
    {
        if (IsDisturbance && Block != null)
        {
            // 最下段の水平方向の連結妨害パネルブロックを取得
            List <PPPanel> links;
            List <PPPanel> horizontal       = new List <PPPanel>();
            PPPanel        mostUnderDisturb = GetEndDisturb(PlayAreaBlock.Dir.Down);
            horizontal.Add(mostUnderDisturb);
            mostUnderDisturb.GetDisturbLinks(out links, PlayAreaBlock.Dir.Left);
            horizontal.AddRange(links);
            mostUnderDisturb.GetDisturbLinks(out links, PlayAreaBlock.Dir.Right);
            horizontal.AddRange(links);

            // 最下段の連結妨害パネルの直下が空ブロックか調べる
            foreach (PPPanel disturb in horizontal)
            {
                if (disturb.Block != null)
                {
                    PPPanelBlock underBlock = disturb.Block.GetLink(PlayAreaBlock.Dir.Down) as PPPanelBlock;
                    if (underBlock != null && underBlock.AttachedPanel != null)
                    {
                        return(false);
                    }
                }
            }
        }

        return(true);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 妨害パネル分解
    /// </summary>
    public int Dissolve(int dissolveCount = 0)
    {
        if (m_State == State.None && IsDisturbance)
        {
            PPPanel bottomRight = null;
            bottomRight = GetEndDisturb(PlayAreaBlock.Dir.Down);
            bottomRight = bottomRight.GetEndDisturb(PlayAreaBlock.Dir.Right);

            // 全連結妨害パネルを取得
            List <PPPanel>      disturbances = new List <PPPanel>();
            List <PPPanelBlock> arounds      = new List <PPPanelBlock>();
            List <PPPanel>      vertical     = null;
            List <PPPanel>      horizontal   = null;
            // 右下から上端にかけてのパネル
            bottomRight.GetDisturbLinks(out vertical, PlayAreaBlock.Dir.Up);
            vertical.Insert(0, bottomRight);
            int line = 0;
            foreach (PPPanel vertPanel in vertical)
            {
                // 右端から左端にかけてのパネル
                vertPanel.GetDisturbLinks(out horizontal, PlayAreaBlock.Dir.Left);
                horizontal.Insert(0, vertPanel);
                foreach (PPPanel horizPanel in horizontal)
                {
                    disturbances.Add(horizPanel);

                    // 水平方向の周囲のブロックを保持
                    if (line == 0 && horizPanel.Block != null)
                    {
                        arounds.Add(horizPanel.Block.GetLink(PlayAreaBlock.Dir.Down) as PPPanelBlock);
                    }
                    if (line == vertical.Count - 1 && horizPanel.Block != null)
                    {
                        arounds.Add(horizPanel.Block.GetLink(PlayAreaBlock.Dir.Up) as PPPanelBlock);
                    }
                }

                // 垂直方向の周囲のブロックを保持
                if (horizontal.Count > 0)
                {
                    if (horizontal[0].Block != null)
                    {
                        arounds.Add(horizontal[0].Block.GetLink(PlayAreaBlock.Dir.Right) as PPPanelBlock);
                    }
                    if (horizontal[horizontal.Count - 1].Block != null)
                    {
                        arounds.Add(horizontal[horizontal.Count - 1].Block.GetLink(PlayAreaBlock.Dir.Left) as PPPanelBlock);
                    }
                }

                ++line;
            }

            // 全連結妨害パネルを分解準備
            int currentCount = 0;
            foreach (PPPanel panel in disturbances)
            {
                if (panel.StandbyDissolve())
                {
                    ++currentCount;
                }
            }

            // 連結妨害パネルと接している別の妨害パネルも分解
            foreach (PPPanelBlock block in arounds)
            {
                if (block != null && block.AttachedPanel != null && block.AttachedPanel.IsDisturbance)
                {
                    currentCount += block.AttachedPanel.Dissolve(dissolveCount + currentCount);
                }
            }

            // 全連結妨害パネルを分解
            float delay   = dissolveCount * PPGame.Config.PanelDissolveDelay;
            float endTime = delay + currentCount * PPGame.Config.PanelDissolveDelay;
            foreach (PPPanel panel in disturbances)
            {
                panel.BeginDissolve(panel.m_DisturbLinks[(int)PlayAreaBlock.Dir.Down] == null, delay, endTime);
                delay += PPGame.Config.PanelDissolveDelay;
            }

            return(currentCount);
        }

        return(0);
    }