private IEnumerator WaitHide()
    {
        yield return(waitTime);

        tweener = DOTween.To(() => canvasGroup.alpha, x => canvasGroup.alpha = x, 0, hideTime);
        tweener.OnComplete(() => { gameObject.SetActive(false); });
    }
    private void DoTweenMoneyEffect(int index)
    {
        //Logger.LogWarp.LogError("DoTweenMoneyEffect " + index + " " + m_TargetPosition + " " + moveTime);
        MoneyEffectData data = m_MoneyEffectChildList[index];

        data.Trans.localScale = scale;
        //Vector2 p2 = Vector2.zero;
        Vector2 p2 = data.Trans.position;

        //if (tweenPos != null)
        //{
        //    if (tweenPos.IsPlaying())
        //    {
        //        tweenPos.Complete();
        //    }
        //    tweenPos.Kill();

        //}

        tweenPos = DOTween.To(() => p2, x => p2 = x, m_TargetPosition, moveTime);
        tweenPos.SetEase(Ease.InSine);
        //data.effect.SetActive(true);
        //Debug.Log("m_TargetPosition=" + m_TargetPosition);
        tweenPos.OnUpdate(() =>
        {
            //Logger.LogWarp.LogError(data.Trans.name + " " + p2);
            data.Trans.position = p2;
        });
        tweenPos.OnComplete(() =>
        {
            //Logger.LogWarp.LogError("tweenPos.OnComplete " + m_CurPlayCount + " " + m_MaxCount);
            data.Trans.localScale = Vector3.zero;

            m_CurPlayCount++;
            //EventManager.Trigger(EventEnum.MoneyEffectPlayUpdate, m_MoneyType);
            //ShakePhone.ShakeLight();
            if ((m_CurPlayCount + 1) >= m_MaxCount)
            {
                m_CurPlayCount = 0;
                switch (m_MoneyType)
                {
                case MoneyType.Diamond:
                    m_DiamondEffectObj.SetActive(true);
                    break;

                case MoneyType.Money:
                    m_MoneyEffectObj.SetActive(true);
                    break;

                case MoneyType.Physic:
                    physicEffectObj.SetActive(true);
                    break;
                }

                RunCoroutine.Run(PlayCompleteEffect());
            }
        });
    }
Ejemplo n.º 3
0
 public void StartTimeMeter()
 {
     timeMeterImage.fillAmount = 0.0f;
     _timerTween = timeMeterImage.DOFillAmount(1.0f, 10.0f);
     _timerTween.OnComplete(() =>
     {
         GameLogic.GetInstance().NotifyTimesUp();
         timesUp.Invoke();
     });
 }
Ejemplo n.º 4
0
    public void FlyInDirection(Vector3 directFly)
    {
        m_directFly  = directFly;
        m_raycastHit = Physics2D.CircleCast(transform.position, m_radius, m_directFly, 100f, m_layerMaskVaCham);

        Vector3 destination = m_raycastHit.point + m_raycastHit.normal * m_radius;  //điểm cuối cách 1 khoảng bằng radius, để bóng ko đi xuyên qua tường hoặc khối

        m_tweener = transform.DOMove(destination, m_raycastHit.distance / m_flySpeed);
        m_tweener.SetEase(Ease.Linear);
        m_tweener.OnComplete(() => OnDoMoveComplete());
        m_ballState = BallState.Flying;
    }
Ejemplo n.º 5
0
        /// <summary>
        /// change the position in the current scene
        /// </summary>
        /// <param name="_idxPos"> my new position </param>
        /// <param name="_length"> number of LL </param>
        /// <param name="_duration"> duration of action </param>
        public void ChangePos(int _idxPos, int _length, float _duration)
        {
            mCollider.enabled = false;
            Vector3 newPos = CalculatePos(_idxPos, _length);

            Vector3 dist = (gameObject.transform.position - newPos) / 2;

            Vector3 pivot = gameObject.transform.position - dist;

            //dist is only on x
            float radius = dist.x + 0.1f;

            float accuracy = 4f;

            for (int i = 1; i <= accuracy; ++i)
            {
                Vector3 p = Vector3.zero;
                p   += pivot;
                p.x += Mathf.Cos(3.14f * (i / accuracy)) * radius;
                p.z += Mathf.Sin(3.14f * (i / accuracy)) * radius;

                positions.Add(p);
            }


            PlayAnimation(LLAnimationStates.LL_walking);
            mLetter.SetWalkingSpeed(1);
            mLetter.HasFear = true;

            transform.DOLookAt(positions[0], 1f);

            TweenerCore <Vector3, Path, PathOptions> value = transform.DOPath(positions.ToArray(), _duration, PathType.CatmullRom);

            value.OnWaypointChange(delegate(int wayPoint) {
                if (wayPoint < positions.Count)
                {
                    transform.DOLookAt(positions[wayPoint], 1f);
                }
            });
            value.OnComplete(delegate {
                transform.DOLookAt(transform.position + Vector3.back, 1f);
                positions.Clear();
                PlayAnimation(m_oDefaultIdleAnimation);
                mCollider.enabled = true;
            });
        }
Ejemplo n.º 6
0
    public void RevokeBall()
    {
        if (m_ballState == BallState.Flying)
        {
            m_ballState = BallState.Revoking;
            m_tweener.Kill();

            Vector3 pos = m_gun.transform.position;
            pos.x = transform.position.x;
            float distance = Vector3.Distance(transform.position, pos);
            m_tweener = transform.DOMove(pos, distance / m_flySpeed); //bay thẳng xuống cái đã
            m_tweener.SetEase(Ease.Linear);
            m_tweener.OnComplete(() =>
            {
                FinishFly();
            });
        }
    }
Ejemplo n.º 7
0
    public void Launch(GrenadeEffect effect, Vector2 target, Transform playerPosition, Action callBack)
    {
        this.effect   = effect;
        this.callBack = callBack;
        TweenerCore <Vector3, Vector3, VectorOptions> moveTween = this.transform.DOMove(target, 1f);

        moveTween.OnStart(() => this.transform.DOScale(3, .5f).OnComplete(() => this.transform.DOScale(2, .5f)));
        moveTween.OnComplete(() =>
        {
            this.transform.DOPunchScale(Vector3.one, .2f);
            Vector3 direction   = (this.transform.position - playerPosition.position).normalized;
            Vector2 newPosition = this.transform.position - (direction);
            //Vector2 newPosition = playerPosition;

            xx = StartCoroutine(GrenadeClockingLoop(target, playerPosition, Random.Range(0.2f, 2.5f), 10));
            damageAreaIndicator.SetActive(true);
            animator.SetTrigger("clocking");
        });
    }
Ejemplo n.º 8
0
    private void StartMoveToTarget(Vector3 target)
    {
        if (isStunned)
        {
            return;
        }
        if (startGameManager.inSetup)
        {
            return;
        }
        start       = transform.position;
        this.target = new Vector3(target.x, transform.position.y, target.z);
        startDist   = Vector3.Distance(start, this.target);
        SetMoving(true);
        transform.LookAt(this.target);

        //TODO with sequence to lerp up then steady then down
        if (moveTween != null && moveTween.IsPlaying())
        {
            moveTween.SetTarget(this.target);
            moveTween.ChangeValues(start, this.target, startDist / speed);
        }
        else
        {
            moveTween = transform.DOMove(this.target, startDist / speed);
            moveTween.OnUpdate(() => {
                var t = (Mathf.Sin(moveTween.ElapsedPercentage().Remap(0, 1, -Mathf.PI + Mathf.PI / 2, Mathf.PI + Mathf.PI / 2)) + 1) / 2.0f;
                animator.SetFloat("Speed", t);

                if (!isMoving || isStunned)
                {
                    moveTween.Kill();
                }
            });
            moveTween.OnComplete(() => {
                SetMoving(false);
            });
            moveTween.OnKill(() => {
                SetMoving(false);
            });
        }
    }
Ejemplo n.º 9
0
 public void Show(bool b)
 {
     if (IsShowMap == b)
     {
         return;
     }
     IsShowMap = b;
     if (mapAlphaTween != null)
     {
         mapAlphaTween.Kill();
     }
     if (frontierColor != null)
     {
         frontierColor.Kill();
     }
     if (cellAlphaTween != null)
     {
         cellAlphaTween.Kill();
     }
     //为了防止行政图内部,不发生dirty,外部强制改下alpha值
     if (TerrainGridSystem.colorizedTerritoriesAlpha == 0.0f)
     {
         TerrainGridSystem.colorizedTerritoriesAlpha = 0.01f;
     }
     else if (TerrainGridSystem.colorizedTerritoriesAlpha == 1.0f)
     {
         TerrainGridSystem.colorizedTerritoriesAlpha = 0.99f;
     }
     //tween地图颜色
     mapAlphaTween = DOTween.To(() => TerrainGridSystem.colorizedTerritoriesAlpha, x => TerrainGridSystem.colorizedTerritoriesAlpha = x, b ? 0.6f : 0.0f, mapTweenDuration);
     mapAlphaTween.OnComplete(OnMapShowed);
     //tween地图边界
     frontierColor = DOTween.ToAlpha(() => TerrainGridSystem.territoryDisputedFrontierColor, x => TerrainGridSystem.territoryDisputedFrontierColor = x, b ? 1.0f : 0.0f, mapTweenDuration);
     //tweenCell边界Alpha
     cellAlphaTween = DOTween.To(() => TerrainGridSystem.cellBorderAlpha, x => TerrainGridSystem.cellBorderAlpha = x, b ? 0.0f : 0.2f, mapTweenDuration);
 }
Ejemplo n.º 10
0
    /// <summary>
    /// Only Deactive UI wont clear Data.
    /// </summary>
    public virtual void Hide()
    {
        GameObject tempObj = null;

        if (m_ContentTrans != null)
        {
            tempObj = m_ContentTrans.gameObject;
        }
        else
        {
            tempObj = this.gameObject;
        }
        if (alphaBackground == UIAlphaBackground.DoAlpha)
        {
            if (bgImg != null)
            {
                if (tweenHideColor != null)
                {
                    tweenHideColor.Kill();
                }
                float p2 = 1;
                tweenHideColor = DOTween.To(() => p2, x => p2 = x, 0, 0.25f);
                tweenHideColor.SetEase(Ease.Linear);
                tweenHideColor.OnUpdate(() =>
                {
                    Color c     = bgImg.color;
                    c.a         = p2;
                    bgImg.color = c;
                });
            }
        }
        if (this.mode == UIMode.DoTween && tempObj != null)
        {
            //				DOTween.To ();
            if (tweenHideScale != null)
            {
                tweenHideScale.Kill();
            }
            if (tweenHideScale1 != null)
            {
                tweenHideScale1.Kill();
            }
            Vector3 p2 = Vector3.one;
            tweenHideScale = DOTween.To(() => p2, x => p2 = x, new Vector3(1.15f, 1.15f, 1), 0.08f);
            tweenHideScale.SetEase(Ease.InSine);
            tweenHideScale.OnUpdate(() =>
            {
                //Debug.Log(p2);
                tempObj.transform.localScale = p2;
            });
            tweenHideScale.OnComplete(() =>
            {
                tweenHideScale1 = DOTween.To(() => p2, x => p2 = x, new Vector3(0, 0, 1), 0.17f);
                tweenHideScale1.SetEase(Ease.InOutSine);
                tweenHideScale1.OnUpdate(() =>
                {
                    tempObj.transform.localScale = p2;
                    //Debug.Log(p2);
                });
                tweenHideScale1.OnComplete(() =>
                {
                    this.gameObject.SetActive(false);
                    isActived = false;
                    //set this page's data null when hide.
                    this.m_data = null;
                    InvokeCloseAndRemoveAllListeners();
                });
            });
            return;
        }
        //if (uiCurrency != null)
        //{
        //    uiCurrency.Hide();
        //}

        this.gameObject.SetActive(false);
        isActived = false;
        //set this page's data null when hide.
        this.m_data = null;
        InvokeCloseAndRemoveAllListeners();
    }
Ejemplo n.º 11
0
    ///Active this UI
    public virtual void Active()
    {
        this.transform.SetAsLastSibling();
        this.gameObject.SetActive(true);
        isActived = true;
        GameObject tempObj = null;

        if (m_ContentTrans != null)
        {
            tempObj = m_ContentTrans.gameObject;
        }
        else
        {
            tempObj = this.gameObject;
        }
        if (alphaBackground == UIAlphaBackground.DoAlpha)
        {
            if (bgImg != null)
            {
                if (tweenShowColor != null)
                {
                    tweenShowColor.Kill();
                }
                float p2 = 0;
                tweenShowColor = DOTween.To(() => p2, x => p2 = x, 1, 0.28f);
                tweenShowColor.SetEase(Ease.Linear);
                tweenShowColor.OnUpdate(() =>
                {
                    Color c     = bgImg.color;
                    c.a         = p2;
                    bgImg.color = c;
                });
            }
        }
        if (this.mode == UIMode.DoTween && tempObj != null)
        {
            if (tweenShowScale != null)
            {
                tweenShowScale.Kill();
            }
            if (tweenShowScale1 != null)
            {
                tweenShowScale1.Kill();
            }
            //				DOTween.To ();
            Vector3 p2 = Vector3.zero;
            tweenShowScale = DOTween.To(() => p2, x => p2 = x, new Vector3(1.15f, 1.15f, 1), 0.12f);
            tweenShowScale.SetEase(Ease.InOutSine);
            tweenShowScale.OnUpdate(() =>
            {
                //Debug.Log(p2);
                tempObj.transform.localScale = p2;
            });
            tweenShowScale.OnComplete(() =>
            {
                tweenShowScale1 = DOTween.To(() => p2, x => p2 = x, Vector3.one, 0.16f);
                tweenShowScale1.SetEase(Ease.InOutSine);
                tweenShowScale1.OnUpdate(() =>
                {
                    //Debug.Log(p2);
                    tempObj.transform.localScale = p2;
                });
            });
        }
        //if (uiCurrency != null)
        //{
        //    uiCurrency.Active();
        //}
    }