1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using LitJson;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- public class CeShi1 : MonoBehaviour
- {
- // Start is called before the first frame update
- public Data_PlayerAttributes dataPA;
- private int myrandom;
- private List<string> playerID = new List<string>();
- private int indexlist;
- private List<Data_PlayerAttributes> dataPlayerAttributesList = new List<Data_PlayerAttributes>();
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- XXX();
- }
- public void XXX()
- {
- myrandom = UnityEngine.Random.Range(0, 2); //随机下标
- if (myrandom == 0)
- {
- dataPA = JsonMapper.ToObject<Data_PlayerAttributes>(JsonRead("cel_Label"));
- }
- else
- {
- dataPA = JsonMapper.ToObject<Data_PlayerAttributes>(JsonRead("cel_Label 1"));
- }
- if (!playerID.Contains(dataPA.data.message.data2.id))
- {
- playerID.Add(dataPA.data.message.data2.id);//得到了两个数字 88888 213123213
- dataPlayerAttributesList.Add(dataPA);
- }
- for (int i = 0; i < dataPlayerAttributesList.Count; i++)
- {
- if (dataPlayerAttributesList[i].data.message.data2.id.Contains(dataPA.data.message.data2.id))
- {
- dataPlayerAttributesList[i] = dataPA;
- }
- Debug.Log(dataPlayerAttributesList[i].data.message.data2.id + " " + i);
- }
- // Debug.Log(dataPlayerAttributesList.Count);
- //for (int i = 0; i < playerID.Count; i++)
- //{
- // if (playerID[i] == dataPA.data.message.data2.id) //1==data || 2==data
- // {
- // indexlist = i;
- // // dataPlayerAttributesList[indexlist] = dataPA;
- // //Debug.Log(playerID[i]+" "+i);
- // }
- //}
- }
- public string JsonRead(string name)
- {
- string json = "";
- TextAsset text = Resources.Load<TextAsset>("Jsons/" + name);
- json = text.text;
- if (string.IsNullOrEmpty(json)) return null;
- return json;
- }
- }
|