I am attempting to go two values in a return however I get an error, one would simply inform the successful participant and one other can be a technique known as StartCloudUpdatePlayerStats() which can also be within the full code I added beneath.
By calling it I’d have the ability to replace the values which are in playfab.
Does anybody have an concept learn how to resolve this?
Thanks prematurely. Any assistance is welcome.
Code snippet the place the error is ->
// Returns the participant who's at the moment forward in rating.
public Participant GetWinningPlayer()
{
Participant winningPlayer = PlayerManager.inst.gamers[0].participant;
// Loop by means of all gamers, aside from the primary one as they're successful by default.
for(int x = 1; x < PlayerManager.inst.gamers.Size; ++x)
{
Participant curPlayer = PlayerManager.inst.gamers[x].participant;
if(curPlayer.rating > winningPlayer.rating)
winningPlayer = curPlayer;
}
return (winningPlayer, StartCloudUpdatePlayerStats()); error<---
}
error->
ScriptsManagersGameManager.cs(311,32): error CS8210: A tuple might not include a price of kind 'void'.
Full CODE –>
utilizing UnityEngine;
utilizing UnityEngine.Occasions;
utilizing PlayFab.Json;
utilizing JsonObject = PlayFab.Json.JsonObject;
utilizing PlayFab;
utilizing PlayFab.ClientModels;
utilizing System.Collections.Generic;
public class GameManager : MonoBehaviour
{
public GameState gameState; // Present state of the sport.
public GameModeType gameMode; // Recreation Mode we're at the moment enjoying.
public SpellDistributionType spellDistribution; // How the spells are given to the participant in-game (not together with pickups).
[Header("Win Conditions")]
[HideInInspector]
public int winningScore; // The rating wanted to win the sport (Rating Primarily based sport mode).
[HideInInspector]
public float timeLimit; // Time till the sport ends (Time Primarily based sport mode).
non-public float startTime; // Time the sport began - used to maintain monitor of time remaining.
public float endGameHangTime; // How lengthy can we wait after the sport ends, earlier than going again to the menu?
[Header("Death")]
public float deadDuration; // The time between the participant dying and respawning.
public float minYKillPos; // Kills the participant in the event that they go beneath this peak (so they do not fall without end).
[Header("Components")]
public PhotonView photonView; // PhotonView part.
non-public Digicam cam; // Principal digital camera, used to calculate the min Y kill pos.
// Map
[HideInInspector]
public Vector3[] spawnPoints; // Array of participant spawn factors.
[HideInInspector]
public bool mapLoaded; // Has the map loaded in?
// Occasions
[HideInInspector] public UnityEvent onMapLoaded; // Referred to as when the map has been loaded in.
[HideInInspector] public UnityEvent onPlayersReady; // Referred to as when all of the gamers are spawned in and able to go.
[HideInInspector] public UnityEvent onGameStart; // Referred to as when the sport begins and the gamers can begin preventing.
[HideInInspector] public System.Motion<int> onGameWin; // Referred to as when a participant has gained the sport.
// Occasion
public static GameManager inst;
#area Subscribing to Occasions
void OnEnable ()
{
// Subscribe to occasions.
onMapLoaded.AddListener(OnMapLoaded);
onPlayersReady.AddListener(OnPlayersReady);
}
void OnDisable ()
{
// Un-subscribe from occasions.
onMapLoaded.RemoveListener(OnMapLoaded);
onPlayersReady.RemoveListener(OnPlayersReady);
}
#endregion
void Awake ()
{
#area Singleton
// If the occasion already exists, destroy this one.
if(inst != this && inst != null)
{
Destroy(gameObject);
return;
}
// Set the occasion to this script.
inst = this;
#endregion
SetState(GameState.Initiation);
}
void Begin ()
{
if(!PhotonNetwork.inRoom)
{
Debug.LogError("Can not straight play this scene earlier than connecting to community! <b>Begin sport in Menu scene.</b>");
return;
}
// Provoke the sport mode.
InitiateGameMode();
// Load the map.
MapLoader.inst.LoadMap(PhotonNetwork.room.CustomProperties["map"].ToString());
// Get the digital camera.
cam = Digicam.foremost;
}
void Replace ()
{
// Are we at the moment enjoying the sport?
if(gameState == GameState.Taking part in)
{
// Host checks win situation each body if it is a Time Primarily based sport mode.
if(PhotonNetwork.isMasterClient && gameMode == GameModeType.TimeBased)
{
if(Time.time > startTime + timeLimit)
CheckWinCondition();
}
}
}
// Referred to as when the map has been loaded in.
void OnMapLoaded ()
{
// Calculate the min Y kill pos.
minYKillPos = MapLoader.inst.GetLowestPoint() - 4.0f;
// When the map has been loaded, inform everybody we're within the sport and able to go.
if(PhotonNetwork.inRoom)
NetworkManager.inst.photonView.RPC("ImInGame", PhotonTargets.AllBuffered);
}
// Referred to as when all of the gamers are spawned and able to go.
void OnPlayersReady ()
{
SetState(GameState.PreGame);
}
// Will get the gamemode from customized properties.
void InitiateGameMode ()
{
int gm = (int)PhotonNetwork.room.CustomProperties["gamemode"];
int gmProp = (int)PhotonNetwork.room.CustomProperties["gamemodeprop"];
gameMode = (GameModeType)gm;
change(gameMode)
{
case GameModeType.ScoreBased:
winningScore = gmProp;
break;
case GameModeType.TimeBased:
timeLimit = (float)gmProp;
break;
}
}
// Referred to as by the host after the countdown to start the sport.
[PunRPC]
public void StartGame ()
{
SetState(GameState.Taking part in);
startTime = Time.time;
onGameStart.Invoke();
}
// Checks if a participant / can win the sport. In that case - finish the sport.
public void CheckWinCondition ()
{
// If we're not at the moment enjoying the sport, return.
if(gameState != GameState.Taking part in) return;
// Get the successful participant.
Participant winningPlayer = GetWinningPlayer();
bool hasWon = false;
change(gameMode)
{
case GameModeType.ScoreBased:
hasWon = winningPlayer.rating >= winningScore;
break;
case GameModeType.TimeBased:
hasWon = Time.time > startTime + timeLimit;
break;
}
// If the situations are proper for a win - then that participant wins.
if(hasWon)
photonView.RPC("WinGame", PhotonTargets.All, winningPlayer.networkPlayer.networkID);
}
// Referred to as when a participant wins the sport.
[PunRPC]
public void WinGame (int winningPlayer)
{
SetState(GameState.EndGame);
onGameWin.Invoke(winningPlayer);
// Return to the menu in 'endGameHangTime' seconds.
Invoke("GoBackToMenu", endGameHangTime);
}
// Referred to as after a participant wins the sport, we return to the menu.
void GoBackToMenu ()
{
NetworkManager.inst.HostBackToMenu();
}
public int playerLevel;
public int gameLevel;
public int playerHealth;
public int playerDamage;
public int playerHighScore;
public int playerGolds;
public void SetStats()
{
PlayFabClientAPI.UpdatePlayerStatistics(new UpdatePlayerStatisticsRequest
{
// request.Statistics is a listing, so a number of StatisticUpdate objects might be outlined if required.
Statistics = new Checklist<StatisticUpdate> {
new StatisticUpdate { StatisticName = "PlayerLevel", Worth = playerLevel },
new StatisticUpdate { StatisticName = "GameLevel", Worth = gameLevel },
new StatisticUpdate { StatisticName = "PlayerHealth", Worth = playerHealth },
new StatisticUpdate { StatisticName = "PlayerDamage", Worth = playerDamage },
new StatisticUpdate { StatisticName = "PlayerHighScore", Worth = playerHighScore },
new StatisticUpdate { StatisticName = "PlayerGolds", Worth = playerGolds },
}
},
outcome => { Debug.Log("Person statistics up to date"); },
error => { Debug.LogError(error.GenerateErrorReport()); });
}
public void GetStats()
{
PlayFabClientAPI.GetPlayerStatistics(
new GetPlayerStatisticsRequest(),
OnGetStats,
error => Debug.LogError(error.GenerateErrorReport())
);
}
public void OnGetStats(GetPlayerStatisticsResult outcome)
{
Debug.Log("Acquired the next Statistics:");
foreach (var eachStat in outcome.Statistics)
{
Debug.Log("Statistic (" + eachStat.StatisticName + "): " + eachStat.Worth);
change (eachStat.StatisticName)
{
case "PlayerLevel":
playerLevel = eachStat.Worth;
break;
case "GameLevel":
gameLevel = eachStat.Worth;
break;
case "PlayerHealth":
playerHealth = eachStat.Worth;
break;
case "PlayerDamage":
playerDamage = eachStat.Worth;
break;
case "PlayerHighScore":
playerHighScore = eachStat.Worth;
break;
case "PlayerGolds":
playerGolds = eachStat.Worth;
break;
}
}
}
// Construct the request object and entry the API
public void StartCloudUpdatePlayerStats()
{
PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
{
FunctionName = "UpdatePlayerStats", // Arbitrary perform title (should exist in your uploaded cloud.js file)
FunctionParameter = new { Stage = playerLevel, GameLevel = gameLevel, Well being = playerHealth, Harm = playerDamage, highScore = playerHighScore, Golds = playerGolds },
GeneratePlayStreamEvent = true, // Non-compulsory - Reveals this occasion in PlayStream
}, OnCloudUpdateStats, OnErrorShared);
}
// OnCloudHelloWorld outlined within the subsequent code block
non-public static void OnCloudUpdateStats(ExecuteCloudScriptResult outcome)
{
// CloudScript (Legacy) returns arbitrary outcomes, so you must consider them one step and one parameter at a time
JsonObject jsonResult = (JsonObject)outcome.FunctionResult;
// object messageValue;
// jsonResult.TryGetValue("messageValue", out messageValue); // observe how "messageValue" straight corresponds to the JSON values set in CloudScript (Legacy)
// Debug.Log((string)messageValue);
}
non-public static void OnErrorShared(PlayFabError error)
{
Debug.Log(error.GenerateErrorReport());
}
// Returns the participant who's at the moment forward in rating.
public Participant GetWinningPlayer()
{
Participant winningPlayer = PlayerManager.inst.gamers[0].participant;
// Loop by means of all gamers, aside from the primary one as they're successful by default.
for(int x = 1; x < PlayerManager.inst.gamers.Size; ++x)
{
Participant curPlayer = PlayerManager.inst.gamers[x].participant;
if(curPlayer.rating > winningPlayer.rating)
winningPlayer = curPlayer;
}
return (winningPlayer, StartCloudUpdatePlayerStats());
}
// Units the present sport state.
public void SetState (GameState state)
{
gameState = state;
}
// If that is of sport mode Rating Primarily based, return the remaining time.
public float TimeRemaining ()
{
return (startTime + timeLimit) - Time.time;
}
}
// The sport state retains monitor of the present state of the sport. This may dictate what will get checked and what issues are allowed to occur.
public enum GameState
{
Initiation, // If we're at the moment ready for gamers, spawning the map, initiating the gamers.
PreGame, // Counting down earlier than the sport begins.
Taking part in, // When the sport is in progress.
EndGame // When the sport has ended and a participant has gained.
}
// The sport mode dictates the win situation for the sport.
public enum GameModeType
{
ScoreBased, // First participant to a selected rating (kills) - wins.
TimeBased // After a set period, the participant with probably the most kills wins.
}
// How the spells are given to the participant in-game (not together with pickups).
public enum SpellDistributionType
{
RandomOnStart, // Random spell in the beginning of the sport.
RandomOnSpawn // Random spell everytime the participant spawns.
}