testManager.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using LitJson;
  2. using SC.XR.Unity;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. public class testManager : MonoBehaviour
  8. {
  9. public SlideList blist;
  10. public RollList alist;
  11. public NormalList clist;
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. Invoke("initList",1f);
  16. }
  17. List<BaseConfig> list = new List<BaseConfig>();
  18. void initList()
  19. {
  20. BaseConfig bc = new BaseConfig();
  21. list.Add(bc);
  22. list.Add(bc);
  23. list.Add(bc);
  24. list.Add(bc);
  25. list.Add(bc);
  26. blist.initList(list);
  27. alist.initList(list);
  28. alist.initList(list);
  29. // blist.showItems(0, 9);
  30. //WSHandler.init();
  31. //WSHandler.User.OnLogin += testFun;
  32. id = Time.deltaTime.ToString() + "_" + UnityEngine.Random.Range(1, 1000);
  33. }
  34. // public
  35. public void initRoom()
  36. {
  37. // NetworkConfiguration.socket_Url_test2
  38. //WSHandler.init();
  39. //WSHandler.User.OnLogin += testFun;
  40. id = Time.deltaTime.ToString() + "_" + UnityEngine.Random.Range(1, 1000);
  41. }
  42. private string id;
  43. public TextMesh test;
  44. private Dictionary<string ,GameObject> testGs=new Dictionary<string, GameObject>();
  45. Queue<JsonData> jsondata = new Queue<JsonData>();
  46. private void testFun(JsonData data)
  47. {
  48. jsondata.Enqueue(data);
  49. }
  50. private void testCt(JsonData data)
  51. {
  52. test.text = data.ToJson();
  53. if (data.Keys.Contains("data"))
  54. {
  55. JsonData jd = JsonMapper.ToObject(data["data"].ToString());
  56. data["data"] = jd;
  57. if (data.Keys.Contains("method"))
  58. {
  59. if (data["method"].ToString() == "login")
  60. {
  61. GameObject obj = (GameObject)Resources.Load("testLogin");
  62. obj = Instantiate(obj);
  63. testGs.Add(data["data"]["id"].ToString(), obj);
  64. }
  65. else if (data["method"].ToString() == "test")
  66. {
  67. if (data.Keys.Contains("data"))
  68. {
  69. if (data["data"].Keys.Contains("pos"))
  70. {
  71. if (!testGs.ContainsKey(data["data"]["id"].ToString()))
  72. {
  73. GameObject obj = (GameObject)Resources.Load("testLogin");
  74. obj = Instantiate(obj);
  75. testGs.Add(data["data"]["id"].ToString(), obj);
  76. }
  77. string[] poss = data["data"]["pos"].ToString().Split('_');
  78. string[] euls = data["data"]["eul"].ToString().Split('_');
  79. string[] scals = data["data"]["scal"].ToString().Split('_');
  80. testGs[data["data"]["id"].ToString()].transform.position = new Vector3(float.Parse(poss[0]), float.Parse(poss[1]), float.Parse(poss[2]));
  81. testGs[data["data"]["id"].ToString()].transform.eulerAngles = new Vector3(float.Parse(euls[0]), float.Parse(euls[1]), float.Parse(euls[2]));
  82. testGs[data["data"]["id"].ToString()].transform.localScale = new Vector3(0.05f, 0.05f, 0.05f);
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. public void isSend()
  90. {
  91. issendd = !issendd;
  92. if(issendd)
  93. {
  94. //WSHandler.User.testLogin(id);
  95. }
  96. }
  97. public void Time30()
  98. {
  99. stime = 0.03f;
  100. }
  101. public void Time60()
  102. {
  103. stime = 0.015f;
  104. }
  105. private bool issendd=false;
  106. private float stime=0.03f;
  107. private float times;
  108. // Update is called once per frame
  109. void Update()
  110. {
  111. // sc3D.value = blist.getProgress();
  112. }
  113. public void login()
  114. {
  115. //WSHandler.User.testLogin(id);
  116. }
  117. public void add()
  118. {
  119. BaseConfig bc = new BaseConfig();
  120. list.Add(bc);
  121. blist.updateConfig(list);
  122. }
  123. public void red()
  124. {
  125. BaseConfig bc = new BaseConfig();
  126. list.RemoveAt(0);
  127. blist.updateConfig(list);
  128. }
  129. }