PlayerHelper.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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,
  18. name = playerInfo.Name,
  19. level = playerInfo.Level,
  20. exp = playerInfo.Exp,
  21. };
  22. }
  23. /// <summary>
  24. /// 玩家信息转proto
  25. /// </summary>
  26. /// <param name="player"></param>
  27. /// <returns></returns>
  28. public static Player PlayerInfoToProto(WNPlayer player)
  29. {
  30. return new Player()
  31. {
  32. id = player.GetId(),
  33. name = player.GetName(),
  34. level = player.GetLevel(),
  35. exp = player.GetExp(),
  36. vip = 0,
  37. hp = 1000,
  38. mp = 0,
  39. fightPower = 5,
  40. gold = player.GetGold(),
  41. diamond = 77,
  42. energy = 0,
  43. };
  44. }
  45. }
  46. }