public static void Handle(MoveStopResult move_stop_result)
 {
     Debug.Log ("move_stop_result");
     Debug.Log ( "player_id : " + move_stop_result.player_id);
     Debug.Log ( "position_x : " + move_stop_result.position_x);
     Debug.Log ( "position_y : " + move_stop_result.position_y);
 }
        public void Handle(MoveStopResult move_stop_result)
        {
            player = GameObject.Find (move_stop_result.player_id.ToString ()).GetComponent<Player> ();
            player.player_info_.SetPosition (move_stop_result.position_x, move_stop_result.position_y, player.transform);
            player.player_info_.SetVelocity (0, 0);

            Debug.Log ( "move_stop_result");
            Debug.Log ( "player_id : " + move_stop_result.player_id);
            Debug.Log ( "position_x : " + move_stop_result.position_x);
            Debug.Log ( "position_y : " + move_stop_result.position_y);
        }
示例#3
0
    IEnumerator ReadPacket()
    {
        while (true) {
            yield return 0;

            if(stream.DataAvailable == true)
            {
                short size = 0;
                short type = 0;
                byte[] bytes;
                size = reader.ReadInt16 ();
                type = reader.ReadInt16 ();
                Debug.Log ("size : " + size + ", type : " + type);
                bytes = reader.ReadBytes (size);

                if (bytes.Length == size)
                {
                    if (0 <= type && type < PKT_MAX)
                    {
                        MemoryStream memory_stream = new MemoryStream ();
                        memory_stream.Write (bytes, 0, size);
                        memory_stream.Position = 0;

                        switch (type)
                        {
                        case PKT_NONE:
                        {

                        } break;
                        case PKT_SC_LOGIN:
                        {
                            LoginResult login_result = new LoginResult ();
                            login_result = ProtoBuf.Serializer.Deserialize<LoginResult> (memory_stream);
                            LoginResultHandler login_result_handler = new LoginResultHandler ();
                            login_result_handler.Handle (login_result);
                        } break;
                        case PKT_SC_LOGIN_BROADCAST:
                        {
                            LoginBroadcastResult login_broadcast_result = new LoginBroadcastResult ();
                            login_broadcast_result = ProtoBuf.Serializer.Deserialize<LoginBroadcastResult> (memory_stream);
                            LoginBroadcastResultHandler login_broadcast_result_handler = new LoginBroadcastResultHandler ();
                            login_broadcast_result_handler.Handle (login_broadcast_result);
                        } break;
                        case PKT_SC_MOVE_START:
                        {
                            MoveResult move_result = new MoveResult ();
                            move_result = ProtoBuf.Serializer.Deserialize<MoveResult> (memory_stream);
                            MoveResultHandler move_result_handler = new MoveResultHandler ();
                            move_result_handler.Handle (move_result);
                        } break;
                        case PKT_SC_MOVE_STOP:
                        {
                            MoveStopResult move_stop_result = new MoveStopResult ();
                            move_stop_result = ProtoBuf.Serializer.Deserialize<MoveStopResult> (memory_stream);
                            MoveStopResultHandler move_stop_result_handler = new MoveStopResultHandler ();
                            move_stop_result_handler.Handle (move_stop_result);
                        } break;
                        }
                            // Check Packet
                    }
                }
            }
        }
    }