public void Clear() { chatModel.Clear(); roleModel.clearRole(); roleModel.ClearFightData(); fightModel.Clear(); fightModel.ClearInvite(); }
public override void Clear() { // Debug.LogError ("clear"); base.Clear(); ClearChat(); // if(mi != null){ // mi.Clear(); // } // PlatForm.inst.timeout = 5f; // TimerManager.inst.Remove (TimeChat_Tick); TimerManager.inst.Remove(Time_Tick); ViewManager.inst.RemoveTopView(micro); NetSocket.inst.RemoveListener(NetBase.SOCKET_TEAMMATCH); NetSocket.inst.RemoveListener(NetBase.SOCKET_STARTMATCHPUSH); NetSocket.inst.RemoveListener(NetBase.SOCKET_ACCEPTINVITEOTHER); NetSocket.inst.RemoveListener(NetBase.SOCKET_KILLTEAMPUSH); //SOCKET_KILLTEAM NetSocket.inst.RemoveListener(NetBase.SOCKET_KILLTEAM); //SOCKET_KILLTEAM NetSocket.inst.RemoveListener(NetBase.SOCKET_QUITTEAMPUSH); NetSocket.inst.RemoveListener(NetBase.SOCKET_CANCELMATCHPUSH); NetSocket.inst.RemoveListener(NetBase.SOCKET_FREESTARTMATCHPUSH); fightModel.Clear(); fightModel.ClearMicro(); }
public override void Clear() { base.Clear(); // PlatForm.inst.timeout = 5f; TimerManager.inst.Remove(Time_Tick); fightModel.Clear(); ViewManager.inst.RemoveTopView(micro); NetSocket.inst.RemoveListener(NetBase.SOCKET_ADDUSER); NetSocket.inst.RemoveListener(NetBase.SOCKET_REMOVEUSER); NetSocket.inst.RemoveListener(NetBase.SOCKET_KILLROOMPUSH); NetSocket.inst.RemoveListener(NetBase.SOCKET_FREESTARTMATCHPUSH); NetSocket.inst.RemoveListener(NetBase.SOCKET_CHANGEMODEPUSH); NetSocket.inst.RemoveListener(NetBase.SOCKET_CHANGEPOSPUSH); NetSocket.inst.RemoveListener(NetBase.SOCKET_FREECHATPUSH); }
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(); }
public override void Init() { base.Init(); this.isAutoClose = false; this.Create(Config.VIEW_FREEMATCH, false, Tools.GetMessageById("25024")); fightModel = ModelManager.inst.fightModel; userModel = ModelManager.inst.userModel; fightModel.fightType = ModelFight.FIGHT_FREEMATCH1; // PlatForm.inst.timeout = 2f; // title = view.GetChild ("n1").asTextField; btn_Change = this.GetChild("n2").asButton; btn_Start = this.GetChild("n12").asButton; btn_Invite = this.GetChild("n13").asButton; btn_Change.text = Tools.GetMessageById("33209"); btn_Start.text = Tools.GetMessageById("33210"); btn_Invite.text = Tools.GetMessageById("33211"); btn_Quit = this.GetChild("n16").asButton; btn_Clos = this.GetChild("n31").asButton; btn_Bot = this.GetChild("n11").asButton; btn_Chat = this.GetChild("n19").asButton; c1 = this.GetController("c1"); btn_Mil = this.GetChild("n28").asButton; bar = this.GetChild("n29").asCom as ComProgressBar; bar.skin = ComProgressBar.BAR10; bar.SetTextVisible(false); bar.value = 0; bar.max = 100; item0 = this.GetChild("n3").asCom; item1 = this.GetChild("n4").asCom; item2 = this.GetChild("n5").asCom; item3 = this.GetChild("n6").asCom; item4 = this.GetChild("n7").asCom; item5 = this.GetChild("n8").asCom; item6 = this.GetChild("n9").asCom; item7 = this.GetChild("n10").asCom; help = this.GetChild("n30").asButton; btn_Invite.onClick.Add(Invite_Click); btn_Clos.onClick.Add(Close_Click); btn_Change.onClick.Add(Change_Click); btn_Start.onClick.Add(Start_Click); btn_Bot.onClick.Add(Bot_Click); btn_Chat.onClick.Add(Chat_Click); btn_Quit.onClick.Add(Close_Click); help.onClick.Add(Help_Click); userModel.GetUnlcok(Config.UNLOCK_FREEMATCH2, btn_Change); // public int[] freeType1 = new int[]{ 0, 1, 2, 3, 4, 5, 6, 7 }; // public int[] freeType2 = new int[]{ 0, 1, 4, 5, 2, 3, 6, 7 }; if (fightModel.freeType == 1) { items = new GComponent[8] { item0, item1, item2, item3, item4, item5, item6, item7 } } ; else { items = new GComponent[8] { item0, item1, item4, item5, item2, item3, item6, item7 } }; this.SetDefault(); if (fightModel.isRequest) { NetSocket.inst.AddListener(NetBase.SOCKET_NEWROOM, (VoSocket vo) => { NetSocket.inst.RemoveListener(NetBase.SOCKET_NEWROOM); fightModel.CreateFreeTeam(vo.data); UpdateItems(); CheckMode(); btn_Bot.visible = fightModel.isLeader; }); Dictionary <string, object> data = new Dictionary <string, object> (); data ["mode"] = fightModel.freeType; NetSocket.inst.Send(NetBase.SOCKET_NEWROOM, data); } else { CheckMode(); UpdateItems(); btn_Bot.visible = fightModel.isLeader; } micro = new MediatorMicro(); ViewManager.inst.AddTopView(micro); // micro.visible = false; NetSocket.inst.AddListener(NetBase.SOCKET_ADDUSER, (VoSocket vo) => { fightModel.ChangeFreeTeam(vo.data); UpdateItems(); }); NetSocket.inst.AddListener(NetBase.SOCKET_REMOVEUSER, (VoSocket vo) => { bool b = fightModel.DelFreeTeam(vo.data); if (b) { fightModel.Clear(); ViewManager.inst.CloseView(this); ViewManager.inst.ShowText(Tools.GetMessageById("25011")); } else { UpdateItems(); } }); NetSocket.inst.AddListener(NetBase.SOCKET_KILLROOMPUSH, (VoSocket vo) => { fightModel.Clear(); ViewManager.inst.CloseView(this); ViewManager.inst.ShowText(Tools.GetMessageById("25008")); Log.debug("解散队伍"); }); NetSocket.inst.AddListener(NetBase.SOCKET_FREESTARTMATCHPUSH, (VoSocket vo) => { if (fightModel.freeType == 1) { fightModel.fightType = ModelFight.FIGHT_FREEMATCH1; } else { fightModel.fightType = ModelFight.FIGHT_FREEMATCH2; } Log.debug("进入战斗"); ViewManager.inst.ShowScene <MediatorFightWorld> (true); }); NetSocket.inst.AddListener(NetBase.SOCKET_CHANGEMODEPUSH, (VoSocket vo) => { Dictionary <string, object> da = (Dictionary <string, object>)vo.data; fightModel.freeType = Convert.ToInt32(da ["new_mode"]); CheckMode(true); Log.debug("更换模式"); // ViewManager.inst.ShowText (Tools.GetMessageById ("25021")); }); NetSocket.inst.AddListener(NetBase.SOCKET_CHANGEPOSPUSH, (VoSocket vo) => { fightModel.RepalceFreeTeam(vo.data); CheckMode(true); Log.debug("更换位置"); // ViewManager.inst.ShowText (Tools.GetMessageById ("25021")); }); NetSocket.inst.AddListener(NetBase.SOCKET_FREECHATPUSH, (VoSocket vo) => { if (userModel.IsChatVoice()) { fightModel.AddMicro(vo.data); } }); this.AddGlobalListener(MainEvent.SOCKET_CLOSE, (MainEvent e) => { this.Close(); }); }