123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- using LitJson;
- using SUIFW;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class JoinRoomForms : BaseUIForms
- {
- public InputField fieldName;
- public Text remind;
- public Button joinBtn;
- public Button returnBtn;
- private bool isClick = false;
- #region 窗体生命周期
- public override void Display()
- {
- base.Display();
- Init();
- }
- public override void Redisplay()
- {
- base.Redisplay();
- }
- public override void Freeze()
- {
- base.Freeze();
- }
- public override void Hiding()
- {
- base.Hiding();
- }
- #endregion
- private void Awake()
- {
- joinBtn.onClick.AddListener(ClickOnJoin);
- returnBtn.onClick.AddListener(ClickOnReturn);
- fieldName.onValueChanged.AddListener(UserValueChanged);
- fieldName.onEndEdit.AddListener(UserValueEnd);
- }
- private void UserValueEnd(string arg0)
- {
- fieldName.image.color = Color.white;
- }
- public void Init()
- {
- isClick = false;
- fieldName.text = "";
- remind.gameObject.SetActive(false);
- fieldName.image.color = Color.white;
- }
- private void UserValueChanged(string arg0)
- {
- ChangeBlue(fieldName.image);
- remind.gameObject.SetActive(false);
- }
- public void ClickOnJoin()
- {
- if (fieldName.text == "")
- {
- remind.gameObject.SetActive(true);
- remind.text = "请输入房间号";
- ChangeRed(fieldName.image);
- }
- else
- {
- if (!isClick)
- {
- isClick = true;
- OnJoinRoom(fieldName.text);
- }
- }
- }
- private void OnJoinRoom(string roomId)
- {
- RoomMainInfo.roomNum = roomId;
- WSHandler.Office.OnJoinRoomReveived -= joinRoom;
- WSHandler.Office.OnJoinRoomReveived += joinRoom;
- WSHandler.Office.JoinRoom(roomId);
- }
- private void joinRoom(JsonData data)
- {
- switch (data["data"]["code"].ToString())
- {
- case "200":
- WSHandler.roomRtcinit(RoomMainInfo.roomNum);
- WSHandler.Office.ChangeUserType(UserInfo.BusyType);
- break;
- case "1000":
- remind.gameObject.SetActive(true);
- remind.text = "房间号无效";
- ChangeRed(fieldName.image);
- isClick = false;
- break;
- case "1001":
- ShowUIForms(SysConst.PopForms);
- PopForms.Instance.ShowPublic(PopType.PopOne, "房间人数已满", "知道了", ()=> {
- ClickOnReturn();
- });
- isClick = false;
- break;
- default:
- TipMgr.Instance.ShowTip(RtcStrConfig.serverError);
- isClick = false;
- break;
- }
- WSHandler.Office.OnJoinRoomReveived -= joinRoom;
- }
- private void ClickOnReturn()
- {
- CloseOrReturnUIForms();
- ShowUIForms(SysConst.MainPanelForms);
- }
- }
|