138 lines
5.9 KiB
C#
138 lines
5.9 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.Networking;
|
|||
|
|
using ZXK.Framework;
|
|||
|
|
using ZXK.UTility;
|
|||
|
|
/*******************************************************************************
|
|||
|
|
*Create By CG
|
|||
|
|
*Function <EFBFBD>豸<EFBFBD><EFBFBD>֪<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*******************************************************************************/
|
|||
|
|
namespace ZXK.BYSS
|
|||
|
|
{
|
|||
|
|
public class EquipmentInfo
|
|||
|
|
{
|
|||
|
|
private string _modelID;
|
|||
|
|
private string _modelName;
|
|||
|
|
private string _modelExplain;
|
|||
|
|
private GameObject _modelPrefab;
|
|||
|
|
|
|||
|
|
public EquipmentInfo(string modelID, string modelName, string modelExplain, GameObject modelPrefab)
|
|||
|
|
{
|
|||
|
|
_ModelID = modelID;
|
|||
|
|
_ModelName = modelName;
|
|||
|
|
_ModelExplain = modelExplain;
|
|||
|
|
_ModelPrefab = modelPrefab;
|
|||
|
|
}
|
|||
|
|
public static EquipmentInfo Default => new EquipmentInfo("", "", "", null);
|
|||
|
|
|
|||
|
|
public string _ModelID { get => _modelID; set => _modelID = value; }
|
|||
|
|
public string _ModelName { get => _modelName; set => _modelName = value; }
|
|||
|
|
public string _ModelExplain { get => _modelExplain; set => _modelExplain = value; }
|
|||
|
|
public GameObject _ModelPrefab { get => _modelPrefab; set => _modelPrefab = value; }
|
|||
|
|
}
|
|||
|
|
public class CognizeModel
|
|||
|
|
{
|
|||
|
|
private Dictionary<string, List<EquipmentInfo>> _equipmentsData = new Dictionary<string, List<EquipmentInfo>>();
|
|||
|
|
public Dictionary<string, List<EquipmentInfo>> _EquipmentData { get => _equipmentsData; }
|
|||
|
|
|
|||
|
|
///// <summary>
|
|||
|
|
///// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
///// </summary>
|
|||
|
|
public IEnumerator InitDataIEnum()
|
|||
|
|
{
|
|||
|
|
yield return null;
|
|||
|
|
string url = System.IO.Path.Combine(Application.streamingAssetsPath, ConstCtrl.DATA_COGNIZE_PATH);
|
|||
|
|
UnityWebRequest request = UnityWebRequest.Get(url);
|
|||
|
|
yield return request.SendWebRequest();
|
|||
|
|
|
|||
|
|
if (request.result != UnityWebRequest.Result.Success)
|
|||
|
|
{
|
|||
|
|
Debug.LogError("Error: " + request.error);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
string t = request.downloadHandler.text;
|
|||
|
|
string[] lines = t.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
|
|||
|
|
|
|||
|
|
string curTypeNameTemp = "";
|
|||
|
|
List<EquipmentInfo> typeEquipmentArrayTemp = null;
|
|||
|
|
for (int i = 2; i < lines.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (lines[i].Contains("*"))
|
|||
|
|
{
|
|||
|
|
curTypeNameTemp = lines[i].Replace("*", "");
|
|||
|
|
typeEquipmentArrayTemp = new List<EquipmentInfo>();
|
|||
|
|
curTypeNameTemp = curTypeNameTemp.Replace("\r", string.Empty).Replace("\n", string.Empty).Replace("\r\n", string.Empty);
|
|||
|
|
WDebug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>壺" + curTypeNameTemp);
|
|||
|
|
|
|||
|
|
//byte[] utf8Bytes = System.Text.Encoding.UTF8.GetBytes(curTypeNameTemp);
|
|||
|
|
//string temp = BitConverter.ToString(utf8Bytes);
|
|||
|
|
//byte[] utf8Bytes1 = System.Text.Encoding.UTF8.GetBytes("ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ");
|
|||
|
|
//string temp1 = BitConverter.ToString(utf8Bytes1);
|
|||
|
|
//WDebug.Log(temp + "=====" + temp1);
|
|||
|
|
|
|||
|
|
if (curTypeNameTemp.Equals("ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ"))
|
|||
|
|
{
|
|||
|
|
WDebug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
|
curTypeNameTemp = EnumCtrl.GetEnumDescription(EnumCtrl.Type.XHBY);
|
|||
|
|
}
|
|||
|
|
_equipmentsData.Add(curTypeNameTemp, typeEquipmentArrayTemp);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (lines[i].Contains("|"))
|
|||
|
|
{
|
|||
|
|
string[] infos = lines[i].Split('|');
|
|||
|
|
|
|||
|
|
if (infos.Length >= 3)
|
|||
|
|
{
|
|||
|
|
EquipmentInfo equipmentTemp = new EquipmentInfo(
|
|||
|
|
infos[0],
|
|||
|
|
infos[1],
|
|||
|
|
infos[2],
|
|||
|
|
null
|
|||
|
|
);
|
|||
|
|
typeEquipmentArrayTemp.Add(equipmentTemp);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Debug.LogWarning("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>: " + lines[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Debug.LogWarning("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>: " + lines[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
for (int i = 0; i < _EquipmentData[EnumCtrl.GetEnumDescription(AppManagement.Instance._CurType)].Count; i++)
|
|||
|
|
{
|
|||
|
|
string idTemp = _EquipmentData[EnumCtrl.GetEnumDescription(AppManagement.Instance._CurType)][i]._ModelID;
|
|||
|
|
WDebug.Log("1<><31><EFBFBD>ص<EFBFBD>"+ idTemp);
|
|||
|
|
string itemPath = ConstCtrl.DATA_MODEL_PATH+AppManagement.Instance._CurType.ToString()+ "/" + idTemp + ".prefab";
|
|||
|
|
//itemPath = "Assets/10_Prefabs/ModelPrefabs/Cognize/ZXJXSBYJGZhengTiPrefab.prefab";
|
|||
|
|
AddressablesManager.Instance.LoadAsset<GameObject>(itemPath, OnLoadedCall);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnLoadedCall(GameObject obj)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < _EquipmentData[EnumCtrl.GetEnumDescription(AppManagement.Instance._CurType)].Count; i++)
|
|||
|
|
{
|
|||
|
|
WDebug.Log($"2<><32><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>壺{obj.name}");
|
|||
|
|
EquipmentInfo temp = _EquipmentData[EnumCtrl.GetEnumDescription(AppManagement.Instance._CurType)][i];
|
|||
|
|
if (temp._ModelID.Equals(obj.name))
|
|||
|
|
{
|
|||
|
|
temp._ModelPrefab = obj;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|