Exemplo n.º 1
0
        private int mIndex; //Variable to control the value of 'Index'.

        public void Play()
        {
            Player FirstPlayer = GetFirstPlayer(Players);

            Index = Array.IndexOf(Players, FirstPlayer); //Gets the index of the FirstPlayer to make him play.

            //The first player plays and is moved accordingly to his result
            Console.WriteLine("\n -- STARTING GAME -- \n");
            Console.WriteLine("\n");

            while (!IsFinished)              //While the game is not finished...
            {
                NextPlayer = Players[Index]; //The next player is the player at the Index's value.

                if (NextPlayer != null)      //If it isn't null, we make him Play and we move him.
                {
                    NextPlayer.Play();
                    board.ActivateSpace(NextPlayer, NextPlayer.CurrentSpace);
                    Index++;  //Next player is going to play
                }
                else
                {
                    Index++; //If it is null, we skip it.
                }

                if (NextPlayer != null && NextPlayer.CurrentSpace == Board.NUMBER_OF_SPACES)
                {
                    IsFinished = true; //Game is finished when NextPlayer is not null and his current space is equal to the last space avaible.
                    Console.WriteLine($"\n -- GAME FINISHED! WINNER IS {NextPlayer.Name}  -- \n");
                }

                Console.WriteLine("\n");
            }
        }
        public void OpenVideoFile(MediaPlaylist.MediaItem mediaItem)
        {
            bool isMediaAlreadyLoaded = false;

            if (NextPlayer.MediaPath == mediaItem.mediaPath)
            {
                isMediaAlreadyLoaded = true;
            }

            if (!mediaItem.isOverrideTransition)
            {
                SetTransition(_defaultTransition, _defaultTransitionDuration, _defaultTransitionEasing);
            }
            else
            {
                SetTransition(mediaItem.overrideTransition, mediaItem.overrideTransitionDuration, mediaItem.overrideTransitionEasing);
            }

            this.Loop              = NextPlayer.Loop = mediaItem.loop;
            NextPlayer.MediaPath   = new MediaPath(mediaItem.mediaPath);
            this.MediaPath         = new MediaPath(mediaItem.mediaPath);
            NextPlayer.AudioMuted  = _playlistAudioMuted;
            NextPlayer.AudioVolume = _playlistAudioVolume;
            if (_transitionTimer < _currentTransitionDuration && _currentTransition != Transition.None)
            {
                NextPlayer.AudioVolume = 0f;
            }

            if (isMediaAlreadyLoaded)
            {
                NextPlayer.Rewind(false);
                if (_nextItem.startMode == StartMode.Immediate)
                {
                    NextPlayer.Play();
                }
                // TODO: We probably want to wait until the new frame arrives before swapping after a Rewind()
                SwapPlayers();
            }
            else
            {
                if (string.IsNullOrEmpty(NextPlayer.MediaPath.Path))
                {
                    NextPlayer.CloseMedia();
                }
                else
                {
                    NextPlayer.OpenMedia(NextPlayer.MediaPath.PathType, NextPlayer.MediaPath.Path, _nextItem.startMode == StartMode.Immediate);
                }
            }
        }
        public void OpenVideoFile(MediaPlaylist.MediaItem mediaItem)
        {
            bool isMediaAlreadyLoaded = false;

            /*
             * if (NextPlayer.m_VideoPath == mediaItem.filePath && NextPlayer.m_VideoLocation == mediaItem.fileLocation)
             * {
             *      isMediaAlreadyLoaded = true;
             * }*/

            if (mediaItem.isOverrideTransition)
            {
                SetTransition(mediaItem.overrideTransition, mediaItem.overrideTransitionDuration, mediaItem.overrideTransitionEasing.preset);
            }
            else
            {
                SetTransition(_nextTransition, _transitionDuration, _transitionEasing.preset);
            }

            this.m_Loop          = NextPlayer.m_Loop = mediaItem.loop;
            this.m_AutoStart     = NextPlayer.m_AutoStart = mediaItem.autoPlay;
            this.m_VideoLocation = NextPlayer.m_VideoLocation = mediaItem.fileLocation;
            this.m_VideoPath     = NextPlayer.m_VideoPath = mediaItem.filePath;
            this.m_StereoPacking = NextPlayer.m_StereoPacking = mediaItem.stereoPacking;
            this.m_AlphaPacking  = NextPlayer.m_AlphaPacking = mediaItem.alphaPacking;

            if (isMediaAlreadyLoaded)
            {
                NextPlayer.Rewind(false);
                if (_nextItem.startMode == StartMode.Immediate)
                {
                    NextPlayer.Play();
                }
                // TODO: We probably want to wait until the new frame arrives before swapping after a Rewind()
                SwapPlayers();
            }
            else
            {
                if (string.IsNullOrEmpty(NextPlayer.m_VideoPath))
                {
                    NextPlayer.CloseVideo();
                }
                else
                {
                    //NextPlayer.m_AutoStart = false;
                    NextPlayer.OpenVideoFromFile(NextPlayer.m_VideoLocation, NextPlayer.m_VideoPath, _nextItem.startMode == StartMode.Immediate);
                }
            }
        }
Exemplo n.º 4
0
        public void OpenVideoFile(MediaPlaylist.MediaItem mediaItem)
        {
            bool isMediaAlreadyLoaded = false;

            if (NextPlayer.m_VideoPath == mediaItem.filePath && NextPlayer.m_VideoLocation == mediaItem.fileLocation)
            {
                isMediaAlreadyLoaded = true;
            }

            SetTransition(_nextTransition);

            this.m_Loop          = NextPlayer.m_Loop = mediaItem.loop;
            this.m_VideoLocation = NextPlayer.m_VideoLocation = mediaItem.fileLocation;
            this.m_VideoPath     = NextPlayer.m_VideoPath = mediaItem.filePath;
            this.m_StereoPacking = NextPlayer.m_StereoPacking = mediaItem.stereoPacking;
            this.m_AlphaPacking  = NextPlayer.m_AlphaPacking = mediaItem.alphaPacking;

            if (isMediaAlreadyLoaded)
            {
                NextPlayer.Rewind(false);
                NextPlayer.Play();
                // TODO: We probably want to wait until the new frame arrives before swapping after a Rewind()
                SwapPlayers();
            }
            else
            {
                if (string.IsNullOrEmpty(NextPlayer.m_VideoPath))
                {
                    NextPlayer.CloseVideo();
                }
                else
                {
                    //NextPlayer.m_AutoStart = false;
                    NextPlayer.OpenVideoFromFile(NextPlayer.m_VideoLocation, NextPlayer.m_VideoPath, true);
                }
            }
        }