private void CreateBackground(RoomUnitModel roomModel) { int typeId; int.TryParse(roomModel.TypeId, out typeId); var gamekey = roomModel.GameKey; if (ViewContainer == null)//没有容器 { ChangeBackGround(BackGround, typeId); return; } //有子背景 if (_view != null) { Destroy(_view); } var prefix = App.Skin.GameInfo; var namePrefix = string.Format("{0}_{1}", prefix, gamekey); //gameinfo_gamekey var roomItemName = string.Format("{0}_{1}", AssetType.ToString().ToLower(), gamekey); //roomlist_gamekey var styleName = string.Format("{0}_{1}", roomItemName, typeId); //先找带typeId样式 var bundleName = string.Format("{0}/{1}", namePrefix, styleName); //gameinfo_gamekey/roomlist_gamekey _view = ResourceManager.LoadAsset(prefix, bundleName, styleName); if (_view == null) //如果没有带typeId样式,加载默认的样式 { bundleName = string.Format("{0}/{1}", namePrefix, roomItemName); //默认样式 _view = ResourceManager.LoadAsset(prefix, bundleName, roomItemName); if (_view == null) { return; } } _view = Instantiate(_view); var ts = _view.transform; ts.parent = ViewContainer; ts.localPosition = Vector3.zero; ts.localScale = Vector3.one; ts.localRotation = Quaternion.identity; var rlView = _view.GetComponent <RoomListItemBaseView>(); if (rlView != null) { rlView.MainYxView = this; rlView.Init(roomModel); } ChangeBackGround(BackGround == null ? ts : BackGround, typeId); _stateObj = _view.GetComponent <RoomListItemState>(); if (_stateObj == null) { return; } _stateObj.StartChangeRoom(); _stateObj.UpAnchor(); }
private void OnOpenQuickGame() { RoomUnitModel model = new RoomUnitModel(null); model.TypeId = _curData.GameType.ToString(); model.GameKey = _curData.GameKey; YxTools.GoldJoinRoom(model.GameKey, model.TypeId, delegate { RoomListController.Instance.OnDirectGame(model); }); }
private void OnOpenQuickGame() { var userInfo = UserInfoModel.Instance.UserInfo; EnumCostType costType = _curData.CostType; var maxCost = _curData.MaxValue; var minCost = _curData.MinVlaue; double haveValue = 0; string costName = ""; if (maxCost > 0) { switch (costType) { case EnumCostType.Cash: haveValue = userInfo.CashA; costName = CashName; break; case EnumCostType.Gold: haveValue = YxUtiles.GetShowNumber(userInfo.CoinA + userInfo.BankCoin); costName = GoldName; break; case EnumCostType.TempCoin: haveValue = int.MaxValue; break; case EnumCostType.GroupCoin: costName = GroupCoinName; haveValue = int.MaxValue; break; default: haveValue = int.MaxValue; break; } if (minCost > haveValue) { YxMessageBox.Show(string.Format(LowerLimitNotice, minCost, costName, haveValue)); return; } if (maxCost < haveValue) { YxMessageBox.Show(string.Format(UpperLimitNotice, minCost, costName, haveValue)); return; } } RoomUnitModel model = new RoomUnitModel(null); model.TypeId = _curData.GameType.ToString(); model.GameKey = _curData.GameKey; RoomListController.Instance.OnDirectGame(model); }
protected override void OnChangeData(IItemData itemData) { _model = itemData as RoomUnitModel; if (_model == null) { return; } CreateBackground(_model); CreateIcon(_model.IconUrl); name = _model.TypeId; if (RoomNameLabel != null) { RoomNameLabel.text = _model.RoomName; } int minCoin; int.TryParse(_model.MinGold, out minCoin); if (BetInfoPanel != null) { var ts = BetInfoPanel.transform; if (App.AppStyle == EAppStyle.Concise || minCoin < 1) { ts.localScale = Vector3.zero; return; } ts.localScale = Vector3.one; } if (AnteLabel != null) { AnteLabel.text = _model.Ante; } int maxCoin; int.TryParse(_model.MaxGold, out maxCoin); if (MaxCoinLabel != null) { MaxCoinLabel.text = maxCoin < 1 ? "∞" : _model.MaxGold.ToString(CultureInfo.InvariantCulture); } if (MinCoinLabel != null) { MinCoinLabel.text = minCoin.ToString(CultureInfo.InvariantCulture); } if (GameNameLabel != null) { var gameunitM = GameListModel.Instance.GameUnitModels; var gkey = _model.GameKey; if (gameunitM.ContainsKey(gkey)) { GameNameLabel.text = gameunitM[gkey].GameName; } } }
protected void OnGUI() { if (string.IsNullOrEmpty(CurGameKey)) { return; } GlobalUtile.ResizeGUIMatrix(); var sh = Screen.height; var fontStyle = new GUIStyle { normal = { // background = null, textColor = Color.white } // fontSize = rowH }; const int gx = 30; GUILayout.BeginHorizontal(); GUI.Label(new Rect(gx, 10, 120, 20), "请输入房间id", fontStyle); _editor_roomId = GUI.TextField(new Rect(gx + 130, 10, 100, 20), _editor_roomId); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUI.Button(new Rect(gx, 95, 40, 20), "确 定")) { int rId; int.TryParse(_editor_roomId, out rId); if (rId > 0) { var roomUm = RoomListModel.Instance.RoomUnitModel; for (var i = 0; i <= rId; i++) { var rm = new RoomUnitModel(null) { TypeId = _editor_roomId, GameKey = CurGameKey }; roomUm.Add(rm); } } RoomListController.Instance.QuickGame(CurGameKey); CurGameKey = ""; } if (GUI.Button(new Rect(gx + 90, 95, 40, 20), "取 消")) { CurGameKey = ""; } GUILayout.EndHorizontal(); }
private void CreateBackground(RoomUnitModel roomModel, string itemType) { int typeId; int.TryParse(roomModel.TypeId, out typeId); var gamekey = roomModel.GameKey; if (ViewContainer == null)//没有容器 { ChangeBackGround(BackGround, typeId); return; } //有子背景 if (_view != null) { Destroy(_view); } var prefix = App.Skin.GameInfo; var roomItemName = string.Format("roomlist_{0}", gamekey); var namePrefix = string.Format("{0}_{1}", prefix, gamekey); if (!string.IsNullOrEmpty(itemType)) { roomItemName = string.Format("{0}_{1}", roomItemName, itemType); } var bundleName = string.Format("{0}/{1}", namePrefix, roomItemName); _view = ResourceManager.LoadAsset(prefix, bundleName, roomItemName); if (_view == null) { return; } _view = Instantiate(_view); var ts = _view.transform; ts.parent = ViewContainer; ts.localPosition = Vector3.zero; ts.localScale = Vector3.one; ts.localRotation = Quaternion.identity; ChangeBackGround(ts, typeId); _stateObj = _view.GetComponent <RoomListItemState>(); if (_stateObj == null) { return; } _stateObj.StartChangeRoom(); _stateObj.UpAnchor(); }
protected override void OnChangeData(IItemData itemData, string itemType) { _model = itemData as RoomUnitModel; if (_model == null) { return; } CreateBackground(_model, itemType); CreateIcon(_model.IconUrl); name = _model.TypeId; if (RoomNameLabel != null) { RoomNameLabel.text = _model.RoomName; } UpdateGameLabel(); UpdateBetInfo(); }
protected override void FreshData() { base.FreshData(); _model = Data as RoomUnitModel; if (_model == null) { return; } CreateBackground(_model);//itemType CreateIcon(_model.IconUrl); name = _model.Index.ToString(); if (RoomNameLabel != null) { RoomNameLabel.text = _model.RoomName; } UpdateGameLabel(); UpdateBetInfo(); }
public void Init(RoomUnitModel roomModel) { RoomInfo = roomModel; OnInit(); }