第一次更新

master
zjm120504 2 years ago
parent 9cd186a1e8
commit 9265e6683b

@ -15,6 +15,7 @@ public class WebConnectSample : MonoBehaviour
//接收从平台发送过来的数据
void ReceiveWebMsg(string data)
{
Debug.Log("ReceiveWebMsg:" + data);
recTxt.text = data;

@ -100,6 +100,14 @@ namespace EduCoderTool
SendDataToWeb(json);
}
public void SendMsg(string type, string msg)
{
Dictionary<string, object> data = new Dictionary<string, object>();
data.Add(type, msg);
string json = JsonConvert.SerializeObject(data);
SendDataToWeb(json);
}
}
}

File diff suppressed because it is too large Load Diff

@ -69,7 +69,7 @@ public class ConversationInput : MonoBehaviour
{
InputField[] myinput = GetComponentsInChildren<InputField>();
print(myinput.Length);
if (k)
{
for (int i = 0; i < myinput.Length; i++)

@ -1,4 +1,6 @@
using System;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
@ -18,6 +20,7 @@ public class EducoderText : MonoBehaviour
public string userName = "";
public string url = "https://data.educoder.net/api/users/get_user_info.json?objective_type=shixun&objective_id=xolfhc7f&school=1";
private void Start()
{
Instance = this;
@ -53,9 +56,53 @@ public class EducoderText : MonoBehaviour
decryptedText = Decrypt(encryptedText, shiftValue);
Debug.Log("Encrypted text: " + decryptedText);
StartCoroutine(SendGetRequest());
// StartCoroutine(SendGetRequest());
SendRequest();
}
private void SendRequest()
{
//发送请求并接收
EduCoderTool.WebConnecter.Singleton.SendMsg("type", "getTaskData");
//解析
string jsonstr = text.text;
JObject jo = (JObject)JsonConvert.DeserializeObject(jsonstr);
if (jo == null)
{
Debug.Log("获取用户信息失败");
return;
}
string userLogin = jo["user"]["login"].ToString();
Debug.Log("Login"+userLogin);
if (userLogin.Contains(decryptedText))
{
if (GameManager.Instance.succeed)
{
GameManager.Instance.OverWnd.SetActive(true);
EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true);
Debug.Log("yes");
}
else
{
GameManager.Instance.FailWnd.SetActive(true);
}
}
else
{
GameManager.Instance.FailWnd.SetActive(true);
}
}
IEnumerator SendGetRequest()
{
using (UnityWebRequest request = UnityWebRequest.Get(url))

@ -46,6 +46,7 @@ public class GameManager : MonoBehaviour
}
private void Start()
{
@ -91,9 +92,21 @@ public class GameManager : MonoBehaviour
private void Update()
{
if (Input.GetKeyDown(KeyCode.K))
if (Input.GetKeyDown(KeyCode.B) && Input.GetKey(KeyCode.LeftControl))
{
//直接跳到最后一步输入框的步骤
CurrentQuesitionIndex = 19;
answers = new List<string>();
answers.Add("1");
answers.Add("2");
}
if (Input.GetKeyDown(KeyCode.Q) && Input.GetKey(KeyCode.LeftControl))
{
StartCoroutine(LoadLeaver(1, () =>
{
@ -101,6 +114,15 @@ public class GameManager : MonoBehaviour
//Application.LoadLevel(Application.loadedLevel);
}
if(Input.GetKeyDown(KeyCode.A) && Input.GetKey(KeyCode.LeftControl))
{
CurrentQuesitionIndex = 6;
answers = new List<string>();
}
}
/// <summary>

Loading…
Cancel
Save