private void CreatMahjongData(List <int> data) { var obj = new GameObject(); var item = new MahjongItem(); var parent = obj.AddComponent <UIGrid>(); for (int i = 0, lenth = data.Count; i < lenth; i++) { item = GameTools.CreateMahjong(data[i], false).GetComponent <MahjongItem>(); GameTools.DestroyDragObject(item); item.SelfData.Action = EnumMahJongAction.StandWith; item.SelfData.Direction = EnumMahJongDirection.Vertical; item.SelfData.ShowDirection = EnumShowDirection.Self; item.SelfData.MahjongLayer = ConstantData.ShowItemLayler; GameTools.AddChild(parent.transform, item.transform); } UIEventListener.Get(parent.gameObject).onClick = OnClickSpecialGangItem; var box = parent.gameObject.AddComponent <BoxCollider>(); box.size = new Vector3(parent.GetChildList().Count *item.BGSprite.width, item.BGSprite.height); box.center = new Vector3(110, 0, 0); parent.cellWidth = 72; parent.repositionNow = true; GameTools.AddChild(_grid.transform, parent.transform); }
public void ShowInfo(List <int> data) { Show(true); data = GameTools.SortCardWithOutLaiZi(data, App.GetGameManager <Mahjong2DGameManager>().LaiZiNum); int ChildLenth = _grid.transform.childCount; while (ChildLenth > 0) { DestroyImmediate(_grid.transform.GetChild(0).gameObject); ChildLenth--; } for (int i = 0, lenth = data.Count; i < lenth; i++) { MahjongItem item = GameTools.CreateMahjong(data[i], false).GetComponent <MahjongItem>(); GameTools.DestroyDragObject(item); item.SelfData.Action = EnumMahJongAction.StandWith; item.SelfData.Direction = EnumMahJongDirection.Vertical; item.SelfData.ShowDirection = EnumShowDirection.Self; item.SelfData.MahjongLayer = ConstantData.ShowItemLayler; UIEventListener.Get(item.gameObject).onClick = OnClickItem; GameTools.AddChild(_grid.transform, item.transform); BoxCollider box = item.gameObject.AddComponent <BoxCollider>(); box.size = new Vector3(item.BGSprite.width, item.BGSprite.height); } _grid.repositionNow = true; _paiBg.width = (int)(_grid.GetChildList().Count *_grid.cellWidth); }