/// <summary> /// 指定数分の隣接ブロック取得 /// </summary> public void GetLinks(out List <PlayAreaBlock> links, Dir dir, int count, bool includeSelf) { PlayAreaBlock block = this; links = new List <PlayAreaBlock>(); if (includeSelf) { links.Add(block); } for (int i = 0; i < count; i++) { block = block.GetLink(dir); if (block != null) { if (dir == Dir.Left || dir == Dir.Up) { links.Insert(0, block); } else { links.Add(block); } } else { break; } } }
/// <summary> /// 各方向にある連続したブロック数取得 /// </summary> public int GetLinkCount(Dir dir) { int count = 0; PlayAreaBlock block = this; while ((block = block.GetLink(dir)) != null) { ++count; } return(count); }
/// <summary> /// 隣接ブロック取得 /// </summary> public PlayAreaBlock GetLink(Dir dir, int distance) { PlayAreaBlock block = this; for (int i = 0; i < distance; i++) { block = block.GetLink(dir); if (block == null) { break; } } return(block); }
/// <summary> /// 最も遠い空ブロックを取得 /// </summary> public MDDropBlock GetFarthestEmptyBlock(Dir dir) { PlayAreaBlock emptyBlock = null; PlayAreaBlock block = GetLink(dir); while (block != null && !(block as MDDropBlock).IsAttachOrReserved) { emptyBlock = block; block = block.GetLink(dir); } return(emptyBlock as MDDropBlock); }
/// <summary> /// 縦方向に繋がった同タイプドロップ数を取得 /// </summary> public void GetVerticallMatchDropCount(out int count, out int validVanishCount, out bool existsPushedDrop, out bool forceVanish) { count = 0; validVanishCount = 0; existsPushedDrop = false; forceVanish = false; if (AttachedDrop == null) { return; } PlayAreaBlock block = this; MDDrop drop = null; Dir dir = Dir.Up; for (int i = 0; i < 2; i++) { while (block != null) { drop = (block as MDDropBlock).AttachedDrop; if (drop != null && drop.DropType == AttachedDrop.DropType && !drop.IsLocked()) { ++count; if (drop.IsValidVanish) { ++validVanishCount; } if (drop.IsPushed) { existsPushedDrop = true; } if (drop.IsMatchPushed) { forceVanish = true; } block = block.GetLink(dir); } else { break; } } dir = Dir.Down; block = GetLink(dir); } }
/// <summary> /// 妨害パネル解除 /// </summary> private void UnsetDisturbance() { IsDisturbance = false; m_SpriteRenderer.color = Color.white; // 連結情報破棄 for (int i = 0; i < m_DisturbLinks.Length; i++) { if (m_DisturbLinks[i] != null) { m_DisturbLinks[i].m_DisturbLinks[(int)PlayAreaBlock.ConvertReverseDir((PlayAreaBlock.Dir)i)] = null; m_DisturbLinks[i] = null; } } }
/// <summary> /// 隣接ブロック登録 /// </summary> public void SetLink(PlayAreaBlock block, Dir dir) { m_Links[(int)dir] = block; }