Exemplo n.º 1
0
    private void OnRoomUpdate(string data)
    {
        string[] storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);

        _currentRoom           = new GP_RTM_Room();
        _currentRoom.id        = storeData[0];
        _currentRoom.creatorId = storeData[1];

        string[] ParticipantsInfo = storeData[2].Split(","[0]);

        for (int i = 0; i < ParticipantsInfo.Length; i += 6)
        {
            if (ParticipantsInfo[i] == AndroidNative.DATA_EOF)
            {
                break;
            }

            GP_Participant p = new GP_Participant(ParticipantsInfo[i], ParticipantsInfo[i + 1], ParticipantsInfo[i + 2], ParticipantsInfo[i + 3], ParticipantsInfo[i + 4], ParticipantsInfo[i + 5]);
            _currentRoom.AddParticipant(p);
        }



        _currentRoom.status            = (GP_RTM_RoomStatus)System.Convert.ToInt32(storeData[3]);
        _currentRoom.creationTimestamp = System.Convert.ToInt64(storeData[4]);

        Debug.Log("GooglePlayRTM OnRoomUpdate Room State: " + _currentRoom.status.ToString());

        ActionRoomUpdated(_currentRoom);
    }
Exemplo n.º 2
0
    public void SetParticipant(GP_Participant p)
    {
        id.text         = "";
        playerId.text   = "";
        playerName.text = "";
        status.text     = GP_RTM_ParticipantStatus.STATUS_UNRESPONSIVE.ToString();

        GooglePlayerTemplate player = GooglePlayManager.Instance.GetPlayerById(p.playerId);

        if (player != null)
        {
            playerId.text   = "Player Id: " + p.playerId;
            playerName.text = "Name: " + player.name;

            if (player.icon != null)
            {
                if (!_id.Equals(p.playerId))
                {
                    icon          = Sprite.Create(player.icon, new Rect(0.0f, 0.0f, player.icon.width, player.icon.height), new Vector2(0.5f, 0.5f));
                    avatar.sprite = icon;
                    _id           = p.playerId;
                }
            }
        }
        else
        {
            avatar.sprite = defaulttexture;
            icon          = null;
            _id           = string.Empty;
        }
        id.text     = "ID: " + p.id;
        status.text = "Status: " + p.Status.ToString();
    }
Exemplo n.º 3
0
	public void SetParticipant(GP_Participant p) {

		id.text = "";
		playerId.text = "";
		playerName.text = "";
		status.text = GP_RTM_ParticipantStatus.STATUS_UNRESPONSIVE.ToString();

		avatar.GetComponent<Renderer>().material.mainTexture = defaulttexture;


		GooglePlayerTemplate player = GooglePlayManager.instance.GetPlayerById(p.playerId);
		if(player != null) {
			playerId.text = "Player Id: " + p.playerId;
			playerName.text = "Name: " + player.name;

			if(player.icon != null) {
				avatar.GetComponent<Renderer>().material.mainTexture = player.icon;
			}

		}
		id.text  = "ID: " +  p.id;
		status.text = "Status: " + p.Status.ToString();


	}
Exemplo n.º 4
0
    public void SetParticipant(GP_Participant p)
    {
        id.text         = "";
        playerId.text   = "";
        playerName.text = "";
        status.text     = GP_RTM_ParticipantStatus.STATUS_UNRESPONSIVE.ToString();

        avatar.GetComponent <Renderer>().material.mainTexture = defaulttexture;


        GooglePlayerTemplate player = GooglePlayManager.instance.GetPlayerById(p.playerId);

        if (player != null)
        {
            playerId.text   = "Player Id: " + p.playerId;
            playerName.text = "Name: " + player.name;

            if (player.icon != null)
            {
                avatar.GetComponent <Renderer>().material.mainTexture = player.icon;
            }
        }
        id.text     = "ID: " + p.id;
        status.text = "Status: " + p.Status.ToString();
    }
Exemplo n.º 5
0
 public UM_RTM_Participant(GP_Participant participant)
 {
     _Id            = participant.id;
     _Name          = participant.DisplayName;
     _gpParticipant = participant;
     _Status        = (UM_RTM_ParticipantStatus)(int)participant.Status;
 }
    private void OnRoomUpdate(string data)
    {
        string[] storeData = data.Split(AndroidNative.DATA_SPLITTER[0]);

        _currentRoom = new GP_RTM_Room {
            id        = storeData[0],
            creatorId = storeData[1]
        };

        var participantsInfo = storeData[2].Split(',');

        for (int i = 0; i < participantsInfo.Length; i += 6)
        {
            if (participantsInfo[i] == AndroidNative.DATA_EOF)
            {
                break;
            }

            var p = new GP_Participant(participantsInfo[i], participantsInfo[i + 1], participantsInfo[i + 2],
                                       participantsInfo[i + 3], participantsInfo[i + 4], participantsInfo[i + 5]);
            _currentRoom.AddParticipant(p);
        }

        _currentRoom.status            = (GP_RTM_RoomStatus)Convert.ToInt32(storeData[3]);
        _currentRoom.creationTimestamp = Convert.ToInt64(storeData[4]);

        Debug.Log("GooglePlayRTM OnRoomUpdate Room State: " + _currentRoom.status);

        ActionRoomUpdated(_currentRoom);
    }
Exemplo n.º 7
0
    //--------------------------------------
    // UTILS
    //--------------------------------------

    public static GP_Participant ParseParticipanData(string[] data, int index)
    {
        GP_Participant participant = new GP_Participant(data[index], data[index + 1], data[index + 2], data[index + 3], data[index + 4], data[index + 5]);

        bool hasResult = Convert.ToBoolean(data[index + 6]);

        if (hasResult)
        {
            GP_ParticipantResult r = new GP_ParticipantResult(data, index + 7);
            participant.SetResult(r);
        }

        return(participant);
    }
Exemplo n.º 8
0
    public static List <GP_Participant> ParseParticipantsData(string[] data, int index)
    {
        List <GP_Participant> Participants = new List <GP_Participant>();

        for (int i = index; i < data.Length; i += 11)
        {
            if (data[i] == AndroidNative.DATA_EOF)
            {
                break;
            }

            GP_Participant p = ParseParticipanData(data, i);
            Participants.Add(p);
        }

        return(Participants);
    }
Exemplo n.º 9
0
	public void SetParticipant(GP_Participant p) {

		id.text = "";
		playerId.text = "";
		playerName.text = "";
		status.text = GP_RTM_ParticipantStatus.STATUS_UNRESPONSIVE.ToString();



		GooglePlayerTemplate player = GooglePlayManager.instance.GetPlayerById(p.playerId);
		if(player != null) {
			playerId.text = "Player Id: " + p.playerId;
			playerName.text = "Name: " + player.name;



		}
		id.text  = "ID: " +  p.id;
		status.text = "Status: " + p.Status.ToString();


	}
Exemplo n.º 10
0
    private void OnGCDataReceived(GP_RTM_Network_Package package)
    {
                #if (UNITY_ANDROID && !UNITY_EDITOR) || SA_DEBUG_MODE
        System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
        string str = enc.GetString(package.buffer);


        string name = package.participantId;


        GP_Participant p = GooglePlayRTM.instance.currentRoom.GetParticipantById(package.participantId);
        if (p != null)
        {
            GooglePlayerTemplate player = GooglePlayManager.instance.GetPlayerById(p.playerId);
            if (player != null)
            {
                name = player.name;
            }
        }

        AndroidMessage.Create("Data Eeceived", "player " + name + " \n " + "data: " + str);
                #endif
    }
Exemplo n.º 11
0
	public void AddParticipant(GP_Participant p) {
		participants.Add(p);
	}
Exemplo n.º 12
0
 public void AddParticipant(GP_Participant p)
 {
     participants.Add(p);
 }
Exemplo n.º 13
0
    public UM_TBM_Participant(GP_Participant participant)
    {
        _GP_Participant = participant;

        _Id          = _GP_Participant.id;
        _Playerid    = _GP_Participant.playerId;
        _DisplayName = _GP_Participant.DisplayName;

        _GP_Participant.BigPhotoLoaded   += HandleBigPhotoLoaded;
        _GP_Participant.SmallPhotoLoaded += HandleSmallPhotoLoaded;

        switch (_GP_Participant.Status)
        {
        case GP_RTM_ParticipantStatus.STATUS_JOINED:
            _Status = UM_TBM_ParticipantStatus.Active;
            break;

        case GP_RTM_ParticipantStatus.STATUS_LEFT:
        case GP_RTM_ParticipantStatus.STATUS_DECLINED:
            _Status = UM_TBM_ParticipantStatus.Declined;
            break;

        case GP_RTM_ParticipantStatus.STATUS_FINISHED:
            _Status = UM_TBM_ParticipantStatus.Done;
            break;

        case GP_RTM_ParticipantStatus.STATUS_INVITED:
            _Status = UM_TBM_ParticipantStatus.Invited;
            break;

        case GP_RTM_ParticipantStatus.STATUS_NOT_INVITED_YET:
        case GP_RTM_ParticipantStatus.STATUS_UNRESPONSIVE:
            _Status = UM_TBM_ParticipantStatus.Unknown;
            break;
        }

        _Outcome = UM_TBM_Outcome.None;
        if (_GP_Participant.Result != null)
        {
            switch (_GP_Participant.Result.Result)
            {
            case GP_TBM_ParticipantResult.MATCH_RESULT_WIN:
                _Outcome = UM_TBM_Outcome.Won;
                break;

            case GP_TBM_ParticipantResult.MATCH_RESULT_LOSS:
                _Outcome = UM_TBM_Outcome.Lost;
                break;

            case GP_TBM_ParticipantResult.MATCH_RESULT_TIE:
                _Outcome = UM_TBM_Outcome.Tied;
                break;

            case GP_TBM_ParticipantResult.MATCH_RESULT_DISCONNECT:
                _Outcome = UM_TBM_Outcome.Disconnected;
                break;

            default:
                _Outcome = UM_TBM_Outcome.None;
                break;
            }
        }
    }