Beispiel #1
0
        public void Play()
        {
            Console.WriteLine("PlayingMovie");
            Thread.Sleep(3000);

            //you fire an event simply by calling it like a method

            //if(MovieEnd != null)
            //{
            //    MovieEnd();
            //}

            MovieEnd?.Invoke(Currentmovie.Title);

            //that will run all methods that are subscribed to the event

            //events with no subcribers are null, and cause null exception when fired
            //so we need to check against null first

            //in c#, we have a couple of null handling operators
            //?, is the null-conditional operator
            //it means, behave like . if the thing to the left is not null
            //otherwise do nothing at all
            //otherwise do nothing at all
        }
Beispiel #2
0
        public void Play()
        {
            Console.WriteLine("Playing movie.");

            Thread.Sleep(3000); // movie plays for 3 seconds

            // you fire an event simply by calling it like a method
            //MovieEnd?.Invoke();

            MovieEnd?.Invoke(CurrentMovie.Title); // pass parameters to all subscribers
            // that will run all methods that are subscribed to the event.

            // events with no subscribers are null, and cause null exception when fired.
            // so we need to check against null first.

            // in C#, we have a couple of null-handling operators.
            // ?. is the null-conditional operator.
            //    it means, behave like . if the thing to the left is not null.
            //    otherwise, do nothing at all.

            //if (a != null)
            //{
            //    if (a.b != null)
            //    {
            //        a.b.operate();
            //    }
            //}
            //a.b.operate();
        }
    public void PlayMovie(AvatarToPlayerNotifications playerNotification, VideoClip videoClip, MovieEnd function)
    {
        if (fadeListener == null)
        {
            fadeListener = GameObject.FindGameObjectWithTag("Listener").GetComponent <FadeListener>();
        }
        fadeListener.SetTargetVolume(0);
        fadeListener.OnFadeListener(0);
        playerNotifications = playerNotification;
        listenerHandle      = playerNotifications.AttachListener(transform);

        videoPlayer               = gameObject.AddComponent <VideoPlayer>();
        videoPlayer.clip          = videoClip;
        videoPlayer.targetTexture = renderTexture;
        videoPlayer.Play();
        Debug.Log("Play Movie:" + videoPlayer.name);

        endFunction    = function;
        waitingForPlay = true;
        Time.timeScale = 0;

        fadeInFadeOut.SetToBlack();
    }
Beispiel #4
0
    public void PlayMovie(VideoClip videoClip, MovieEnd function)
    {
        if (fadeListener == null)
        {
            fadeListener = GameObject.FindGameObjectWithTag("Listener").GetComponent <FadeListener>();
        }

        var subtitlesPath = $"Subtitles/{videoClip.name}.sv";

        Debug.Log($"loading subtitles from resource '{subtitlesPath}'");
        var textAsset = Resources.Load(subtitlesPath) as TextAsset;

        if (textAsset == null)
        {
            Debug.LogError($"missing subtitles text, should have been here '{subtitlesPath}'");
        }

        Debug.Log($"found text:{textAsset.text}");

        var subtitlesObject = GameObject.Find("Subtitles");

        Debug.Log($"Found gameobject {subtitlesObject.name}");
        subtitles = subtitlesObject.GetComponent <Subtitles>();
        subtitles.OnSubtitleStart(textAsset.text);
        fadeListener.SetTargetVolume(0);
        fadeListener.OnFadeListener(0);

        videoPlayer.clip = videoClip;
        videoPlayer.Play();
        Debug.Log("Play Movie:" + videoPlayer.name);

        endFunction    = function;
        waitingForPlay = true;
        Time.timeScale = 0;

        fadeInFadeOut.SetToTransparent(); // SetToBlack();
    }