/// <summary> /// 指定方向に連続した同タイプのパネル数を取得 /// </summary> public int GetMatchPanelCountDir(Dir dir) { int count = 0; if (AttachedPanel != null) { count = 1; PPPanel.Type type = AttachedPanel.PanelType; PPPanelBlock block = this; while ((block = block.GetLink(dir) as PPPanelBlock) != null && block.AttachedPanel != null && block.AttachedPanel.PanelType == type) { ++count; } } return(count); }
/// <summary> /// タイプが一致するパネルがアタッチされた連続するブロックを取得 /// </summary> private void GetMatchPanelBlocks(ref List <PPPanelBlock> match, PPPanel.Type type, Dir dir, bool first = true) { if (m_Panel == null || m_Panel.IsLocked() || m_Panel.PanelType != type || m_Panel.IsDisturbance) { return; } if (first) { match = new List <PPPanelBlock>(); // 水平方向 if (GetLink(Dir.Left) != null) { (GetLink(Dir.Left) as PPPanelBlock).GetMatchPanelBlocks(ref match, type, Dir.Left, false); } if (GetLink(Dir.Right) != null) { (GetLink(Dir.Right) as PPPanelBlock).GetMatchPanelBlocks(ref match, type, Dir.Right, false); } // 消滅に必要な数に満たない if (match.Count + 1 < PPGame.Config.MinVanishMatchCount) { match.Clear(); } int horizCount = match.Count; // 垂直方向 if (GetLink(Dir.Up) != null) { (GetLink(Dir.Up) as PPPanelBlock).GetMatchPanelBlocks(ref match, type, Dir.Up, false); } if (GetLink(Dir.Down) != null) { (GetLink(Dir.Down) as PPPanelBlock).GetMatchPanelBlocks(ref match, type, Dir.Down, false); } // 消滅に必要な数に満たない if (match.Count - horizCount + 1 < PPGame.Config.MinVanishMatchCount) { match.RemoveRange(horizCount, match.Count - horizCount); } // 自身を追加 if (match.Count > 0) { match.Add(this); } } else { if (match != null) { match.Add(this); } if (GetLink(dir) != null) { (GetLink(dir) as PPPanelBlock).GetMatchPanelBlocks(ref match, type, dir, false); } } }