Exemple #1
0
 private void FixedUpdate()
 {
     if (queue.Count > 0)
     {
         VoteResult v = queue.Dequeue();
         handleVote(v);
     }
 }
 private void UpdateTask()
 {
     lock (_queue)
     {
         if (_queue.Count > 0)
         {
             VoteResult v = _queue.Dequeue();
             HandleVote(v);
         }
     }
 }
Exemple #3
0
        static void wc_DownloadStringCompleted(System.Net.DownloadStringCompletedEventArgs e, UnturnedPlayer _caller, Service _service, ServiceDefinition _apidefinition, bool _giveItemDirectly)
        {
            VoteResult v = new VoteResult()
            {
                caller = _caller, result = e.Result, apidefinition = _apidefinition, service = _service, giveItemDirectly = _giveItemDirectly
            };

            lock (queue)
            {
                queue.Enqueue(v);
            }
        }
        private void OnDownloadStringCompleted(System.Net.DownloadStringCompletedEventArgs e, UnturnedPlayer caller, Service service, ServiceDefinition apidefinition, bool giveItemDirectly)
        {
            VoteResult v = new VoteResult
            {
                Caller           = caller,
                Result           = e.Result,
                ApiDefinition    = apidefinition,
                Service          = service,
                GiveItemDirectly = giveItemDirectly
            };

            lock (_queue)
            {
                _queue.Enqueue(v);
            }
        }
        private void HandleVote(VoteResult result)
        {
            switch (result.Result)
            {
            case "0":
                result.Caller.User.SendLocalizedMessage(Translations, "not_yet_voted", result.Service.Name);
                break;

            case "1":
                if (result.GiveItemDirectly)
                {
                    if (!ConfigurationInstance.EnableRewardBundles)
                    {
                        return;
                    }

                    EventManager.Emit(this, new PlayerVotedEvent(result.Caller, result.ApiDefinition), (e) =>
                    {
                        var @event = (PlayerVotedEvent)e;
                        if (@event.IsCancelled)
                        {
                            return;
                        }

                        Votifier_OnPlayerVoted((UnturnedPlayer)@event.Player, @event.Service);
                    });

                    new VotifierWebclient().DownloadStringAsync(new Uri(String.Format(result.ApiDefinition.ReportSuccess, result.Service.APIKey, result.Caller.ToString())));
                    return;
                }
                else
                {
                    result.Caller.User.SendLocalizedMessage(Translations, "vote_pending_message", result.Service.Name);
                    return;
                }

            case "2":
                result.Caller.User.SendLocalizedMessage(Translations, "vote_due_message", result.Service.Name);
                break;
            }
        }
Exemple #6
0
        static void handleVote(VoteResult result)
        {
            UnturnedPlayer p = result.caller;

#if DEBUG
            Console.WriteLine("Webserver returns: " + result.result);
#endif

            switch (result.result)
            {
            case "0":
                UnturnedChat.Say(result.caller, Instance.Translations.Instance.Translate("not_yet_voted", result.service.Name));
                break;

            case "1":
                if (result.giveItemDirectly)
                {
                    if (Instance.OnPlayerVoted != null)
                    {
                        Instance.OnPlayerVoted(result.caller, result.apidefinition);
                    }

                    new VotifierWebclient().DownloadStringAsync(new Uri(String.Format(result.apidefinition.ReportSuccess, result.service.APIKey, result.caller.ToString())));
                    return;
                }
                else
                {
                    UnturnedChat.Say(result.caller, Instance.Translations.Instance.Translate("vote_pending_message", result.service.Name));
                    return;
                }

            case "2":
                UnturnedChat.Say(result.caller, Instance.Translations.Instance.Translate("vote_due_message", result.service.Name));
                break;
            }
        }