HomeProxyExtensions.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using ShadowStudio.Model;
  2. using Studio.Scripts.HttpMessage;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. namespace Studio.Scripts
  8. {
  9. public static class HomeProxyExtensions
  10. {
  11. /// <summary>
  12. /// 根据ArtCallBackData 获取ArtInfo列表
  13. /// </summary>
  14. /// <param name="homeProxy"></param>
  15. /// <param name="backData"></param>
  16. /// <returns></returns>
  17. public static ArtInfo GetArtInfoByArtCallBackData(this HomeProxy homeProxy,ArtCallBackData backData)
  18. {
  19. ArtInfo artInfo = new ArtInfo();
  20. artInfo.AID = backData.id;
  21. artInfo.ArtId = backData.artID;
  22. artInfo.ArtName = backData.artName;
  23. artInfo.InstaceType = (InstaceType)int.Parse(backData.instanceType);
  24. artInfo.Url = backData.url;
  25. artInfo.Icon = backData.icon;
  26. artInfo.ArtType = (ArtType)Enum.ToObject(typeof(ArtType), (int)Math.Pow(2, int.Parse(backData.artType)));
  27. artInfo.Version = backData.version;
  28. artInfo.Distance = float.Parse(backData.distance);
  29. artInfo.ContainerName = backData.containerName;
  30. artInfo.ImmediateSyn = backData.immediateSyn;
  31. artInfo.Component = backData.component;
  32. artInfo.Description = backData.description;
  33. if (string.IsNullOrEmpty(artInfo.Component))
  34. {
  35. if (artInfo.ArtType == ArtType.Image)
  36. {
  37. artInfo.Component = "PictureComponent";
  38. }
  39. else if (artInfo.ArtType == ArtType.Movies)
  40. {
  41. artInfo.Component = "VideoComponent";
  42. }
  43. }
  44. return artInfo;
  45. }
  46. /// <summary>
  47. /// 根据artCallBackDatas列表获取artinfo列表
  48. /// </summary>
  49. /// <param name="homeProxy"></param>
  50. /// <param name="artCallBackDatas"></param>
  51. /// <returns></returns>
  52. public static List<ArtInfo> GetArtInfoListByArtCallBackDatas(this HomeProxy homeProxy, List<ArtCallBackData> artCallBackDatas)
  53. {
  54. List<ArtInfo> artInfos = new List<ArtInfo>();
  55. artCallBackDatas.ForEach(artCBD => artInfos.Add(homeProxy.GetArtInfoByArtCallBackData(artCBD)));
  56. return artInfos;
  57. }
  58. }
  59. }