//Turns a minkou into a shouminkan public void MakeShouminkan(Tile draw) { Type = MeldType.Shouminkan; Tiles.Add(draw); draw.GetComponent <Tile>().InOpenMeld = true; GameObject container = Tiles[0].gameObject.transform.parent.gameObject; ArrangeOpenMeldGroup(ref container, this); }
//Arranges an open meld within the transform of the container public static void ArrangeOpenMeldGroup(ref GameObject container, OpenMeld meld) { Debug.Log("ArrangeOpenMeldGroup: arranging " + meld.ConvertToPotentialMeld()); meld.PlayerNumber = meld.PlayerNumber; int i = 0; List <TileRenderer> tr = new List <TileRenderer>(); for (i = 0; i < meld.Count; i++) { meld.Tiles[i].transform.parent = container.transform; tr.Add(meld.Tiles[i].Renderer); } TileRenderer low = null; TileRenderer mid = null; TileRenderer high = null; Tile a = null; Tile b = null; Tile c = null; TileRenderer stolen = null; switch (meld.Type) { case MeldType.Ankan: tr[0].Orientation = TileOrientation.Bottom; tr[1].Orientation = TileOrientation.Bottom; tr[2].Orientation = TileOrientation.Bottom; tr[3].Orientation = TileOrientation.Bottom; tr[0].LowerRight = new Vector2(0.5f * meld.Width, 0f); tr[1].LowerRight = tr[0].LowerLeft; tr[2].LowerRight = tr[1].LowerLeft; tr[3].LowerRight = tr[2].LowerLeft; meld.Tiles[1].GetComponent <Tile>().SetVisibility(TileVisibility.FaceDown); meld.Tiles[2].GetComponent <Tile>().SetVisibility(TileVisibility.FaceDown); break; case MeldType.Minjun: for (i = 0; i < 3; i++) { if (meld.Tiles[i].GetComponent <Tile>().StolenDiscard) { stolen = meld.Tiles[i].GetComponent <TileRenderer>(); } else if (a == null) { a = meld.Tiles[i]; } else { b = meld.Tiles[i]; } } if (a.GetComponent <Tile>().Query() < b.GetComponent <Tile>().Query()) { low = a.GetComponent <TileRenderer>(); high = b.GetComponent <TileRenderer>(); } else { low = b.GetComponent <TileRenderer>(); high = a.GetComponent <TileRenderer>(); } //Always stolen from left (kamicha) stolen.Orientation = TileOrientation.Right; low.Orientation = TileOrientation.Bottom; high.Orientation = TileOrientation.Bottom; high.LowerRight = new Vector2(0.5f * meld.Width, 0f); low.LowerRight = high.LowerLeft; stolen.LowerRight = low.LowerLeft; break; case MeldType.Minkou: for (i = 0; i < 3; i++) { if (meld.Tiles[i].GetComponent <Tile>().StolenDiscard) { stolen = meld.Tiles[i].GetComponent <TileRenderer>(); } else if (a == null) { a = meld.Tiles[i]; } else { b = meld.Tiles[i]; } } low = a.GetComponent <TileRenderer>(); high = b.GetComponent <TileRenderer>(); low.Orientation = TileOrientation.Bottom; high.Orientation = TileOrientation.Bottom; stolen.Orientation = TileOrientation.Right; if ((meld.StolenFrom - meld.PlayerNumber + 4) % 4 == 1) { //Stole from right (shimocha) stolen.LowerRight = new Vector2(0.5f * meld.Width, 0f); low.LowerRight = stolen.LowerLeft; high.LowerRight = low.LowerLeft; } else if ((meld.StolenFrom - meld.PlayerNumber + 4) % 4 == 2) { //stolen from across (toimen) low.LowerRight = new Vector2(0.5f * meld.Width, 0f); stolen.LowerRight = low.LowerLeft; high.LowerRight = stolen.LowerLeft; } else if ((meld.StolenFrom - meld.PlayerNumber + 4) % 4 == 3) { //stolen from left (kamicha) low.LowerRight = new Vector2(0.5f * meld.Width, 0f); high.LowerRight = low.LowerLeft; stolen.LowerRight = high.LowerLeft; } break; case MeldType.Daiminkan: for (i = 0; i < 4; i++) { if (meld.Tiles[i].GetComponent <Tile>().StolenDiscard) { stolen = meld.Tiles[i].GetComponent <TileRenderer>(); } else if (a == null) { a = meld.Tiles[i]; } else if (b == null) { b = meld.Tiles[i]; } else { c = meld.Tiles[i]; } } low = a.Renderer; high = b.Renderer; mid = c.Renderer; low.Orientation = TileOrientation.Bottom; high.Orientation = TileOrientation.Bottom; mid.Orientation = TileOrientation.Right; stolen.Orientation = TileOrientation.Right; if ((meld.StolenFrom - meld.PlayerNumber + 4) % 4 == 1) { //Stole from right (shimocha) stolen.Orientation = TileOrientation.Left; stolen.LowerRight = new Vector2(0.5f * meld.Width, 0f); low.LowerRight = stolen.LowerLeft; high.LowerRight = low.LowerLeft; mid.LowerRight = stolen.UpperRight; } else if ((meld.StolenFrom - meld.PlayerNumber + 4) % 4 == 2) { //stolen from across (toimen) low.LowerRight = new Vector2(0.5f * meld.Width, 0f); stolen.LowerRight = low.LowerLeft; high.LowerRight = stolen.LowerLeft; mid.LowerRight = stolen.UpperRight; } else if ((meld.StolenFrom - meld.PlayerNumber + 4) % 4 == 3) { //stolen from left (kamicha) low.LowerRight = new Vector2(0.5f * meld.Width, 0f); high.LowerRight = low.LowerLeft; stolen.LowerRight = high.LowerLeft; mid.LowerRight = stolen.UpperRight; } break; case MeldType.Shouminkan: for (i = 0; i < 4; i++) { if (meld.Tiles[i].GetComponent <Tile>().StolenDiscard) { stolen = meld.Tiles[i].Renderer; } else if (a == null) { a = meld.Tiles[i]; } else if (b == null) { b = meld.Tiles[i]; } else { c = meld.Tiles[i]; } } low = a.Renderer; high = b.Renderer; mid = c.Renderer; low.Orientation = TileOrientation.Bottom; mid.Orientation = TileOrientation.Bottom; high.Orientation = TileOrientation.Bottom; stolen.Orientation = TileOrientation.Right; if ((meld.StolenFrom - meld.PlayerNumber + 4) % 4 == 1) { //Stole from right (shimocha) stolen.Orientation = TileOrientation.Left; stolen.LowerRight = new Vector2(0.5f * meld.Width, 0f); low.LowerRight = stolen.LowerLeft; high.LowerRight = low.LowerLeft; mid.LowerRight = high.LowerLeft; } else if ((meld.StolenFrom - meld.PlayerNumber + 4) % 4 == 2) { //stolen from across (toimen) low.LowerRight = new Vector2(0.5f * meld.Width, 0f); stolen.LowerRight = low.LowerLeft; high.LowerRight = stolen.LowerLeft; mid.LowerRight = high.LowerLeft; } else if ((meld.StolenFrom - meld.PlayerNumber + 4) % 4 == 3) { //stolen from left (kamicha) low.LowerRight = new Vector2(0.5f * meld.Width, 0f); mid.LowerRight = low.LowerLeft; high.LowerRight = mid.LowerLeft; stolen.LowerRight = high.LowerLeft; } break; } }