Exemple #1
0
    void RemoveGemstone(Gemstone c)
    {
        Debug.Log("RemoveGemstone");
        c.ClearGemstone();
        //audiosource.PlayOneShot(Match3Sound);
        for (int i = c.RowIndex + 1; i < RowNumber; i++)
        {
            Gemstone tmpgemstone = GetGemstone(i, c.ColIndex);
            tmpgemstone.RowIndex--;
            SetGemstone(tmpgemstone.RowIndex, tmpgemstone.ColIndex, tmpgemstone);
            tmpgemstone.TweenToPosition(tmpgemstone.RowIndex, tmpgemstone.ColIndex);//tmpgemstone.UpdatePosition(tmpgemstone.RowIndex,tmpgemstone.ColIndex);
        }

        Gemstone newgemstone = CreateGemstone(RowNumber, c.ColIndex);

        newgemstone.RowIndex--;
        SetGemstone(newgemstone.RowIndex, newgemstone.ColIndex, newgemstone);
        newgemstone.TweenToPosition(newgemstone.RowIndex, newgemstone.ColIndex);//newgemstone.UpdatePosition(newgemstone.RowIndex,newgemstone.ColIndex);
    }
Exemple #2
0
    void RemoveGemstone(Gemstone c)
    {
        c.Dispose();
        audio.PlayOneShot(match3Clip);
        for (int i = c.rowIndex + 1; i < rowNum; i++)
        {
            Gemstone tempGemstone = GetGemstone(i, c.columIndex);
            tempGemstone.rowIndex--;
            SetGemstone(tempGemstone.rowIndex, tempGemstone.columIndex, tempGemstone);
            //tempGemstone.UpdatePosition(tempGemstone.rowIndex, tempGemstone.columIndex);
            tempGemstone.TweenToPosition(tempGemstone.rowIndex, tempGemstone.columIndex);
        }

        Gemstone newGemstone = AddGemstone(rowNum, c.columIndex);

        newGemstone.rowIndex--;
        SetGemstone(newGemstone.rowIndex, newGemstone.columIndex, newGemstone);
        //newGemstone.UpdatePosition(newGemstone.rowIndex, newGemstone.columIndex);
        newGemstone.TweenToPosition(newGemstone.rowIndex, newGemstone.columIndex);
    }
Exemple #3
0
    /// <summary>
    /// 消除一个宝石
    /// </summary>
    /// <param name="g"></param>
    private void RemoveGemstone(Gemstone g)
    {
        g.Dispose();

        //消除并下降
        for (int i = g.rowIndex + 1; i < rowNum; i++)
        {
            Gemstone tempGemstone = GetGemstone(i, g.columIndex);
            tempGemstone.rowIndex--;
            SetGemStone(tempGemstone.rowIndex, tempGemstone.columIndex, tempGemstone);
            tempGemstone.TweenToPosition(tempGemstone.rowIndex, tempGemstone.columIndex);
        }

        //生成新的宝石
        Gemstone newGemstone = AddGemstone(rowNum, g.columIndex);

        newGemstone.rowIndex--;
        SetGemStone(newGemstone.rowIndex, newGemstone.columIndex, newGemstone);
        newGemstone.TweenToPosition(newGemstone.rowIndex, newGemstone.columIndex);
    }
Exemple #4
0
    /// <summary>
    /// 交换位置和数据
    /// </summary>
    /// <param name="g1"></param>
    /// <param name="g2"></param>
    public void ExChange(Gemstone g1, Gemstone g2)
    {
        SetGemStone(g1.rowIndex, g1.columIndex, g2);
        SetGemStone(g2.rowIndex, g2.columIndex, g1);

        //交换行号和列号并开始位置动画
        int tempRowIndex, tempColumeIndex;

        tempRowIndex    = g1.rowIndex;
        tempColumeIndex = g1.columIndex;

        g1.rowIndex   = g2.rowIndex;
        g1.columIndex = g2.columIndex;

        g2.rowIndex   = tempRowIndex;
        g2.columIndex = tempColumeIndex;

        g1.TweenToPosition(g1.rowIndex, g1.columIndex);
        g2.TweenToPosition(g2.rowIndex, g2.columIndex);
    }
Exemple #5
0
    void ExchangeGemstone(Gemstone c1, Gemstone c2)
    {
        SetGemstone(c1.RowIndex, c1.ColIndex, c2);
        SetGemstone(c2.RowIndex, c2.ColIndex, c1);

        int tmprowindex;

        tmprowindex = c1.RowIndex;
        c1.RowIndex = c2.RowIndex;
        c2.RowIndex = tmprowindex;

        int tmpcolindex;

        tmpcolindex = c1.ColIndex;
        c1.ColIndex = c2.ColIndex;
        c2.ColIndex = tmpcolindex;

        c1.TweenToPosition(c1.RowIndex, c1.ColIndex); //c1.UpdatePosition (c1.RowIndex, c1.ColIndex);
        c2.TweenToPosition(c2.RowIndex, c2.ColIndex); //c2.UpdatePosition (c2.RowIndex, c2.ColIndex);
    }
Exemple #6
0
    //very important: this function is: REMOVE+ GENERATE new gemstones
    //only responsible for individual spawning, should not know anything about the chain number, RemoveMatches() should know the chain number
    //the prioerSpawnContainer has the highest spawn priority
    void RemoveGemstone(Gemstone c)     //删除宝石
    //Debug.Log("删除宝石");
    {
        c.Dispose();
        //play sound
        this.gameObject.GetComponent <AudioSource> ().PlayOneShot(match3Clip);
        //all the gemstones fall
        for (int i = c.rowIndex + 1; i < rowNum; i++)
        {
            Gemstone temGemstone = GetGemstone(i, c.columIndex);
            temGemstone.rowIndex--;
            SetGemstone(temGemstone.rowIndex, temGemstone.columIndex, temGemstone);
            //temGemstone.UpdatePosition(temGemstone.rowIndex,temGemstone.columIndex);
            temGemstone.TweenToPosition(temGemstone.rowIndex, temGemstone.columIndex);
        }


        //START SPAWNING
        Gemstone newGemstone;

        //check the priorSpawninfo, if has anything, spawn upgraded gems first
        if (priorSpawnInfo.Count != 0)
        {
            //Debug.Log ("has prior spawns  " + priorSpawnInfo.Count);
            //Debug.Log ("the chain is : " + matchesGemstone.Count);
            newGemstone = AddUpgradedGemstone(rowNum, c.columIndex, matchesGemstone.Count, priorSpawnInfo[0]);
            priorSpawnInfo.RemoveAt(0);
            //Debug.Log ("remove complete "+ priorSpawnInfo.Count);
        }
        else
        {
            newGemstone = AddRegularGemstone(rowNum, c.columIndex);
        }


        newGemstone.rowIndex--;
        SetGemstone(newGemstone.rowIndex, newGemstone.columIndex, newGemstone);
        //newGemstone.UpdatePosition (newGemstone.rowIndex, newGemstone.columIndex);
        newGemstone.TweenToPosition(newGemstone.rowIndex, newGemstone.columIndex);
    }
Exemple #7
0
    public void Exchange(Gemstone c1, Gemstone c2)    //实现宝石交换位置
    {
        this.gameObject.GetComponent <AudioSource> ().PlayOneShot(swapClip);
        SetGemstone(c1.rowIndex, c1.columIndex, c2);
        SetGemstone(c2.rowIndex, c2.columIndex, c1);
        //交换c1,c2的行号
        int tempRowIndex;

        tempRowIndex = c1.rowIndex;
        c1.rowIndex  = c2.rowIndex;
        c2.rowIndex  = tempRowIndex;
        //交换c1,c2的列号
        int tempColumIndex;

        tempColumIndex = c1.columIndex;
        c1.columIndex  = c2.columIndex;
        c2.columIndex  = tempColumIndex;

        //c1.UpdatePosition (c1.rowIndex, c1.columIndex);
        //c2.UpdatePosition (c2.rowIndex, c2.columIndex);
        c1.TweenToPosition(c1.rowIndex, c1.columIndex);
        c2.TweenToPosition(c2.rowIndex, c2.columIndex);
    }
Exemple #8
0
    //实现宝石之间交换位置
    public void Exchange(Gemstone c1, Gemstone c2)
    {
        audio.PlayOneShot(swapClip);
        SetGemstone(c1.rowIndex, c1.columIndex, c2);
        SetGemstone(c2.rowIndex, c2.columIndex, c1);

        //交换c1和c2的行号
        int tempRowIndex = c1.rowIndex;

        c1.rowIndex = c2.rowIndex;
        c2.rowIndex = tempRowIndex;

        //交换c1和c2的列号
        int tempColumIndex = c1.columIndex;

        c1.columIndex = c2.columIndex;
        c2.columIndex = tempColumIndex;

        //c1.UpdatePosition(c1.rowIndex, c1.columIndex);
        //c2.UpdatePosition(c2.rowIndex, c2.columIndex);

        c1.TweenToPosition(c1.rowIndex, c1.columIndex);
        c2.TweenToPosition(c2.rowIndex, c2.columIndex);
    }
Exemple #9
0
    public void Exchange2(Gemstone c1, Gemstone c2)     //实现宝石交换位置  , c1: original, c2: destination
    {
        int originalRow   = c1.rowIndex;
        int originalColum = c1.columIndex;
        int destRow       = c2.rowIndex;
        int destColum     = c2.columIndex;



        if (c1.rowIndex == c2.rowIndex)           //when they are on the same ROW, we are modifying and comparing the columns

        {
            int tempGemNum = Mathf.Abs(c1.columIndex - c2.columIndex);
            if ((c1.columIndex - c2.columIndex) < 0)                //if the original gem is moving upward, affected gems move downwards

            {
                for (int i = 0; i < tempGemNum; i++)                                 //except the original c1, all affected gems move 1 down
                {
                    Gemstone temp = GetGemstone(c1.rowIndex, c1.columIndex + 1 + i); //because the original one is at below, 向上遍历
                    SetGemstone(temp.rowIndex, temp.columIndex - 1, temp);
                    temp.columIndex -= 1;
                    //finally the visual tween move
                    temp.TweenToPosition(temp.rowIndex, temp.columIndex);
                }
                //play sound effect
                StartCoroutine(playClip(swapClip, tempGemNum));
            }
            else                // when the original gem is moving downwards, affected gems move upwards

            {
                for (int i = 0; i < tempGemNum; i++)                                 //except the original c1, all affected gems move 1 down
                {
                    Gemstone temp = GetGemstone(c1.rowIndex, c1.columIndex - 1 - i); //同理,向下遍历
                    SetGemstone(temp.rowIndex, temp.columIndex + 1, temp);
                    temp.columIndex += 1;
                    //finally the visual tween move
                    temp.TweenToPosition(temp.rowIndex, temp.columIndex);
                }
                //play sound effect
                StartCoroutine(playClip(swapClip, tempGemNum));
            }
        }
        if (c1.columIndex == c2.columIndex)                   //when they are on the same COLUM, we are modifying and comparing the rows

        {
            int tempGemNum2 = Mathf.Abs(c1.rowIndex - c2.rowIndex);
            if ((c1.rowIndex - c2.rowIndex) < 0)                        //if the original gem is moving upward, affected gems move downwards

            {
                for (int i = 0; i < tempGemNum2; i++)                                //except the original c1, all affected gems move 1 down
                {
                    Gemstone temp = GetGemstone(c1.rowIndex + 1 + i, c1.columIndex); //because the original one is at below, 向上遍历
                    SetGemstone(temp.rowIndex - 1, temp.columIndex, temp);
                    temp.rowIndex -= 1;
                    //finally the visual tween move
                    temp.TweenToPosition(temp.rowIndex, temp.columIndex);
                }
                //play sound effect
                StartCoroutine(playClip(swapClip, tempGemNum2));
            }
            else                        // when the original gem is moving downwards, affected gems move upwards

            {
                for (int i = 0; i < tempGemNum2; i++)                                //except the original c1, all affected gems move 1 down
                {
                    Gemstone temp = GetGemstone(c1.rowIndex - 1 - i, c1.columIndex); //同理,向下遍历
                    SetGemstone(temp.rowIndex + 1, temp.columIndex, temp);
                    temp.rowIndex += 1;
                    //finally the visual tween move
                    temp.TweenToPosition(temp.rowIndex, temp.columIndex);
                }
                //play sound effect
                StartCoroutine(playClip(swapClip, tempGemNum2));
            }
        }

        SetGemstone(destRow, destColum, c1);
        c1.rowIndex   = destRow;
        c1.columIndex = destColum;
        //finally the visual tween move
        c1.TweenToPosition(c1.rowIndex, c1.columIndex);
        //play sound effect
        //audi.PlayOneShot (swapClip);

        exchangeBack = GetGemstone(originalRow, originalColum);
        //	c1.TweenToPosition (c1.rowIndex, c1.columIndex);
        //c2.TweenToPosition (c2.rowIndex, c2.columIndex);
    }