protected override void OnClickHandler(GameObject go)
    {
        base.OnClickHandler(go);
        switch (go.name)
        {
        case "btnEnterGame":
            SceneManager.GetInstance().GotoRealScene("MainCity", delegate() {
                UIManager.GetInstance().SwitchScene("MainCityUI");
            });
            break;

        case "btnChange":
            if (mlist == null)
            {
                mlist = UIManager.GetInstance().GetNewUI <ServerListUI>();
                mlist.transform.SetParent(this.transform);
                mlist.OnSelectHandler += Mlist_OnSelectHandler;
            }
            else
            {
                mlist.gameObject.SetActive(true);
            }
            break;
        }
    }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        Instance = this;
        UIEventListener.Get(mOk).onClick = OnOkBtnClick;

        HeroCfg herocfg = HeroCfgManager.Instance.GetDataByID(1);

        if (herocfg != null)
        {
            mLabel.text = herocfg.Name + "  " + herocfg.AP_Name;
        }
    }
Exemple #3
0
    public static void LoginOK(Packet _packet)
    {
        int          id         = _packet.ReadInt();
        string       token      = _packet.ReadString();
        ServerListUI serverList = UIManager.Instance.UIWindows["ServerList"].GetComponent <ServerListUI>();

        for (int i = 0; i < _packet.UnreadLength(); i += 3)
        {
            GameServerData data = new GameServerData();
            data.name = _packet.ReadString();
            data.ip   = _packet.ReadString();
            data.port = _packet.ReadInt();
            data.ping = data.getPing();
            serverList.servers.Add(data);
        }

        GameManager.Instance.id    = id;
        GameManager.Instance.token = token;
        Debug.Log($"ID: {id} \n TOKEN: {token}");
        UIManager.Instance.ChangeUIWindow("ServerList");
        serverList.GenerateListing();
        GameManager.Instance.hasToken = true;
    }
 // Use this for initialization
 void Start()
 {
     Instance = this;
     UIEventListener.Get(mOk).onClick = OnOkBtnClick;
 }
        void Refresh_Thread_Function()
        {
            while (true)
            {
                main.Dispatcher.Invoke(() =>
                {
                    //main.listView.Items.Clear();
                    //main.list.Items.Clear();
                    //listServerListUI.Clear();
                    //listUI_Trans.Clear();
                });
                for (int i = 0; i < ListeningThread.DeviceList_Thread.Count; i++)
                {
                    ServerListUI data = new ServerListUI
                    {
                        Index       = i.ToString(),
                        IPAddress   = ListeningThread.DeviceList_Thread[i].ipaddress,
                        Port        = ListeningThread.DeviceList_Thread[i].port,
                        ID          = ListeningThread.DeviceList_Thread[i].Device_Recv_Struct.Device_ID,
                        State       = ListeningThread.DeviceList_Thread[i].Device_Recv_Struct.Device_State,
                        Error       = ListeningThread.DeviceList_Thread[i].GetAllErrorNumber().ToString(),
                        RepairTimes = ListeningThread.DeviceList_Thread[i].GetAllRepairNumber().ToString()
                    };
                    UI_Trans data2 = new UI_Trans
                    {
                        Index = i.ToString(),
                        ID    = ListeningThread.DeviceList_Thread[i].Device_Recv_Struct.Device_ID,
                        Bind  = ListeningThread.DeviceList_Thread[i].Device_Recv_Struct.Bind_User,
                    };
                    main.Dispatcher.Invoke(() =>
                    {
                        // ListViewItem item = new ListViewItem();
                        // item.DataContext = data;
                        // main.listView.Items.Add(data);
                        bool flag = false;
                        for (int j = 0; j < listUI_Trans.Count; j++)
                        {
                            if (listUI_Trans[j].ID == data2.ID)
                            {
                                flag = true;
                                listUI_Trans[j].Index = data2.index;
                                listUI_Trans[j].Bind  = data2.Bind;
                            }
                        }
                        if (flag == false)
                        {
                            listUI_Trans.Add(data2);
                        }


                        flag = false;
                        for (int j = 0; j < listServerListUI.Count; j++)
                        {
                            if (listServerListUI[j].ID == data.ID)
                            {
                                flag = true;
                                listServerListUI[j].Error       = data.Error;
                                listServerListUI[j].Index       = data.index;
                                listServerListUI[j].IPAddress   = data.IPAddress;
                                listServerListUI[j].Port        = data.Port;
                                listServerListUI[j].RepairTimes = data.RepairTimes;
                                listServerListUI[j].State       = data.State;
                            }
                        }
                        if (flag == false)
                        {
                            listServerListUI.Add(data);
                        }



                        //item.DataContext = data2;
                        //main.list.Items.Add(data2);
                    });
                }
                Thread.Sleep(100);
            }
        }