public static void RandomMap(LobbyMapSelectUI ___mapSelectUI)
        {
            var trav = Traverse.Create(___mapSelectUI);

            Utils.Sound.Play(SystemSE.ok_s);
            validMaps.Clear();

            var datas = trav.Field("scrollCtrl").Field("scrollerDatas").GetValue <LobbyMapSelectInfoScrollController.ScrollData[]>();

            foreach (var data in datas)
            {
                if (data.isEnable)
                {
                    validMaps.Add(data);
                }
            }

            trav.Field("scrollCtrl").Method("OnClick", validMaps[rand.Next(validMaps.Count)]).GetValue();
            trav.Field("scrollCtrl").Method("SetNowLine").GetValue();
        }
Exemplo n.º 2
0
        private static void LobbyMainUI_LoadMapImage_CreateRandomButtons(LobbySelectUI ___selectUI, LobbyMapSelectUI ___mapSelectUI)
        {
            if (___selectUI.transform.Find("Select/SelectView/btnRandom") != null || ___mapSelectUI.transform.Find("Parent/btnRandom") != null)
            {
                return;
            }

            for (var i = 0; i < 2; i++)
            {
                var i1 = i;

                var orig = i == 0 ? ___selectUI.transform.Find("Select/SelectView/btnChange") : ___mapSelectUI.transform.Find("Parent/btnStart");
                if (orig == null)
                {
                    return;
                }

                var copy = Object.Instantiate(orig, orig.transform.parent);
                copy.localPosition = i == 0 ? new Vector3(135, -605) : new Vector3(0, -383);
                copy.name          = "btnRandom";

                var text = copy.GetComponentInChildren <Text>();
                text.text = "■ Random";

                var button = copy.GetComponent <Button>();

                button.onClick.RemoveAllListeners();
                button.onClick.AddListener(delegate
                {
                    if (i1 == 0)
                    {
                        HS2_RandomHPicker.RandomCharacter(___selectUI);
                    }
                    else
                    {
                        HS2_RandomHPicker.RandomMap(___mapSelectUI);
                    }
                });

                if (i == 0)
                {
                    var action = copy.GetComponent <PointerEnterExitAction>();

                    action.listActionEnter.Clear();
                    action.listActionEnter.Add(delegate
                    {
                        if (!button.IsInteractable())
                        {
                            return;
                        }

                        Utils.Sound.Play(SystemSE.sel);
                        text.color = Game.selectFontColor;
                    });

                    action.listActionExit.Clear();
                    action.listActionExit.Add(delegate
                    {
                        if (button.IsInteractable())
                        {
                            text.color = Game.defaultFontColor;
                        }
                    });
                }
                else
                {
                    button.OnPointerEnterAsObservable().Subscribe(delegate
                    {
                        if (!button.IsInteractable())
                        {
                            return;
                        }

                        Utils.Sound.Play(SystemSE.sel);
                        text.color = Game.selectFontColor;
                    });

                    button.OnPointerExitAsObservable().Subscribe(delegate
                    {
                        if (button.IsInteractable())
                        {
                            text.color = Game.defaultFontColor;
                        }
                    });
                }
            }
        }