Ejemplo n.º 1
0
    public void Start()
    {
        onSliceMesh.AddListener((o, upper) => {
            o.GetComponent <MDSmelt>().value = 0;
            Destroy(o.GetComponent <MDSmelt>());
            if (upper)
            {
                MDDrop mdDrop  = o.GetComponent <MDDrop>();
                mdDrop.enabled = true;
                StartCoroutine(CoroutineUtils.Chain(
                                   CoroutineUtils.LinearAction(mdDrop.dropTime, (w) => {
                    mdDrop.value = w;
                }),
                                   CoroutineUtils.Do(() => {
                    o.GetComponent <Rigidbody>().useGravity = true;
                })
                                   ));
            }
            else
            {
                MeshDeformation[] md        = o.GetComponents <MeshDeformation>();
                MeshDeformationExtent[] mde = o.GetComponents <MeshDeformationExtent>();

                for (int i = 0; i < md.Length; i++)
                {
                    Destroy(md[i]);
                }

                for (int i = 0; i < mde.Length; i++)
                {
                    Destroy(mde[i]);
                }
            }
        });
    }
Ejemplo n.º 2
0
 /// <summary>
 /// デタッチ
 /// </summary>
 public void Detach()
 {
     if (m_Drop != null)
     {
         m_Drop.Block = null;
         m_Drop       = null;
     }
     m_Reserve = false;
 }
Ejemplo n.º 3
0
    /// <summary>
    /// アタッチ予約
    /// </summary>
    public void Reserve(MDDrop drop)
    {
        m_Drop    = drop;
        m_Reserve = true;

        if (m_Drop != null)
        {
            m_Drop.Block = this;
        }
    }
Ejemplo n.º 4
0
    /// <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);
        }
    }
Ejemplo n.º 5
0
 /// <summary>
 /// ドロップ除外
 /// </summary>
 public void RemoveDrop(MDDrop drop)
 {
     foreach (MDDropBlock[] line in m_Lines)
     {
         foreach (MDDropBlock block in line)
         {
             if (block.AttachedDrop == drop || block.ReservedDrop == drop)
             {
                 block.Detach();
                 m_UnusedDrops.Add(drop);
                 return;
             }
         }
     }
 }
Ejemplo n.º 6
0
    /// <summary>
    /// アタッチ
    /// </summary>
    public void Attach(MDDrop drop, bool updateDropPosition = false)
    {
        m_Drop    = drop;
        m_Reserve = false;

        if (m_Drop != null)
        {
            m_Drop.Block = this;

            if (updateDropPosition)
            {
                m_Drop.transform.position = Position;
            }
        }
    }
Ejemplo n.º 7
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);
    }
Ejemplo n.º 8
0
    /// <summary>
    /// ドロップを詰める
    /// </summary>
    public void CloseDrop()
    {
        MDDropBlock emptyBlock = null;
        MDDrop      drop       = null;

        // 奥からチェック
        for (int i = m_Lines.Count - 1; i >= 0; i--)
        {
            foreach (MDDropBlock block in m_Lines[i])
            {
                if (block.ReservedDrop != null || (block.AttachedDrop != null && block.AttachedDrop.CurrentState != MDDrop.State.Vanish))
                {
                    // 上方向の空ブロック取得
                    emptyBlock = block.GetFarthestEmptyBlock(PlayAreaBlock.Dir.Up);

                    // 空ブロックを予約
                    if (emptyBlock != null)
                    {
                        // アタッチされてたドロップ
                        if (block.AttachedDrop != null)
                        {
                            drop = block.AttachedDrop;
                            block.Detach();
                            emptyBlock.Reserve(drop);

                            drop.IsValidVanish = true;

                            // 上詰め開始
                            drop.BeginClose();
                        }
                        // 予約されてたドロップ
                        else
                        {
                            drop = block.ReservedDrop;
                            block.CancelReserve();
                            emptyBlock.Reserve(drop);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 9
0
 /// <summary>
 /// プッシュ終了イベント
 /// </summary>
 public void PushEndEvent(MDDrop drop)
 {
     m_PushingDrops.Remove(drop);
 }
Ejemplo n.º 10
0
    /// <summary>
    /// ライン追加
    /// </summary>
    public void AddNewLine()
    {
        // 空のラインを追加
        AddEmptyLine(false);

        MDDrop drop = null;

        foreach (MDDropBlock block in m_Lines[m_Lines.Count - 1])
        {
            // ドロップ再利用
            if (m_UnusedDrops.Count > 0)
            {
                drop = m_UnusedDrops[0];
                m_UnusedDrops.RemoveAt(0);
            }
            // ドロップ生成
            else
            {
                drop = Instantiate(DropTemplate, transform).GetComponent <MDDrop>();
                drop.transform.SetParent(m_BlockParent.transform, false);
                m_Drops.Add(drop);
            }

            // 初期化
            drop.Initialize(this);

            // アタッチ
            block.Attach(drop, true);
        }

        // 2本以上空のラインがあったら1本残して消す
        int  emptyLineCount = 0;
        bool empty          = true;

        for (int i = 0; i < m_Lines.Count; i++)
        {
            foreach (MDDropBlock block in m_Lines[i])
            {
                if (block.IsAttachOrReserved)
                {
                    empty = false;
                    break;
                }
            }
            if (!empty)
            {
                break;
            }
            ++emptyLineCount;
        }
        if (emptyLineCount >= 2)
        {
            for (int i = 0; i < emptyLineCount - 1; i++)
            {
                foreach (MDDropBlock block in m_Lines[1])
                {
                    block.SetLink(null, PlayAreaBlock.Dir.Down);
                }
                m_Lines.RemoveAt(0);
            }
        }
    }