ShanxiKnowledgeBase/SXElectricity Marketing 2.0/Assets/Zion/Scripts/YL/ReadLoginInfo.cs

129 lines
4.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using static InterfaceManager;
public class ReadLoginInfo : MonoBehaviour
{
/// <summary>
/// 判断跳入什么考试还是练习模式
/// </summary>
public MainSelect mainselect;
/// <summary>
/// 获取登入时间
/// </summary>
public string time;
/// <summary>
/// 获取接口
/// </summary>
public MainRoot mainRoot = new MainRoot();
public List<ExamContent> examContents = new List<ExamContent>();
private void Awake()
{
Init();
}
private void Init()
{
DontDestroyOnLoad(this.gameObject);
string path = Application.streamingAssetsPath + @"\start.ini";
if (File.Exists(path))
{
File.WriteAllText(Application.streamingAssetsPath + @"\start.ini", "1");
}
time = DateTime.Now.ToString();
PlayerPrefs.SetString("time", time);
LoadInfo();
}
/// <summary>
/// 通过判断跳转场景
/// </summary>
private void LoadInfo()
{
string str;
string path = Application.streamingAssetsPath + @"\info.ini";
Debug.Log(path);
if (File.Exists(path))
{
str = File.ReadAllText(path);
Debug.Log(str);
string[] data = str.Split(new char[] { ';' });
string[] datas = data[1].Split(new char[] { ',' });
if (0 < datas[9].Length)
{
IpAddress = datas[9];
Debug.Log(IpAddress);
}
if (datas[0] == "lyht")
{
if (datas[1] == "0")
{
PlayerPrefs.SetInt("Id", int.Parse(datas[2]));
PlayerPrefs.SetString("UserId", datas[3]);
PlayerPrefs.SetString("Name", datas[4]);
mainselect.practicebutton.onClick.Invoke();
}
else if (datas[1] == "1")
{
PlayerPrefs.SetInt("Id", int.Parse(datas[2]));
PlayerPrefs.SetString("UserId", datas[3]);
PlayerPrefs.SetString("Name", datas[4]);
PlayerPrefs.SetString("Time", datas[6]);
PlayerPrefs.SetInt("calssID", int.Parse(datas[8]));
mainselect.examinationbutton.onClick.Invoke();
}
}
else if (datas[0] == "dfhs")
{
if (datas[1] == "0")
{
PlayerPrefs.SetInt("Id", int.Parse(datas[2]));
PlayerPrefs.SetString("UserId", datas[3]);
PlayerPrefs.SetString("Name", datas[4]);
mainselect.Electricchargeexercise.onClick.Invoke();
}
else if (datas[1] == "1")
{
Debug.Log(int.Parse(datas[2]));
PlayerPrefs.SetInt("Id", int.Parse(datas[2]));
PlayerPrefs.SetString("UserId", datas[3]);
PlayerPrefs.SetString("Name", datas[4]);
PlayerPrefs.SetString("Time", datas[6]);
PlayerPrefs.SetInt("calssID", int.Parse(datas[8]));
mainselect.Electricityfeetest.onClick.Invoke();
}
}
else if (datas[0] == "gdht")
{
if (datas[1] == "0")
{
Debug.Log(datas[2]);
PlayerPrefs.SetInt("Id", int.Parse(datas[2]));
PlayerPrefs.SetString("UserId", datas[3]);
PlayerPrefs.SetString("Name", datas[4]);
mainselect.Powersupplyexercise.onClick.Invoke();
}
else if (datas[1] == "1")
{
PlayerPrefs.SetInt("Id", int.Parse(datas[2]));
PlayerPrefs.SetString("UserId", datas[3]);
PlayerPrefs.SetString("Name", datas[4]);
PlayerPrefs.SetString("Time", datas[6]);
PlayerPrefs.SetInt("calssID", int.Parse(datas[8]));
mainselect.Powersupplytest.onClick.Invoke();
}
}
}
}
void Update()
{
}
}