RoleMgr.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /* 内置角色信息管理者,(PK模式用到的角色选择) */
  5. public class RoleMgr
  6. {
  7. static string[] roleNames = {"海绵宝宝", "方狗狗", "五六七", "CHANEL", "Mimi", "喵了个咪"};
  8. public static int roleCount {
  9. get {
  10. return roleNames.Length;
  11. }
  12. }
  13. public static (Sprite, string) GetRoleInfo(int id)
  14. {
  15. Sprite sprite = GetAvatar(id);
  16. string nickname = null;
  17. if (IsRoleAvatar(id)) {
  18. nickname = roleNames[id - 1];
  19. } else {
  20. nickname = LoginMgr.myUserInfo.nickname;
  21. }
  22. return (sprite, nickname);
  23. }
  24. public static bool IsRoleAvatar(int id) {
  25. return id >= 1 && id <= 6;
  26. }
  27. public static int GetAvatarListLen() {
  28. return 7 + 24;
  29. }
  30. public static Sprite GetAvatar(int id)
  31. {
  32. string path = "Textures/Avatar/";
  33. if (id < 7) path += "Player" + id;
  34. else path += id - 7;
  35. return Resources.Load<Sprite>(path);
  36. }
  37. }