Example #1
0
        public Sequence(int length, PlayOrder order)
        {
            current   = 0;
            playOrder = order;

            if ((int)playOrder != 2)
            {
                sequence = new int[length];
                // Fill the array, otherwise the randomization won't have anything
                // to randomize
                for (int i = 0; i < sequence.Length; i++)
                {
                    sequence[i] = i;
                }
            }

            orderers = new IPlayOrder[] {
                new PlayOrderSeq(),
                new PlayOrderRnd(),
                new PlayOrderBlank(),
                new PlayOrderSeq()
            };

            GetOrderer(playOrder).Sort(sequence);
        }
Example #2
0
        public Player NextTurn()
        {
            var currentPlayer = PlayOrder.First();

            PlayOrder.RemoveAt(0);
            PlayOrder.Add(currentPlayer);
            CurrentPlayer = PlayOrder.First();
            return(CurrentPlayer);
        }
Example #3
0
        public void Start(ObservableCollection <Player> players)
        {
            var firstPlayerIndex = players.IndexOf(players.OrderBy(p => p.Character.Birthday).FirstOrDefault());

            foreach (var player in players.Skip(firstPlayerIndex))
            {
                PlayOrder.Add(player);
            }
            foreach (var player in players.Take(firstPlayerIndex))
            {
                PlayOrder.Add(player);
            }
            CurrentPlayer = PlayOrder.First();
        }
Example #4
0
        private void playNextSong(PlayOrder order)
        {
            if (nowPlayingMusic == null || playList.Count <= 0)
            {
                return;
            }
            Music nextSong = null;

            switch (order)
            {
            case PlayOrder.random:
                if (playList.Count == 1)
                {
                    nextSong = nowPlayingMusic;
                    break;
                }
                Random random = new Random();
                while (true)
                {
                    var randomIndex = random.Next(playList.Count);
                    if (randomIndex != nowPlayingMusic.number)
                    {
                        nextSong = playList[randomIndex];
                        break;
                    }
                }
                break;

            case PlayOrder.order:
                if (nowPlayingMusic.number + 1 < playList.Count)
                {
                    nextSong = playList[nowPlayingMusic.number + 1];
                }
                else
                {
                    nextSong = playList[0];
                }
                break;

            case PlayOrder.loop:
                nextSong = nowPlayingMusic;
                break;

            case PlayOrder.reverseOrder:
                if (nowPlayingMusic.number - 1 >= 0)
                {
                    nextSong = playList[nowPlayingMusic.number - 1];
                }
                else
                {
                    nextSong = playList[playList.Count - 1];
                }
                break;

            default:
                break;
            }
            stop();
            nowPlayingMusic    = nextSong;
            audioEngine.Source = nextSong.path;
            play();
        }
Example #5
0
 private IPlayOrder GetOrderer(PlayOrder po)
 {
     return(orderers[(int)po]);
 }
Example #6
0
 public Settings(Uri lastMusicUri, PlayOrder playOrder, double volumeValue)
 {
     this.lastMusicUri = lastMusicUri;
     this.playOrder    = playOrder;
     this.volumeValue  = volumeValue;
 }