Пример #1
0
    /// <summary>
    /// 展示奖励
    /// </summary>
    void ShowAward()
    {
        //Debug.Log("展示奖励");
        if (_prizes != null && _currShowDataIndex < _prizes.Count)
        {
            CSWareHouseStruct data = _prizes[_currShowDataIndex];
            //Debug.Log("奖品展示:" + data.GoodId);
            _showMoveGiftItem.transform.localPosition = Vector3.zero;
            _showMoveGiftItem.ShowPrize(data);
            _showMoveGiftItem.Show(true);

            ReceiveAwardGiftItemController item = GameObject.Instantiate(_receiveAwardGiftItemController, _giftBoxTra).GetComponent <ReceiveAwardGiftItemController>();
            item.ShowPrize(data);
            item.Show(false);
            _receiveAwardGiftItemControllers.Add(item);
            _currShowDataIndex++;
            LayoutRebuilder.ForceRebuildLayoutImmediate(_giftBoxTra.GetComponent <RectTransform>());
            StartCoroutine(ItemShowMove(item));
        }
        else
        {
            //Debug.Log("奖品展示完毕");
            StopAllCoroutines();
            _maskBtn.enabled = true;
        }
    }
Пример #2
0
    /// <summary>
    /// 移动item
    /// </summary>
    /// <param name="tage"></param>
    /// <returns></returns>
    IEnumerator ItemShowMove(ReceiveAwardGiftItemController tage)
    {
        RectTransform rect = tage.transform.GetComponent <RectTransform>();

        Camera  tageCamera = transform.parent.parent.Find("UICamera").GetComponent <Camera>();
        Vector3 vector3    = tageCamera.WorldToScreenPoint(new Vector3(rect.position.x, rect.position.y, rect.position.z));

        Vector2 tageVector = Vector3.zero;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(_showMoveGiftItem.transform.GetComponent <RectTransform>(), vector3, tageCamera, out tageVector);
        //Debug.Log("移动目标:" + tageVector);
        //Debug.Log("当前目标:" + _showMoveGiftItem.transform.localPosition);
        while (Vector3.Distance(_showMoveGiftItem.transform.localPosition, tageVector) > 0.1f)
        {
            _showMoveGiftItem.transform.localPosition = Vector3.MoveTowards(_showMoveGiftItem.transform.localPosition, tageVector, 100f);
            yield return(new WaitForSeconds(0.01f));
        }
        //Debug.Log("奖品移动完毕");
        _showMoveGiftItem.Show(false);
        tage.Show(true);
        ShowAward();
    }