using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class WelcomeScreen : MonoBehaviour
{
    private PlayerInputManager playerInputManager;

    // Start is called before the first frame update
    void Start()
    {
        playerInputManager = GetComponent<PlayerInputManager>();
        playerInputManager.onPlayerJoined += PlayerInputManager_onPlayerJoined;
        PlayersTracking.Instance.players.Clear();
    }

    private void OnLevelWasLoaded(int level)
    {
        PlayersTracking.Instance.players.Clear();
    }

    private void PlayerInputManager_onPlayerJoined(PlayerInput obj)
    {
        string pName = obj.GetComponent<SausageGamePlay>().Init(obj.playerIndex, 4);
        PlayersTracking.Instance.AddPlayer(obj.playerIndex, obj.devices[0], pName);
        obj.transform.localScale = Vector3.one * 0.6f;
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void SetVolume(float volume)
    {
        AudioListener.volume = volume;
    }

    public void QuitApp()
    {
        Application.Quit();
    }
}
