MergeWith() public method

public MergeWith ( GameProgress, other ) : void
other GameProgress,
return void
Beispiel #1
0
    void ProcessCloudData(byte[] cloudData)
    {
        if (cloudData == null)
        {
            Debug.Log("No data saved to the cloud yet...");
            return;
        }
        Debug.Log("Decoding cloud data from bytes.");
        GameProgress progress = GameProgress.FromBytes(cloudData);

        Debug.Log("Merging with existing game progress.");
        mProgress.MergeWith(progress);
    }
Beispiel #2
0
    public byte[] OnStateConflict(int slot, byte[] local, byte[] server)
    {
        Debug.Log("Conflict callback called. Resolving conflict.");

        // decode byte arrays into game progress and merge them
        GameProgress localProgress = local == null ?
                                     new GameProgress() : GameProgress.FromBytes(local);
        GameProgress serverProgress = server == null ?
                                      new GameProgress() : GameProgress.FromBytes(server);

        localProgress.MergeWith(serverProgress);

        // resolve conflict
        return(localProgress.ToBytes());
    }