﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PersistentData : MonoBehaviour {

	public static PersistentData instance;

    public static string player1LevelId;
    public static string player2LevelId;
	public static string matchId;
    public static string matchShortcode;
    public static string levelData;
    public static PlayerData localPlayerData;
    public static string remotePlayerPlayFabId;
    public static string remotePlayerPlayFabId2; // used only in spectating mode
    public static int photonID;
	public static int playerNumber;

    void Awake ()
	{
		if (instance != null) {
			Destroy(gameObject);
			return;
		}

		instance = this;
		DontDestroyOnLoad(gameObject);
	}

    public void DestroyPersistentData() {
        player1LevelId = null;
        player2LevelId = null;
		matchId = null;
        matchShortcode = null;
        remotePlayerPlayFabId = null;
        remotePlayerPlayFabId2 = null;
        photonID = 0;
		playerNumber = 0;
        // Don't reset localPlayerData because it is set on login and 
        // used across matches

        //        Destroy(instance);
        //        Destroy(instance.gameObject);
    }
}

public struct PlayerData {
    public string playFabId;
    public string username;
}