예제 #1
0
 /// <summary>
 /// Provided for resetting the demo state.
 /// </summary>
 public void LeaveGame()
 {
     this.isAuthenticated = false;
     this.isJoined        = false;
     this.activeState     = GuiStates.loading;
     this.team            = string.Empty;
     this.hideTips        = false;
 }
예제 #2
0
    // standard example for logging in with an Android device id
    public void LoginToPlayFab()
    {
        Debug.Log("Using demo device id");
        LoginWithAndroidDeviceIDRequest request = new LoginWithAndroidDeviceIDRequest();

        request.AndroidDeviceId = deviceId;
        request.TitleId         = playfabTitleId;
        request.CreateAccount   = true;
        PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnLoginSuccess, OnPlayFabError);
        this.activeState = GuiStates.loading;
    }
	void OnGUI()
	{
	
		// await our photon session, and poll for certain state changes.
		if(photonComponent.GameInstance != null)
		{
			// this is triggered when our session has joined the master server.
			if(photonComponent.GameInstance.State == ExitGames.Client.Photon.LoadBalancing.ClientState.JoinedLobby && this.isAuthenticated == false)
			{
				this.isAuthenticated = true;
				this.activeState = GuiStates.createRoom;
				// refresh our player stats after the photon webhooks have had time to run
				StartCoroutine(GetUserStats(1.0f));
			}
			// this is triggered when our session has joined a photon game room
			else if(photonComponent.GameInstance.State == ExitGames.Client.Photon.LoadBalancing.ClientState.Joined && this.isJoined == false)
			{
				this.isJoined = true;		
				this.activeState = GuiStates.customEvents;
				// refresh our player stats after the photon webhooks have had time to run
				StartCoroutine(GetUserStats(1.0f));
			}
		}
		
//	Draw the PlayFab overlay prompts 
		if(this.activeState != GuiStates.off)
		{
			GUI.depth = this.gui_depth;
		
			if(pf_logo != null && this.hideTips == false)
			{	
				GUI.Box(new Rect(0, Screen.height * .75f, Screen.width, Screen.height*25f), "");
				GUI.Box(new Rect(0, Screen.height * .75f, Screen.width, Screen.height*25f), "");
				GUI.Box(new Rect(0, Screen.height * .75f, Screen.width, Screen.height*25f), "");
				GUI.Box(new Rect(0, Screen.height * .75f, Screen.width, Screen.height*25f), "");
				GUI.DrawTexture(new Rect(5, Screen.height - this.logoDims.height, this.logoDims.width, this.logoDims.height), this.pf_logo);	
					
			}
			
			if(this.activeState == GuiStates.createRoom || this.activeState == GuiStates.customEvents || this.activeState == GuiStates.loading)
			{
				Rect statsRect = new Rect(Screen.width*.82f -5, Screen.height*.75f, Screen.width*.25f, Screen.height*.25f);
				GUI.Box(statsRect, "");
				
				GUILayout.BeginArea(statsRect);
					string redTeamValue =  this.userStats.ContainsKey("RedTeamJoinedCount") ? this.userStats["RedTeamJoinedCount"].ToString() : "...";
					string bluTeamValue =  this.userStats.ContainsKey("BluTeamJoinedCount") ? this.userStats["BluTeamJoinedCount"].ToString() : "...";
					string mvpValue =  this.userStats.ContainsKey("MVPsWonCount") ? this.userStats["MVPsWonCount"].ToString() : "...";
					string expValue =  this.userStats.ContainsKey("ExperiencePoints") ? this.userStats["ExperiencePoints"].ToString() : "...";
					
						GUI.color = this.pf_orange;
						GUILayout.BeginHorizontal();
						GUILayout.Label("PlayFab Player Stats:");
						GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
					GUI.color = this.pf_blue;
					GUILayout.Label(string.Format("RedTeamJoinedCount: {0}", redTeamValue));
					GUILayout.Label(string.Format("BluTeamJoinedCount: {0}", bluTeamValue));
					GUILayout.Label(string.Format("MVPsWonCount: {0}", mvpValue));
					GUILayout.Label(string.Format("ExperiencePoints: {0}", expValue));
					GUI.color = Color.white;
				GUILayout.EndArea();
			}
		
			Rect centralBox = new Rect();
			
			if(hideTips == false)
			{
				switch(this.activeState)
				{
					case GuiStates.login:
						centralBox = new  Rect(Screen.width/4, Screen.height*.75f, Screen.width/2, Screen.height*.25f);
						
						 GUILayout.BeginArea(centralBox);
							GUI.color = this.pf_orange;
							GUILayout.Label("Photon Custom Authentication with Playfab Credentials:");
							GUI.color = Color.white;
							GUILayout.Label("For the purposes of this demo, we will be using a testing device id for the login credentials. We provide these credentials to Photon, which then validates and permits entry into the MasterServer--MainLobby. From the main lobby a user can create and join rooms and games. Doing so will in turn fire the web hook associated with the player action.");
							GUILayout.Label("");
							GUI.color = Color.white;
						GUILayout.EndArea();	
					break;
					
					case GuiStates.createRoom:
						centralBox = new  Rect(Screen.width/4, Screen.height*.75f, Screen.width/2, Screen.height*.25f);
						
						GUILayout.BeginArea(centralBox);	
							GUI.color = this.pf_orange;
							GUILayout.Label("PlayFab Authentication Successful!");
							GUI.color = Color.white;
							GUILayout.Label("In the bottm right you can see the most up-to-date PlayFab PlayerStatistics for this user. You will see these stats change in real time as web hooks are called to process game logic.");
							GUILayout.Label("From the MainLobby, a player can join existing rooms or create a new one. When you create and join a room our cloud script is randomly assigning the player to a team (Red or Blu) and tracking the results in Player Stats. Watch the stats to see on which team you are assigned.");
							GUI.color = Color.white;
						GUILayout.EndArea();	
					break;
					
					case GuiStates.customEvents:
						centralBox = new  Rect(Screen.width/4, Screen.height*.75f, Screen.width/2, Screen.height*.25f);
						
						GUILayout.BeginArea(centralBox);
							GUI.color = this.pf_orange;
							GUILayout.Label(string.Format("You are now in the game, welcome to the {0} team", this.team));
							GUI.color = Color.white;
							GUILayout.Label("While the game is running your loops and mechanics, custom room events can be raised to augment your logic flow. These events can have custom input parameters as well as access basic Photon room details. This provides an all-purpose, flexible event system to benifit most game mode types");
							GUILayout.Label("");
							GUI.color = Color.white;
							
							if(GUILayout.Button("Ok, I got it. [hide these tips]"))
							{
								this.hideTips = true;
							}
							
							GUILayout.Label("");
						GUILayout.EndArea();	
					break;
					
					default:
						GUILayout.BeginArea(centralBox);
							GUILayout.Label("Awaiting Server...");
						GUILayout.EndArea();
					break;
				}	
			}
		}
	}
	void Start()
	{
		
		PlayFabSettings.TitleId = playfabTitleId; // PlayFab title must be stored for the web API calls to succeed.
		this.activeState = GuiStates.login; // Initialization of our active state, awaitng the player's login to playfab.
	}
	/// <summary>
	/// Provided for resetting the demo state.
	/// </summary>
	public void LeaveGame()
	{
		this.isAuthenticated = false;
		this.isJoined = false;
		this.activeState = GuiStates.loading;
		this.team = string.Empty;
		this.hideTips = false;
	}
	// standard example for logging in with an Android device id
	public void LoginToPlayFab()
	{
		Debug.Log("Using demo device id");
		LoginWithAndroidDeviceIDRequest request = new LoginWithAndroidDeviceIDRequest();
		request.AndroidDeviceId = deviceId;
		request.TitleId = playfabTitleId;
		request.CreateAccount = true;
		PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnLoginSuccess, OnPlayFabError);
		this.activeState = GuiStates.loading;
	}
예제 #7
0
    void OnGUI()
    {
        // await our photon session, and poll for certain state changes.
        if (photonComponent.GameInstance != null)
        {
            // this is triggered when our session has joined the master server.
            if (photonComponent.GameInstance.State == ExitGames.Client.Photon.LoadBalancing.ClientState.JoinedLobby && this.isAuthenticated == false)
            {
                this.isAuthenticated = true;
                this.activeState     = GuiStates.createRoom;
                // refresh our player stats after the photon webhooks have had time to run
                StartCoroutine(GetUserStats(1.0f));
            }
            // this is triggered when our session has joined a photon game room
            else if (photonComponent.GameInstance.State == ExitGames.Client.Photon.LoadBalancing.ClientState.Joined && this.isJoined == false)
            {
                this.isJoined    = true;
                this.activeState = GuiStates.customEvents;
                // refresh our player stats after the photon webhooks have had time to run
                StartCoroutine(GetUserStats(1.0f));
            }
        }

//	Draw the PlayFab overlay prompts
        if (this.activeState != GuiStates.off)
        {
            GUI.depth = this.gui_depth;

            if (pf_logo != null && this.hideTips == false)
            {
                GUI.Box(new Rect(0, Screen.height * .75f, Screen.width, Screen.height * 25f), "");
                GUI.Box(new Rect(0, Screen.height * .75f, Screen.width, Screen.height * 25f), "");
                GUI.Box(new Rect(0, Screen.height * .75f, Screen.width, Screen.height * 25f), "");
                GUI.Box(new Rect(0, Screen.height * .75f, Screen.width, Screen.height * 25f), "");
                GUI.DrawTexture(new Rect(5, Screen.height - this.logoDims.height, this.logoDims.width, this.logoDims.height), this.pf_logo);
            }

            if (this.activeState == GuiStates.createRoom || this.activeState == GuiStates.customEvents || this.activeState == GuiStates.loading)
            {
                Rect statsRect = new Rect(Screen.width * .82f - 5, Screen.height * .75f, Screen.width * .25f, Screen.height * .25f);
                GUI.Box(statsRect, "");

                GUILayout.BeginArea(statsRect);
                string redTeamValue = this.userStats.ContainsKey("RedTeamJoinedCount") ? this.userStats["RedTeamJoinedCount"].ToString() : "...";
                string bluTeamValue = this.userStats.ContainsKey("BluTeamJoinedCount") ? this.userStats["BluTeamJoinedCount"].ToString() : "...";
                string mvpValue     = this.userStats.ContainsKey("MVPsWonCount") ? this.userStats["MVPsWonCount"].ToString() : "...";
                string expValue     = this.userStats.ContainsKey("ExperiencePoints") ? this.userStats["ExperiencePoints"].ToString() : "...";

                GUI.color = this.pf_orange;
                GUILayout.BeginHorizontal();
                GUILayout.Label("PlayFab Player Stats:");
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUI.color = this.pf_blue;
                GUILayout.Label(string.Format("RedTeamJoinedCount: {0}", redTeamValue));
                GUILayout.Label(string.Format("BluTeamJoinedCount: {0}", bluTeamValue));
                GUILayout.Label(string.Format("MVPsWonCount: {0}", mvpValue));
                GUILayout.Label(string.Format("ExperiencePoints: {0}", expValue));
                GUI.color = Color.white;
                GUILayout.EndArea();
            }

            Rect centralBox = new Rect();

            if (hideTips == false)
            {
                switch (this.activeState)
                {
                case GuiStates.login:
                    centralBox = new  Rect(Screen.width / 4, Screen.height * .75f, Screen.width / 2, Screen.height * .25f);

                    GUILayout.BeginArea(centralBox);
                    GUI.color = this.pf_orange;
                    GUILayout.Label("Photon Custom Authentication with Playfab Credentials:");
                    GUI.color = Color.white;
                    GUILayout.Label("For the purposes of this demo, we will be using a testing device id for the login credentials. We provide these credentials to Photon, which then validates and permits entry into the MasterServer--MainLobby. From the main lobby a user can create and join rooms and games. Doing so will in turn fire the web hook associated with the player action.");
                    GUILayout.Label("");
                    GUI.color = Color.white;
                    GUILayout.EndArea();
                    break;

                case GuiStates.createRoom:
                    centralBox = new  Rect(Screen.width / 4, Screen.height * .75f, Screen.width / 2, Screen.height * .25f);

                    GUILayout.BeginArea(centralBox);
                    GUI.color = this.pf_orange;
                    GUILayout.Label("PlayFab Authentication Successful!");
                    GUI.color = Color.white;
                    GUILayout.Label("In the bottm right you can see the most up-to-date PlayFab PlayerStatistics for this user. You will see these stats change in real time as web hooks are called to process game logic.");
                    GUILayout.Label("From the MainLobby, a player can join existing rooms or create a new one. When you create and join a room our cloud script is randomly assigning the player to a team (Red or Blu) and tracking the results in Player Stats. Watch the stats to see on which team you are assigned.");
                    GUI.color = Color.white;
                    GUILayout.EndArea();
                    break;

                case GuiStates.customEvents:
                    centralBox = new  Rect(Screen.width / 4, Screen.height * .75f, Screen.width / 2, Screen.height * .25f);

                    GUILayout.BeginArea(centralBox);
                    GUI.color = this.pf_orange;
                    GUILayout.Label(string.Format("You are now in the game, welcome to the {0} team", this.team));
                    GUI.color = Color.white;
                    GUILayout.Label("While the game is running your loops and mechanics, custom room events can be raised to augment your logic flow. These events can have custom input parameters as well as access basic Photon room details. This provides an all-purpose, flexible event system to benifit most game mode types");
                    GUILayout.Label("");
                    GUI.color = Color.white;

                    if (GUILayout.Button("Ok, I got it. [hide these tips]"))
                    {
                        this.hideTips = true;
                    }

                    GUILayout.Label("");
                    GUILayout.EndArea();
                    break;

                default:
                    GUILayout.BeginArea(centralBox);
                    GUILayout.Label("Awaiting Server...");
                    GUILayout.EndArea();
                    break;
                }
            }
        }
    }
예제 #8
0
 void Start()
 {
     PlayFabSettings.TitleId = playfabTitleId;   // PlayFab title must be stored for the web API calls to succeed.
     this.activeState        = GuiStates.login;  // Initialization of our active state, awaitng the player's login to playfab.
 }