Exemple #1
0
    public override void ConfirmAction()
    {
        switch (CurrentState)
        {
        case PlayState.PlayCards:
            CurrentState = PlayState.AssignDamage;
            break;

        case PlayState.AssignDamage:
            CurrentState = PlayState.TakeDamage;
            break;

        case PlayState.TakeDamage:
            CurrentState = PlayState.DrawBuy;
            break;

        case PlayState.DrawBuy:
            CurrentState = PlayState.PlayCards;
            break;

        default:
            CurrentState = PlayState.PlayCards;
            break;
        }

        UIController.Warn(currentState.ToString());

        if (CurrentState == PlayState.TakeDamage)
        {
            StartCoroutine(TimedNextState());
        }
    }
        /// <summary>
        /// Called when the playstate changes, except for the Error state (see OnError)
        /// </summary>
        /// <param name="player">The BackgroundAudioPlayer</param>
        /// <param name="track">The track playing at the time the playstate changed</param>
        /// <param name="playState">The new playstate of the player</param>
        /// <remarks>
        /// Play State changes cannot be cancelled. They are raised even if the application
        /// caused the state change itself, assuming the application has opted-in to the callback.
        ///
        /// Notable playstate events:
        /// (a) TrackEnded: invoked when the player has no current track. The agent can set the next track.
        /// (b) TrackReady: an audio track has been set and it is now ready for playack.
        ///
        /// Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.
        /// </remarks>
        protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
        {
            System.Diagnostics.Debug.WriteLine("AGENT PLAY STATE CHANGED: " + playState.ToString());
            switch (playState)
            {
            case PlayState.TrackEnded:
                player.Track = GetNextTrack();
                break;

            case PlayState.TrackReady:
                player.Play();
                break;

            case PlayState.Shutdown:
                SaveTrackAndTime(player, track);
                break;

            case PlayState.Unknown:
                break;

            case PlayState.Stopped:
                break;

            case PlayState.Paused:
                break;

            case PlayState.Playing:
                break;

            case PlayState.BufferingStarted:
                break;

            case PlayState.BufferingStopped:
                break;

            case PlayState.Rewinding:
                break;

            case PlayState.FastForwarding:
                break;
            }

            NotifyComplete();
        }
        private void UpdatePresence(string song, string duration, int position, PlayState state)
        {
            DiscordRPC.RichPresence presence = new DiscordRPC.RichPresence();
            //presence.state = state;
            song                   = Utility.Utf16ToUtf8(song);
            presence.details       = song.Substring(0, song.Length - 1);
            presence.largeImageKey = "musicbee";
            long now = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            if (state == PlayState.Playing)
            {
                presence.state          = "Listening to music";
                presence.startTimestamp = now - position;
            }
            else if (state == PlayState.Paused || state == PlayState.Stopped)
            {
                presence.state          = state.ToString();
                presence.startTimestamp = 0;
            }
            // string[] durations = duration.Split(':');
            // long end = now + System.Convert.ToInt64(durations[0]) * 60 + System.Convert.ToInt64(durations[1]);
            // presence.endTimestamp = end;
            DiscordRPC.UpdatePresence(ref presence);
        }
 public SetPlayStateCommand(int playerId, PlayState playState)
     : base($"player/set_play_state?pid={playerId}&state={playState.ToString().ToLower()} ")
 {
     PlayerId  = playerId;
     PlayState = playState;
 }
        /// <summary>
        /// Called when the playstate changes, except for the Error state (see OnError)
        /// </summary>
        /// <param name="player">The BackgroundAudioPlayer</param>
        /// <param name="track">The track playing at the time the playstate changed</param>
        /// <param name="playState">The new playstate of the player</param>
        /// <remarks>
        /// Play State changes cannot be cancelled. They are raised even if the application
        /// caused the state change itself, assuming the application has opted-in to the callback.
        /// 
        /// Notable playstate events: 
        /// (a) TrackEnded: invoked when the player has no current track. The agent can set the next track.
        /// (b) TrackReady: an audio track has been set and it is now ready for playack.
        /// 
        /// Call NotifyComplete() only once, after the agent request has been completed, including async callbacks.
        /// </remarks>
        protected override void OnPlayStateChanged(BackgroundAudioPlayer player, AudioTrack track, PlayState playState)
        {
            System.Diagnostics.Debug.WriteLine("AGENT PLAY STATE CHANGED: " + playState.ToString());
            switch (playState)
            {
                case PlayState.TrackEnded:
                    player.Track = GetNextTrack();
                    break;
                case PlayState.TrackReady:
                    player.Play();
                    break;
                case PlayState.Shutdown:
                    SaveTrackAndTime(player, track);
                    break;
                case PlayState.Unknown:
                    break;
                case PlayState.Stopped:
                    break;
                case PlayState.Paused:
                    break;
                case PlayState.Playing:
                    break;
                case PlayState.BufferingStarted:
                    break;
                case PlayState.BufferingStopped:
                    break;
                case PlayState.Rewinding:
                    break;
                case PlayState.FastForwarding:
                    break;
            }

            NotifyComplete();
        }
Exemple #6
0
        public async Task <Client> Connect()
        {
            if (state == PlayState.CONNECTING)
            {
                //
                Logger.Debug("it is connecting...");
                return(null);
            }
            if (state != PlayState.INIT && state != PlayState.DISCONNECT)
            {
                throw new PlayException(PlayExceptionCode.StateError,
                                        string.Format("You cannot call Connect() on {0} state", state.ToString()));
            }
            try {
                state     = PlayState.CONNECTING;
                lobbyConn = await ConnectLobby();

                state = PlayState.LOBBY;
                Logger.Debug("connected at: {0}", Thread.CurrentThread.ManagedThreadId);
                lobbyConn.OnMessage += OnLobbyConnMessage;
                lobbyConn.OnClose   += OnLobbyConnClose;
                return(this);
            } catch (Exception e) {
                state = PlayState.INIT;
                throw e;
            }
        }
Exemple #7
0
 public void OnStateChange(PlayState NewState)
 {
     GetComponent <Text>().text = NewState.ToString();
 }
 public static String PlayStateToString(PlayState currentPlayState)
 {
     return("PLAY_STATE|" + currentPlayState.ToString());
 }