private void OnRecvTreasureWear(IChannel channel, Message message) { Console.WriteLine("OnRecvTreasureWear"); CTreasureWear request = message as CTreasureWear; Player player = (Player)channel.GetContent(); ConnectDB connect = new ConnectDB(); int result; // modify player's attribute foreach (KeyValuePair <string, bool> kv in request.treasureWear) { Console.WriteLine("update treasure wear: " + player.user + kv.Key + kv.Value); result = connect.UpdateTreasureWear(player.user, kv.Key, kv.Value); if (result == 0) { Console.WriteLine("Modify wear treasure status failure."); } } }
public void SendMessage() { // attribute message CPlayerAttribute msg1 = new CPlayerAttribute() { intelligence = PlayerInfo.intelligence, speed = PlayerInfo.speed, attack = PlayerInfo.attack, defense = PlayerInfo.defense }; MyNetwork.Send(msg1); // treasure wear or put off message if (TreasureInfo.modifiedTreasure.Count != 0) { CTreasureWear msg2 = new CTreasureWear() { treasureWear = new Dictionary <string, bool>(TreasureInfo.modifiedTreasure) }; MyNetwork.Send(msg2); } }