using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using DG.Tweening;
using FairyGUI;
using FGUI.Common_01;
using FGUI.Lobby_03;
using IgnoreOPS;
using Newtonsoft.Json;
using SGModule.ApplePay;
using Spine.Unity;
using UnityEngine;

namespace ChillConnect
{
    public class HallUI : BaseUI
    {
        private HallUICtrl ctrl;
        private HallModel model;
        public com_hall ui;

        public static bool isClosed;

        private long userUid;
        public int ad_numbers;
        public int ad_times;
        public int active_cd = 10;
        private Tweener tweener;

        private SkeletonAnimation anim_ad;

        private int limitTimes;
        private int OnlineLimit;
        private string formattedDate = "";
        private btn_noads btn_noads;
        public HallUI(HallUICtrl ctrl) : base(ctrl)
        {
            uiName = UIConst.HallUI;
            this.ctrl = ctrl;
        }

        protected override void SetUIInfo(UIInfo uiInfo)
        {
            uiInfo.packageName = "Lobby_03";
            uiInfo.assetName = "com_hall";
            uiInfo.layerType = UILayerType.Normal;
            uiInfo.isNeedOpenAnim = false;
            uiInfo.isNeedCloseAnim = false;
            uiInfo.isNeedUIMask = false;
        }

        #region 生命周期

        protected override void OnInit()
        {
            model = moduleManager.GetModel(ModelConst.HallModel) as HallModel;
            InitData();
        }

        protected override void OnClose()
        {
            HallManager.Instance.UpdateSecondEvent -= UpBtnCoin;

            isClosed = true;
            //关闭时保存cd数据
            PlayerPrefs.SetInt($"active_cd_num_{userUid}", active_cd);
            // HallManager.Instance.countTimes = (int)Time.time;

            CommonHelper.FadeOut(ui);
            tweener?.Kill();
            closeCallback?.Invoke();
        }

        protected override void OnBind()
        {
            ui = baseUI as com_hall;
        }

        protected override void OnOpenBefore(object args)
        {
            if (Screen.safeArea.y != 0)
            {
                //   ui.top_group.y += 68;
                ui.left_group.y += 68;
                ui.right_group.y += 68;
            }

            // ui.com_panel.scrollPane.ScrollRight(12,false);
            // if(GameHelper.IsGiftSwitch())
            // {
            //     ui.com_panel.scrollPane.touchEffect = false;
            // }
            var anim_paly = FXManager.Instance.SetFx<SkeletonAnimation>(ui.btn_gold.GetChild("gold_anim") as GGraph,
                Fx_Type.fx_coin, ref closeCallback);
            anim_paly.state.SetAnimation(0, "animation", true);

            CreateGoldtimeList();

            int num = PlayerPrefs.GetInt("new_one", 0);


            limitTimes = ConfigSystem.GetConfig<OnlineRewardsModel>().DataList[0].OnlineCountTime;
            OnlineLimit = ConfigSystem.GetConfig<OnlineRewardsModel>().DataList[0].OnlineLimitNum;

            DateTime dataTime = DateTime.Now;
            formattedDate = dataTime.ToString("yyyy_MM_dd");

            btn_noads = ui.btn_noads as btn_noads;

            // int hall_cd = PlayerPrefs.GetInt($"coin_cd_times_{formattedDate}", 0);
            // if (HallManager.Instance.countTimes != 0)
            // {
            //     int cds = (int)Time.time - HallManager.Instance.countTimes;
            //     cds = hall_cd - cds;
            //     PlayerPrefs.SetInt($"coin_cd_times_{formattedDate}", cds <= 0 ? 0 : cds);
            //     HallManager.Instance.countTimes = 0;
            // }
            GameHelper.IsShowFirstReward();

            isClosed = false;

            var loginModel = GameHelper.GetLoginModel();
            userUid = loginModel.Uid;

            RankSystemMgr.Instance.checkUsers();
            InitView();
            UpBtnCoin();

            HallManager.Instance.UpdateSecondEvent += UpBtnCoin;
            (ui.btn_money as com_money).btn_ch.title = GameHelper.getDesByKey("ch_out_1");

        }

        protected override void OnOpen(object args)
        {
            // CommonHelper.FadeIn(ui);
        }

        protected override void OnHide()
        {
        }

        protected override void OnDisplay(object args)
        {
        }

        public override void OnSwitchLanguage()
        {
            base.OnSwitchLanguage();
            InitView();
        }

        #endregion

        #region 消息

        protected override void AddListener()
        {
            HallManager.Instance.AddChangeGiftSwitch(InitView);
            GameDispatcher.Instance.AddListener(GameMsg.RefreshMakeupData, OnRefreshMakeupData);
            GameDispatcher.Instance.AddListener(GameMsg.RefreshRedDot, RefreshRed);
            PreferencesDispatcher<int>.Instance.AddListener(DataMsg.playerAvatarId, UpdataAvatar);
            GameDispatcher.Instance.AddListener(GameMsg.noads_refresh, SetBtnAds);
            PreferencesDispatcher<string>.Instance.AddListener(DataMsg.playerName, OnChangeName);
            HallManager.Instance.UpdateEvent += UpdateEvent;
        }

        protected override void RemoveListener()
        {
            HallManager.Instance.RemoveChangeGiftSwitch(InitView);
            GameDispatcher.Instance.RemoveListener(GameMsg.RefreshMakeupData, OnRefreshMakeupData);
            GameDispatcher.Instance.RemoveListener(GameMsg.RefreshRedDot, RefreshRed);
            GameDispatcher.Instance.RemoveListener(GameMsg.noads_refresh, SetBtnAds);
            PreferencesDispatcher<int>.Instance.RemoveListener(DataMsg.playerAvatarId, UpdataAvatar);

            PreferencesDispatcher<string>.Instance.RemoveListener(DataMsg.playerName, OnChangeName);
            HallManager.Instance.UpdateEvent -= UpdateEvent;
        }

        #endregion

        private List<Paidcoins> Paidcoins_list = ConfigSystem.GetConfig<PaidcoinsModel>().DataList;

        private int time_count = 11;
        private com_broadcast_text1 text_ui;

        void CreateGoldtimeList()
        {
            // 获取保存对象
            var saveObject = SaveData.GetSaveObject();

            // 检查_goldtime是否为null或者长度与Paidcoins_list.Count不相等
            if (saveObject._goldtime == null || saveObject._goldtime.Length != Paidcoins_list.Count)
            {
                // 重置_goldtime，并创建一个新的数组，长度为Paidcoins_list.Count
                saveObject._goldtime = new int[Paidcoins_list.Count];
            }
        }

        private void UpBtnCoin()
        {
            int time = SaveData.GetSaveObject()._goldtime[0];
            com_gold btn_gold = ui.btn_gold as com_gold;
            if (time + Paidcoins_list[0].receive_CD < GameHelper.GetNowTime())
            {
                btn_gold.state.selectedIndex = 2;
                ui.btn_shop.red.visible = true;
            }
            else
            {
                btn_gold.state.selectedIndex = 1;
                ui.btn_shop.red.visible = false;
            }
            checkThreeGift();
            time_count++;
            ui.btn_sign.red.visible = signRed();
            if (!GameHelper.IsGiftSwitch())
                return;
            if (DataMgr.MakeupTaskHistory.Value.Count < 1)
                return;
            MakeupTaskData data = DataMgr.MakeupTaskHistory.Value[DataMgr.MakeupTaskHistory.Value.Count - 1];
            if (data.status != MakeupTaskStatus.Level)
            {
                (ui.btn_money as com_money).group_tips.visible = false;
                return;
            }
            if (data.ch_time > GameHelper.GetNowTime())
            {
                (ui.btn_money as com_money).text_time.text = "Only " + CommonHelper.TimeFormat((int)data.ch_time - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
            }
            else
            {
                (ui.btn_money as com_money).group_tips.visible = false;
                return;
            }
            time_number++;
            if (time_number > 15)
            {
                (ui.btn_money as com_money).group_tips.visible = true;
            }
            if (time_number > 20)
            {
                (ui.btn_money as com_money).group_tips.visible = false;
                time_number = 0;
            }
        }
        private int time_number = 0;

        void OnRefreshMakeupData(object obj)
        {
        }

        private void InitData()
        {
            model.showCoin = DataMgr.Coin.Value;
            model.showDollar = DataMgr.Ticket.Value;
        }

        private Action closeCallback;

        private List<btn_level_play> btn_play_list;
        private void InitView()
        {
            // var anim_paly = FXManager.Instance.SetFx<SkeletonAnimation>(ui.btn_play.GetChild("btn_parent") as GGraph,
            //     Fx_Type.fx_btn_play, ref closeCallback);
            // anim_paly.state.SetAnimation(0, "animation", true);

            btn_play_list = new List<btn_level_play> { ui.com_level.btn_play1, ui.com_level.btn_play2, ui.com_level.btn_play3, ui.com_level.btn_play4, ui.com_level.btn_play5 };

            InitBtn();
            Set101();
            Set102();
            SetName(ui.text_name);
            RefreshRed();
            SetBtnAds();
            UpdataAvatar();


            ui.btn_sign.SetClickDownEffect(1.0f);
            ui.btn_sign.SetClick(OnClickTreasure);

            ui.btn_spin.SetClick(() =>
            {
                OnClickLuckySpin();
            });
            ui.bnt_luck_gift.SetClick(() =>
            {
                OnClickShop();
            });
            ui.btn_shop.SetClick(() =>
            {
                OnClickShop();
            });

           // ui.head_red.visible = PlayerPrefs.GetInt("player_head_red", 0) == 0;
            ui.btn_head.SetClick(() =>
            {
                // if (PlayerPrefs.GetInt("player_head_red", 0) == 0) PlayerPrefs.SetInt("player_head_red", 1);
                // ui.head_red.visible = PlayerPrefs.GetInt("player_head_red", 0) == 0;
                UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.MenuUI_Open);
            });

            var btnCoin = ui.btn_gold as com_gold;
            btnCoin.text_gold.text = $"{DataMgr.Coin.Value:N0}";
            btnCoin.SetClick(OnClickShop);

            ad_times = PlayerPrefs.GetInt("main_ad_times", 0);
            ad_numbers = PlayerPrefs.GetInt("main_ad_numbers", 1);

            if (HallManager.Instance.enterHallTimes == 1)
            {
                reCreatPur();
            }

            ui.state.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;

            if (ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 0 || !GameHelper.IsGiftSwitch())
            {
                ui.btn_saveingpot.visible = false;
            }

            ui.btn_saveingpot.SetClick(() =>
            {
                uiCtrlDispatcher.Dispatch(UICtrlMsg.SaveingPotUI_Open);
            });

            btn_noads.SetClick(() =>
            {
                if (!SaveData.GetSaveObject().is_get_packreward && !SaveData.GetSaveObject().is_get_removead)
                {
                    if (btn_noads.GetChild("img_ad").visible)
                    {
                        PackRewardData param = new PackRewardData();
                        param.isAutoPop = false;
                        param.isNeedScroll = true;
                        UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PackrewardUI_Open, param);
                    }
                    else
                    {
                        UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PackrewardUI_Open);
                    }

                }
                else if (SaveData.GetSaveObject().is_get_packreward)
                {
                    PackRewardData param = new PackRewardData();
                    param.isAutoPop = false;
                    param.isNeedScroll = true;
                    UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PackrewardUI_Open, param);
                }
                else
                {
                    UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PackrewardUI_Open);
                }
                GameHelper.showGameUI = false;
            });

            if (ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1 && GameHelper.IsGiftSwitch())
            {
                bool isPopPot = false;
                if (GameHelper.GetLoginModel().NewPlayer)
                {
                    isPopPot = true;
                    uiCtrlDispatcher.Dispatch(UICtrlMsg.SaveingPotUI_Open);
                }
                else
                {
                    if (DateTime.Now.Day != PlayerPrefs.GetInt("pot_day", 0))
                    {
                        isPopPot = true;
                        uiCtrlDispatcher.Dispatch(UICtrlMsg.SaveingPotUI_Open);
                        PlayerPrefs.SetInt("pot_day", DateTime.Now.Day);
                    }
                }

                if (!isPopPot)
                {
                    var data = SaveData.GetRankData().rankRewardData;
                    if (data.Count > 0 && !HallManager.Instance.isShowRankView)
                    {
                        HallManager.Instance.isShowRankView = true;
                        uiCtrlDispatcher.Dispatch(UICtrlMsg.RankRewardUI_Open);
                    }
                }
            }

            checkThreeGift();
            ui.btn_failpack.SetClick(() =>
            {
                float progress = showResurgence();

                UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ResurgenceUI_Open, progress);
            });

            ui.btn_three_day.SetClick(() =>
            {
                uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open);
            });

            ui.btn_battle.SetClick(() =>
            {
                OnClickPass();
            });

            ui.btn_faq.SetClick(() =>
            {
                UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.FAQUI_Open);
            });
            ui.btn_rank.SetClick(() =>
            {
                UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.RankUI_Open);
            });
            ui.btn_restore.SetClick(() =>
            {
                ApplePayManager.Instance.AppleRestore((success, message) =>
                {
                    if (success)
                    {
                        GameHelper.ShowTips("Restore Purchases Success!");
                        // SaveData.GetSaveObject().is_get_packreward = success;
                        SaveData.GetSaveObject().have_slot = success;
                        GameDispatcher.Instance.Dispatch(GameMsg.noads_refresh);
                    }
                    else
                    {
                        // Debug.Log("[barry] restore failed: " + success);
                        GameHelper.ShowTips("There are no recoverable transactions");
                    }
                });
            });
            ui.btn_task.SetClick(() => { OnClickTask(false); });
            ui.btn_start.SetClick(() =>
            {
                if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().have_slot && (DateTime.Now.Day != PlayerPrefs.GetInt("off_new", 0)))
                {
                    UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AddviewnewUI_Open);
                    PlayerPrefs.SetInt("off_new", DateTime.Now.Day);
                }
                else if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().have_slot && UnityEngine.Random.Range(0, 100) < ConfigSystem.GetConfig<CommonModel>().BonusInside)
                {
                    uiCtrlDispatcher.Dispatch(UICtrlMsg.AddviewnewUI_Open);
                }
                else
                    OnClickPlay();
            });
            ui.btn_setting.SetClick(() =>
            {
                UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PersonViewUI_Open);
            });
        }
        private void OnClickTask(bool isLevel)
        {
            UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NewTaskUI_Open, isLevel);
        }
        private void InitBtn()
        {
            int level_ = GameHelper.GetLevel();
            int start_level = 0;
            if (level_ >= 3)
            {
                start_level = level_ - 2;
                ui.com_level.state.selectedIndex = 2;
            }
            else
            {
                ui.com_level.state.selectedIndex = level_ - 1;
                start_level = 1;
            }

            for (int i = 0; i < 5; i++)
            {
                int lv = start_level + i;
                btn_play_list[i].text_level.text = lv.ToString();
                if (lv < level_)
                {
                    btn_play_list[i].state.selectedIndex = 2;
                }
                else if (lv == level_)
                {
                    btn_play_list[i].state.selectedIndex = 1;
                    btn_play_list[i].SetClick(() =>
                    {
                        if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().have_slot && (DateTime.Now.Day != PlayerPrefs.GetInt("off_new", 0)))
                        {
                            UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AddviewnewUI_Open);
                            PlayerPrefs.SetInt("off_new", DateTime.Now.Day);
                        }
                        else if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().have_slot && UnityEngine.Random.Range(0, 100) < ConfigSystem.GetConfig<CommonModel>().BonusInside)
                        {
                            uiCtrlDispatcher.Dispatch(UICtrlMsg.AddviewnewUI_Open);
                        }
                        else
                            OnClickPlay();
                    });
                }
                else
                {
                    btn_play_list[i].state.selectedIndex = 0;
                }
            }
        }
        void SetBtnAds(object a = null)
        {
            // if (SaveData.GetSaveObject().is_get_removead && SaveData.GetSaveObject().is_get_packreward)
            // {

            //     btn_noads.visible = false;
            // }

            if (!SaveData.GetSaveObject().is_get_removead && !SaveData.GetSaveObject().is_get_packreward)
            {
                btn_noads.t0.Play(-1, 0, null);
            }
            else if (SaveData.GetSaveObject().is_get_removead && SaveData.GetSaveObject().is_get_packreward)
            {
                btn_noads.t0.Stop();
                // btn_noads.visible = false;
                btn_noads.img_pack.visible = false;
                btn_noads.img_ad.visible = true;
            }
            else if (SaveData.GetSaveObject().is_get_packreward)
            {
                btn_noads.t0.Stop();
                btn_noads.t1.Play();
                //btn_noads.state.selectedIndex = 0;
                btn_noads.img_pack.visible = false;
                btn_noads.img_ad.visible = true;

            }
            else if (SaveData.GetSaveObject().is_get_removead)
            {
                btn_noads.t0.Stop();
                btn_noads.t1.Play();
                btn_noads.img_pack.visible = true;
                btn_noads.img_ad.visible = false;
                //btn_noads.state.selectedIndex = 1;
            }

        }

        private void RefreshRed(object isShow = null)
        {
            ui.btn_battle.GetChild("red").visible = SaveData.battlepassred();
            ui.btn_task.GetChild("red").visible = SaveData.timetaskred() || SaveData.passtaskred() || SaveData.AdTaskred();
            ui.btn_rank.GetChild("red").visible = SaveData.GetRankData().rankRewardData.Count > 0;
        }

        private bool signRed()
        {
            for (var i = 0; i < 7; i++)
            {
                var signDays = DataMgr.SignState.Value.Count;
                var isToday = false;
                if (signDays > 0)
                {
                    isToday = GameHelper.InToday(DataMgr.SignState.Value[signDays - 1], 0, true);
                }
                if (i == signDays)
                {
                    if (signDays > 0 && isToday)
                    {
                        continue;
                    }
                    else
                    {
                        // sk.SetActive(true);
                        // sk.state.SetAnimation(0, "signin1_6", true);
                        // btnSign.status.selectedIndex = btn_sign.State_today;
                        return true;
                    }
                }
            }

            return false;
        }

        private void checkThreeGift(object obj = null)
        {
            var isToday = GameHelper.InToday(SaveData.GetSaveObject().last_got_three_gift_time, 0, true);
            int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
            if (three_gift_got_index > (int)rewardState.day3)
            {
                ui.btn_three_day.visible = false;
            }
            else if (!isToday)
            {
                ui.btn_three_day.GetChild("red").visible = true;
            }
            else
            {
                ui.btn_three_day.GetChild("red").visible = false;
            }
        }

        float showResurgence()
        {
            string jsonFilePath = Path.Combine(Application.persistentDataPath, "RainData1.json");
            string jsonstr = "";
            if (File.Exists(jsonFilePath))
            {
                jsonstr = File.ReadAllText(jsonFilePath);
                //return JsonUtility.FromJson<MyData>(json);
            }

            List<List<Card_item>> card_item_list = JsonConvert.DeserializeObject<List<List<Card_item>>>(jsonstr);


            int surplus_item = 0;
            for (int i = 0; i < card_item_list.Count; i++)
            {
                for (int j = 0; j < card_item_list[i].Count; j++)
                {
                    //  if (card_item_list[i][j].sheep_card.IsDestroyed() || card_item_list[i][j].sheep_card == null) continue;
                    surplus_item++;
                }
            }

            return 1 - (float)surplus_item / (SaveData.GetSaveObject().all_card_numbers * 3);
        }

        void UpdateEvent()
        {
            long t = SaveData.GetSaveObject().failed_pack_time;

            if (t > GameHelper.GetNowTime())
            {
                ui.btn_failpack.visible = true;
                long time_ = t * 1000 - GameHelper.getNowTimeByMillisecond();
                DateTime oldDate = new DateTime(1970, 1, 1);
                oldDate = oldDate.AddMilliseconds(time_);
                ui.btn_failpack.GetChild("lab_time").text = DateTimeManager.Instance.DateTimeToFFFString(oldDate);
            }
            else
            {
                ui.btn_failpack.visible = false;
                HallManager.Instance.UpdateEvent -= UpdateEvent;
            }
        }

        private void UpdataAvatar(object obj = null)
        {
            var head = ui.btn_head as btn_head;
            GameHelper.SetSelfAvatar(head.load_avatar);

            // if (btn_play_list.Count == 0) return;
            // for (int i = 0; i < btn_play_list.Count; i++)
            // {
            //     var head1 = btn_play_list[i].btn_hall_head.btn_head as btn_head;
            //     GameHelper.SetSelfAvatar(head1.load_avatar);

            // }
            ;
        }
        void reCreatPur(object a = null)
        {
            // PurchasingManager.Instance.startPay();
        }

        private void OnClickLuckySpin()
        {
            UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.WheelUI_Open);
        }

        private void OnClickTreasure()
        {
            UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SignInUI_Open);
        }

        private void OnClickShop()
        {
            UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Open);
        }

        private void OnClickSetting()
        {
            UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.MenuUI_Open);
        }

        private void OnClickPass()
        {
            UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PassViewUI_Open);
        }

        private void OnClickPlay()
        {
            GameHelper.gameType = 0;
            GameDispatcher.Instance.Dispatch(GameMsg.OpenGame);
        }

        public void OnUpdate101(object obj = null)
        {
            Set101();
        }

        public void OnUpdate102(object obj = null)
        {
            Set102();
        }

        public void Set101(decimal coin = -1)
        {
            if (coin < 0)
            {
                coin = DataMgr.Coin.Value;
            }
            var btnCoin = ui.btn_gold as com_gold;
            btnCoin.text_gold.text = $"{coin:N0}";
        }

        public void Set102()
        {
            decimal coin = DataMgr.Ticket.Value;

            com_money com_money = ui.btn_money as com_money;
            com_money.text_gold.text = coin.ToString("0.00");
            com_money.SetClick(() =>
            {
                var makeupTaskData = DataMgr.MakeupTaskHistory.Value.Last();
                var vo = ConfigSystem.GetConfig<MakeupModel>().GetData(makeupTaskData.tableId);
                //DataMgr.Ticket.Value=99999;
                //makeupTaskData.videoCount = 50;
                if (vo == null)
                {
                    return;
                }

                var leftCash = (double)Math.Max(vo.item_need - DataMgr.Coin.Value, 0);
                //com_box.text_more.SetVar("left", GameHelper.Get101Str((decimal)leftCash)).FlushVars();
                // com_box.pb_num.max = vo.item_need;
                // com_box.pb_num.value = vo.item_need - leftCash;
                // pbTxt.text =
                //     $"{GameHelper.Get101Str((decimal)(vo.item_need - leftCash))}/{GameHelper.Get101Str((decimal)com_box.pb_num.max)}";
                GameHelper.showGameUI = false;
                uiCtrlDispatcher.Dispatch(UICtrlMsg.MakeupConfirmUI_Open, makeupTaskData);
            });
        }

        private void OnChangeName(ChangeValue<string> obj)
        {
            GameHelper.SetName(ui.text_name);
        }

        private void SetName(GTextField gTextField)
        {
            GameHelper.SetName(gTextField);
        }
    }
}
