Пример #1
0
    bool WaterDrop()
    {
        DropBlock();

        if (DropAnimaionCount != 0)
        {
            return(true);
        }



        bool result = false;


        int col = m_MapLoad.GetColCount();
        int row = m_MapLoad.GetRowCount();

        int Interval = col;
        int index    = 0;

        List <int> createPosIndexs = new List <int>();

        for (int i = 0; i < CreateBlockPosition.Count; i++)
        {
            createPosIndexs.Add(m_MapLoad.GetHiveBlockIndex(CreateBlockPosition[i]) / row);
        }

        for (int i = 0; i < row * col; i++)
        {
            if (i % col == 0)
            {
                index++;
            }

            int aryIndex = (index * Interval) - 1;
            aryIndex = (aryIndex) - (i % col);

            GameObject go = m_MapLoad.blocks[aryIndex];

            if (go == null)
            {
                continue;
            }

            if (go.GetComponent <BlockHive>().blockobj == null)
            {
                int blockIndex = m_MapLoad.GetHiveBlockIndex(go);
                int rowIndex   = blockIndex / row;


                if (!createPosIndexs.Contains(rowIndex))
                {
                    if (createPosIndexs[createPosIndexs.Count - 1] < rowIndex)
                    {
                        if (rowIndex % 2 == 1)
                        {
                            if (m_MapLoad.blocks[blockIndex - row] != null && m_MapLoad.blocks[blockIndex - row].GetComponent <BlockHive>().blockobj != null)
                            {
                                int resultValue = FindAbleWaterDropBlock(blockIndex - row);

                                if (resultValue != -1)
                                {
                                    Vector3 path = FindPath(blockIndex, false);

                                    GameObject BlockObj = m_MapLoad.blocks[resultValue].GetComponent <BlockHive>().blockobj.gameObject;
                                    m_MapLoad.blocks[resultValue].GetComponent <BlockHive>().InitData(false);
                                    BlockObj.transform.parent = go.transform;
                                    StartCoroutine(WaterDropAnimation(BlockObj, go, aryIndex, path));

                                    return(true);                                   // result = true;
                                }
                            }
                        }
                        else
                        {
                            if (m_MapLoad.blocks[blockIndex - row - 1] != null && m_MapLoad.blocks[blockIndex - row - 1].GetComponent <BlockHive>().blockobj != null)
                            {
                                int resultValue = FindAbleWaterDropBlock(blockIndex - row - 1);

                                if (resultValue != -1)
                                {
                                    Vector3 path = FindPath(blockIndex, false);

                                    GameObject BlockObj = m_MapLoad.blocks[resultValue].GetComponent <BlockHive>().blockobj.gameObject;
                                    m_MapLoad.blocks[resultValue].GetComponent <BlockHive>().InitData(false);
                                    BlockObj.transform.parent = go.transform;
                                    StartCoroutine(WaterDropAnimation(BlockObj, go, aryIndex, path));

                                    return(true);                                    //result = true;
                                }
                            }
                        }
                    }
                    else if (createPosIndexs[createPosIndexs.Count - 1] > rowIndex)
                    {
                        if (rowIndex % 2 == 1)
                        {
                            if (m_MapLoad.blocks[blockIndex + row] != null && m_MapLoad.blocks[blockIndex + row].GetComponent <BlockHive>().blockobj != null)
                            {
                                int resultValue = FindAbleWaterDropBlock(blockIndex + row);

                                if (resultValue != -1)
                                {
                                    Vector3 path = FindPath(blockIndex, true);

                                    GameObject BlockObj = m_MapLoad.blocks[resultValue].GetComponent <BlockHive>().blockobj.gameObject;
                                    m_MapLoad.blocks[resultValue].GetComponent <BlockHive>().InitData(false);
                                    BlockObj.transform.parent = go.transform;
                                    StartCoroutine(WaterDropAnimation(BlockObj, go, aryIndex, path));

                                    return(true);                                    //result = true;
                                }
                            }
                        }
                        else
                        {
                            if (m_MapLoad.blocks[blockIndex + row - 1] != null && m_MapLoad.blocks[blockIndex + row - 1].GetComponent <BlockHive>().blockobj != null)
                            {
                                int resultValue = FindAbleWaterDropBlock(blockIndex + row - 1);

                                if (resultValue != -1)
                                {
                                    Vector3 path = FindPath(blockIndex, true);

                                    GameObject BlockObj = m_MapLoad.blocks[resultValue].GetComponent <BlockHive>().blockobj.gameObject;
                                    m_MapLoad.blocks[resultValue].GetComponent <BlockHive>().InitData(false);
                                    BlockObj.transform.parent = go.transform;
                                    StartCoroutine(WaterDropAnimation(BlockObj, go, aryIndex, path));

                                    return(true);                                    //result = true;
                                }
                            }
                        }
                    }
                }
            }
        }



        return(result);
    }