コード例 #1
0
    public void PopUpBillboard(BillboardController src)
    {
        foreach (var item in OnStageBillboard)
        {
            if (item == null)
            {
                continue;
            }

            BillboardController _ctrl = item.GetComponent <BillboardController>();
            if (_ctrl == null)
            {
                continue;
            }

            if (src == _ctrl)
            {
                IncreaseSortLayer();
                _ctrl.SetToForeground(sortZ);
            }
            else
            {
                _ctrl.SetToBackground(beBackgroundColor);
            }
        }
    }
コード例 #2
0
    public BillboardController FindBillboardWithTerm(string term)
    {
        foreach (var item in OnStageBillboard)
        {
            if (item == null)
            {
                continue;
            }
            BillboardController atlasData = item.GetComponent <BillboardController>();
            if (atlasData == null)
            {
                continue;
            }
            if (atlasData.BelongAtlas == null)
            {
                continue;
            }

            if (atlasData.BelongAtlas.characterTerm == term)
            {
                return(atlasData);
            }
        }
        return(null);
    }
コード例 #3
0
    public void ResumeBillboardPop()
    {
        foreach (var item in OnStageBillboard)
        {
            if (item == null)
            {
                continue;
            }

            BillboardController _ctrl = item.GetComponent <BillboardController>();
            if (_ctrl == null)
            {
                continue;
            }

            IncreaseSortLayer();
            _ctrl.SetToForeground(sortZ);
        }
    }
コード例 #4
0
    public virtual void ShowBillboard(BillboardOptions options)
    {
        //正常情況下,擷取 來自位置 以及 目標位置
        GameObject fromOb = GetPosition(options.toDistance, options.fromPosition);
        GameObject toOb   = GetPosition(options.toDistance, options.toPosition);

        // LeanTween doesn't handle 0 duration properly
        float durationFade = (options.fadeDuration > 0f) ? options.fadeDuration : float.Epsilon;
        // LeanTween doesn't handle 0 duration properly
        float durationMove = (options.moveDuration > 0f) ? options.moveDuration : float.Epsilon;

        //淡出已存在於位置上的舊立繪
        GameObject oldObj = GetBillboardOnStage(options.toPosition);

        if (oldObj != null)
        {
            DicedSpriteRenderer oldRect = oldObj.GetComponent <DicedSpriteRenderer>();
            if (oldRect != null)
            {
                DOTween.To(() => oldRect.Color, x => oldRect.Color = x, new Color(1, 1, 1, 0), durationFade).SetEase(tweenEaseType).OnComplete(() => {
                    Destroy(oldRect.gameObject);
                });
            }
            SpriteRenderer oldRectEnemy = oldObj.GetComponent <SpriteRenderer>();
            if (oldRectEnemy != null)
            {
                DOTween.To(() => oldRectEnemy.color, x => oldRectEnemy.color = x, new Color(1, 1, 1, 0), durationFade).SetEase(tweenEaseType).OnComplete(() => {
                    Destroy(oldRectEnemy.gameObject);
                });
            }
        }

        //新立繪進來
        if (options.billboardDiceSprite != null)
        {
            //以'來自位置'取出 Stage 上的 位置 , 並以此當作新的立繪存在於場景
            GameObject tempGO = null;

            //當選用座標偏移移動時,取代掉 from來自位置
            if (options.shiftIntoPlace && options.move)
            {
                //複製一份TO, 用以代替 from 來進行 offset 滑入
                tempGO = Instantiate(toOb) as GameObject;
                tempGO.transform.position =
                    new Vector2(tempGO.transform.position.x + options.shiftOffset.x,
                                tempGO.transform.position.y + options.shiftOffset.y);
            }
            else
            {
                //一般狀況, 使用 from 訊息
                tempGO = GameObject.Instantiate(fromOb);
                if (!options.move)
                {
                    tempGO.transform.position = ShiftPosition(tempGO.transform.position, options);
                }
            }

            tempGO.transform.SetParent(transform, false);
            //tempGO.transform.localPosition = Vector3.zero;
            //tempGO.transform.localScale = fromRT.transform.localScale;
            tempGO.name = options.billboardDiceSprite.name;
            //啟用物件,複製出來時預設為關閉
            tempGO.SetActive(true);
            //設置SortOrder, 以Z 軸來 sort
            IncreaseSortLayer();
            tempGO.transform.position += new Vector3(0, 0, sortZ);

            //設置立繪圖案,一開始給透明
            DicedSpriteRenderer tempImage = tempGO.GetComponent <DicedSpriteRenderer>();
            tempImage.DicedSprite = options.billboardDiceSprite;
            tempImage.Color       = new Color(1f, 1f, 1f, 0f);

            //設置 Atlas
            BillboardController tempAtlas = tempGO.GetComponent <BillboardController>();
            tempAtlas.BelongAtlas = options.billboardDiceAtlas;
            if (tempAtlas.BelongAtlas == null)
            {
                Debug.Log("動態立繪 Atlas 設置失敗, 以純立繪使用");
            }

            //處理翻轉選項
            if (options.flipFace == true)
            {
                tempGO.transform.localScale = new Vector3(-tempGO.transform.localScale.x, tempGO.transform.localScale.y, tempGO.transform.localScale.z);
            }

            //Do Alpha Tween 淡入場璟
            //LeanTween.alpha(tempGO, 1f, durationFade).setEase(stage.FadeEaseType).setRecursive(false);
            DOTween.To(() => tempImage.Color, x => tempImage.Color = x, new Color(1, 1, 1, 1), durationFade).SetEase(tweenEaseType);

            //Do Move Tween 滑入場景
            //LeanTween.move(tempGO, toOb.transform.position, durationMove).setEase(stage.FadeEaseType);
            Vector3 posTo = toOb.transform.position + new Vector3(0, 0, sortZ);
            posTo = ShiftPosition(posTo, options);
            tempGO.transform.DOMove(posTo, durationMove).SetEase(tweenEaseType);
            if (options.waitUntilFinished)
            {
                waitTimer = Mathf.Max(durationMove, durationFade);
            }

            //Save Upload billboard to stage
            SetBillboardOnStage(options.toPosition, tempGO);
        }

        //Call Contunue with Wait until Finished
        FinishCommand(options);
    }