public void Enter(object roomId) { NetModule.instance.AddACMDListener(Module.ROOM, Command.ACMD_ROOM_INFO, this.OnRoomInfo); NetModule.instance.AddACMDListener(Module.ROOM, Command.ACMD_LEAVE_ROOM, this.OnLeaveRoom); NetModule.instance.AddACMDListener(Module.ROOM, Command.ACMD_BEGIN_FIGHT, this.OnBeginFight); NetModule.instance.AddQCMDListener(Module.ROOM, Command.QCMD_LEAVE_ROOM, this.OnLeaveRoomResult); NetModule.instance.AddQCMDListener(Module.ROOM, Command.QCMD_ROOM_INFO, this.OnRoomInfoResult); NetModule.instance.AddQCMDListener(Module.ROOM, Command.QCMD_CHANGE_TEAM, this.OnChangeTeamResult); NetModule.instance.AddQCMDListener(Module.ROOM, Command.QCMD_CHANGE_MAP, this.OnChangeMapResult); NetModule.instance.AddQCMDListener(Module.ROOM, Command.QCMD_CHANGE_HERO, this.OnChangeHeroResult); NetModule.instance.AddQCMDListener(Module.ROOM, Command.QCMD_BEGIN_FIGHT, this.OnBeginFightResult); NetModule.instance.AddQCMDListener(Module.ROOM, Command.QCMD_ADD_FIGHT_READY, this.OnAddFightReadyResult); NetModule.instance.AddQCMDListener(Module.ROOM, Command.QCMD_REMOVE_FIGHT_READY, this.OnRemoveFightReadyResult); this._id = ( int )roomId; this._root = UIPackage.CreateObject("room", "Main").asCom; GRoot.inst.AddChild(this._root); this._root.size = GRoot.inst.size; GButton fightBtn = this._root["fightBtn"].asButton; //fightBtn.grayed = true; //fightBtn.touchable = false; fightBtn.onClick.Add(this.OnFightBtnClick); GButton readyBtn = this._root["readyBtn"].asButton; readyBtn.onClick.Add(this.OnReadyBtnClick); GButton leaveBtn = this._root["leaveBtn"].asButton; leaveBtn.onClick.Add(this.OnLeaveBtnClick); this._root["t1"].onClick.Add(this.OnTeamOneClick); this._root["t2"].onClick.Add(this.OnTeamTwoeClick); Hashtable mapsDef = Defs.Get("maps"); GComboBox maps = this._root["map"].asComboBox; maps.popupDirection = PopupDirection.Downward; maps.popupConstraint = PopupConstraint.Any; maps.autoSizeDropdown = true; maps.onChanged.Add(this.OnMapChangedBtnClick); maps.items = new string[mapsDef.Count]; maps.values = new string[mapsDef.Count]; int i = 0; foreach (DictionaryEntry de in mapsDef) { string id = ( string )de.Key; maps.SetItem(i, id); maps.values[i] = id; ++i; } GComboBox heros = this._root["hero"].asComboBox; heros.popupDirection = PopupDirection.Right; heros.popupConstraint = PopupConstraint.Any; //heros.autoSizeDropdown = true; heros.onChanged.Add(this.OnHeroChangedBtnClick); Hashtable entitiesDef = Defs.Get("entities"); Hashtable heroDef = new Hashtable(); foreach (DictionaryEntry de in entitiesDef) { Hashtable hero = ( Hashtable )de.Value; string id = ( string )de.Key; if (!id.StartsWith("c")) { continue; } heroDef[id] = hero; } heros.items = new string[heroDef.Count]; heros.values = new string[heroDef.Count]; i = 0; foreach (DictionaryEntry de in heroDef) { Hashtable hero = ( Hashtable )de.Value; string id = ( string )de.Key; if (!id.StartsWith("c")) { continue; } heros.SetItem(i, hero.GetString("name")); heros.values[i] = id; ++i; } GComboBox models = this._root["model"].asComboBox; models.popupDirection = PopupDirection.Downward; models.popupConstraint = PopupConstraint.Any; models.autoSizeDropdown = true; models.onChanged.Add(this.OnModelChangedBtnClick); models.items = new string[mapsDef.Count]; models.values = new string[mapsDef.Count]; for (int j = 0; j < 3; j++) { models.SetItem(j, j.ToString()); models.values[j] = j.ToString(); } GComboBox skin = this._root["skin"].asComboBox; skin.popupDirection = PopupDirection.Downward; skin.popupConstraint = PopupConstraint.Any; skin.autoSizeDropdown = true; skin.onChanged.Add(this.OnSkinChangedBtnClick); skin.items = new string[mapsDef.Count]; skin.values = new string[mapsDef.Count]; for (int j = 0; j < 3; j++) { skin.SetItem(j, j.ToString()); skin.values[j] = j.ToString(); } this._root.ShowModalWait(); NetModule.instance.Send(ProtocolManager.PACKET_ROOM_QCMD_ROOM_INFO(-1)); }
public IBuildingProto D_GetProto <TDef>(string name) where TDef : BldgDef => buildings[defs.Get <TDef>(name)];