コード例 #1
0
    public static GP_TBM_Match ParceMatchInfo(string[] MatchData, int index)
    {
        GP_TBM_Match mtach = new GP_TBM_Match();

        mtach.Id                      = MatchData[index];
        mtach.RematchId               = MatchData[index + 1];
        mtach.Description             = MatchData[index + 2];
        mtach.AvailableAutoMatchSlots = Convert.ToInt32(MatchData[index + 3]);
        mtach.CreationTimestamp       = Convert.ToInt64(MatchData[index + 4]);
        mtach.CreatorId               = MatchData[index + 5];
        mtach.LastUpdatedTimestamp    = Convert.ToInt64(MatchData[index + 6]);
        mtach.LastUpdaterId           = MatchData[index + 7];
        mtach.MatchNumber             = Convert.ToInt32(MatchData[index + 8]);
        mtach.Status                  = (GP_TBM_MatchStatus)Convert.ToInt32(MatchData[index + 9]);
        mtach.TurnStatus              = (GP_TBM_MatchTurnStatus)Convert.ToInt32(MatchData[index + 10]);
        mtach.CanRematch              = Convert.ToBoolean(MatchData[index + 11]);
        mtach.Variant                 = Convert.ToInt32(MatchData[index + 12]);
        mtach.Version                 = Convert.ToInt32(MatchData[index + 13]);

        mtach.SetData(MatchData[index + 14]);
        mtach.SetPreviousMatchData(MatchData[index + 15]);
        mtach.PendingParticipantId = MatchData[index + 16];
        mtach.Participants         = GooglePlayManager.ParseParticipantsData(MatchData, index + 17);

        return(mtach);
    }
コード例 #2
0
    void DealWithMatchData(GP_TBM_Match match)
    {
        mMatch = match;
        // Common.DebugPopUp("Dealing with match nata", "Participant info " + mMatch.PendingParticipantId);
        if (mMatch.Data != null)
        {
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            string stringData = encoding.GetString(mMatch.Data, 0, mMatch.Data.Length);
            if (stringData.Length > 10)
            {
                Common.roundInformation.SetNewGameDataFromGooglePlay(mMatch.Data);
                // AndroidMessage.Create("match data not empty", "it is  " + stringData);
                StartDoingTurn(mMatch);
                CreateParticipantUI();
                return;
            }
        }

        // Otherwise, this is the first player. Initialize the game state.
        initGame(mMatch);


        // Let the player take the first turn
        StartDoingTurn(mMatch);
        CreateParticipantUI();
        //SetGameStateBased on gameState
    }
コード例 #3
0
    public void MatchSelectedFromData(int counter)
    {
        GP_TBM_Match match = matchDatasLoaded[counter];

        DealWithMatchData(match);
        //   matchUI.SetActive(false);
    }
コード例 #4
0
    private void OnInvitationAcceptedCallback(string data)
    {
        Debug.Log("OnInvitationAcceptedCallback received");

        string[] DataArray = data.Split(AndroidNative.DATA_SPLITTER[0]);


        string invitationId = "";
        GP_TBM_MatchInitiatedResult result = new GP_TBM_MatchInitiatedResult(DataArray[0]);



        if (DataArray.Length > 1)
        {
            invitationId = DataArray[1];

            GP_TBM_Match match = ParceMatchInfo(DataArray, 2);
            UpdateMatchInfo(match);
            result.Match = match;
        }

        Debug.Log("OnInvitationAcceptedCallback fired " + result.IsSucceeded);

        ActionMatchInvitationAccepted(invitationId, result);
    }
コード例 #5
0
 private void UpdateMatchInfo(GP_TBM_Match match)
 {
     if (Matches.ContainsKey(match.Id))
     {
         Matches[match.Id] = match;
     }
     else
     {
         Matches.Add(match.Id, match);
     }
 }
コード例 #6
0
    private void ActionMatchDataLoadedFunction(GP_TBM_LoadMatchResult result)
    {
        Debug_previous_method_name();
        AndroidMessage.Create("Loaded match data ", "loaad ");
        foreach (GP_Participant part in result.Match.Participants)
        {
            //  AndroidMessage.Create("Participant", "Participant info " + part.DisplayName + " +" + part.IconImageUrl + " id " + part.id + " pid " + part.playerId);
        }
        GP_TBM_Match match = result.Match;

        DealWithMatchData(match);
    }
コード例 #7
0
    void initGame(GP_TBM_Match match)
    {
        AndroidMessage.Create("Initializing match data ", " match data initialization");
        List <string> playerIDS = new List <string>();

        foreach (GP_Participant participant in match.Participants)
        {
            playerIDS.Add(participant.id); //TODO katso onko playerID vai joku toinen ID
        }
        Common.roundInformation.InitializeGameData(playerIDS, match.Id);
        Common.cloudServiceMaster.CreateAlbumOnGameStarted();
    }
コード例 #8
0
    private void OnTurnBasedMatchReceived(string data)
    {
        string[] DataArray = data.Split(AndroidNative.DATA_SPLITTER[0]);
        GP_TBM_UpdateMatchResult result = new GP_TBM_UpdateMatchResult("0");

        GP_TBM_Match match = ParceMatchInfo(DataArray, 0);

        UpdateMatchInfo(match);
        result.Match = match;

        ActionMatchUpdated(result);

        //ActionMatchReceived(new GP_TBM_MatchReceivedResult(ParceMatchInfo(data)));
    }
コード例 #9
0
    private void OnUpdateMatchResult(string data)
    {
        string[] DataArray = data.Split(AndroidNative.DATA_SPLITTER[0]);

        GP_TBM_UpdateMatchResult result = new GP_TBM_UpdateMatchResult(DataArray[0]);

        if (DataArray.Length > 1)
        {
            GP_TBM_Match match = ParceMatchInfo(DataArray, 1);
            UpdateMatchInfo(match);
            result.Match = match;
        }

        ActionMatchUpdated(result);
    }
コード例 #10
0
    void HandleActionMatchesResultLoaded(GP_TBM_LoadMatchesResult res)
    {
        _Matches.Clear();

        if (res.IsSucceeded)
        {
            foreach (KeyValuePair <string, GP_TBM_Match> pair in res.LoadedMatches)
            {
                GP_TBM_Match match = pair.Value;
                UM_TBM_Match m     = new UM_TBM_Match(match);
                UpdateMatchData(m);
            }
        }

        CheckDataCounter();
    }
コード例 #11
0
    private void AN_OnTurnResult(string data)
    {
        Debug.Log("AN_OnTurnResult");

        string[] DataArray = data.Split(AndroidNative.DATA_SPLITTER[0]);

        GP_TBM_UpdateMatchResult result = new GP_TBM_UpdateMatchResult(DataArray[0]);

        if (DataArray.Length > 1)
        {
            GP_TBM_Match match = ParceMatchInfo(DataArray, 1);
            UpdateMatchInfo(match);
            result.Match = match;
        }
        Debug.Log("ActionMatchTurnFinished fired");
        ActionMatchTurnFinished(result);
    }
コード例 #12
0
    void StartDoingTurn(GP_TBM_Match match)
    {
        string id = FindIDfromConnectedPlayerID(match); //

        Common.playerInformation.SetMyPlayerInformationAndItsValues(id);
        Common.gameLoader.LoadSceneBasedOnState();  //Loads the wanted scene and changes UI.

        return;
        //string id=match.PendingParticipantId; //TODO CHECK ID.

        //   if (Common.playerInformation.playerNumber == -1)
        //  {

        //   Common.playerInformation.SetMyPlayerInformation();
        // Common.playerInformation.SetMyPlayerInformation(id);
        //}
        // hi.SetActive(true);
    }
コード例 #13
0
    public string FindIDfromConnectedPlayerID(GP_TBM_Match match)
    {
        string playerIDToFind = GooglePlayManager.Instance.player.playerId;
        int    counter        = 0;

        foreach (GP_Participant participant in match.Participants)
        {
            string id = participant.playerId;
            if (id.Contains(playerIDToFind))
            {
                // AN_PoupsProxy.showMessage("FindMyPlayerNumber in playerinformation", "found player number " + counter.ToString());
                TBM_Debug("FindMyPlayerNumber in TBM_Game/FindIDfromPlayerID", "found player number " + participant.id.ToString());
                return(participant.id);
            }
            counter++;
        }
        Common.DebugLog("Warning", "Error", "DIDNT FIND PLAYER ID in TBM/FindIDFromPLayerID");
        return("ERROR_FindingID_Didnt_Find_ID");
    }
コード例 #14
0
    void ActionMatchInitiated(GP_TBM_MatchInitiatedResult result)
    {
        Debug_previous_method_name();
        unShowLoadingPopUp();

        if (!result.IsSucceeded)
        {
            AndroidMessage.Create("Match Initi Failed", "Status code: " + result.Response);
            return;
        }


        // If this player is not the first player in this match, continue.
        AndroidMessage.Create("Match Initiated ", "Status code: " + result.Response);
        int counter = 0;

        GP_TBM_Match Match = result.Match;

        mMatch = result.Match;
        DealWithMatchData(mMatch);
    }
コード例 #15
0
    public UM_TBM_Match(GP_TBM_Match match)
    {
        _Id   = match.Id;
        _Data = match.Data;

        foreach (GP_Participant participant in match.Participants)
        {
            UM_TBM_Participant p = new UM_TBM_Participant(participant);
            _Participants.Add(p);
            if (match.PendingParticipantId.Equals(participant.id))
            {
                _CurrentParticipant = p;
            }
        }


        if (match.TurnStatus == GP_TBM_MatchTurnStatus.MATCH_TURN_STATUS_MY_TURN)
        {
            _IsCurrentPlayerTurn = true;
        }


        switch (match.Status)
        {
        case GP_TBM_MatchStatus.MATCH_STATUS_ACTIVE:
            _Status = UM_TBM_MatchStatus.Active;
            break;

        case GP_TBM_MatchStatus.MATCH_STATUS_AUTO_MATCHING:
            _Status = UM_TBM_MatchStatus.Matching;
            break;

        case GP_TBM_MatchStatus.MATCH_STATUS_CANCELED:
        case GP_TBM_MatchStatus.MATCH_STATUS_COMPLETE:
        case GP_TBM_MatchStatus.MATCH_STATUS_EXPIRED:
            _Status = UM_TBM_MatchStatus.Ended;
            break;
        }
    }
コード例 #16
0
    void ActionMatchInitiated(GP_TBM_MatchInitiatedResult result)
    {
        if (!result.IsSucceeded)
        {
            AndroidMessage.Create("Match Initi Failed", "Status code: " + result.Response);
            return;
        }

        GP_TBM_Match Match = result.Match;

        // If this player is not the first player in this match, continue.
        if (Match.Data != null)
        {
            //showTurnUI(match);
            return;
        }

        // Otherwise, this is the first player. Initialize the game state.
        //initGame(match);

        // Let the player take the first turn
        //showTurnUI(match);
    }
コード例 #17
0
    // --------------------------------------
    // Native Events
    // --------------------------------------

    private void OnLoadMatchesResult(string data)
    {
        string[] DataArray = data.Split(new string[] { AndroidNative.DATA_SPLITTER2 }, StringSplitOptions.None);
        GP_TBM_LoadMatchesResult result = new GP_TBM_LoadMatchesResult(DataArray[0]);

        if (DataArray.Length > 1)
        {
            result.LoadedMatches = new Dictionary <string, GP_TBM_Match>();
            for (int i = 1; i < DataArray.Length; i++)
            {
                if (DataArray[i] == AndroidNative.DATA_EOF)
                {
                    break;
                }

                GP_TBM_Match match = ParceMatchInfo(DataArray[i]);
                UpdateMatchInfo(match);
                result.LoadedMatches.Add(match.Id, match);
            }
        }


        ActionMatchesResultLoaded(result);
    }
コード例 #18
0
	public GP_TBM_MatchReceivedResult(GP_TBM_Match match) {
		_Match = match;
	} 
コード例 #19
0
 public GP_TBM_MatchReceivedResult(GP_TBM_Match match)
 {
     _Match = match;
 }