コード例 #1
0
    // Use this for initialization
    void Start()
    {
        chatDeControles = new ControladorDelChat(maximoDeLogsEnChat);
        chat.text       = "";

        // Load emulator
        IVideoOutput drawable   = new DefaultVideoOutput();
        IAudioOutput audio      = GetComponent <DefaultAudioOutput>();
        ISaveMemory  saveMemory = new DefaultSaveMemory();

        Emulator = new Emulator(drawable, audio, saveMemory);
        ScreenRenderer.material.mainTexture = ((DefaultVideoOutput)Emulator.Video).Texture;

        gameObject.GetComponent <AudioSource>().enabled = false;
        StartCoroutine(LoadRom(Filename));

        //twitch
        commands = new Dictionary <string, BotCommand>();
        commands.Add("!a", new BotCommand((a, b) => { //accion de comando
            Emulator.SetInput(EmulatorBase.Button.A, true);
            this.StartCoroutineAsync(EnElProximoFrameQuitarlo(EmulatorBase.Button.A));
            AgregandoComandoAlChat(b, "A");
        }));
        commands.Add("!b", new BotCommand((a, b) => { //aqui accion de comando
            Emulator.SetInput(EmulatorBase.Button.B, true);
            this.StartCoroutineAsync(EnElProximoFrameQuitarlo(EmulatorBase.Button.B));
            AgregandoComandoAlChat(b, "B");
        }));
        commands.Add("!down", new BotCommand((a, b) => { //aqui accion de comando
            Emulator.SetInput(EmulatorBase.Button.Down, true);
            this.StartCoroutineAsync(EnElProximoFrameQuitarlo(EmulatorBase.Button.Down));
            AgregandoComandoAlChat(b, "down");
        }));
        commands.Add("!left", new BotCommand((a, b) => { //aqui accion de comando
            Emulator.SetInput(EmulatorBase.Button.Left, true);
            this.StartCoroutineAsync(EnElProximoFrameQuitarlo(EmulatorBase.Button.Left));
            AgregandoComandoAlChat(b, "left");
        }));
        commands.Add("!right", new BotCommand((a, b) => { //aqui accion de comando
            Emulator.SetInput(EmulatorBase.Button.Right, true);
            this.StartCoroutineAsync(EnElProximoFrameQuitarlo(EmulatorBase.Button.Right));
            AgregandoComandoAlChat(b, "right");
        }));
        commands.Add("!select", new BotCommand((a, b) => { //aqui accion de comando
            Emulator.SetInput(EmulatorBase.Button.Select, true);
            this.StartCoroutineAsync(EnElProximoFrameQuitarlo(EmulatorBase.Button.Select));
            AgregandoComandoAlChat(b, "select");
        }));
        commands.Add("!start", new BotCommand((a, b) => { //aqui accion de comando
            Emulator.SetInput(EmulatorBase.Button.Start, true);
            this.StartCoroutineAsync(EnElProximoFrameQuitarlo(EmulatorBase.Button.Start));
            AgregandoComandoAlChat(b, "start");
        }));
        commands.Add("!up", new BotCommand((a, b) => { //aqui accion de comando
            Emulator.SetInput(EmulatorBase.Button.Up, true);
            this.StartCoroutineAsync(EnElProximoFrameQuitarlo(EmulatorBase.Button.Up));
            AgregandoComandoAlChat(b, "up");
        }));


        whenNewMessage       += (username, message) => Debug.Log($"{username}: {message}");
        whenNewSystemMessage += (message) => Debug.Log($"System: {message}");
        whenDisconnect       += () => Debug.Log("Desconexion");
        whenStart            += () => Debug.Log("Conexion");
        whenNewChater        += (username) => SendMessageToChat($"{username}, bienvenido al stream!");

        this.StartCoroutineAsync(StartConnection(maxRetry));
    }