public override void Init() { base.Init(); this.isAutoClose = false; this.Create(Config.VIEW_TEAMMATCH, false); // PlatForm.inst.timeout = 20000f; fightModel = ModelManager.inst.fightModel; roleModel = ModelManager.inst.roleModel; userModel = ModelManager.inst.userModel; fightModel.fightType = ModelFight.FIGHT_MATCHTEAM; list = this.GetChild("n2").asList; btn_Enter = this.GetChild("n3").asButton; btn_Enter.text = Tools.GetMessageById("25062"); btn_Invite = this.GetChild("n4").asButton; c1 = this.GetController("c1"); text1 = this.GetChild("n7").asTextField; text2 = this.GetChild("n8").asTextField; text3 = this.GetChild("n9").asTextField; // btn_Cancel = this.GetChild("n6").asButton; btn_Cancel.text = Tools.GetMessageById("14025"); btn_Quit = this.GetChild("n29").asTextField; btn_Chat = this.GetChild("n18").asButton; //btn_Chat.text = Tools.GetMessageById("25067"); btn_Mil = this.GetChild("n19").asButton; btn_Mil.GetChild("n2").asTextField.text = Tools.GetMessageById("25067"); bar = this.GetChild("n20").asCom as ComProgressBar; bar.skin = ComProgressBar.BAR10; bar.SetTextVisible(false); bar.value = 0; bar.max = 100; btn_Close = this.GetChild("close").asButton; btn_Close.onClick.Add(this.Close); // this.GetChild("title").asTextField.text = Tools.GetMessageById("25033"); // btn_Enter.onClick.Add(Enter_Click); btn_Invite.onClick.Add(Invite_Click); btn_Cancel.onClick.Add(Cancel_Click); // btn_Quit.onClick.Add (Quit_Click); btn_Quit.text = Tools.GetMessageById("25058"); btn_Chat.onClick.Add(Chat_Click); btn_Mil.onClick.Add(Chat_Click_Over); fightModel.isMatch = false; //麦克风功能 micro = new MediatorMicro(); ViewManager.inst.AddTopView(micro); //房间内部操作 NetSocket.inst.AddListener(NetBase.SOCKET_TEAMMATCH, (VoSocket vo) => { // Debug.LogError("NetSocket.inst.AddListener"); if (vo.data is Boolean) { bool isOk = Convert.ToBoolean(vo.data); if (!isOk) { ViewManager.inst.ShowText(Tools.GetMessageById("25026")); TimerManager.inst.Remove(Time_Tick); fightModel.isMatch = false; list.numItems = 4; if (fightModel.isLeader) { c1.selectedIndex = 0; } else { c1.selectedIndex = 1; } } } else { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; fightModel.team1 = (object[])data ["team"]; list.numItems = 4; //fightModel.team1.Length; c1.selectedIndex = 4; this.closeEnable = false; text3.text = Tools.GetMessageById("25064"); TimerManager.inst.Add(5f, 1, (float t) => { TimerManager.inst.Remove(Time_Tick); c1.selectedIndex = 4; // Log.debug ("准备开始 - " + vo.data.ToString ()); DispatchManager.inst.Dispatch(new MainEvent(MainEvent.START_FIGHT, data)); }); } }); NetSocket.inst.AddListener(NetBase.SOCKET_STARTMATCHPUSH, (VoSocket vo) => { fightModel.isMatch = true; list.numItems = 4; //fightModel.team1.Length; // NetSocket.inst.RemoveListener (NetBase.SOCKET_STARTMATCH); if (fightModel.isLeader) { c1.selectedIndex = 2; } else { c1.selectedIndex = 3; } fightModel.preTime = Convert.ToInt32(vo.data); fightModel.matchTime = 0; // Log.debug ("开始匹配 - " + fightModel.preTime.ToString ()); if (fightModel.isLeader) { text1.text = Tools.GetMessageById("25005", new string[] { fightModel.preTime.ToString(), fightModel.matchTime.ToString() }); } else { text2.text = Tools.GetMessageById("25005", new string[] { fightModel.preTime.ToString(), fightModel.matchTime.ToString() }); } TimerManager.inst.Add(1f, 0, Time_Tick); // ViewManager.inst.ShowText (Tools.GetMessageById ("25013")); }); NetSocket.inst.AddListener(NetBase.SOCKET_ACCEPTINVITEOTHER, (VoSocket vo) => { string uid = fightModel.AddTeam(vo.data); list.numItems = 4; //fightModel.team1.Length; ViewManager.inst.ShowText(Tools.GetMessageById("25012", new String[] { uid })); }); NetSocket.inst.AddListener(NetBase.SOCKET_KILLTEAMPUSH, (VoSocket vo) => { fightModel.Clear(); ViewManager.inst.CloseView(this); ViewManager.inst.ShowText(Tools.GetMessageById("25008")); // Log.debug ("解散队伍 - " + vo.data.ToString ()); }); NetSocket.inst.AddListener(NetBase.SOCKET_QUITTEAMPUSH, (VoSocket vo) => { // if (vo.data is Boolean && !Convert.ToBoolean (vo.data)) // { // ViewManager.inst.ShowText (Tools.GetMessageById ("25016")); // return; // } string uid = vo.data.ToString(); if (userModel.uid == uid) { ViewManager.inst.CloseView(this); ViewManager.inst.ShowText(Tools.GetMessageById("25011")); // Log.debug ("退出队伍 - " + vo.data.ToString ()); } else { fightModel.ChangeTeam(vo.data); list.numItems = 4; if (fightModel.isLeader) { c1.selectedIndex = 0; } else { c1.selectedIndex = 1; } this.btn_Enter.enabled = false; TimerManager.inst.Add(2f, 1, (float t) => { this.btn_Enter.enabled = true; }); } }); NetSocket.inst.AddListener(NetBase.SOCKET_CANCELMATCHPUSH, (VoSocket vo) => { if (!Convert.ToBoolean(vo.data)) { return; } fightModel.isMatch = false; if (fightModel.isLeader) { c1.selectedIndex = 0; } else { c1.selectedIndex = 1; } TimerManager.inst.Remove(Time_Tick); ViewManager.inst.ShowText(Tools.GetMessageById("25015")); }); NetSocket.inst.AddListener(NetBase.SOCKET_MATCHTEAMCHATPUSH, (VoSocket vo) => { if (userModel.IsChatVoice()) { fightModel.AddMicro(vo.data); } }); this.AddGlobalListener(MainEvent.SOCKET_CLOSE, (MainEvent e) => { this.Close(); }); // this.InitData(); }