Example #1
0
 // Fadeの開始
 public static void StartFadeAll(FADE_TYPE fadeType)
 {
     foreach (Fader fader in Fader.faders)
     {
         fader.StartFade(fader.fadeTime, fadeType);
     }
 }
Example #2
0
        //************************************************************************************************
        //
        //************************************************************************************************

        public bool Begin(FADE_TYPE type, float duration, OnFadeFinished evtHandler = null)
        {
            if (m_type != type)
            {
                m_type = type;

                m_start = Time.time;

                m_progress = (duration > 0.0f) ? 1.0f - m_progress : 1.0f;

                m_duration = duration;

                m_evtHandler = evtHandler;

                return(true);
            }
            else
            {
                if (duration < m_duration)
                {
                    m_progress = (duration > 0.0f) ? m_progress * (m_duration / duration) : 1.0f;

                    m_duration = duration;

                    m_evtHandler = evtHandler;

                    return(true);
                }
            }

            return(false);
        }
Example #3
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public void OnFadeFinished(FADE_TYPE type)
    {
        if (type == FADE_TYPE.FADE_IN)
        {
            EnableButons((1 << ( int )BUTON.DELETE) | (1 << ( int )BUTON.CANCEL));
        }
    }
Example #4
0
    void OnGUI()
    {
        if (currType == FADE_TYPE.IN)
        {
            Color old      = GUI.color;
            Color newColor = currFadeColor;
            newColor.a = Mathf.Lerp(0, 1, (Time.realtimeSinceStartup - beginFadeTime) / this.currFadeTime);
            GUI.color  = newColor;
            GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), FadeTex);
            GUI.color = old;
        }
        else if (currType == FADE_TYPE.OUT)
        {
            Color old      = GUI.color;
            Color newColor = currFadeColor;
            newColor.a = Mathf.Lerp(1, 0, (Time.realtimeSinceStartup - beginFadeTime) / this.currFadeTime);
            GUI.color  = newColor;
            GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), FadeTex);
            GUI.color = old;

            if ((Time.realtimeSinceStartup - beginFadeTime) > this.currFadeTime)
            {
                currType     = FADE_TYPE.None;
                this.enabled = false;
            }
        }
    }
Example #5
0
    void ScreenOverlayFade(Material screenMaterial, FADE_TYPE fadeType, float fadeSpeed)
    {
        Color col      = screenMaterial.color;
        float newAlpha = Mathf.Clamp(col.a + Time.deltaTime * (fadeType == FADE_TYPE.FADE_IN ? 1.0f : -1.0f) * fadeSpeed, 0.0f, 1.0f);

        screenMaterial.color = new Color(col.r, col.g, col.b, newAlpha);
    }
Example #6
0
        IEnumerator FadeCoroutine(float duration, FADE_TYPE type)
        {
            m_RenderingIsNeeded = true;

            var timeElapsed = 0f;

            while (timeElapsed <= duration)
            {
                timeElapsed  += Time.deltaTime;
                m_FadeColor.a = CalculateAlpha();
                yield return(null);
            }

            m_RenderingIsNeeded = false;

            float CalculateAlpha()
            {
                switch (type)
                {
                default:
                    return(0f);

                case FADE_TYPE.FadeIn:
                    return(1f - timeElapsed / duration);

                case FADE_TYPE.FadeOut:
                    return(timeElapsed / duration);
                }
            }
        }
    // フェード処理
    public void FadeStart(FADE_TYPE type, float time = 1.0f, float delay = 0.0f)
    {
        uiImage.enabled = true;

        float from = 0.0f;
        float to   = 0.0f;

        if (type == FADE_TYPE.FADE_IN)
        {
            from = 1.0f;
            to   = 0.0f;
        }
        else if (type == FADE_TYPE.FADE_OUT)
        {
            from = 0.0f;
            to   = 1.0f;
        }

        iTween.ValueTo(this.gameObject,
                       iTween.Hash(
                           "time", time,
                           "delay", delay,
                           "from", from,
                           "to", to,
                           "onupdate", "fading",
                           "onupdatetarget", this.gameObject,
                           "oncomplete", "faded",
                           "oncompletetarget", this.gameObject));
    }
Example #8
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public void OnFadeFinished(FADE_TYPE type)
    {
        if (type == FADE_TYPE.FADE_IN)
        {
            EnableButons(BUTON_FLAG.F_CANCEL);
        }
    }
Example #9
0
    void Update()
    {
        if (mFadeType == FADE_TYPE.FADE_NOT)
        {
            return;
        }

        float deltaFade = mDeltaFade * Time.deltaTime;

        //处理每个特效alpha
        for (int i = 0; i < mPsCurAlphas.Length; i++)
        {
            float psDelta = deltaFade * mPsAlphas[i];

            mPsCurAlphas[i] += psDelta;

            if (mPsCurAlphas[i] <= 0.0f)
            {
                mPsCurAlphas[i] = 0.0f;
            }
            else if (mPsCurAlphas[i] >= 1.0f)
            {
                mPsCurAlphas[i] = 1.0f;
            }

            Color colour = mParticleSystems[i].startColor;

            mParticleSystems[i].startColor = new Color(colour.r, colour.g, colour.b, mPsCurAlphas[i]);
        }

        //淡入效果
        if (mFadeType == FADE_TYPE.FADE_IN)
        {
            mCurFadeValue = mCurFadeValue + deltaFade;
            //结束
            if (mCurFadeValue >= mFadeValue)
            {
                mCurFadeValue = mFadeValue;
                mFadeType     = FADE_TYPE.FADE_NOT;
                ChangeMaterial(mDefaultMat);
            }
            mTransparentMat.SetColor("_Color", new Color(1, 1, 1, mCurFadeValue));
        }
        //淡出效果
        else if (mFadeType == FADE_TYPE.FADE_OUT)
        {
            mCurFadeValue = mCurFadeValue + deltaFade;
            //结束
            if (mCurFadeValue <= mFadeValue)
            {
                mCurFadeValue = mFadeValue;
                mFadeType     = FADE_TYPE.FADE_NOT;

                // SetMeshVisible(false);
            }

            mTransparentMat.SetColor("_Color", new Color(1, 1, 1, mCurFadeValue));
        }
    }
Example #10
0
 void Start()
 {
     initalScale = (FadeType == FADE_TYPE.FADE_OUT) ? 0 : initalScale;
             if (TimeLimit == 0)
                     TimeLimit = 10;
             if (FadeType == 0)
                     FadeType = FADE_TYPE.FADE_IN;
 }
Example #11
0
 void Start()
 {
     if (TimeLimit == 0)
                     TimeLimit = 10;
             if (FadeType == 0)
                     FadeType = FADE_TYPE.FADE_IN;
             materialColor = renderer.material.color;
             materialColor.a = (FadeType == FADE_TYPE.FADE_IN) ? materialColor.a : 0;
 }
Example #12
0
		public void StartFade(float fadeTime, FADE_TYPE fadeType)
		{
			if(UseFade)
			{
				this.fadeTime = fadeTime;
				this.fadeType = fadeType;
			
				StartCoroutine(FadeIn());
			}
		}
Example #13
0
        public void StartFade(float fadeTime, FADE_TYPE fadeType, float targetAlpha = 1.0f)
        {
            if (UseFade)
            {
                this.fadeTime = fadeTime;
                this.fadeType = fadeType;

                StartCoroutine(FadeIn(targetAlpha));
            }
        }
Example #14
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    private void OnFadeFinished(FADE_TYPE type)
    {
        if (type == FADE_TYPE.FADE_IN)
        {
            if (m_CANCEL != null)
            {
                m_CANCEL.interactable = true;
            }
        }
    }
Example #15
0
 void Start()
 {
     ScreenSize = Camera.main.ScreenToWorldPoint (new Vector3 (Screen.width, Screen.height));
             initalScale = (FadeType == FADE_TYPE.FADE_OUT) ? 0 : initalScale;
             initilaizeShapes ();
             if (TimeLimit == 0)
                     TimeLimit = 10;
             if (FadeType == 0)
                     FadeType = FADE_TYPE.FADE_IN;
 }
Example #16
0
 //淡出效果
 public void FadeOut(float deltaTime, float alphaValue)
 {
     if (alphaValue < mCurFadeValue)
     {
         mFadeType  = FADE_TYPE.FADE_OUT;
         mFadeValue = alphaValue;
         mFadeTime  = deltaTime;
         mDeltaFade = (alphaValue - mCurFadeValue) / deltaTime;
         ChangeMaterial(mTransparentMat);
     }
 }
Example #17
0
 private void FadeIn()
 {
     _alpha += Time.deltaTime * _speed;
     if (_alpha > 1)
     {
         _alpha = 1;
         if (_loopFlag)
         {
             _fadeType = FADE_TYPE.OUT;
         }
     }
 }
Example #18
0
 private void FadeOut()
 {
     _alpha -= Time.deltaTime * _speed;
     if (_alpha < 0)
     {
         _alpha = 0;
         if (_loopFlag)
         {
             _fadeType = FADE_TYPE.IN;
         }
     }
 }
Example #19
0
    //淡入效果
    public void FadeIn(float deltaTime, float alphaValue)
    {
        if (alphaValue > mCurFadeValue)
        {
            mFadeType  = FADE_TYPE.FADE_IN;
            mFadeValue = alphaValue;
            mFadeTime  = deltaTime;
            mDeltaFade = (alphaValue - mCurFadeValue) / deltaTime;
            ChangeMaterial(mTransparentMat);

            SetMeshVisible(true);
        }
    }
Example #20
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    static public bool Begin(FADE_TYPE type, float duration = 1.0f, CORE.Fade.OnFadeFinished evtHandler = null)
    {
        if (m_fade.Begin(type, duration, evtHandler))
        {
            m_instance.enabled = true;

            m_instance.Update();

            return(true);
        }

        return(false);
    }
Example #21
0
    protected override void HandleDetection()
    {
        Color col = redScreenOverlayMaterial.color;

        if (col.a >= 1.0f)
        {
            redScreenOverlayFadeType = FADE_TYPE.FADE_OUT;
        }
        else if (col.a <= 0.25f)
        {
            redScreenOverlayFadeType = FADE_TYPE.FADE_IN;
        }
    }
Example #22
0
    public void FadeIn(float fadeTime, Color fadeColor, Action callback = null)
    {
        this.enabled  = true;
        currType      = FADE_TYPE.IN;
        beginFadeTime = Time.realtimeSinceStartup;
        currFadeColor = fadeColor;
        currFadeTime  = fadeTime;
        //Debug.LogError(" FadeHelper FadeIn");
        InOverFun = null;
        InOverFun = callback;

        StartCoroutine("DelayRunInOverFun", fadeTime);
    }
Example #23
0
 protected override void OnBecomeUndetected()
 {
     if (backgroundMusicSource != null && UndetectedBackgroundMusicClip != null)
     {
         if (backgroundMusicSource.clip != UndetectedBackgroundMusicClip)
         {
             backgroundMusicSource.clip = UndetectedBackgroundMusicClip;
         }
         if (!backgroundMusicSource.isPlaying)
         {
             backgroundMusicSource.Play();
         }
     }
     redScreenOverlayFadeType = FADE_TYPE.FADE_OUT;
 }
Example #24
0
    public void FadeOut(float fadeTime, Action callback = null)
    {
        if (currType != FADE_TYPE.IN)
        {
            return;
        }
        currType      = FADE_TYPE.OUT;
        beginFadeTime = Time.realtimeSinceStartup;
        currFadeTime  = fadeTime;
        //Debug.LogError(" FadeHelper FadeOut");
        OutOverFun = null;
        OutOverFun = callback;

        StartCoroutine("DelayRunOutOverFun", fadeTime);
    }
Example #25
0
    private void Awake()
    {
        //ScripttableObjectからのデータ読み込み
        _close_scene = _data.getCloseScene;
        _after_scene = _data.getAfterScene;
        _fade_type   = _data.getFadeType;
        _idle_time   = _data.getIdleTime;

        //アクティブシーン名の保存
        _active_scene_keeper.scene_name = _after_scene;

        //初期フェーズに移行
        _phase = PHASE.PHASE_0;
        _time  = 0.0f;

        //アクティブ化
        _effects[(int)_fade_type].gameObject.SetActive(true);

        //デリケートの登録
        SceneManager.sceneLoaded += loadSceneDetected;
    }
Example #26
0
        IEnumerator FadeCoroutine(FADE_TYPE fadeType, float duration, float delay = 0f)
        {
            yield return(new WaitForSeconds(delay));

            var timeElapsed = 0f;

            while (timeElapsed <= duration)
            {
                timeElapsed += Time.deltaTime;

                switch (fadeType)
                {
                case FADE_TYPE.FadeIn:
                    transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one, timeElapsed / duration);
                    break;

                case FADE_TYPE.FadeOut:
                    transform.localScale = Vector3.Lerp(Vector3.one, Vector3.zero, timeElapsed / duration);
                    break;
                }

                yield return(null);
            }
        }
Example #27
0
        IEnumerator FadeCoroutine(FADE_TYPE fadeType, float duration, float delay = 0f)
        {
            yield return(new WaitForSeconds(delay));

            var timeElapsed = 0f;

            while (timeElapsed <= duration)
            {
                timeElapsed += Time.deltaTime;

                switch (fadeType)
                {
                case FADE_TYPE.FadeIn:
                    SetTextAlpha(timeElapsed / duration);
                    break;

                case FADE_TYPE.FadeOut:
                    SetTextAlpha(1f - timeElapsed / duration);
                    break;
                }

                yield return(null);
            }
        }
Example #28
0
 public bool fade(FADE_TYPE fadeType)
 {
     effectInPlace = true;
     this.fadeType = fadeType;
     if (this.fadeType == FADE_TYPE.OUT)
     {
         fadeDirection = 1;
     }
     else
     {
         fadeDirection = -1;
     }
     return true;
 }
Example #29
0
 void Fade(FADE_TYPE type, Color?color = null, float?duration = null)
 {
     m_FadeColor = color == null ? DefaultFadeColor : (Color)color;
     StartCoroutine(FadeCoroutine(duration == null ? DefaultFadeDuration : (float)duration, type));
 }
Example #30
0
    // Update is called once per frame
    protected override void Update()
    {
        base.Update();

        if (Input.GetKeyUp(KeyCode.Escape))
        {
            Application.Quit();
        }

        ScreenOverlayFade(whiteScreenOverlayMaterial, whiteScreenOverlayFadeType, whiteScreenOverlayFadeSpeed);
        ScreenOverlayFade(blackScreenOverlayMaterial, blackScreenOverlayFadeType, blackScreenOverlayFadeSpeed);
        ScreenOverlayFade(redScreenOverlayMaterial, redScreenOverlayFadeType, redScreenOverlayFadeSpeed);

        if (!mainPlayerCaught)
        {
            TransformCached.position -= Velocity;

            Vector3            playerTileLocationUnrounded     = TransformCached.position / LevelManager.LevelScale;
            Vector3            playerTileLocation              = new Vector3(Mathf.Round(playerTileLocationUnrounded.x), Mathf.Round(playerTileLocationUnrounded.y), Mathf.Round(playerTileLocationUnrounded.z));
            Vector3            xDirectionTileLocationUnrounded = playerTileLocation + Vector3.Project(Velocity, Vector3.right).normalized;
            Vector3            xDirectionTileLocation          = new Vector3(xDirectionTileLocationUnrounded.x, xDirectionTileLocationUnrounded.y, xDirectionTileLocationUnrounded.z);
            AbstractGameObject xDirectionTile = LevelManager.CurrentLevel.GetGameObjectAtRowColumnIndex((int)xDirectionTileLocation.z, (int)xDirectionTileLocation.x);
            Vector3            zDirectionTileLocationUnrounded = playerTileLocation + Vector3.Project(Velocity, Vector3.forward).normalized;
            Vector3            zDirectionTileLocation          = new Vector3(zDirectionTileLocationUnrounded.x, zDirectionTileLocationUnrounded.y, zDirectionTileLocationUnrounded.z);
            AbstractGameObject zDirectionTile = LevelManager.CurrentLevel.GetGameObjectAtRowColumnIndex((int)zDirectionTileLocation.z, (int)zDirectionTileLocation.x);

            if (xDirectionTile != null && !xDirectionTile.CompareTag("SpaceTile") &&
                Vector3.Project(xDirectionTile.TransformCached.position - TransformCached.position, Vector3.right).sqrMagnitude <=
                Mathf.Pow(LevelManager.LevelScale, 2))
            {
                Velocity = Vector3.ProjectOnPlane(Velocity, Vector3.right).normalized *Velocity.magnitude;
            }

            if (zDirectionTile != null && !zDirectionTile.CompareTag("SpaceTile") &&
                Vector3.Project(zDirectionTile.TransformCached.position - TransformCached.position, Vector3.forward).sqrMagnitude <=
                Mathf.Pow(LevelManager.LevelScale, 2))
            {
                Velocity = Vector3.ProjectOnPlane(Velocity, Vector3.forward).normalized *Velocity.magnitude;
            }

            Vector3 destDiff = Destination - TransformCached.position;
            if ((Destination - TransformCached.position).sqrMagnitude <= Velocity.sqrMagnitude ||
                ((Destination - TransformCached.position).sqrMagnitude <= 0.8f * LevelManager.LevelScale &&
                 Vector2.Dot(new Vector2(destDiff.x, destDiff.z).normalized, new Vector2(Velocity.x, Velocity.z).normalized) <= 0.9f))
            {
                DestinationReached();
                lastFootStepElapsedTimeSeconds = footStepInitialOffset;
            }
            else
            {
                if (lastFootStepElapsedTimeSeconds >= footStepIntervalSeconds && !footStepsAudioSource.isPlaying)
                {
                    footStepsAudioSource.Play();
                    lastFootStepElapsedTimeSeconds = 0.0f;
                }
                lastFootStepElapsedTimeSeconds += Time.deltaTime;
            }

            TransformCached.position += Velocity;

            if ((TransformCached.position - LevelManager.CurrentLevel.GoalLocation).sqrMagnitude < Mathf.Pow(0.5f * LevelManager.LevelScale, 2.0f))
            {
                whiteScreenOverlayFadeType = FADE_TYPE.FADE_IN;
                Color col = whiteScreenOverlayMaterial.color;
                if (col.a >= 1.0f)
                {
                    soundEffectAudioSource.PlayOneShot(NextLevelAudioClip);
                    LevelManager.LoadNextLevel();
                }
            }
            else
            {
                whiteScreenOverlayFadeType = FADE_TYPE.FADE_OUT;
            }
        }

        if (blackScreenOverlayFadeType == FADE_TYPE.FADE_IN)
        {
            Color col = blackScreenOverlayMaterial.color;
            if (col.a >= 1.0f)
            {
                LevelManager.LoadLevel(LevelManager.LevelNumber);
                blackScreenOverlayFadeType = FADE_TYPE.FADE_OUT;
            }
        }
    }
Example #31
0
 public override void HandleGameOver()
 {
     base.HandleGameOver();
     blackScreenOverlayFadeType = FADE_TYPE.FADE_IN;
     soundEffectAudioSource.PlayOneShot(GameOverAudioClip);
 }
Example #32
0
 public void StartFade(FADE_TYPE fadeType, float targetAlpha = 1.0f)
 {
     StartFade(fadeTime, fadeType, targetAlpha);
 }