Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
28 kB
3
Indexable
Never
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Gadgets.EverilionIntegration.Scripts.EverilionApi;
using NakaSDK;
using NakaSDK.Events;
using UnityEngine;

#region SubClasses

[Serializable]
public class RouletteQuestion : ExportComponent
{
    public static string getScriptPath() { return NakaSDK.Utils.getScriptPathReal(); }


    [NakaSDK.Label("$key_Question")]
    public string question;
    [NakaSDK.Label("$key_Answers"), NakaSDK.Description("$key_AnswersDescription")]
    public string[] answers;
    [NakaSDK.Label("$key_CorrectAnswer"), NakaSDK.Description("$key_CorrectAnswerDescription")]
    public int correct;
}


[Serializable]
public class RouletteVoiceLines
{
    //Cuando el jugador cae en una casilla al girar la ruleta
    [NakaSDK.Label("$key_rouletteNormalPieceScored255075"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] rouletteNormalPieceScored_25_50_75 = null;
    [NakaSDK.Label("$key_rouletteNormalPieceScored100200"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] rouletteNormalPieceScored_100_200 = null;
    [NakaSDK.Label("$key_roulettePieceScoredX2"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] roulettePieceScored_X2 = null;
    [NakaSDK.Label("$key_roulettePieceScoredX05"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] roulettePieceScored_X05 = null;
    [NakaSDK.Label("$key_roulettePieceScoredPassTurn"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] roulettePieceScored_PassTurn = null;
    [NakaSDK.Label("$key_roulettePieceScoredBankrupt"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] roulettePieceScored_Bankrupt = null;

    //Cuando el jugador gana los puntos
    [NakaSDK.Label("$key_rouletteCorrectAnswer255075"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] rouletteCorrectAnswer_25_50_75 = null;
    [NakaSDK.Label("$key_rouletteCorrectAnswer100200"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] rouletteCorrectAnswer_100_200 = null;
    [NakaSDK.Label("$key_rouletteCorrectAnswerX2"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] rouletteCorrectAnswer_X2 = null;
    [NakaSDK.Label("$key_rouletteCorrectAnswerX05"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] rouletteCorrectAnswer_X05 = null;

    //Cuando el jugador pierde los puntos
    [NakaSDK.Label("$key_rouletteIncorrectAnswer255075"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] rouletteIncorrectAnswer_25_50_75 = null;
    [NakaSDK.Label("$key_rouletteIncorrectAnswer100200"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] rouletteIncorrectAnswer_100_200 = null;
    [NakaSDK.Label("$key_rouletteIncorrectAnswerX2"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] rouletteIncorrectAnswer_X2 = null;
    [NakaSDK.Label("$key_rouletteIncorrectAnswerX05"), NakaSDK.Description("$key_PieceScoredDescription")]
    public string[] rouletteIncorrectAnswer_X05 = null;

    //Cuando Se cambia el turno
    [NakaSDK.Label("$key_rouletteChangeTurn"), NakaSDK.Description("$key_TurnDescription")]
    public string[] rouletteChangeTurn = null;

    //public RouletteVoiceLines() { }
}


[NakaSDK.GadgetDataClass(GadgetPackageName = "RouletteGame", Selectable = true, Label = "$key_RouletteData")]
[Serializable]
public class RouletteData : ExportComponent
{

    public static string getScriptPath() { return NakaSDK.Utils.getScriptPathReal(); }


    [NakaSDK.Label("$key_PlayerNumber")]
    public int playerNumber;
    [NakaSDK.Label("$key_RoundsNumber")]
    public int roundsNumber;
    [NakaSDK.Label("$key_QuestionsData")]
    public RouletteQuestion[] rouletteData;
    [NakaSDK.Label("$key_VoiceLines")]
    public RouletteVoiceLines voiceLines;
    //[NakaSDK.Label("$key_rouletteChangeTurn"), NakaSDK.Description("$key_TurnDescription")]
    //public TraductionVoiceLine[] rouletteChangeTurn = null;
}

[NakaSDK.GadgetDataClass(GadgetPackageName = "RouletteGame", Selectable = true, Label = "$key_RouletteData")]
[Serializable]
public class TraductionVoiceLine : ExportComponent
{

    public static string getScriptPath() { return NakaSDK.Utils.getScriptPathReal(); }

    public string rouletteChangeTurn = null;
}


[Serializable]
public class PlayerAnswer : ExportComponent
{
    public static string getScriptPath() { return NakaSDK.Utils.getScriptPathReal(); }

    public int score;
    public string question;
    public int selected;

    public PlayerAnswer() { }
    public PlayerAnswer(int _score, string _question, int _selected = -1) {score = _score; question = _question; selected = _selected; }
}

[Serializable]
public class PlayerJoinedData : ExportComponent
{
    public static string getScriptPath() { return NakaSDK.Utils.getScriptPathReal(); }

    public int networkId;
    public string nickname;
    public bool itsme;
    public int index;

    public PlayerJoinedData(MeetingUser _user, int _index) 
    { 
        networkId = _user.networkId;
        nickname = _user.nickname;
        itsme = _user.itsme;
        index = _index; 
    }
}

#endregion

public class GameLauncher : MonoBehaviour, ExportComponent
{
    public static string getScriptPath() { return NakaSDK.Utils.getScriptPathReal(); }


    private Gadget _gadget;
    private ServiceWrapper _service;
    private RouletteData parsedData;
    private LoggerNaka _loggerNaka;
    private PlayerTurns _turns;


    private List<RouletteQuestion> rouletteQuestionsDone = new List<RouletteQuestion>();
    private List<RouletteQuestion> rouletteQuestionsAvailable;

    [Header("Lecterns")]
    public LecternLogic[] _pointsPosition;

    [Header("UI")]
    public ScreenUI ScreenUI;

    [Header("Start Question Panel")]
    public GameObject startPanel;
    public GameObject playButton;
    public GameObject spectateButton;
    public Transform spawnPlayer;
    public GameObject startGameButton;
    public GameObject repeatButton;

    public static bool IsVRDeviceConnected = true;

    private int userCardID = -1;


    #region Gadget

    public async void setData(string Data)
    {
        _gadget = GetComponent<Gadget>();

        spectateButton.GetComponent<SimpleButton>().RegisterInteractable(_gadget);
        playButton.GetComponent<SimpleButton>().RegisterInteractable(_gadget);
        startGameButton.GetComponent<SimpleButton>().RegisterInteractable(_gadget);
        repeatButton.GetComponent<SimpleButton>().RegisterInteractable(_gadget);
         
        spectateButton.GetComponent<SimpleButton>().OnSelect.AddListener(() => { 
            startPanel.SetActive(false);
            InitializeGadget(Data, true);
        });
        playButton.GetComponent<SimpleButton>().OnSelect.AddListener(() => {
            InitializeGadget(Data); 
            startPanel.SetActive(false); 
        });

        GameSynchronizer.Instance.AddAction(TypeEvent.PlayerJoin, (data, id) => {

            PlayerJoinedData parsedData = JsonUtility.FromJson<PlayerJoinedData>(data);

            MeetingUser user = new MeetingUser();
            user.nickname = parsedData.nickname;
            user.networkId = parsedData.networkId;
            user.itsme = parsedData.itsme;
            _pointsPosition[parsedData.index].SetUser(user);
            _pointsPosition[parsedData.index].isEmpty = false;
            _pointsPosition[parsedData.index].index = parsedData.index;
        });

        _gadget.nakaInterface.AddEventReciever(GameSynchronizer.Instance.gameObject, GameSynchronizer.Instance);

        await Task.Delay(1000);

        Utils.Transform player = GetPlayerHead();
        Transform startingPanel = spectateButton.transform.parent;
        startingPanel.rotation = Quaternion.Euler(0, player.rotation.eulerAngles.y, 0);
        startingPanel.position = player.position + startingPanel.forward * 0.5f;

        InvokeRepeating(nameof(CheckDevice), 0, 0.1f);
    }

    private string FakeData()
    {
        return "{\"playerNumber\": 1, \"roundsNumber\": 2, \"rouletteData\":[{\"question\":\"¿Cuántos planetas hay en el sistema solar?\",\"answers\":[\"7\",\"8\",\"9\"],\"correct\":2},{\"question\":\"¿Quién descubrió América?\",\"answers\":[\"Cristobal Colón\",\"Amerigo Vespucci\"],\"correct\":0},{\"question\":\"¿Qué es un hexágono?\",\"answers\":[\"Un polígono de 4 lados\",\"Un polígono de 5 lados\",\"Un polígono de 6 lados\"],\"correct\":2},{\"question\":\"¿Qué fruta es considerada el rey de las frutas?\",\"answers\":[\"Manzana\",\"Pera\",\"Banana\",\"Durazno\"],\"correct\":3},{\"question\":\"¿Qué animal es el más rápido en tierra?\",\"answers\":[\"Leopardo\",\"Guepardo\"],\"correct\":1},{\"question\":\"¿Quién escribió la obra 'Romeo y Julieta'?\",\"answers\":[\"William Shakespeare\",\"Mark Twain\",\"Charlotte Bronte\",\"Jane Austen\"],\"correct\":0},{\"question\":\"¿Cuántas patas tiene una araña?\",\"answers\":[\"6\",\"8\"],\"correct\":1},{\"question\":\"¿Quién pintó la Mona Lisa?\",\"answers\":[\"Leonardo da Vinci\",\"Michelangelo\",\"Rafael\",\"Jan Vermeer\"],\"correct\":0},{\"question\":\"¿Cuál es la capital de España?\",\"answers\":[\"Barcelona\",\"Madrid\",\"Valencia\",\"Sevilla\"],\"correct\":1},{\"question\":\"¿Quién es el autor de la obra 'Cien años de soledad'?\",\"answers\":[\"Gabriel García Márquez\",\"Jorge Luis Borges\",\"Mario Vargas Llosa\",\"Carlos Fuentes\"],\"correct\":0},{\"question\":\"¿Qué es un pentágono?\",\"answers\":[\"Un polígono de 4 lados\",\"Un polígono de 5 lados\",\"Un polígono de 6 lados\"],\"correct\":1},{\"question\":\"¿Cuál es el animal más grande del mundo?\",\"answers\":[\"Elefante\",\"Rinoceronte\",\"Ballena Azul\",\"Anaconda\"],\"correct\":2},{\"question\":\"¿Qué es un octágono?\",\"answers\":[\"Un polígono de 4 lados\",\"Un polígono de 5 lados\"],\"correct\":3},{\"question\":\"¿En qué año fue fundada NTTDATA?\",\"answers\":[\"1988\",\"2000\",\"2010\",\"2015\"],\"correct\":0},{\"question\":\"¿Cuál es el lema de NTTDATA?\",\"answers\":[\"Transformamos los negocios a través de la tecnología\",\"Innovación, colaboración, valor\",\"Construyendo un futuro mejor juntos\",\"Acelerando la transformación digital\"],\"correct\":0},{\"question\":\"¿En qué país se encuentra la sede central de NTTDATA?\",\"answers\":[\"Japón\",\"Estados Unidos\",\"India\",\"Australia\"],\"correct\":0},{\"question\":\"¿Qué servicios ofrece NTTDATA?\",\"answers\":[\"Consultoría, soluciones de TI y outsourcing\",\"Servicios de telecomunicaciones\"],\"correct\":0},{\"question\":\"¿Cuántos empleados tiene NTTDATA a nivel mundial?\",\"answers\":[\"50,000\",\"100,000\",\"150,000\"],\"correct\":2},{\"question\":\"¿En qué industrias se especializa NTTDATA?\",\"answers\":[\"Finanzas, seguros, retail, fabricación, servicios públicos\",\"Medios de comunicación, entretenimiento, tecnología\",\"Automóviles, construcción, servicios públicos\",\"Salud, educación, servicios públicos\"],\"correct\":0},{\"question\":\"¿Cuál es la filosofía de NTTDATA en cuanto a sus empleados?\",\"answers\":[\"Empleados felices = clientes felices\",\"Empleados primero = clientes primero\",\"Clientes primero = empleados felices\",\"Empleados felices = empresa exitosa\"],\"correct\":0}]}";
    }

    public void OnEventGadget(object e)
    {
        NakaSDK.Events.NetworkSyncEvent networkEvent = (NakaSDK.Events.NetworkSyncEvent)e;
        switch (networkEvent.networkEventType)
        {
            case NakaSDK.Events.NetworkSyncEvent.NetworkEventType.OnUserJoin:
                Debug.Log("User enter: " + networkEvent.meetingUser.nickname);
                break;
            case NakaSDK.Events.NetworkSyncEvent.NetworkEventType.OnUserExit:
                Debug.Log("User exit: " + networkEvent.meetingUser.nickname);
                //_gadget.nakaInterface.postEvent(gameObject, (int)TypeEvent.PlayerLeave, networkEvent.meetingUser.networkId.ToString(), NakaNetworkSync.ReceiverGroupFlags.All);
                GetComponent<PlayerTurns>().OnPlayerLeave(networkEvent.meetingUser.networkId.ToString());
                break;
        }
    }

    #endregion

    #region Init

    private async void InitializeGadget(string Data, bool spectator = false)
    {
        if (string.IsNullOrEmpty(Data))
        {
            Data = FakeData();
        }

        // InitializeLogger();

        Debug.LogError("Data: " + Data);
        parsedData = _gadget.nakaInterface.NAKAJsonUtility.fromJSON<RouletteData>(Data);//LitJson.JsonMapper.ToObject<RouletteData>(Data);
        rouletteQuestionsAvailable = new List<RouletteQuestion>(parsedData.rouletteData);
        Debug.LogError("Data parsed");
        _service = GetComponent<ServiceWrapper>();
        Debug.LogError("[Roulette] everillion 1");
        userCardID = await GetUserCardData();
        Debug.LogError("[Roulette] everillion 2");

        if (!spectator)
        {
            int index = await PositionPlayer();
            InitializeTurns(index);
            InitButtonSelectables();

            if (index == parsedData.playerNumber - 1)//_pointsPosition.Length - 1)
                SendData(index);
        }
        else
        {
            InitializeTurns(-1, true);
        }


    }

    private void InitializeTurns(int index, bool spectator = false)
    {
        _turns = GetComponent<PlayerTurns>();

        if (!spectator)
            _turns.Initialize(_pointsPosition, index, parsedData.playerNumber, parsedData.roundsNumber);
        else
            _turns.InitializeAsPublic(_pointsPosition, parsedData.playerNumber, parsedData.roundsNumber);
    }

    private void InitButtonSelectables()
    {
        foreach (LecternLogic l in _pointsPosition)
        {
            l.lever.InitMechanism(_gadget);
            l.Button.RegisterInteractable(_gadget, ()=> { 
                l.wantToPlay = true; 
                GameSynchronizer.Instance.SendData(TypeEvent.PlayGame, "");
                l.Button.gameObject.SetActive(false);
            });

            foreach (GameObject b in l.Answers)
            {
                b.GetComponent<SimpleButton>().RegisterInteractable(_gadget);
            }
        }
    }

    private void InitializeLogger()
    {
        int userID = _gadget.nakaInterface.getMeetingUser().networkId;

        _loggerNaka = new LoggerNaka(userID);
    }


    #endregion

    #region User Management

    private bool CheckUsers(MeetingUser []meetingUsers)
    {
        if (meetingUsers == null)
        {
            Debug.Log("[GAME] Not User List");
            return false;
        }
        
        if (_pointsPosition == null)
        {
            Debug.Log($"[GAME] PointPosition NULL");
            return false;
        }

        if (meetingUsers.Length > _pointsPosition.Length)
        {
            Debug.Log($"[GAME] Hay mas gente que posiciones, por ahora no hacemos nada con esto");
            return false;
        }

        return true;
    }

    public MeetingUser[] GetMeetingUsers()
    {
        return _gadget.nakaInterface.getMeetingUsers();
    }

    public MeetingUser GetUser()
    {
        return _gadget.nakaInterface.getMeetingUser();
    }

    public MeetingUser GetUserByID(int networkid)
    {
        foreach (var user in _gadget.nakaInterface.getMeetingUsers())
        {
            if (user.networkId == networkid)
                return user;
        }

        Debug.LogError("Could not find any user with this nework id : " + networkid);
        return new MeetingUser();
    }

    #endregion

    #region Teleport User

    private async Task<int> PositionPlayer()
    {
        int index = -1;
        LecternLogic lectern = GetEmptyLectern(out index);

        if(lectern != null)
        {
            Vector3 position = lectern.Position.position;
            Quaternion rotation = lectern.Position.rotation;

            Debug.Log($"Teleport: index{index}, position {position} rotation: {rotation}");

            await TeleportSite(position, rotation);

            lectern.index = index;
            lectern.lever.IsLocal = true;

            Debug.Log($"[INDEX] Index: {index} Length: {_pointsPosition.Length - 1}");
        }

        return index;
    }

    private LecternLogic GetEmptyLectern(out int index)
    {
        index = -1;
        for (int i = 0; i < _pointsPosition.Length; i++)
        {
            LecternLogic lec = _pointsPosition[i];
            if (lec.isEmpty)
            {
                index = i;

                var data = new PlayerJoinedData(_gadget.nakaInterface.getMeetingUser(), index);
                GameSynchronizer.Instance.SendData(TypeEvent.PlayerJoin, data);

                return lec;
            }
        }

        return null;
    }

    private async Task TeleportSite(Vector3 position, Quaternion rotation)
    {
        await Task.Delay(250);
        _gadget.nakaInterface.teleport(position, rotation);
    }
    #endregion


    #region Events
    public async void SendData(int userNumber)
    {

        //ScreenUI.PostPanelMessage("Todos los usuarios conectados, Empieza el juego");
        EventData data = new EventData() { numUsers = userNumber};
        
        Debug.Log($"Create Event Data: {data}");
        GameSynchronizer.Instance.SendData(TypeEvent.StartGame, data);
        Debug.Log($"Send Data");
    }
    
    public void OnReciveHelloEvent(string data ,int fromUserID )
    {
        Debug.Log($"Recuve code {fromUserID} data {data}");
        EventData helloData = JsonUtility.FromJson<EventData>(data);
    }
    #endregion


    #region Utils
    public RouletteQuestion GenerateRandomQuestion()
    {
        return rouletteQuestionsAvailable[UnityEngine.Random.Range(0, rouletteQuestionsAvailable.Count)];
    }

    public void RemoveQuestionFromAvailable(RouletteQuestion question)
    {
        rouletteQuestionsAvailable.Remove(question);
        rouletteQuestionsDone.Add(question);
    }

    public Utils.Transform GetPlayerHead()
    {
        return _gadget.nakaInterface.getHeadTransform();
    }

    private void CheckDevice()
    {
        if (UnityEngine.Input.GetMouseButton(0))
        {
            IsVRDeviceConnected = false;
            CancelInvoke(nameof(CheckDevice));
        }
    }

    //public string GetNextTurnVoiceLine()
    //{

    //    if (parsedData.voiceLines.rouletteChangeTurn != null && parsedData.voiceLines.rouletteChangeTurn.Length > 0)
    //        return parsedData.voiceLines.rouletteChangeTurn[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteChangeTurn.Length - 1)];
    //    else
    //        return "&, es tu turno";
    //}

    //public string GetBoxScoredVoiceLine(RouletteScore.RoulettePieceType type, int value = 0)
    //{
    //    string ret = null;

    //    switch (type)
    //    {
    //        case RouletteScore.RoulettePieceType.NORMAL:

    //            if(value >= 100)
    //            {
    //                if (parsedData.voiceLines.rouletteNormalPieceScored_100_200 != null && parsedData.voiceLines.rouletteNormalPieceScored_100_200.Length > 0)
    //                    ret = parsedData.voiceLines.rouletteNormalPieceScored_100_200[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteNormalPieceScored_100_200.Length - 1)];
    //                else
    //                    ret = "&, juegas por % puntos";
    //            }
    //            else
    //            {
    //                if (parsedData.voiceLines.rouletteNormalPieceScored_25_50_75 != null && parsedData.voiceLines.rouletteNormalPieceScored_25_50_75.Length > 0)
    //                    ret = parsedData.voiceLines.rouletteNormalPieceScored_25_50_75[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteNormalPieceScored_25_50_75.Length - 1)];
    //                else
    //                    ret = "&, juegas por % puntos";
    //            }

    //            break;
    //        case RouletteScore.RoulettePieceType.MULTIPLY:

    //            if (parsedData.voiceLines.roulettePieceScored_X2 != null && parsedData.voiceLines.roulettePieceScored_X2.Length > 0)
    //                ret = parsedData.voiceLines.roulettePieceScored_X2[UnityEngine.Random.Range(0, parsedData.voiceLines.roulettePieceScored_X2.Length - 1)];
    //            else
    //                ret = "&, juegas por el doble de puntos";

    //            break;
    //        case RouletteScore.RoulettePieceType.DIVIDE:

    //            if (parsedData.voiceLines.roulettePieceScored_X05 != null && parsedData.voiceLines.roulettePieceScored_X05.Length > 0)
    //                ret = parsedData.voiceLines.roulettePieceScored_X05[UnityEngine.Random.Range(0, parsedData.voiceLines.roulettePieceScored_X05.Length - 1)];
    //            else
    //                ret = "&, juegas por perder la mitad de tus puntos";

    //            break;
    //        case RouletteScore.RoulettePieceType.PASS_TURN:

    //            if (parsedData.voiceLines.roulettePieceScored_PassTurn != null && parsedData.voiceLines.roulettePieceScored_PassTurn.Length > 0)
    //                ret = parsedData.voiceLines.roulettePieceScored_PassTurn[UnityEngine.Random.Range(0, parsedData.voiceLines.roulettePieceScored_PassTurn.Length - 1)];
    //            else
    //                ret = "&, pierdes el turno";

    //            break;
    //        case RouletteScore.RoulettePieceType.BANKRUPT:

    //            if (parsedData.voiceLines.roulettePieceScored_Bankrupt != null && parsedData.voiceLines.roulettePieceScored_Bankrupt.Length > 0)
    //                ret = parsedData.voiceLines.roulettePieceScored_Bankrupt[UnityEngine.Random.Range(0, parsedData.voiceLines.roulettePieceScored_Bankrupt.Length - 1)];
    //            else
    //                ret = "&, pierdes el turno y todos tus puntos";

    //            break;
    //    }

    //    return ret;
    //}

    //public string GetCorrectAnswerVoiceLine(RouletteScore.RoulettePieceType type, int value = 0)
    //{
    //    string ret = null;

    //    switch (type)
    //    {
    //        case RouletteScore.RoulettePieceType.NORMAL:

    //            if (value >= 100)
    //            {
    //                if (parsedData.voiceLines.rouletteCorrectAnswer_100_200 != null && parsedData.voiceLines.rouletteCorrectAnswer_100_200.Length > 0)
    //                    ret = parsedData.voiceLines.rouletteCorrectAnswer_100_200[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteCorrectAnswer_100_200.Length - 1)];
    //                else
    //                    ret = "&, sumas % puntos";
    //            }
    //            else
    //            {
    //                if (parsedData.voiceLines.rouletteCorrectAnswer_25_50_75 != null && parsedData.voiceLines.rouletteCorrectAnswer_25_50_75.Length > 0)
    //                    ret = parsedData.voiceLines.rouletteCorrectAnswer_25_50_75[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteCorrectAnswer_25_50_75.Length - 1)];
    //                else
    //                    ret = "&, sumas % puntos";
    //            }

    //            break;
    //        case RouletteScore.RoulettePieceType.MULTIPLY:

    //            if (parsedData.voiceLines.rouletteCorrectAnswer_X2 != null && parsedData.voiceLines.rouletteCorrectAnswer_X2.Length > 0)
    //                ret = parsedData.voiceLines.rouletteCorrectAnswer_X2[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteCorrectAnswer_X2.Length - 1)];
    //            else
    //                ret = "&, sumas % puntos";

    //            break;
    //        case RouletteScore.RoulettePieceType.DIVIDE:

    //            if (parsedData.voiceLines.rouletteCorrectAnswer_X05 != null && parsedData.voiceLines.rouletteCorrectAnswer_X05.Length > 0)
    //                ret = parsedData.voiceLines.rouletteCorrectAnswer_X05[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteCorrectAnswer_X05.Length - 1)];
    //            else
    //                ret = "&, no pierdes puntos";

    //            break;
    //    }

    //    return ret;
    //}

    //public string GetIncorrectAnswerVoiceLine(RouletteScore.RoulettePieceType type, int value = 0)
    //{
    //    string ret = null;

    //    switch (type)
    //    {
    //        case RouletteScore.RoulettePieceType.NORMAL:

    //            if (value >= 100)
    //            {
    //                if (parsedData.voiceLines.rouletteIncorrectAnswer_100_200 != null && parsedData.voiceLines.rouletteIncorrectAnswer_100_200.Length > 0)
    //                    ret = parsedData.voiceLines.rouletteIncorrectAnswer_100_200[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteIncorrectAnswer_100_200.Length - 1)];
    //                else
    //                    ret = "&, no sumas ningun punto";
    //            }
    //            else
    //            {
    //                if (parsedData.voiceLines.rouletteIncorrectAnswer_25_50_75 != null && parsedData.voiceLines.rouletteIncorrectAnswer_25_50_75.Length > 0)
    //                    ret = parsedData.voiceLines.rouletteIncorrectAnswer_25_50_75[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteIncorrectAnswer_25_50_75.Length - 1)];
    //                else
    //                    ret = "&, no sumas ningun punto";
    //            }

    //            break;
    //        case RouletteScore.RoulettePieceType.MULTIPLY:

    //            if (parsedData.voiceLines.rouletteIncorrectAnswer_X2 != null && parsedData.voiceLines.rouletteIncorrectAnswer_X2.Length > 0)
    //                ret = parsedData.voiceLines.rouletteIncorrectAnswer_X2[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteIncorrectAnswer_X2.Length - 1)];
    //            else
    //                ret = "&, no sumas ningun punto";

    //            break;
    //        case RouletteScore.RoulettePieceType.DIVIDE:

    //            if (parsedData.voiceLines.rouletteIncorrectAnswer_X05 != null && parsedData.voiceLines.rouletteIncorrectAnswer_X05.Length > 0)
    //                ret = parsedData.voiceLines.rouletteIncorrectAnswer_X05[UnityEngine.Random.Range(0, parsedData.voiceLines.rouletteIncorrectAnswer_X05.Length - 1)];
    //            else
    //                ret = "&, pierdes % puntos";

    //            break;
    //    }

    //    return ret;
    //}

    public string GetFinalVoiceLine(string username, string value, string voiceLine, string key = "[points]")
    {
        string ret = voiceLine.Replace("[username]", username);
        ret = ret.Replace(key, value);
        return ret;
    }

    #endregion

    #region Unity
    private void OnDestroy() => _loggerNaka.Destroy();

    #endregion

    #region Reflection
    bool testPause = false;
    [ContextMenu(nameof(TestPause))]
    public void TestPause()
    {
        testPause = !testPause;
        PauseGameRequest(testPause);
    }

    public void PauseGameRequest(bool pause)
    {
        _turns.PauseGameRequest(pause);
    }
    #endregion

    #region Everillion

    private async Task<int> GetUserCardData()
    {
        return await _service.GetUserCardIDBySN(_gadget.nakaInterface.getMeetingUser().nickname, _gadget.nakaInterface.getMeetingUser().nickname);
    }

    public void SaveUserPoints(int points)
    {

        Debug.LogError("[Everillion] pasa 0" + points);

        if (points > 0)
        {
            _service.PostUserPoints(userCardID, points);
        }
    }

    #endregion

}

[Serializable]
public class EventData : ExportComponent 
{
    public static string getScriptPath() { return NakaSDK.Utils.getScriptPathReal(); }
    
    public int numUsers;
}