public void AddMahjong(Mahjong mjToAdd) { ResetStatus(); valueList.Add(mjToAdd.GetMahjongValue()); mjToAdd.SetStatus(Mahjong.Status.Holding); mjToAdd.name = mjToAdd.GetMahjongValue().ToString(); mjToAdd.isMine = true; mjToAdd.transform.SetParent(this.gameObject.transform, false); valueList.Sort(); mjToAdd.transform.SetSiblingIndex(valueList.IndexOf(mjToAdd.GetMahjongValue())); }
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(); } }
private void AddCurrentMahjongToMine() { if (!mahjongCurrent) { mahjongCurrent = GameObject.Find("CurrentMahjong"); } Mahjong currentMahjong = mahjongCurrent.GetComponent <Mahjong>(); CreateMahjongByValue((currentMahjong.GetMahjongValue())); currentMahjong.SetStatus(Mahjong.Status.Gone); }
public void OnPointUp() { MyTilesScript myMahjongs = GameObject.Find("MyTiles").GetComponent <MyTilesScript>() as MyTilesScript; switch (currentStatus) { case Status.Selecting: case Status.Closed: myMahjongs.ResetStatus(); if (myMahjongs.CreateMahjongByValue(mahjongValue)) { SetStatus(Status.Gone); return; //如果被手里的牌接收了,则处理结束 } NewFetchScript currentMahjong = GameObject.Find("NewFetched").GetComponent <NewFetchScript>() as NewFetchScript; if (currentMahjong.ReceiveMahjong(this.GetMahjongValue())) { // GameObject.Destroy(this); // 已经被传给当前牌了,因为当前牌是复用,所以可以直接销毁被摸的牌 // transform.SetParent(null); SetStatus(Status.Gone); return; // 摸牌的情况 } break; case Status.Holding: SetStatus(Status.HoldingToThrow); break; case Status.HoldingToThrow: // 如果不是手里的牌,直接销毁 if (!this.isMine) { SetStatus(Status.Gone); } else { // 如果是手里的牌,则需要把新抓的牌替代进去 GameObject currentMahjong2 = GameObject.Find("CurrentMahjong"); if (currentMahjong2 != null) { Mahjong to = currentMahjong2.GetComponent <Mahjong>() as Mahjong; if (to.GetStatus() != Status.Gone) { myMahjongs.updateMahjong(this, to.GetMahjongValue()); to.SetStatus(Status.Gone); } } else { // (未知错误的时候,通常不会发生)如果是手里的牌,但又没有摸牌,则恢复。 SetStatus(Status.Holding); } } break; case Status.HoldingToGang: myMahjongs.OnMahjongSelectedToGang(mahjongValue); break; } }