Esempio n. 1
0
        public void Update()
        {
            buttonTween.Update(Time.deltaTime);

            var rtf = _button.GetComponent <RectTransform>();

            rtf.sizeDelta = new Vector2(buttonTween.CurrentValue, rtf.sizeDelta.y);

            if (buttonTween.State == TweenState.Stopped)
            {
                buttonTween.Start(buttonTween.EndValue, buttonTween.StartValue, 0.6f, ScaleFuncs.SineEaseInOut);
            }
        }
        private void Update(float deltaTime)
        {
            if (!mTargetInited)
            {
                return;
            }
            bool flag = false;

            mTweenTargetOffset.Update(deltaTime);
            Vector3 pos = mTweenTargetOffset.Value;

            if (FollowTarget != null)
            {
                pos += FollowTarget.position;
            }
            bool targetMoved = false;

            if ((mPrevPos - pos).sqrMagnitude > 1E-8f)
            {
                targetMoved = true;
                mPrevPos    = pos;
            }
            if (targetMoved || (pos - mTargetPos.Value).sqrMagnitude > 1E-8f)
            {
                switch (mTargetPos.State)
                {
                case ePropTweenState.None:
                    if (mFollowSpeedFactor <= 0f)
                    {
                        mTargetPos.Value = pos;
                    }
                    else
                    {
                        mTargetPos.GoTo(pos, mFollowSpeedFactor, mFollowMinSpeed, mFollowMaxSpeed);
                        mPropTweening = true;
                    }
                    break;

                case ePropTweenState.SpeedControl:
                    mTargetPos.To = pos;
                    break;
                }
                flag = true;
            }
            if (mPropTweening)
            {
                mPropTweening = false;
                if (mTargetPos.Update(deltaTime) != eUpdateReturn.Finished)
                {
                    mPropTweening = true;
                }
                if (mRotY.Update(deltaTime) != eUpdateReturn.Finished)
                {
                    mPropTweening = true;
                }
                if (mLookDown.Update(deltaTime) != eUpdateReturn.Finished)
                {
                    mPropTweening = true;
                }
                if (mDistance.Update(deltaTime) != eUpdateReturn.Finished)
                {
                    mPropTweening = true;
                }
                if (mCamFovOrSize.Update(deltaTime) != eUpdateReturn.Finished)
                {
                    mPropTweening = true;
                }
                flag = true;
            }
            if (flag)
            {
                FlushCamera();
            }
            if (mEarthQuakeTimer > 0f)
            {
                float t0 = (mEarthQuakeTimer / mEarthQuakeDur) % 1f;
                mEarthQuakeTimer -= deltaTime;
                float   t1          = mEarthQuakeTimer > 0f ? (mEarthQuakeTimer / mEarthQuakeDur) % 1f : 0f;
                bool    flush       = false;
                Vector2 flushOffset = Vector2.zero;
                if (mEarthQuakeTimer <= 0f)
                {
                    mCamera.ResetProjectionMatrix();
                }
                else if (t0 < t1)
                {
                    mEarthQuakeOffsetFrom = mEarthQuakeOffsetTo;
                    if (mEarthQuakeTimer < mEarthQuakeDur)
                    {
                        mEarthQuakeOffsetTo = Vector2.zero;
                    }
                    else
                    {
                        if (mEarthQuakeRandomDirection)
                        {
                            float delta = Random.Range(2f, 4f) * Mathf.PI / 3f;
                            if (mEarthQuakeDirection > 0f)
                            {
                                mEarthQuakeDirection -= delta;
                            }
                            else
                            {
                                mEarthQuakeDirection += delta;
                            }
                        }
                        else
                        {
                            if (mEarthQuakeDirection > 0f)
                            {
                                mEarthQuakeDirection -= Mathf.PI;
                            }
                            else
                            {
                                mEarthQuakeDirection += Mathf.PI;
                            }
                        }
                        mEarthQuakeOffsetTo = new Vector2(Mathf.Cos(mEarthQuakeDirection), Mathf.Sin(mEarthQuakeDirection)) * mEarthQuakeAmplitude;
                    }
                    if (mEarthQuakeHardMode)
                    {
                        flush       = true;
                        flushOffset = mEarthQuakeOffsetTo;
                    }
                }
                if (!mEarthQuakeHardMode)
                {
                    flush       = true;
                    flushOffset = Vector2.LerpUnclamped(mEarthQuakeOffsetTo, mEarthQuakeOffsetFrom, Mathf.Sin((t1 - 0.5f) * Mathf.PI) * 0.5f + 0.5f);
                }
                if (flush)
                {
                    flushOffset *= Mathf.Min(Screen.width, Screen.height) / 100f;
                    Vector3 screenOffset = new Vector3(flushOffset.x / Screen.width, flushOffset.y / Screen.height, 0f);
                    mCamera.projectionMatrix = Matrix4x4.Translate(screenOffset) * mCaneraProjection;
                }
            }
        }