PlayerHelper.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. namespace ET.Server
  2. {
  3. /// <summary>
  4. /// 玩家工具类
  5. /// </summary>
  6. public static class PlayerHelper
  7. {
  8. /// <summary>
  9. /// 玩家基础信息转proto
  10. /// </summary>
  11. /// <param name="playerInfo"></param>
  12. /// <returns></returns>
  13. public static PlayerBasic PlayerInfoToPlayerBasicProto(PlayerInfo playerInfo)
  14. {
  15. return new PlayerBasic()
  16. {
  17. id = playerInfo.Id.ToString(),
  18. uid = playerInfo.UserId.ToString(),
  19. name = playerInfo.Name,
  20. level = playerInfo.Level,
  21. exp = playerInfo.Exp,
  22. };
  23. }
  24. /// <summary>
  25. /// 玩家信息转proto
  26. /// </summary>
  27. /// <param name="player"></param>
  28. /// <returns></returns>
  29. public static Player PlayerInfoToProto(WNPlayer player)
  30. {
  31. return new Player()
  32. {
  33. id = player.GetId().ToString(),
  34. uid = player.GetUserId().ToString(),
  35. name = player.GetName(),
  36. level = player.GetLevel(),
  37. exp = player.GetExp(),
  38. vip = 0,
  39. hp = 1000,
  40. mp = 0,
  41. fightPower = 5,
  42. gold = player.GetGold(),
  43. diamond = 77,
  44. energy = 0,
  45. };
  46. }
  47. }
  48. }