Beispiel #1
0
    /// <summary>
    /// 创建除草奖励
    /// </summary>
    /// <param name="tagePoin"></param>
    void CreationAwardItem(Vector3 tagePoin)
    {
        GameObject  obj  = GameObject.Instantiate(_awardItem.gameObject, transform);
        UIPanelDrag item = obj.GetComponent <UIPanelDrag>();

        item.localPos = tagePoin;
        item.transform.localPosition = tagePoin;
        int   index     = Random.Range(0, _awardItemSprites.Count);
        Image awardIcon = item.GetComponent <Image>();

        awardIcon.sprite = _awardItemSprites[index];
        awardIcon.SetNativeSize();
        Transform trashCanTage = _trashCan[index];

        item.actionOnPointerUp = DragUp;
        if (_showAwardItemDic.ContainsKey(trashCanTage))
        {
            _showAwardItemDic[trashCanTage].Add(item);
        }
        else
        {
            List <UIPanelDrag> uIPanelDrags = new List <UIPanelDrag>();
            uIPanelDrags.Add(item);
            _showAwardItemDic.Add(trashCanTage, uIPanelDrags);
        }
        _allAwards.Add(item);
        item.gameObject.SetActive(true);
        //item.enabled = false;
        if (onece)
        {//创建引导
            createGuidance = () =>
            {
                var        parfab   = ABManager.GetAsset <GameObject>("ChapterGuidance");
                GameObject guidance = GameObject.Instantiate(parfab, transform);
                chapterGuidance = guidance.GetComponent <ChapterGuidance>();
                chapterGuidance.PlayGuidanceAnima(item.transform.localPosition, trashCanTage.transform.localPosition);
            };
            onece = false;
        }
    }
Beispiel #2
0
    private void OnDragOutFromPanel(PointerEventData eventData)
    {
        int seedCount = StaticData.GetWareHouseItem(CropGoodId).GoodNum;

        if (seedCount <= 0)
        {
            //判定金钱
            if (StaticData.GetWareHouseItem(currPlantSeed.coinPriceId).GoodNum < currPlantSeed.price)
            {
                ToBuyCurrency();
                uiPanelDrag.OnEndDrag(eventData);
                return;
            }
        }
        PlantSeedDragComponent plantSeedDragComponent = StaticData.GetUIWorldHandleComponent().plantSeedDragComponent;

        plantSeedDragComponent.gameObject.SetActive(true);
        uiPanelDrag.OnEndDrag(eventData);
        StaticData.GetUIWorldHandleComponent().SetHandleTileUIClose();
        plantSeedDragComponent.GetComponent <Image>().sprite = uiPanelDrag.GetComponent <Image>().sprite;
        plantSeedDragComponent.BeginDrag(this);
    }