public void Update(EFuuroType newType, Hai[] newHais, int newRelation, int newPick) { Type = newType; Hais = newHais; FromRelation = newRelation; NewPickIndex = newPick; }
public Fuuro(EFuuroType newType, Hai[] newHais, int newRelation, int newPickIndex) { this._type = newType; this._hais = newHais; this._fromRelation = newRelation; this._newPickIndex = newPickIndex; }
public void UpdateFuuro(Fuuro[] fuuros) { if (fuuros == null) { return; } // clear all fuuro. Clear(); // create new. for (int i = 0; i < fuuros.Length; i++) { Fuuro fuu = fuuros[i]; EFuuroType fuuroType = fuu.Type; if (i > 0) { curMaxPosX -= FuuroOffsetX; } int newPickIndex = fuu.NewPickIndex; Hai[] hais = fuu.Hais; //int relation = fuu.Relation; bool shouldSetLand = false; switch (fuuroType) { case EFuuroType.MinShun: //Chii. case EFuuroType.MinKou: // Pon. case EFuuroType.KaKan: // 加杠. case EFuuroType.DaiMinKan: // 大明杠. { for (int j = 0; j < hais.Length; j++) { if (hais[j].ID < 0) { continue; } shouldSetLand = (j == newPickIndex); float posX = curMaxPosX - GetMahjongRange(shouldSetLand) * 0.5f; Vector3 localPos = new Vector3(posX, 0, 0); MahjongPai pai = PlayerUI.CreateMahjongPai(transform, localPos, hais[j], true); if (shouldSetLand) { pai.SetOrientation(EOrientation.Landscape_Left); pai.transform.localPosition += new Vector3(0, MahjongPai.LandHaiPosOffsetY, 0); } pai.DisableInput(); fuuroHais.Add(pai); // update curMaxPosX. curMaxPosX -= GetMahjongRange(shouldSetLand); } } break; case EFuuroType.AnKan: // 暗杠. { for (int j = 0; j < hais.Length; j++) { if (hais[j].ID < 0) { continue; } shouldSetLand = false; float posX = curMaxPosX - GetMahjongRange(shouldSetLand) * 0.5f; Vector3 localPos = new Vector3(posX, 0, 0); bool isShow = (j != 0 && j != hais.Length - 1); // 2 sides hide. MahjongPai pai = PlayerUI.CreateMahjongPai(transform, localPos, hais[j], isShow); fuuroHais.Add(pai); // update curMaxPosX. curMaxPosX -= GetMahjongRange(shouldSetLand); } } break; } } // end for(). }
public void UpdateFuuro(Fuuro[] fuuros, bool isAI) { if (fuuros == null) { return; } // clear all fuuro. Clear(); // create new. for (int i = 0; i < fuuros.Length; i++) { Fuuro fuu = fuuros[i]; EFuuroType fuuroType = fuu.Type; if (i > 0) { curMaxPosX -= FuuroOffsetX; } int newPickIndex = fuu.NewPickIndex; Hai[] hais = fuu.Hais; //int relation = fuu.Relation; bool shouldSetLand = false; switch (fuuroType) { case EFuuroType.MinShun: //Chii. case EFuuroType.MinKou: // Pon. case EFuuroType.KaKan: // 加杠. case EFuuroType.DaiMinKan: // 大明杠. { for (int j = 0; j < hais.Length; j++) { if (hais[j].ID < 0) { continue; } shouldSetLand = (j == newPickIndex); //是否擺橫的 float posX = curMaxPosX - GetMahjongRange(shouldSetLand) * 0.5f; Vector3 localPos = new Vector3(posX, 0, 0); //吃牌要擺中間 if (j == 0) { localPos = new Vector3(posX - GetMahjongRange(shouldSetLand), 0, 0); } else if (j == 1) { localPos = new Vector3(posX + GetMahjongRange(shouldSetLand), 0, 0); } else if (j == 3) { localPos = new Vector3(posX + GetMahjongRange(shouldSetLand) * 2, 0.4f, 0); } MahjongPai pai = PlayerUI.CreateMahjongPai(transform, localPos, hais[j], true); if (!isAI) { Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("PlayerFuuro")); } else { Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("Default")); } //if( shouldSetLand ) { // //pai.SetOrientation(EOrientation.Landscape_Left); // pai.transform.localPosition += new Vector3(0, MahjongPai.LandHaiPosOffsetY, 0); //} pai.DisableInput(); fuuroHais.Add(pai); // update curMaxPosX. if (j != 3) { curMaxPosX -= GetMahjongRange(shouldSetLand); } } } break; case EFuuroType.AnKan: // 暗杠. { for (int j = 0; j < hais.Length; j++) { if (hais[j].ID < 0) { continue; } shouldSetLand = false; float posX = curMaxPosX - GetMahjongRange(shouldSetLand) * 0.5f; Vector3 localPos = new Vector3(posX, 0, 0); //bool isShow = (j != 0 && j != hais.Length - 1); // 2 sides hide. bool isShow = (j == 3); // 2 sides hide. //第四張擺上面 if (j == 3) { localPos = new Vector3(posX + GetMahjongRange(shouldSetLand) * 2, 0.4f, 0); } MahjongPai pai = PlayerUI.CreateMahjongPai(transform, localPos, hais[j], isShow); if (!isAI) { Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("PlayerFuuro")); } else { Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("Default")); } fuuroHais.Add(pai); // update curMaxPosX. if (j != 3) { curMaxPosX -= GetMahjongRange(shouldSetLand); } } } break; } } // end for(). }