Exemplo n.º 1
0
    //新建糖果
    private Candy NewCandy(int col, int row, Vector3 sPos, _TYPE ptype, int type_Index)
    {
        Candy ca = this.reuseCandy(ptype, type_Index);

        if (null == ca)
        {
            //
            GameObject go = Instantiate(T) as GameObject;
            //
            Sprite sprite = this.getSpecialSprite(ptype, type_Index);
            //
            SpriteRenderer sr = go.GetComponent <SpriteRenderer>();
            sr.sprite = sprite;
            //
            if (null != go)
            {
                go.transform.parent   = this.transform;
                go.transform.position = sPos;
                ca           = go.GetComponent(typeof(Candy)) as Candy;
                ca.mIndex    = type_Index;
                ca.mType     = ptype;
                ca.isSpecial = (!(ptype == _TYPE.NORMAL));
                ca.mPos      = new Vector3(BVector.x + col * xOff, BVector.y + row * yOff, 0);
                ca.mRow      = row;
                ca.mCol      = col;
                ca.AttachEventCallback(ac.ExchangeEventCallback);
            }
        }
        else
        {
            ca.gameObject.SetActive(true);
            ca.gameObject.transform.position = sPos;
            ca.isSpecial = (!(ptype == _TYPE.NORMAL));
            ca.mPos      = new Vector3(BVector.x + col * xOff, BVector.y + row * yOff, 0);
            ca.mRow      = row;
            ca.mCol      = col;
            ca.setDark(false);
            ca.setChosen(false);
        }
        //
        return(ca);
    }