示例#1
0
    private void PhoneDataListUpdate(PhoneJson phoneData)
    {
        bool exist   = false;
        int  listNum = 0;

        for (int i = 0; i < phoneDataList.Count; i++)
        {
            if (phoneDataList[i].ip == phoneData.ip)
            {
                exist   = true;
                listNum = i;
                break;
            }
        }

        if (exist)
        {
            phoneDataList[listNum].ip        = phoneData.ip;
            phoneDataList[listNum].ball      = phoneData.ball;
            phoneDataList[listNum].direction = phoneData.direction;
        }
        else
        {
            phoneDataList.Add(phoneData);
        }
    }
示例#2
0
    private void ReadJson(string data)
    {
        PhoneJson jsonData = JsonUtility.FromJson <PhoneJson>(data);

        print(data);

        if (jsonData.key == udpKey)
        {
            PhoneDataListUpdate(jsonData);
        }
    }