Пример #1
0
    void PutGoodInCart(Good3D good)
    {
        if (GameMrg.mInstance.curBuyGoodList.Contains(good.goodInfo))
        {
            GameMrg.mInstance.LoadPopUpTip("已经购买了!");
            return;
        }

        if (GameMrg.mInstance.curBuyGoodList.Count >= GameMrg.mInstance.curTask.goodList.Count)
        {
            GameMrg.mInstance.LoadPopUpTip("已达购买最大数目限制");
            return;
        }

        GameMrg.mInstance.curBuyGoodList.Add(good.goodInfo);

        if (good.moveObj == null)
        {
            return;
        }

        //复制一个放在购物车中
        GameObject copyObj = Instantiate(good.moveObj) as GameObject;

        copyObj.transform.parent        = transPos [0].parent;
        copyObj.transform.localPosition = transPos [GameMrg.mInstance.curBuyGoodList.Count - 1].localPosition;

        Good3DCopy goodCopy = copyObj.AddComponent <Good3DCopy> ();

        goodCopy.good3d = good;
        copyGoodList.Add(goodCopy);

        //隐藏货架上的物品
        good.moveObj.SetActive(false);
    }
Пример #2
0
    public void RemoveGood3D(Good goodInfo)
    {
        //查找对应的good3d
        Good3D curGood3d = null;

        for (int i = 0; i < good3DArray.Length; i++)
        {
            if (good3DArray [i].goodInfo == goodInfo)
            {
                curGood3d = good3DArray [i];
                break;
            }
        }

        if (curGood3d == null)
        {
            Debug.Log("删除的物品在商店中未找到!");
            return;
        }

        //还原显示货架上的物品
        if (curGood3d.moveObj != null)
        {
            curGood3d.moveObj.SetActive(true);
        }

        Good3DCopy desCy = null;

        for (int i = 0; i < copyGoodList.Count; i++)
        {
            if (copyGoodList [i].good3d == curGood3d)
            {
                desCy = copyGoodList[i];
                break;
            }
        }

        if (desCy != null)
        {
            Destroy(desCy.gameObject);
        }
    }