private void OnRecvPlayerAttribute(IChannel channel, Message message)
        {
            Console.WriteLine("OnRecvPlayerAttribute");
            CPlayerAttribute request = message as CPlayerAttribute;
            Player           player  = (Player)channel.GetContent();
            ConnectDB        connect = new ConnectDB();

            // resolve message
            int intelligence = request.intelligence;
            int speed        = request.speed;
            int attack       = request.attack;
            int defense      = request.defense;

            Console.WriteLine("palyer attribute: " + speed + intelligence + attack + defense);

            // modify player's attribute
            player.intelligence = intelligence;
            player.speed        = speed;
            player.attack       = attack;
            player.defense      = defense;

            // modify database
            int result = connect.UpdatePlayerAttribute(player.user, speed, intelligence, attack, defense);

            if (result == 0)
            {
                Console.WriteLine("Update player attribute failure.");
            }
        }
Beispiel #2
0
    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);
        }
    }