Home Game Development Error on go two values in return Unity C#

Error on go two values in return Unity C#

0
Error on go two values in return Unity C#

[ad_1]

I’m making an attempt to go two values in a return however I get an error, one would simply inform the successful participant and one other could be a way referred to as StartCloudUpdatePlayerStats() which can also be within the full code I added beneath.

By calling it I’d be capable of replace the values which might be in playfab.
Does anybody have an thought how you can resolve this?
Thanks prematurely. Any assistance is welcome.

Code snippet the place the error is ->

// Returns the participant who's presently forward in rating.
public Player GetWinningPlayer()
{
    Player successfulPlayer = PlayerSupervisor.inst.gamers[0].participant;

    // Loop by all gamers, apart from the primary one as they're successful by default.
    for(int x = 1; x < PlayerSupervisor.inst.gamers.Length; ++x)
    {
        Player curPlayer = PlayerSupervisor.inst.gamers[x].participant;

        if(curPlayer.rating > successfulPlayer.rating)
            successfulPlayer = curPlayer;
    }

    return (successfulPlayer, StartCloudUpdatePlayerStats()); error<---
}

error->

ScriptsManagersGameSupervisor.cs(311,32): error CS8210: A tuple might not include a price of kind 'void'.

Full CODE –>

utilizing UnityEngine;
utilizing UnityEngine.Events;
utilizing PlayFab.Json;
utilizing JsonObject = PlayFab.Json.JsonObject;
utilizing PlayFab;
utilizing PlayFab.ConsumerModels;
utilizing System.Collections.Generic;
public class GameSupervisor : MonoBehaviour
{
    public GameState gameState;                         // Current state of the sport.
    public GameModeKind sportMode;                       // Game Mode we're presently enjoying.
    public SpellDistributionType spellDistribution;     // How the spells are given to the participant in-game (not together with pickups).

    [Header("Win Conditions")]
    [HideInInspector]
    public int successfulScore;                // The rating wanted to win the sport (Score Based sport mode).
    [HideInInspector]
    public float timeLimit;                 // Time till the sport ends (Time Based sport mode).
    non-public float beginTime;                // Time the sport began - used to maintain observe of time remaining.
    public float finishGameClingTime;           // 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 top (so they do not fall ceaselessly).

    [Header("Components")]
    public PhotonView photonView;           // PhotonView part.
    non-public Camera cam;                     // Main digicam, 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?

    // Events
    [HideInInspector] public UnityOccasion onMapLoaded;            // Called when the map has been loaded in.
    [HideInInspector] public UnityOccasion onPlayersReady;         // Called when all of the gamers are spawned in and able to go.
    [HideInInspector] public UnityOccasion onGameStart;            // Called when the sport begins and the gamers can begin preventing.
    [HideInInspector] public System.Action<int> onGameWin;      // Called when a participant has gained the sport.

    // Instance
    public static GameSupervisor inst;

    #area Subscribing to Events

    void OnEnable ()
    {
        // Subscribe to occasions.
        onMapLoaded.AddListener(OnMapLoaded);
        onPlayersReady.AddListener(OnPlayersReady);
    }

    void OnDisable ()
    {
        // Un-subscribe from occasions.
        onMapLoaded.Take awayListener(OnMapLoaded);
        onPlayersReady.Take awayListener(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 Start ()
    {
        if(!PhotonNetwork.inRoom)
        {
            Debug.LogError("Cannot instantly play this scene earlier than connecting to community! <b>Start sport in Menu scene.</b>");
            return;
        }

        // Initiate the sport mode.
        InitiateGameMode();

        // Load the map.
        MapLoader.inst.LoadMap(PhotonNetwork.room.CustomProperties["map"].ToString());

        // Get the digicam.
        cam = Camera.foremost;
    }

    void Update ()
    {
        // Are we presently enjoying the sport?
        if(gameState == GameState.Playing)
        {
            // Host checks win situation each body if it is a Time Based sport mode.
            if(PhotonNetwork.isMasterClient && sportMode == GameModeKind.TimeBased)
            {
                if(Time.time > beginTime + timeLimit)
                    VerifyWinSituation();
            }
        }
    }

    // Called 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);
    }

    // Called when all of the gamers are spawned and able to go.
    void OnPlayersReady ()
    {
        SetState(GameState.PreGame);
    }

    // Gets the gamemode from customized properties.
    void InitiateGameMode ()
    {
        int gm = (int)PhotonNetwork.room.CustomProperties["gamemode"];
        int gmProp = (int)PhotonNetwork.room.CustomProperties["gamemodeprop"];

        sportMode = (GameModeKind)gm;

        change(sportMode)
        {
            case GameModeKind.ScoreBased:
                successfulScore = gmProp;
                break;
            case GameModeKind.TimeBased:
                timeLimit = (float)gmProp;
                break;
        }
    }

    // Called by the host after the countdown to start the sport.
    [PunRPC]
    public void StartGame ()
    {
        SetState(GameState.Playing);
        beginTime = Time.time;
        onGameStart.Invoke();
    }

    // Checks if a participant / can win the sport. If so - finish the sport.
    public void VerifyWinSituation ()
    {
        // If we're not presently enjoying the sport, return.
        if(gameState != GameState.Playing) return;

        // Get the successful participant.
        Player successfulPlayer = GetWinningPlayer();
        bool hasWon = false;

        change(sportMode)
        {
            case GameModeKind.ScoreBased:
                hasWon = successfulPlayer.rating >= successfulScore;
                break;
            case GameModeKind.TimeBased:
                hasWon = Time.time > beginTime + timeLimit;
                break;
        }

        // If the circumstances are proper for a win - then that participant wins.
        if(hasWon)
            photonView.RPC("WinGame", PhotonTargets.All, successfulPlayer.communityPlayer.networkID);
    }

    // Called when a participant wins the sport.
    [PunRPC]
    public void WinGame (int successfulPlayer)
    {
        SetState(GameState.FinishGame);
        onGameWin.Invoke(successfulPlayer);

        // Go again to the menu in 'finishGameClingTime' seconds.
        Invoke("GoBackToMenu", finishGameClingTime);
    }

    // Called after a participant wins the sport, we return to the menu.
    void GoBackToMenu ()
    {
        NetworkManager.inst.HostBackToMenu();
    }
    public int participantLevel;
    public int sportLevel;

    public int participantHealth;
    public int participantDamage;

    public int playerHighScore;
    public int participantGolds;


   

    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 List<StatisticUpdate> {
        new StatisticUpdate { StatisticIdentify = "PlayerLevel", Value = participantLevel },
        new StatisticUpdate { StatisticIdentify = "GameLevel", Value = sportLevel },
        new StatisticUpdate { StatisticIdentify = "PlayerHealth", Value = participantHealth },
        new StatisticUpdate { StatisticIdentify = "PlayerDamage", Value = participantDamage },
        new StatisticUpdate { StatisticIdentify = "PlayerExcessiveScore", Value = playerHighScore },
        new StatisticUpdate { StatisticIdentify = "PlayerGolds", Value = participantGolds },
    }
        },
    consequence => { Debug.Log("User 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(GetPlayerStatisticsEnd result consequence)
    {
        Debug.Log("Received the next Statistics:");
        foreach (var eachStat in consequence.Statistics)
        {
            Debug.Log("Statistic (" + eachStat.StatisticIdentify + "): " + eachStat.Value);
            change (eachStat.StatisticIdentify)
            {
                case "PlayerLevel":
                    participantLevel = eachStat.Value;
                    
                    break;
                case "GameLevel":
                    sportLevel = eachStat.Value;
                    break;
                case "PlayerHealth":
                    participantHealth = eachStat.Value;
                    break;
                case "PlayerDamage":
                    participantDamage = eachStat.Value;
                    break;
                case "PlayerExcessiveScore":
                    playerHighScore = eachStat.Value;
                    break;
                case "PlayerGolds":
                    participantGolds = eachStat.Value;
                    break;
            }
        }
    }
    // Build the request object and entry the API
    public void StartCloudUpdatePlayerStats()
    {
        PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
        {
            FunctionName = "UpdatePlayerStats", // Arbitrary operate identify (should exist in your uploaded cloud.js file)
            FunctionParameter = new { Level = participantLevel, GameLevel = sportLevel, Health = participantHealth, Damage = participantDamage, excessiveScore = playerHighScore, Golds = participantGolds },
            GeneratePlayStreamEvent = true, // Optional - Shows this occasion in PlayStream
        }, OnCloudUpdateStats, OnErrorShared);
    }
    // OnCloudHelloWorld outlined within the subsequent code block

    non-public static void OnCloudUpdateStats(ExecuteCloudScriptResult consequence)
    {
        // CloudScript (Legacy) returns arbitrary outcomes, so you need to consider them one step and one parameter at a time

        JsonObject jsonResult = (JsonObject)consequence.FunctionResult;
        // object messageValue;
        // jsonResult.AttemptGetValue("messageValue", out messageValue); // word how "messageValue" instantly 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 presently forward in rating.
    public Player GetWinningPlayer()
    {
        Player successfulPlayer = PlayerSupervisor.inst.gamers[0].participant;

        // Loop by all gamers, apart from the primary one as they're successful by default.
        for(int x = 1; x < PlayerSupervisor.inst.gamers.Length; ++x)
        {
            Player curPlayer = PlayerSupervisor.inst.gamers[x].participant;

            if(curPlayer.rating > successfulPlayer.rating)
                successfulPlayer = curPlayer;
        }

        return (successfulPlayer, StartCloudUpdatePlayerStats());
    }

    // Sets the present sport state.
    public void SetState (GameState state)
    {
        gameState = state;
    }

    // If that is of sport mode Score Based, return the remaining time.
    public float TimeRemaining ()
    {
        return (beginTime + timeLimit) - Time.time;
    }
}

// The sport state retains observe of the present state of the sport. This can dictate what will get checked and what issues are allowed to occur.
public enum GameState
{
    Initiation,         // If we're presently ready for gamers, spawning the map, initiating the gamers.
    PreGame,            // Counting down earlier than the sport begins.
    Playing,            // When the sport is in progress.
    FinishGame             // When the sport has ended and a participant has gained.
}

// The sport mode dictates the win situation for the sport.
public enum GameModeKind
{
    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 firstly of the sport.
    RandomOnSpawn       // Random spell everytime the participant spawns.
}

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here