AssistMethods.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using LitJson;
  5. namespace FSAssist {
  6. public class AssistMethods {
  7. /*
  8. * 判断两个区域是否相交
  9. * 传入两个区域
  10. */
  11. public static bool IsRectContain(Vector3 minP1, Vector3 maxP1, Transform pos) {
  12. return false;
  13. }
  14. /*
  15. * 获取json中的数据
  16. */
  17. public static object Get(JsonData data, string key) {
  18. return null;
  19. }
  20. /*
  21. * 获取int数据
  22. */
  23. public static int ReadInt(JsonData data, string key) {
  24. // 首先判断key对应的值是否存在
  25. if (data[key] == null) {
  26. return 0;
  27. }
  28. return (int)data[key];
  29. }
  30. /*
  31. * 从数组中读取
  32. */
  33. public static int ReadInt(JsonData data, int index) {
  34. // 首先判断key对应的值是否存在
  35. if (data[index] == null) {
  36. return 0;
  37. }
  38. return (int)data[index];
  39. }
  40. /*
  41. * 获取string数据
  42. */
  43. public static string ReadString(JsonData data, string key) {
  44. // 首先判断key对应的值是否存在
  45. if (data[key] == null) {
  46. return null;
  47. }
  48. return (string)data[key];
  49. }
  50. /*
  51. * 从数组中读取
  52. */
  53. public static string ReadString(JsonData data, int key) {
  54. // 首先判断key对应的值是否存在
  55. if (data[key] == null) {
  56. return null;
  57. }
  58. return (string)data[key];
  59. }
  60. }
  61. }