コード例 #1
0
ファイル: GameController.cs プロジェクト: Wuziyi12/3xiao
    void ExchangeGemstoneNoEffect(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.UpdatePosition(c1.RowIndex, c1.ColIndex);
        c2.UpdatePosition(c2.RowIndex, c2.ColIndex);
    }
コード例 #2
0
    /// <summary>
    /// 删除宝石
    /// </summary>
    /// <param name="c">要删除的宝石</param>
    void RemoveGemstone(Gemstone c)
    {
        if (c == null)
        {
            return;
        }
        c.Dispose();
        gameObject.GetComponent <AudioSource>().PlayOneShot(match3Clip);
        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);
        }
        Gemstone newGemstone = AddGemstone(rowNum, c.columIndex);

        newGemstone.rowIndex--;
        SetGemstone(newGemstone.rowIndex, newGemstone.columIndex, newGemstone);
        newGemstone.UpdatePosition(newGemstone.rowIndex, newGemstone.columIndex);
    }
コード例 #3
0
    /// <summary>
    /// 实现宝石交换位置
    /// </summary>
    /// <param name="c1"></param>
    /// <param name="c2"></param>
    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.TweenToPostion(c1.rowIndex, c1.columIndex);
        //c2.TweenToPostion(c2.rowIndex, c2.columIndex);
    }