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

116 lines
3.8 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);
time = DateTime.Now.ToString();
PlayerPrefs.SetString("time", time);
LoadInfo();
}
/// <summary>
/// 通过判断跳转场景
/// </summary>
private void LoadInfo()
{
string str;
string path = Application.streamingAssetsPath + @"\info.ini";
if (File.Exists(path))
{
str = File.ReadAllText(path);
string[] data = str.Split(new char[] {';'});
string[] datas = data[1].Split(new char[] { ',' });
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.SetString("calssID", datas[7]);
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.SetString("calssID", datas[7]);
mainselect.Electricityfeetest.onClick.Invoke();
}
}
else if (datas[0] == "gdht")
{
if (datas[1] == "0")
{
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.SetString("calssID", datas[7]);
mainselect.Powersupplytest.onClick.Invoke();
}
}
}
}
void Update()
{
}
}