public void updateMahjong(Mahjong from, int toValue) { ResetStatus(); int fromValue = from.GetMahjongValue(); Debug.Log("[updateMahjong] " + fromValue + " > " + toValue); valueList.Remove(fromValue); valueList.Add(toValue); string before = ""; valueList.ForEach((v) => { before += v + ","; }); Debug.Log("BeforeSort " + before); valueList.Sort(); string after = ""; valueList.ForEach((v) => { after += v + ","; }); Debug.Log("AfterSort " + after); from.SetStatus(Mahjong.Status.Holding); from.SetMahjongValue(toValue); from.transform.SetSiblingIndex(valueList.IndexOf(toValue)); if (checkGang() == true) { return; } else if (checkHupai()) { handleHupai(); } }
internal bool ReceiveMahjong(int value) { Debug.Log("[ReceiveMahjong]"); if (!currentMahjong) { currentMahjong = GameObject.Find("CurrentMahjong"); } if (currentMahjong != null) { Mahjong new_mahjong = currentMahjong.GetComponent <Mahjong>(); new_mahjong.SetMahjongValue(value); new_mahjong.SetStatus(Mahjong.Status.Holding); } return(true); }
// Update is called once per frame public bool CreateMahjongByValue(int value) { if (transform.childCount >= MaxCount) { Debug.LogWarning("[AddMahjong] Can not add any more Mahjong. We already have " + transform.childCount); return(false); } GameObject newCell = Instantiate <GameObject>(mahjongPrefab) as GameObject; Mahjong mjToAdd = newCell.GetComponent <Mahjong>() as Mahjong; mjToAdd.SetMahjongValue(value); AddMahjong(mjToAdd); if (checkGang() == true) { return(true); } return(true); }
private void InitAllTiles(int row, int col) { Debug.Log("[InitAllTiles] row:" + row + " col:" + col); List <Transform> allTiles = new List <Transform>(); List <int> indexList = MJHelper.GenerateForFirstChoose(row * col); GridLayoutGroup gridLayoutGroup = GetComponent <GridLayoutGroup>(); gridLayoutGroup.constraint = GridLayoutGroup.Constraint.Flexible; // gridLayoutGroup.constraintCount = row; for (int i = 0; i < indexList.Count; i++) { GameObject newCell = Instantiate <GameObject>(mahjongPrefab) as GameObject; Mahjong mahjong = newCell.GetComponent <Mahjong>() as Mahjong; mahjong.SetMahjongValue(indexList[i]); mahjong.SetStatus(Mahjong.Status.Selecting); // mahjong.SetStatus(Mahjong.Status.Closed); newCell.transform.SetParent(this.gameObject.transform, false); } }