Beispiel #1
0
        public void Init()
        {
            btn.GetComponent <Button>().onClick.AddListener(() =>
            {
                if (DataController.instance.catsPurse.Hearts > 0 || game_type == GameType.COINS)
                {
                    //MessageBus.Restore();
                    DataController.instance.other_storage["game_name"] =
                        game_name.ToString();

                    DataController.instance.other_storage["game_type"] =
                        game_type.ToString();

                    MessageBus.Instance.SendMessage(new Message(
                                                        Common.LoadingScreen.API.LoadingScreenAPI.OPEN_OPEN_ANIM,
                                                        new Common.LoadingScreen.API.SceneNameParametr(
                                                            Common.LoadingScreen.API.SceneNames.MINIGAMES, false)));
                }

                else
                {
                    MessageBus.Instance.SendMessage(MainMenuMessageType.NOTE_ENOUGH_HEARTS);
                }
            });

            icon.sprite = ResourceHelper.LoadSprite(game_name.ToString());

            title.text = game_name.ToString().ToUpper() + " CAT";

            //if (game_type == GameType.COINS)
            //{
            //    GameRecords rec =
            //        DataController.instance.gamesRecords.Record(game_name.ToString());
            //    score.text = "Best: " + rec.best_value + "\n" +
            //        "Last: " + rec.last_value;
            //}
            //else if(game_type == GameType.STARS)
            //{
            //    var task = StarTasksController.instance.get_cur_task(game_name.ToString());
            //    string text = TextManager.getText("mm_minigames_aims_text");

            //    foreach (TaskInfo t in task.task_info)
            //    {
            //        text += TextManager.getText("mm_minigames_" + t.type.ToString() + "_text")
            //            + " " + t.value.ToString() + "\n";
            //    }

            //    score.text = text;
            //}

            btn.transform.GetChild(0).gameObject.GetComponent <Text>().text = TextManager.getText("mm_minigames_play_btn_text");
        }
Beispiel #2
0
        private List <string> EnumToString()
        {
            List <string> strings = new List <string>();

            strings.Add(Game.ToString());
            return(strings);
        }
Beispiel #3
0
        public async Task New(GameName gameName, string apiKey = "")
        {
            _gameName   = gameName.ToString().ToLower();
            _httpClient = new HttpClient()
            {
                BaseAddress = new Uri("https://api.nexusmods.com"),
                Timeout     = TimeSpan.FromSeconds(5)
            };

            if (apiKey != string.Empty)
            {
                _apiKey = apiKey;

                _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                _httpClient.DefaultRequestHeaders.Add("APIKEY", _apiKey);
                _httpClient.Timeout = TimeSpan.FromMinutes(1);

                // Get the premium status of the account
                var response = await _httpClient.GetAsync("/v1/users/validate.json");

                _isPremium  = (bool)JObject.Parse(response.Content.ReadAsStringAsync().Result)["is_premium"];
                _isLoggedIn = true;

                RemainingDailyRequests = Convert.ToInt32(response.Headers.GetValues("X-RL-Daily-Remaining").ToList().First());

                HasLoggedInEvent.Invoke();

                return;
            }

            // If there is no API key passed through, generate a new one.
            var guid      = Guid.NewGuid();
            var websocket = new WebSocket("wss://sso.nexusmods.com")
            {
                SslConfiguration = { EnabledSslProtocols = SslProtocols.Tls12 }
            };

            websocket.OnMessage += (sender, args) =>
            {
                if (args == null || string.IsNullOrEmpty(args.Data))
                {
                    return;
                }

                _apiKey = args.Data;

                _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                _httpClient.DefaultRequestHeaders.Add("APIKEY", _apiKey);

                // Get the premium status of the account
                var response = _httpClient.GetAsync("/v1/users/validate.json").Result;
                _isPremium  = (bool)JObject.Parse(response.Content.ReadAsStringAsync().Result)["is_premium"];
                _isLoggedIn = true;

                RemainingDailyRequests = Convert.ToInt32(response.Headers.GetValues("X-RL-Daily-Remaining").ToList().First());

                HasLoggedInEvent.Invoke();
            };

            await Task.Factory.StartNew(() =>
            {
                websocket.Connect();
                websocket.Send("{\"id\": \"" + guid + "\", \"appid\": \"The Automaton Framework\"}");
            });

            Process.Start($"https://www.nexusmods.com/sso?id={guid}");
        }