Esempio n. 1
0
    void GetNeighbour()
    {
        int ColumnIndex = FirstHex.parent.GetSiblingIndex();
        int RowIndex    = FirstHex.GetSiblingIndex();


        if (RightColumn)
        {
            if (ColumnIndex != Xrow - 1)
            {
                Transform NeighbourRight = this.transform.GetChild(ColumnIndex + 1);
                if (RowIndex % 2 != 0)
                {
                    OddOrEvenCheck = NeighbourRight;
                }
                else if (RowIndex % 2 == 0)
                {
                    OddOrEvenCheck = FirstHex.parent;
                }
                if (DownRow && RowIndex != 0)
                {
                    SecoundHex = OddOrEvenCheck.GetChild(RowIndex - 1);
                    ThirdHex   = NeighbourRight.GetChild(RowIndex);
                }
                else if (DownRow && RowIndex == 0)
                {
                    SecoundHex = OddOrEvenCheck.GetChild(RowIndex + 1);
                    ThirdHex   = NeighbourRight.GetChild(RowIndex);
                }
                else if (!DownRow && RowIndex != Yrow - 1)
                {
                    SecoundHex = OddOrEvenCheck.GetChild(RowIndex + 1);
                    ThirdHex   = NeighbourRight.GetChild(RowIndex);
                }
                else if (!DownRow && RowIndex == Yrow - 1)
                {
                    SecoundHex = OddOrEvenCheck.GetChild(RowIndex - 1);
                    ThirdHex   = NeighbourRight.GetChild(RowIndex);
                }
                PlayAnim = true;
                ShowSelected();
                pos1         = FirstHex.transform.position;
                pos2         = SecoundHex.transform.position;
                pos3         = ThirdHex.transform.position;
                index1       = FirstHex.GetSiblingIndex();
                index2       = SecoundHex.GetSiblingIndex();
                index3       = ThirdHex.GetSiblingIndex();
                column1index = FirstHex.parent;
                column2index = SecoundHex.parent;
                column3index = ThirdHex.parent;
            }
            else if (ColumnIndex == Xrow - 1)
            {
                PlayAnim    = true;
                RightColumn = false;
                GetNeighbour();
            }
        }
        else if (!RightColumn)
        {
            if (ColumnIndex != 0)
            {
                Transform NeighbourLeft = this.transform.GetChild(ColumnIndex - 1);
                if (RowIndex % 2 != 0)
                {
                    OddOrEvenCheck = FirstHex.parent;
                }
                else if (RowIndex % 2 == 0)
                {
                    OddOrEvenCheck = NeighbourLeft;
                }

                if (DownRow && RowIndex != 0)
                {
                    SecoundHex = OddOrEvenCheck.GetChild(RowIndex - 1);
                    ThirdHex   = NeighbourLeft.GetChild(RowIndex);
                }
                else if (DownRow && RowIndex == 0)
                {
                    SecoundHex = OddOrEvenCheck.GetChild(RowIndex + 1);
                    ThirdHex   = NeighbourLeft.GetChild(RowIndex);
                }
                else if (!DownRow && RowIndex != Yrow - 1)
                {
                    SecoundHex = OddOrEvenCheck.GetChild(RowIndex + 1);
                    ThirdHex   = NeighbourLeft.GetChild(RowIndex);
                }
                else if (!DownRow && RowIndex == Yrow - 1)
                {
                    SecoundHex = OddOrEvenCheck.GetChild(RowIndex - 1);
                    ThirdHex   = NeighbourLeft.GetChild(RowIndex);
                }
                PlayAnim = true;
                ShowSelected();
                pos1         = FirstHex.transform.position;
                pos2         = SecoundHex.transform.position;
                pos3         = ThirdHex.transform.position;
                index1       = FirstHex.GetSiblingIndex();
                index2       = SecoundHex.GetSiblingIndex();
                index3       = ThirdHex.GetSiblingIndex();
                column1index = FirstHex.parent;
                column2index = SecoundHex.parent;
                column3index = ThirdHex.parent;
            }
            else if (ColumnIndex == 0)
            {
                PlayAnim    = true;
                RightColumn = true;
                GetNeighbour();
            }
        }
    }