/// <summary> /// Sends packets to clients /// </summary> /// <param name="start"></param> /// <param name="sendDice"></param> /// <param name="sendCards"></param> public static void SendMonsterPackets(bool start = false, bool sendDice = false, bool sendCards = false) { var outMsg = _server.CreateMessage(); if (start) { outMsg.Write((byte)PacketTypes.Start); } else { outMsg.Write((byte)PacketTypes.Update); } var packets = MonsterController.GetDataPackets(); outMsg.Write(packets.Length); foreach (var packet in packets) { var json = JsonConvert.SerializeObject(packet); outMsg.Write(json); } if (sendDice) { outMsg.Write((byte)PacketTypes.Dice); var dice = DiceController.GetDataPacket(); outMsg.Write(JsonConvert.SerializeObject(dice)); } else if (!start) { outMsg.Write((byte)PacketTypes.NoDice); } if (sendCards) { outMsg.Write((byte)PacketTypes.Cards); var cards = CardController.GetCardsForSale().Select(CardController.CreateDataPacket).ToArray(); outMsg.Write(JsonConvert.SerializeObject(cards)); } else if (!start) { outMsg.Write((byte)PacketTypes.NoCards); } _server.SendToAll(outMsg, NetDeliveryMethod.ReliableOrdered); }