public bool SendRuleMessage() { MahjongServer host = __instance == null ? null : __instance.host as MahjongServer; if (host == null) { return(false); } Node node; if (!host.GetNode(__instance.node.index, out node) || node.connectionId < 0) { return(false); } ReadOnlyCollection <Mahjong.RuleNode> ruleNodes = Start(); if (ruleNodes == null || ruleNodes.Count < 1) { return(false); } host.SendRuleMessage(node.connectionId, ruleNodes); return(true); }
private void __Reset() { if (__instance == null) { return; } if (__tileCodes != null) { MahjongServer host = __instance.host as MahjongServer; if (host != null) { Node node; if (host.GetNode(__instance.node.index, out node) && node.connectionId >= 0) { host.SendTileCodeMessage(node.connectionId, (byte)__tileCodes.Length, __tileCodes); } } } }
public new void Reset() { __isShow = false; if (__room != null) { if (__room.__mahjong != null) { __instance.type = (short)((this.index + 4 - __room.__mahjong.dealerIndex) & 3); } if (__room.isRunning) { MahjongServer host = __instance == null ? null : __instance.host as MahjongServer; if (host != null) { Node node; if (host.GetNode(__instance.node.index, out node) && node.connectionId >= 0) { host.SendShuffleMessage(node.connectionId, (byte)__room.point0, (byte)__room.point1, (byte)__room.point2, (byte)__room.point3, (byte)__room.tileCount); } } } } int count = (int)Mahjong.TileType.Unknown, step = (256 - count) / count; if (__tileCodes == null) { __tileCodes = new byte[count]; } int index = 0; for (int i = 0; i < count; ++i) { __tileCodes[i] = (byte)UnityEngine.Random.Range(index, index += step); } __Reset(); }
public bool SendReadyHand() { MahjongServer host = __instance == null ? null : __instance.host as MahjongServer; if (host == null) { return(false); } Node node; if (!host.GetNode(__instance.node.index, out node) || node.connectionId < 0) { return(false); } if (__readyHandleIndices == null) { __readyHandleIndices = new List <byte>(); } else { __readyHandleIndices.Clear(); } IEnumerator <int> checker = GetChecker(null); while (checker.MoveNext()) { __readyHandleIndices.Add((byte)checker.Current); } if (__readyHandleIndices.Count < 1) { return(false); } host.SendReadyHandMessage(node.connectionId, __readyHandleIndices.AsReadOnly()); return(true); }
void Awake() { __server = GetComponent <MahjongServer>(); DontDestroyOnLoad(gameObject); }
public override int Score(Mahjong.RuleType type, int playerIndex, int tileIndex, IEnumerable <Mahjong.Rule.WinFlag> winFlags) { MahjongServer host = instance == null ? null : instance.host as MahjongServer; if (host == null) { return(0); } NetworkWriter writer = __instance.RpcStart(); if (writer != null) { writer.Write((byte)((int)type - (int)Mahjong.RuleType.Win)); writer.Write((byte)(((int)playerIndex + 4 - index) & 3)); writer.Write((byte)Mahjong.Tile.Get(tileIndex)); } int score = 0, kongCount = base.kongCount; score += __Write(MahjongScoreType.Flower, flowerCount + groupCount - kongCount, writer, host.scores); score += __Write(MahjongScoreType.Kong, kongCount, writer, host.scores); switch (type) { case Mahjong.RuleType.Win: case Mahjong.RuleType.SelfDraw: case Mahjong.RuleType.BreakKong: case Mahjong.RuleType.OverKong: if (type == Mahjong.RuleType.SelfDraw) { if (drawType == DrawType.Flower) { score += __Write(MahjongScoreType.FlowerDraw, 1, writer, host.scores); } } if (type == Mahjong.RuleType.OverKong) { score += __Write(MahjongScoreType.KongDraw, 1, writer, host.scores); if (drawType == DrawType.Flower) { score += __Write(MahjongScoreType.FlowerDraw, 1, writer, host.scores); } } break; default: if (writer != null) { writer.Write((byte)255); } return(0); } IEnumerable <int> handTileIndices = base.handTileIndices; if (winFlags != null) { foreach (Mahjong.Rule.WinFlag winFlag in winFlags) { switch (winFlag.index) { case 0: score += __Write(MahjongScoreType.AllPongHand, 1, writer, host.scores); if (Mahjong.Rule.IsGreatHand258(handTileIndices)) { score += __Write(MahjongScoreType.GreatHand258, 1, writer, host.scores); } break; case 1: case 2: case 3: score += __Write(MahjongScoreType.Normal, 1, writer, host.scores); break; case 4: break; case 5: score += __Write(MahjongScoreType.SevenPairsHand, 1, writer, host.scores); break; } } } if (Mahjong.Rule.IsCleanHand(handTileIndices)) { score += __Write(MahjongScoreType.CleanHand, 1, writer, host.scores); } if (Mahjong.Rule.IsPureHand(handTileIndices)) { score += __Write(MahjongScoreType.PureHand, 1, writer, host.scores); } if (Mahjong.Rule.IsSimpleHand(handTileIndices)) { score += __Write(MahjongScoreType.SimpleHand, 1, writer, host.scores); } if (count < 2) { score += __Write(MahjongScoreType.Single, 1, writer, host.scores); } Mahjong mahjong = base.mahjong; if (mahjong != null) { if (poolTileIndexCount < 1) { score += __Write(index == mahjong.dealerIndex ? MahjongScoreType.HeavenlyHand : MahjongScoreType.EarthlyHand, 1, writer, host.scores); } } if (writer != null) { writer.Write((byte)255); } instance.RpcEnd((short)MahjongNetworkRPCHandle.Score); return(score); }