コード例 #1
0
	// Update is called once per frame
	void Update () {

        switch(currentState)
        {
            case CreditsState.FadingIn:
                if (!fadeScript.FadingToClear)
                {
                    currentState = CreditsState.WaitingTitle;
                    waitingTime = 0;
                }
                break;

            case CreditsState.WaitingTitle:
                waitingTime += Time.deltaTime;
                if (waitingTime > initialDelay)
                    currentState = CreditsState.Crawling;
                break;

            case CreditsState.Crawling:
                Vector3 displacement = Vector3.up * Time.deltaTime * crawlingSpeed;
                credits.Translate(displacement);
                copyright.Translate(displacement);
                if (copyright.transform.position.y > Screen.height/2)
                {
                    currentState = CreditsState.WaitingCopyRight;
                    waitingTime = 0;
                }
                break;

            case CreditsState.WaitingCopyRight:
                credits.Translate(Vector3.up * Time.deltaTime * crawlingSpeed);
                waitingTime += Time.deltaTime;
                if (waitingTime > finalDelay)
                {
                    fadeScript.StartFadingToColor(Color.black, 4f);
                    volumeFadeTime = 0f;
                    currentState = CreditsState.FadingOut;
                }
                break;

            case CreditsState.FadingOut:
                //Continue crawling
                //credits.Translate(Vector3.up * Time.deltaTime * crawlingSpeed);
                volumeFadeTime += Time.deltaTime;
                music.volume = Mathf.Lerp(1, 0, 1 / 4f * volumeFadeTime);

                if (!fadeScript.FadingToColor)
                {
                    SceneManager.LoadScene("MainMenu");
                }
                break;
        }

        if (Input.GetButtonDown("Back"))
        {
            fadeScript.StartFadingToColor(Color.black, 2f);
            volumeFadeTime = 0f;
            currentState = CreditsState.FadingOut;
        }
    }
コード例 #2
0
    void Update()
    {
        JSONNode currentNode = creditsJson [frame];

        Debug.Log ("Value: " + scrollbar.value + " / " + scrollbar.size + " / " + frame);
        switch (state) {
        case CreditsState.Start:
            string currentTitle = currentNode ["title"].Value;
            string currentText = currentNode ["text"].Value;

            title.color = new Color (1f, 1f, 1f, 0f);
            credits.color = new Color (1f, 1f, 1f, 0f);
            title.text = currentTitle;
            credits.text = "\n" + currentText + "\n";

            state = CreditsState.FadeIn;
            break;

        case CreditsState.FadeIn:
            scrollbar.value = 1f;
            title.color = new Color (1f, 1f, 1f, Mathf.Lerp (title.color.a, 1f, .15f));
            credits.color = new Color (1f, 1f, 1f, Mathf.Lerp (credits.color.a, 1f, .15f));

            if (title.color.a > .9f) {
                title.color = new Color (1f, 1f, 1f, 1f);
                credits.color = new Color (1f, 1f, 1f, 1f);
                state = CreditsState.Show;
                frameShowTime = Time.realtimeSinceStartup;
            }
            break;
        case CreditsState.Show:
            if (scrollbar.value > .05f && scrollbar.size < .95f) {
                scrollbar.value = scrollbar.value - scrollbar.size / 10f;
                frameShowTime = Time.realtimeSinceStartup;
            } else {
                if (Time.realtimeSinceStartup > frameShowTime + 4f) {
                    state = CreditsState.FadeOut;
                }
            }
            break;
        case CreditsState.FadeOut:
            title.color = new Color (1f, 1f, 1f, Mathf.Lerp (title.color.a, 0, .15f));
            credits.color = new Color (1f, 1f, 1f, Mathf.Lerp (credits.color.a, 0, .15f));
            if (title.color.a < .05f) {
                state = CreditsState.Start;
                frame = frame + 1;
                if (creditsJson [frame] == null) {
                    frame = 0;
                }
            }
            break;
        }
    }
コード例 #3
0
        /// <summary>
        /// Creates a new credtis screen.
        /// </summary>
        public Credits()
        {
            _spriteFont = ScrollingShooterGame.Game.Content.Load<SpriteFont>(SPRITESHEET);
            _position = new Vector2(50, 50);
            _state = CreditsState.Display;
            _timer = 0;
            _index = 0;
            _displayString = _credits[_index++];

            Music = ScrollingShooterGame.Game.Content.Load<Song>("Music/12 Superbia");
            NextLevel = (int)LevelManager.Level.Airbase;
        }
コード例 #4
0
ファイル: MenuCredits.cs プロジェクト: SteinLabs/Gravity
		public void SetState (int state)
		{
			_state = (CreditsState)state;

			Load ();
		}
コード例 #5
0
 void ShowCredits()
 {
     state = CreditsState.Start;
     frame = 0;
 }
コード例 #6
0
 /// <summary>
 /// Updates the display of the credits screen.
 /// </summary>
 /// <param name="elapsedTime">Time since the last call.</param>
 public override void Update(float elapsedTime)
 {
     _timer += elapsedTime;
     if (_timer >= STATE_TIME)
     {
         _timer = 0;
         switch (_state)
         {
             case CreditsState.Display:
                 _state = (_index == _credits.Length) ? CreditsState.Finished : CreditsState.NonDisplay;
                 _displayString = String.Empty;
                 break;
             case CreditsState.NonDisplay:
                 _state = CreditsState.Display;
                 _displayString = _credits[_index++];
                 break;
             case CreditsState.Finished:
                 _displayString = "Thank you for playing\n\nPress enter to play again.";
                 Done = true;
                 break;
             default:
                 throw new Exception("Unexpected State.");
         }
     }
 }
コード例 #7
0
	// Use this for initialization
	void Start ()
    {
        currentState = CreditsState.FadingIn;
        fadeScript.StartFadingToClear();
	}