예제 #1
0
파일: HoveringText.cs 프로젝트: Jonas90/iss
    private void Fade( bool fadeIn )
    {
        float a = TimeLeft/FadeDuration;
        if ( a < 0 )
        {
            a = 0;
            Status = FadeState.None;

            if ( !fadeIn )
            {
                GuiText.text = "";
            }
        }

        if ( fadeIn )
        {
            a = 1 - a;
        }

        Color temp = GuiText.font.material.color;/* * GuiTextAlphaOriginal*/;
        temp.a = a;
        GuiText.font.material.color = temp;

        if ( Background )
        {
            temp = Background.color;
            temp.a = a*BackgroundAlphaOriginal;

            Background.color = temp;
        }
    }
예제 #2
0
파일: Fade.cs 프로젝트: shikoist/tanks
 void Update()
 {
     //if (oldFadeState != fadeState)
     //{
     //    OnChangeFadeState();
     //    oldFadeState = fadeState;
     //}
     
     float deltaTime = Time.deltaTime;
     
     if (fadeState == FadeState.FromFade)
     {
         colorAlpha -= speed * deltaTime;
         if (colorAlpha <= 0.0f)
         {
             colorAlpha = 0.0f;
             fadeState = FadeState.Nothing;
         }
         blackMat.color = new Color(1.0f, 1.0f, 1.0f, colorAlpha);
     }
     else if (fadeState == FadeState.ToFade)
     {
         colorAlpha += speed * deltaTime;
         if (colorAlpha >= 1.0f)
         {
             colorAlpha = 1.0f;
             fadeState = FadeState.Nothing;
         }
         blackMat.color = new Color(1.0f, 1.0f, 1.0f, colorAlpha);
     }
 }
예제 #3
0
    private void HandleShotState()
    {
        if (CurrentFade == FadeState.None)
        {
            SplineProgress += (Shots[CurrentShot].Velocity / Shots[CurrentShot].Path.GetDeriv(SplineProgress).magnitude)*Time.deltaTime;
            Vector3 diff = Shots[CurrentShot].Path.GetPoint(Shots[CurrentShot].Path.GetCurveCount())
                         - Shots[CurrentShot].Path.GetPoint(SplineProgress);

            if ((float)Shots[CurrentShot].Path.GetCurveCount() - SplineProgress < 0.05f)
            {
                CurrentFade = FadeState.FadeOut;
                FadeStartTime = Time.time;
            }
        }
        else if (Time.time >= FadeStartTime + FadeLength)
        {
            if (CurrentFade == FadeState.FadeIn)
            {
                FadeStartTime = -1;
                CurrentFade = FadeState.None;
            } else
            {
                CurrentShot++;
                CurrentShot %= Shots.Length;
                SplineProgress = 0;
                FadeStartTime = Time.time;

                CurrentFade = FadeState.FadeIn;
            }
        }
    }
예제 #4
0
 void OnGUI()
 {
     GUI.depth = depth;
     if(fs != FadeState.NONE){
         switch(fs){
         case FadeState.FADEIN:
             GUI.DrawTexture(new Rect(posFadex*Screen.width, 0f, Screen.width*2f, Screen.height), fade);
             posFadex -= Time.deltaTime/speedFade;
             if(posFadex <= posxfinal){
                 fs = FadeState.DISPLAY;
                 if(!String.IsNullOrEmpty(levelToLoad)) Application.LoadLevel(DataManager.Instance.giveLevelToLoad(levelToLoad));
             }
             break;
         case FadeState.FADEOUT:
             GUI.DrawTexture(new Rect(posFadex*Screen.width, 0f, Screen.width*2f, Screen.height), fade);
             posFadex += Time.deltaTime/speedFade;
             if(posFadex >= 1f){
                 fs = FadeState.NONE;
                 if(disableWhenFinish)
                 {
                     this.enabled = false;
                 }
             }
             break;
         case FadeState.DISPLAY:
             GUI.DrawTexture(new Rect(posFadex*Screen.width, 0f, Screen.width*2f, Screen.height), fade);
             break;
         }
     }
 }
예제 #5
0
    void Update()
    {
        if (_fadeState == FadeState.Idle)
            return;

        _timer += Time.deltaTime;
        numerator += Time.deltaTime * (int)_fadeState;
        if (_timer >= _halfTime && _fadeState == FadeState.Into)
        {
                if (onFadeIn != null)
                    onFadeIn();

                _fadeState = FadeState.Outto;
        }
        else if(_timer >= fadeTime && _fadeState == FadeState.Outto)
        {
            Debug.Log("Delta is : " + Time.deltaTime);
            if (onFadeOut != null)
                onFadeOut();

            _fadeState = FadeState.Idle;
            _timer = 0;
            numerator = 0;
        }

        float perc = Mathf.Clamp01(numerator / _halfTime);
        color.a = perc;
        img.color = color;
        Debug.Log("Color A : " + img.color.a);
    }
예제 #6
0
    private void Update()
    {
        switch(fadeState)
        {
            case FadeState.FadeIn:
                if (alpha < ColorConcentration.max)
                {
                    alpha += speed * Time.deltaTime;
                }
                else
                {
                    alpha = ColorConcentration.max;
                    fadeState = FadeState.FadeOut;
                }
                break;

            case FadeState.FadeOut:
                if (alpha > ColorConcentration.min)
                {
                    alpha -= speed * Time.deltaTime;
                }
                else
                {
                    alpha = ColorConcentration.min;
                    fadeState = FadeState.FadeIn;
                }
                break;
        }

        color = new Color(color.r, color.g, color.b, alpha);
        GetComponent<Renderer>().material.color = color;
    }
예제 #7
0
    void UpdateLevelChangeCheck()
    {
        if (isEnableLevelChange && !isRequestExit && !isRequestCustomLevelChange)
        {
            if (!isEnableFadeIn || fadeAlpha <= 0.0f)
            {
                if (Time.time - startTime > showTimeSec)
                    isRequestExit = true;
                else if (isExitWithAnyKey && Input.anyKeyDown && Time.time - startTime > minsShowTimeSec)
                    isRequestExit = true;
            }
        }

        bool isExit = (isRequestExit || isRequestCustomLevelChange);
        if (isEnableFadeOut)
        {
            if (isExit)
                fadingState = FadeState.FADE_OUT;
            if (fadingState == FadeState.FADE_OUT && fadeAlpha < 1.0f)
                isExit = false;
        }

        if (isExit && !isAlreadyCallExit)
        {
            isAlreadyCallExit = true;
			SceneManager.LoadScene(isRequestCustomLevelChange ? customTargetLevel : targetLevel);
        }
    }
 public void BeginFadeOut(double fadeDurationInMilliseconds) {
     lock (lockObject) {
         fadeSamplePosition = 0;
         fadeSampleCount = (int)((fadeDurationInMilliseconds * source.WaveFormat.SampleRate) / 1000);
         fadeState = FadeState.FadingOut;
     }
 }
 public void FadeOut(float time)
 {
     fadeState = FadeState.FadeOut;
     fadeTimer = maxFadeTime = (int)(1000.0f * time);
     fadeIdleTime = 0;
     fadeValue = 1.0f;
 }
 public void FadeIn(float time, float idleTime)
 {
     fadeState = FadeState.FadeIn;
     fadeTimer = maxFadeTime = (int)(1000.0f * time);
     fadeIdleTime = -(int)(1000.0f * idleTime);
     fadeTimer -= fadeIdleTime;
     fadeValue = 0.0f;
 }
예제 #11
0
    // Use this for initialization
    void Start()
    {
        this.TextObject = this.GetComponentInChildren<TextMesh>();
        this.Particles = this.GetComponentInChildren<ParticleSystem>();
        this.TextProperty = Text;

        this.State = FadeState.FadeIn;
    }
        /// <summary>
        ///   Starts highlighting the target sprite by fading it in and out.
        /// </summary>
        public void StartHighlight()
        {
            if (this.fadeState == FadeState.FadeIn || this.fadeState == FadeState.FadeOut)
            {
                return;
            }

            this.fadeState = FadeState.FadeOut;
        }
예제 #13
0
 // Use this for initialization
 void Start()
 {
     fade = (Texture2D) Resources.Load("Fade");
     fs = FadeState.NONE;
     if(startFeded){
         fs = FadeState.DISPLAY;
         posFadex = posxfinal;
     }
 }
        /// <summary>
        ///   Stops highlighting the target sprite by fading it in and stopping fading.
        /// </summary>
        public void StopHighlight()
        {
            if (this.fadeState == FadeState.None || this.fadeState == FadeState.FadeInAndStop)
            {
                return;
            }

            this.fadeState = FadeState.FadeInAndStop;
        }
예제 #15
0
파일: HoveringText.cs 프로젝트: Jonas90/iss
    // =============================================================================
    // =============================================================================
    // METHODS  --------------------------------------------------------------------
    public void ViewOnTarget( Transform target, Vector3 offset, string text )
    {
        Status = FadeState.FadeIn;
        TransTarget = target;
        TransTargetOffset = offset;
        GuiText.text = text;

        TimeStart = Time.time;
    }
예제 #16
0
 void Start()
 {
     startTime = Time.time;
     isRequestExit = false;
     isRequestCustomLevelChange = false;
     isAlreadyCallExit = false;
     fadingState = FadeState.FADE_IN;
     fadeAlpha = isEnableFadeIn ? 1.0f : 0.0f;
     if (isEnableGameState)
         GameStateManager.Instance.setState(gameStateAtStart);
 }
	void Start ()
	{
		// Initialise animation
		animationIndex = 0;
		animationImage.sprite = animationSprites[animationIndex];
		animationImage.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);

		// Start fade in
		fadeState = FadeState.IN;
		StartCoroutine(FadeImage());
	}
 public PlayerCharacterStatusBox(Vector2 position, PlayerCharacterStatusBoxMode mode)
     : base("General/StatusBoxBG", position, Vector2.Zero)
 {
     this.mode = mode;
        alpha = 0.0f;
        fadeState = FadeState.IdleFaded;
        levelUpOccurred = false;
        newTechniqueLearned = false;
        controls = new GamePadController(PlayerIndex.One);
        debugControls = new KeyboardController();
        addEXPTimer = 0.0f;
 }
예제 #19
0
	public void Start () {
        if(musicClips.Length >= 5)
        {
            music.clip = musicClips[4];
            music.Play();
            state = FadeState.FadingIn;
        }
        else
        {
            state = FadeState.None;
        }
        music.volume = 0.1f;
	}
        public override void Initialize()
        {
            this.spriteBatch = SCSServices.Instance.SpriteBatch;

            background = SCSServices.Instance.ResourceManager.GetResource<Texture2D>(@"Images\Controls\Loading");
            alpha = 0;

            this.timer = FADE_TIME;
            this.state = FadeState.FadeIn;

            this.backgroundSound = SCSServices.Instance.ResourceManager.GetResource<Sound>(BACKGROUND_SOUNDNAME);

            base.Initialize();
        }
예제 #21
0
    public void FadeOut( Action then = null )
    {
        if ( fadeState != FadeState.Normal )
        {
            Debug.LogWarning("FadeOut called in state " + fadeState);
            return;
        }

        fadeState = FadeState.FadingOut;
        Singletons.player.FadeToDark( onComplete: () => {
                                            fadeState = FadeState.Darkness;
                                            if ( then != null )
                                                then();
                                            });
    }
예제 #22
0
 public void Play(int targetClip)
 {
     if(targetClip >= 0 && targetClip < musicClips.Length)
     {
         this.state = FadeState.FadingOut;
         this.targetClip = targetClip;
     }
     else
     {
         this.state = FadeState.None;
         this.targetClip = -1;
         music.Stop();
         music.clip = null;
     }
 }
 private void FadeOut(float[] buffer, int offset, int sourceSamplesRead) {
     int sample = 0;
     while (sample <sourceSamplesRead) {
         float multiplier = 1.0f - (fadeSamplePosition / (float)fadeSampleCount);
         for (int ch = 0; ch < source.WaveFormat.Channels; ch++) {
             buffer[offset + sample++] *= multiplier;
         }
         fadeSamplePosition++;
         if (fadeSamplePosition > fadeSampleCount) {
             fadeState = FadeState.Silence;
             // clear out the end
             ClearBuffer(buffer, sample + offset, sourceSamplesRead - sample);
             break;
         }
     }
 }
예제 #24
0
	void Update()
    {
        time += Time.deltaTime;

        switch (fadeState)
        {
            case FadeState.FadingIn:
                if (time >= fadeInTime) fadeState = FadeState.None;
                guiTex.color = new Color(guiTex.color.r, guiTex.color.b, guiTex.color.g, fadeInCurve.Evaluate(time / fadeInTime));
                break;
            case FadeState.FadingOut:
                if (time >= fadeOutTime) fadeState = FadeState.None;
                guiTex.color = new Color(guiTex.color.r, guiTex.color.b, guiTex.color.g, fadeOutCurve.Evaluate(time / fadeOutTime));
                break;
        }
	}
예제 #25
0
파일: Fader.cs 프로젝트: wj205/Bochi
 public void SwitchToState(FadeState s)
 {
     this.state = s;
     switch (this.state)
     {
         case FadeState.IN:
             this.SwitchToFadeIn();
             break;
         case FadeState.IDLE:
             this.SwitchToIdle();
             break;
         case FadeState.OUT:
             this.SwitchToFadeOut();
             break;
     }
 }
예제 #26
0
    public void FadeIn( float duration=2, Action then = null )
    {
        if ( fadeState != FadeState.Darkness )
        {
            Debug.LogWarning("FadeIn called in state " + fadeState);
            return;
        }

        fadeState = FadeState.FadingIn;
        Singletons.player.FadeFromDark( duration:duration,
                                                        onComplete: () => {
                                                        fadeState = FadeState.Normal;
                                                        if ( then != null )
                                                            then();
                                                        });
    }
        public SplashScreenState(ContentManager newManager)
        {
            contentManager = newManager;

            IsUpdateable = true;

            calledLoadAssets = false;
            flashOffText = false;

            startButtonDown = false;

            state = SplashScreenVisualState.Loading;
            fadeState = FadeState.FadeIn;
            fadeTimer = 0;

            gameInput = new GameInput(Game1.graphics.GraphicsDevice);
        }
예제 #28
0
    /// <summary>
    /// resets the time scale + any ongoing timers, begins full
    /// screen fadeout and loads the specified level
    /// </summary>
    public void LoadLevel(int level)
    {
        ClosingDown = true;
        vp_Timer.CancelAll();
        vp_TimeUtility.TimeScale = 1.0f;

        m_FadeState = FadeState.FadeOut;
        CurrentFullScreenFadeTime = Time.time + m_FullScreenFadeOutDuration;

        vp_Timer.In(m_FullScreenFadeOutDuration, delegate()
        {
#if UNITY_5_4_OR_NEWER
            SceneManager.LoadScene(level);
#else
            Application.LoadLevel(level);
#endif
        });
    }
예제 #29
0
 protected internal override void Draw(int X, int Y)
 {
     if (GFader.m_Fade)
     {
         if (Gumps.LastOver == null || !Gumps.LastOver.IsChildOf((Gump)this))
         {
             if (this.State != FadeState.O2F && this.State != FadeState.Faded)
             {
                 this.State = FadeState.O2F;
             }
         }
         else if (this.State != FadeState.F2O && this.State != FadeState.Opaque)
         {
             this.State = FadeState.F2O;
         }
     }
     base.Draw(X, Y);
 }
예제 #30
0
    public void FadeTo(float volume, float duration, OnFadeComplete completeCallback)
    {
        if (fadeState == FadeState.Fading) {
            if (completionCallback != null) {
                completionCallback(false);
            }
        }

        if (audioSource == null)
            return;

        targetVolume = volume;
        startTime = Time.time;
        startVolume = audioSource.volume;
        completionCallback = completeCallback;
        fadeState = FadeState.Fading;
        fadeDuration = duration;
    }
예제 #31
0
    /// <summary>
    /// フェードインするコルーチン
    /// </summary>
    /// <param name="frame">フェードさせるフレーム</param>
    /// <param name="fadeInFinished">フェードイン終了後に行う関数</param>
    /// <returns></returns>
    public IEnumerator FadeInCoroutine(float frame, FadeInFinishedFunc fadeInFinished = null)
    {
        state = FadeState.FadeIn;
        float speed = 1 / frame;

        for (int i = 0; i < frame; i++)
        {
            Alpha += speed;
            yield return(null);
        }

        if (fadeInFinished != null)
        {
            fadeInFinished();
        }
        state = FadeState.None;
        yield break;
    }
예제 #32
0
    // Start is called before the first frame update
    void Start()
    {
        switch (state)
        {
        case FadeState.Unset:
            Color c = fadeImage.color;
            c.a             = 0f;
            fadeImage.color = c;
            state           = FadeState.FadeIn;
            fadeImage.gameObject.SetActive(false);
            break;

        case FadeState.FadeIn:
            StaticDelegates.UpdateAllMovement(false);
            StartCoroutine(FadeFromBlack());
            break;
        }
    }
예제 #33
0
        } // End of ChangeColor.

        /// <summary>
        /// @brief  ステータスを変更
        /// @brief  [in]FadeState : フェードステータス
        /// </summary>
        public void ChangeState(FadeState in_state)
        {
            // フェードステートを取得
            m_fade_state = in_state;

            // フェード情報を初期化
            m_fade_count = 0f;
            m_fade_flag  = false;
            switch (in_state)
            {
            case FadeState.FADE_IN:
                m_fade_alpha = 1f;
                break;

            case FadeState.FADE_OUT:
                m_fade_alpha = 0f;
                break;
            }
        } // End of ChangeState.
예제 #34
0
 /// <summary>
 /// フェードを開始する
 /// </summary>
 public void Play(FadeState state, ushort floor, bool isWait = false, float duration = 1, bool ignoreTimeScale = true)
 {
     if (state == FadeState.FadeOut)
     {
         _fadeTarget.alpha = 1;
     }
     else
     {
         _fadeTarget.alpha = 0;
     }
     _fadeTarget.transform.Find("DungeonFloorText").GetComponent <Text>().text
                      = string.Format("{0} F", floor);
     FadeState        = state;
     _duration        = duration;
     isWait           = false;
     IsFadeinEnd      = false;
     IsFadeChange     = false;
     _ignoreTimeScale = ignoreTimeScale;
 }
        /// <summary>
        /// Manages the fadein/fadeout logic
        /// </summary>
        /// <param name="elapsed"></param>
        public void Update(TimeSpan elapsed)
        {
            switch (_currentFadeState)
            {
            case FadeState.FadeIn:

                _elapsed += elapsed;

                if (_elapsed >= _fadeDuration)
                {
                    _currentFadeState = FadeState.Static;
                    CurrentAlpha      = 1f;
                    OverlayColor      = _originalColor.WithAlpha(CurrentAlpha);
                    FadeInCompleted?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    CurrentAlpha = (float)(_elapsed.TotalSeconds / _fadeDuration.TotalSeconds);
                    OverlayColor = _originalColor.WithAlpha(CurrentAlpha);
                }

                break;

            case FadeState.FadeOut:

                _elapsed += elapsed;

                if (_elapsed >= _fadeDuration)
                {
                    _currentFadeState = FadeState.Static;
                    CurrentAlpha      = 0f;
                    OverlayColor      = _originalColor.WithAlpha(CurrentAlpha);
                    FadeOutCompleted?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    CurrentAlpha = 1f - ((float)(_elapsed.TotalSeconds / _fadeDuration.TotalSeconds));
                    OverlayColor = _originalColor.WithAlpha(CurrentAlpha);
                }

                break;
            }
        }
예제 #36
0
 private void FadeIn(float[] buffer, int offset, int sourceSamplesRead)
 {
     int sample = 0;
     while (sample < sourceSamplesRead)
     {
         float multiplier = (fadeSamplePosition / (float)fadeSampleCount);
         for (int ch = 0; ch < source.WaveFormat.Channels; ch++)
         {
             buffer[offset + sample++] *= multiplier;
         }
         fadeSamplePosition++;
         if (fadeSamplePosition > fadeSampleCount)
         {
             fadeState = FadeState.FullVolume;
             // no need to multiply any more
             break;
         }
     }
 }
예제 #37
0
    //Function called from the EventManager
    private void BeginFade(EVTData data_)
    {
        //Making sure the combat transition class isn't null, or else we stop
        if (data_.combatTransition == null)
        {
            return;
        }

        //Storing all of the fade information
        this.fadeToBlackTime = data_.combatTransition.fadeToBlackTime;
        this.stayOnBlackTime = data_.combatTransition.stayOnBlackTime;
        this.fadeInTime      = data_.combatTransition.fadeInTime;
        this.eventOnBlack    = data_.combatTransition.eventOnBlack;

        //Starts the transition
        this.currentlyTransitioning = true;
        this.currentState           = FadeState.FadeOut;
        this.currentTime            = 0;
    }
예제 #38
0
    void Start()
    {
        _creditPanels = new List <GameObject>();

        for (int i = 0; i < CreditsScreen.transform.childCount; i++)
        {
            _creditPanels.Add(CreditsScreen.transform.GetChild(i).gameObject);
        }

        _screenTexts = _creditPanels[_currentScreen].GetComponentsInChildren <TMPro.TMP_Text>();
        foreach (var item in _screenTexts)
        {
            item.alpha = 0;
        }

        fadeState = FadeState.None;

        StartCoroutine(StartChangeScreens());
    }
예제 #39
0
    private void Update()
    {
        displayTime -= Time.deltaTime;
        float pct = 0f;

        switch (CurrentState)
        {
        case FadeState.ShowDelay:
            if (displayTime <= 0)
            {
                CurrentState = FadeState.FadeIn;
                displayTime  = FADE_TIME;
            }
            break;

        case FadeState.FadeIn:
            pct          = Mathf.Min(1f - (displayTime / FADE_TIME), 1f);
            Canvas.alpha = pct;
            if (displayTime <= 0)
            {
                CurrentState = FadeState.Displaying;
                displayTime  = DISPLAY_TIME;
            }
            break;

        case FadeState.Displaying:
            if (displayTime <= 0)
            {
                CurrentState = FadeState.FadeOut;
                displayTime  = FADE_TIME;
            }
            break;

        case FadeState.FadeOut:
            pct          = Mathf.Max(displayTime / FADE_TIME, 0f);
            Canvas.alpha = pct;
            if (displayTime <= 0)
            {
                CurrentState = FadeState.Hidden;
            }
            break;
        }
    }
예제 #40
0
    private void Update2()
    {
        if (FadeState == FadeState.None ||
            isWait == true)
        {
            return;
        }
        float fadeSpeed = 1f / _duration;

        if (_ignoreTimeScale)
        {
            fadeSpeed *= Time.unscaledDeltaTime;
        }
        else
        {
            fadeSpeed *= Time.smoothDeltaTime;
        }

        _fadeTarget.alpha += fadeSpeed * (FadeState == FadeState.FadeIn ? 1f : -1f);

        //フェード終了判定
        if (_fadeTarget.alpha > 0 && _fadeTarget.alpha < 1)
        {
            return;
        }

        //フェードインが終了したらフェードアウトに切り替え
        if (FadeState == FadeState.FadeIn)
        {
            isWait      = true;
            IsFadeinEnd = true;
            FadeState   = FadeState.FadeOut;
            MainThreadDispatcher.StartUpdateMicroCoroutine(WaitCorutine());
            //StartCoroutine("WaitCorutine");
        }
        //フェードアウトが終了したら終了フラグを出す
        else if (FadeState == FadeState.FadeOut && isWait == false)
        {
            IsFadeChange = true;
            FadeState    = FadeState.None;
        }
    }
예제 #41
0
    protected override void OnInit()
    {
        this.go = gameObject;
        DontDestroyOnLoad(this.gameObject);

        var tmpCanvas = this.go.AddComponent <Canvas>();

        this.canvas              = tmpCanvas;
        this.canvas.renderMode   = RenderMode.ScreenSpaceCamera;
        this.canvas.sortingOrder = 999;

        var scale = this.go.AddComponent <CanvasScaler>();

        scale.uiScaleMode         = CanvasScaler.ScaleMode.ScaleWithScreenSize;
        scale.referenceResolution = Vector2.one;

        var obj = new GameObject("FadeImage");

        obj.transform.SetParent(this.transform, false);
        var tmpImage = obj.AddComponent <Image>();

        this.image = tmpImage;

        this.FadeColor = Color.black;
        this.FadeAlpha = 0;

        if (this.isStartFade)
        {
            this.FadeAlpha = 1;
            this.StartCoroutine(this.FadeIn(this.startFadeTime));
        }

        if (Application.platform == RuntimePlatform.WindowsPlayer ||
            Application.platform == RuntimePlatform.OSXPlayer ||
            Application.platform == RuntimePlatform.LinuxPlayer)
        {
            Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
            Screen.SetResolution(this.screenWidth, this.screenHeight, false);
        }

        this.state = FadeState.Free;
    }
	private void UpdateAnimation()
	{
        if(!animationImage)
            return;

		// Switch the state flade
		fadeState = (fadeState == FadeState.IN) ? FadeState.OUT : FadeState.IN;

		// Check if we are fading in
		if(fadeState == FadeState.IN)
		{
			// Update image index
			animationIndex++;
			Utility.Wrap(ref animationIndex, 0, animationSprites.Count - 1);
			animationImage.sprite = animationSprites[animationIndex];
		}

		// Start the animation again
		StartCoroutine(FadeImage());
	}
예제 #43
0
    /// <summary>
    /// 実際にフェードを開始
    /// </summary>
    /// <param name="_isFadeOut"></param>
    /// <param name="_duration"></param>
    /// <param name="_ignoreTimeScale"></param>
    /// <param name="_onFinished"></param>
    public void Play(bool _isFadeOut, float _duration, bool _ignoreTimeScale = true, Action _onFinished = null)
    {
        this.enabled = true;

        m_ignoreTimeScale = _ignoreTimeScale;
        m_onFinished      = _onFinished;

        if (_isFadeOut)
        {
            Alpha       = 1;
            m_fadeState = FadeState.FadeOut;
        }
        else
        {
            Alpha       = 0;
            m_fadeState = FadeState.FadeIn;

            m_duration = _duration;
        }
    }
예제 #44
0
	/*
	-----------------------
	Stop()
	-----------------------
	*/
	public void Stop() {
		// overrides everything
		state = FadeState.Null:
		StopAllCoroutines():
		if ( audioSource != null ) {
			audioSource.Stop():
		}
		if ( onFinished != null ) {
			onFinished():
			onFinished = null:
		}
		if ( onFinishedObject != null ) {
			onFinishedObject( onFinishedParam ):
			onFinishedObject = null:
		}
		if ( playingSoundGroup != null ) {
			playingSoundGroup.DecrementPlayCount():
			playingSoundGroup = null:
		}
	}
예제 #45
0
    IEnumerator fade(AudioSource backgroundAudioSource, FadeState state)
    {
        float elapsedTime = 0f;

        float currentVolume = backgroundAudioSource.volume;

        while (elapsedTime < delay)
        {
            elapsedTime += Time.deltaTime;
            if (state == FadeState.FADE_IN)
            {
                backgroundAudioSource.volume = Mathf.Lerp(0f, 1f, elapsedTime / delay);
            }
            else if (state == FadeState.FADE_OUT)
            {
                backgroundAudioSource.volume = Mathf.Lerp(1f, 0f, elapsedTime / delay);
            }
            yield return(null);
        }
    }
예제 #46
0
 private void FadeOut(float[] buffer, int offset, int sourceSamplesRead)
 {
     int sample = 0;
     while (sample < sourceSamplesRead)
     {
         float multiplier = 1.0f - (fadeSamplePosition / (float)fadeSampleCount);
         for (int ch = 0; ch < source.WaveFormat.Channels; ch++)
         {
             buffer[offset + sample++] *= multiplier;
         }
         fadeSamplePosition++;
         if (fadeSamplePosition > fadeSampleCount)
         {
             fadeState = FadeState.Silence;
             // clear out the end
             ClearBuffer(buffer, sample + offset, sourceSamplesRead - sample);
             break;
         }
     }
 }
예제 #47
0
        public void Stop(float fadeTime = 0f)
        {
            if (IsFadingOut || !IsPlaying)
            {
                return;
            }

            if (fadeTime > 0f)
            {
                float p = Mathf.Clamp01(_currFadeTime / this._fadeTime);
                _fadeDir      = -1f;
                _fadeTime     = fadeTime;
                _currFadeTime = _fadeTime * p;
                _state        = FadeState.FadingOut;
            }
            else
            {
                _source.Stop();
            }
        }
예제 #48
0
    public void OnFade(FadeState state)
    {
        fadeState = state;

        switch (fadeState)
        {
        case FadeState.FadeIn:
            StartCoroutine(Fade(1, 0));
            break;

        case FadeState.FadeOut:
            StartCoroutine(Fade(0, 1));
            break;

        case FadeState.FadeInOut:
        case FadeState.FadeLoop:
            StartCoroutine(FadeInOut());
            break;
        }
    }
예제 #49
0
    /// <summary>
    /// Fadeする
    /// </summary>
    private void Fade()
    {
        Color newColor = image.color;

        newColor.a += FadeValue();
        image.color = newColor;
        effect.SetFloat("_Count", newColor.a * newColor.a * maxPrefer);
        effect.SetFloat("_Alpha", newColor.a);
        lockImage.color = newColor * 2;

        if (newColor.a >= 1.0f)
        {
            state = FadeState.None;
        }

        if (newColor.a <= 0.0f)                                 //FadeOut後削除
        {
            Destroy(gameObject);
        }
    }
예제 #50
0
    // Update is called once per frame
    void Update()
    {
        if (!IsFade)
        {
            return;
        }
        float fadeSpeed = 1.0f / m_duration;

        if (m_ignoreTimeScale)
        {
            fadeSpeed *= Time.unscaledDeltaTime;
        }
        else
        {
            fadeSpeed *= Time.deltaTime;
        }

        if (m_fadeState == FadeState.FadeIn)
        {
            Alpha += fadeSpeed * 1.0f;
        }
        else
        {
            Alpha += fadeSpeed * -1.0f;
        }

        // Fade中
        if (Alpha > 0 && Alpha < 1)
        {
            return;
        }

        m_fadeState = FadeState.None;
        //this.enabled = false;

        if (m_onFinished != null)
        {
            //           Debug.Log("FadeFade");
            m_onFinished();
        }
    }
예제 #51
0
        public void Update(GameTime gameTime, float upperElementMix)
        {
            if (mFadeState == FadeState.Waiting)
            {
                return;
            }

            if (mFadeState == FadeState.FadeIn)
            {
                mFadeTime += gameTime.ElapsedGameTime.Milliseconds;

                if (mFadeTime > mFadeInTime)
                {
                    mFadeState = FadeState.Playing;
                    mMix       = 1.0f;
                }
                else
                {
                    mMix = mFadeTime / (float)mFadeInTime;
                }

                // An animation which isn't looping we want to first fade in before we start playing it
                if (!mLoop)
                {
                    mAnimationStartTime = (float)gameTime.TotalGameTime.TotalMilliseconds;
                }
            }

            if (mFadeState == FadeState.FadeOut)
            {
                mMix = mFadeOutWeight * (1.0f - upperElementMix);

                if (!(mMix > 0.0f))
                {
                    mFadeState = FadeState.Stopped;
                    mMix       = 0.0f;
                }
            }

            UpdateAnimationTime(gameTime);
        }
예제 #52
0
        private void ExecuteWhenStateTransitionsToCrossFade(float[] buffer, int sampleCount)
        {
            fadeState = FadeState.FullVolume;

            if (!_nondivisibleFlag)
            {
                var time = bytesRead * 1000 / source.WaveFormat.SampleRate * source.WaveFormat.Channels;
                source = source.Skip(TimeSpan.FromMilliseconds(timetoSkip + time));
            }
            else
            {
                var tempBuffer = new float[copyofOffsetSamples];
                source = source.Skip(TimeSpan.FromMilliseconds(timetoSkip));

                try
                {
                    source.Read(tempBuffer, 0, copyofOffsetSamples);
                }
                catch { }

                var mod = bytesRead % sampleCount;
                if (mod == 0)
                {
                    var times = bytesRead / sampleCount;
                    for (int count = 0; count < times; count++)
                    {
                        source.Read(buffer, 0, sampleCount);
                    }
                }
                else
                {
                    // for wasapi exlusive and non-exclusive mode
                    while (bytesRead > sampleCount)
                    {
                        source.Read(buffer, 0, sampleCount);
                        bytesRead -= sampleCount;
                    }
                    source.Read(buffer, 0, bytesRead);
                }
            }
        }
예제 #53
0
        void Start()
        {
#if UNITY_WSA
            if (!HolographicSettings.IsDisplayOpaque)
            {
                GetComponentInChildren <MeshRenderer>().enabled = false;
                Debug.Log("Removing unnecessary full screen effect from HoloLens");
                return;
            }
#endif

            currentState = FadeState.idle;
            if (FadeSharedMaterial)
            {
                fadeMaterial = GetComponentInChildren <MeshRenderer>().sharedMaterial;
            }
            else
            {
                fadeMaterial = GetComponentInChildren <MeshRenderer>().material;
            }
        }
예제 #54
0
        public void PerformFade(string main, string sub, Action action)
        {
            _fadeState = FadeState.FadeIn;
            Fading     = true;

            _bottomPanel.color = new Color(0, 0, 0, 1);
            _bottomPanel.gameObject.SetActive(false);

            _topPanel.color = new Color(0, 0, 0, 0);
            _topPanel.gameObject.SetActive(true);

            _mainText.text = main;
            _subText.text  = sub;

            _mainText.gameObject.SetActive(false);
            _subText.gameObject.SetActive(false);

            _action = action;

            this.gameObject.SetActive(true);
        }
        private void FadeIn(float[] buffer, int offset, int sourceSamplesRead)
        {
            int sample = 0;

            while (sample < sourceSamplesRead)
            {
                for (int ch = 0; ch < source.WaveFormat.Channels; ch++)
                {
                    buffer[offset + sample++] *= fadePosition;
                }
                fadePosition += fadeStep;
                if (fadePosition >= 1)
                {
                    fadePosition = 1;
                    fadeState    = FadeState.FullVolume;
                    // no need to multiply any more
                    eventInvokeQueue.Enqueue(() => OnFadeInCompleted?.Invoke(this, EventArgs.Empty));
                    break;
                }
            }
        }
예제 #56
0
    IEnumerator FadeFromBlack()
    {
        Debug.Log("Fading");
        Color c = fadeImage.color;

        c.a             = 1f;
        fadeImage.color = c;

        while (c.a > 0f)
        {
            c.a            -= fadeSpeed * Time.deltaTime;
            fadeImage.color = c;
            yield return(null);
        }

        c.a             = 0f;
        fadeImage.color = c;
        state           = FadeState.FadeOut;
        fadeImage.gameObject.SetActive(false);
        StaticDelegates.PlaySequence(true);
    }
예제 #57
0
        public void OnFadeTweenComplete()
        {
            switch (_fadeState)
            {
            case FadeState.Idle:
                break;

            case FadeState.FadeOut:
                ChangeScene();
                _fadeState = FadeState.FadeIn;
                var fadeLayer = GetNode <FadeLayer>("FadeLayer");
                var fadeTween = fadeLayer.GetNode <Tween>("FadeTween");
                fadeTween.InterpolateProperty(fadeLayer, "Percent", 1.0, 0.0, 0.5F, Tween.TransitionType.Linear, Tween.EaseType.In, 0.0F);
                fadeTween.Start();
                break;

            case FadeState.FadeIn:
                _fadeState = FadeState.Idle;
                break;
            }
        }
예제 #58
0
        /// <summary>
        /// Fades the information.
        /// </summary>
        /// <param name="buffer">The buffer.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="sourceSamplesRead">The source samples read.</param>
        private void FadeIn(float[] buffer, int offset, int sourceSamplesRead)
        {
            var sample = 0;

            while (sample < sourceSamplesRead)
            {
                var multiplier = fadeSamplePosition / (float)fadeSampleCount;
                for (var ch = 0; ch < source.WaveFormat.Channels; ch++)
                {
                    buffer[offset + sample] *= multiplier;
                    sample++;
                }

                fadeSamplePosition++;
                if (fadeSamplePosition > fadeSampleCount)
                {
                    fadeState = FadeState.FullVolume;
                    break;
                }
            }
        }
예제 #59
0
    private void FadeIn(float[] buffer, int offset, int sourceSamplesRead)
    {
        int sample = 0;

        while (sample < sourceSamplesRead)
        {
            float multiplier = this.fadeSamplePosition / (float)this.fadeSampleCount;
            for (int ch = 0; ch < this.source.WaveFormat.Channels; ch++)
            {
                buffer[offset + sample++] *= multiplier;
            }
            this.fadeSamplePosition++;
            if (this.fadeSamplePosition > this.fadeSampleCount)
            {
                this.fadeState = FadeState.FullVolume;
                // no need to multiply any more
                this.FadingFinished?.Invoke(this, EventArgs.Empty);
                break;
            }
        }
    }
예제 #60
0
 private void Awake()
 {
     if(GetComponent<Renderer>().material.color != null)
     {
         color = GetComponent<Renderer>().material.color;
         if(color.a > ColorConcentration.centor)
         {
             alpha = ColorConcentration.max;
             fadeState = FadeState.FadeOut;
         }
         else
         {
             alpha = ColorConcentration.min;
             fadeState = FadeState.FadeIn;
         }
         color = new Color(color.r, color.g, color.b, alpha);
     }
     else
     {
         enabled = false;
     }
 }