123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- using Blue;
- using LitJson;
- using Newtonsoft.Json.Linq;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Threading;
- using UnityEngine;
- using UnityEngine.UI;
- public enum ELoadState
- {
- login,//登录
- getUserInfo,//获取用户信息
- getAllScene,//获取账号下所有场景
- initscene,//场景初始化
- sninfo,//绑定设备
- sninfoEnd,//绑定设备完成
- sceneChoose,//场景选择
- getMaterialValue,//获取素材库
- download,// 更新下载
- createScene,// 生成场景
- updateEnd,// 更新完成
- SaveSpoitData, //更新景点数据
- SaveSpoitDataEnd,
- }
- public class LoadingPanel : BaseUI
- {
- private Text m_Text;
- private string m_TextStr;
- private Text m_Progress;
- private string m_ProgressStr;
- public string TextStr
- {
- get { return m_TextStr; }
- set
- {
- m_TextStr = value;
- if (m_Text != null)
- {
- m_Text.text = m_TextStr;
- }
- }
- }
- public string ProgressStr
- {
- get { return ProgressStr; }
- set
- {
- m_ProgressStr = value;
- if (m_Progress != null)
- {
- m_Progress.text = m_ProgressStr;
- }
- }
- }
- protected override void OnAwake()
- {
- base.OnAwake();
- m_Text = CacheTransform.Find("Text").GetComponent<Text>();
- m_Progress = CacheTransform.Find("Progress").GetComponent<Text>();
- ProgressStr = "";
- this.SendCommand(new GetGameObjectCommand(gameObject));
- }
- protected override void OnShow(object param)
- {
- base.OnShow(param);
- transform.localPosition = new Vector3(0, 0, -25f);
- if(param is int)
- {
- int state = (int)param;
- OnStateChange(state);
- }else if(param is string)
- {
- m_Text.text = param as string ;
- }
- }
- private void OnStateChange(int state)
- {
- switch (state)
- {
- case (int)ELoadState.login:
- m_Text.text = "正在登录";
- break;
- case (int)ELoadState.getUserInfo:
- m_Text.text = "获取用户信息";
- break;
- case (int)ELoadState.initscene:
- m_Text.text = "正在场景初始化";
- break;
- case (int)ELoadState.sninfo:
- m_Text.text = "正在绑定设备";
- break;
- case (int)ELoadState.sninfoEnd:
- m_Text.text = "";
- break;
- case (int)ELoadState.sceneChoose:
- m_Text.text = "获取当前选择场景数据";
- break;
- case (int)ELoadState.getMaterialValue:
- m_Text.text = "获取素材库数据";
- break;
- case (int)ELoadState.download:
- m_Text.text = "正在更新素材库数据";
- break;
- case (int)ELoadState.getAllScene:
- m_Text.text = "获取账号下所有场景";
- break;
- case (int)ELoadState.createScene:
- m_Text.text = "正在创建场景";
- break;
- case (int)ELoadState.updateEnd:
- m_Text.text = "更新完成";
- break;
- case (int)ELoadState.SaveSpoitData:
- m_Text.text = "保存景点数据";
- break;
- case (int)ELoadState.SaveSpoitDataEnd:
- StartCoroutine(SaveDataEnd());
- break;
- default:
- break;
- }
- }
- IEnumerator UpdateEnd()
- {
- yield return new WaitForSeconds(1f);
- m_Text.text = "初始化场景";
- yield return new WaitForSeconds(1f);
- GameManager.Instance.IntoScene();
- Hide();
- }
- IEnumerator SaveDataEnd()
- {
- yield return new WaitForSeconds(1f);
- Hide();
- }
- protected override void OnDestroy()
- {
- base.OnDestroy();
- }
- }
|