コード例 #1
0
ファイル: Run_Desk.cs プロジェクト: dsesclei/DS501
    public void reset()
    {
        //TODO: get participant id somewhere
        //set_ParticipantID(1001);

        minigames = new List<MinigameHelper>();
        logger_results.participant_id = 1001;

        active_minigame = null;
        active_minigame_index = -1;

        id_string = "";
        is_starting_enter_id = false;
        is_entering_id = false;

        is_showing_instructions = false;
        is_showing_results = false;

        is_ended = false;

        should_scene_advance = false;

        success_text.SetActive(false);
        failure_text.SetActive(false);
        instructions_text.SetActive(false);

        InputTracking.Recenter();

        //start by entering ID
        is_starting_enter_id = true;
    }
コード例 #2
0
ファイル: Run_Desk.cs プロジェクト: dsesclei/DS501
    public virtual void Update()
    {
        if (Input.GetKeyDown( KeyCode.R ))
            InputTracking.Recenter();

        if (Input.GetKeyDown(KeyCode.Q))
        {
            Application.Quit();
        }

        if (Input.GetKeyDown(KeyCode.F5))
        {
            Debug.Log("F5: reset");
            reset();
        }

        if (is_ended) return;

        //TODO: reset button?
        if (is_entering_id || is_starting_enter_id)
        {
            if (is_starting_enter_id)
            {
                id_string = "";
                instructions_text.SetActive(true);
                is_starting_enter_id = false;
                is_entering_id = true;
            }
            if (is_entering_id)
            {
                string new_input = Input.inputString;
                foreach (char c in new_input)
                {
                    if (c == '\b' && id_string.Length > 0)
                    {
                        id_string = id_string.Remove(id_string.Length - 1, 1);
                    }
                    else if (c == '\n' || Input.GetKeyDown(KeyCode.Return))
                    {
                        set_ParticipantID(Int32.Parse(id_string));
                        is_entering_id = false;
                        instructions_text.SetActive(false);
                    }
                    else if (Char.IsNumber(c))
                        id_string += c;
                }
                instructions_text.GetComponent<TextMesh>().text = "Enter ID\n" + id_string;

            }

            return;
        }

        if (active_minigame == null || active_minigame.has_ended)
        // time to show results, process last game, and advance
        {
            //process last game, if exists
            if (active_minigame != null)
            {
                //show results
                if (!is_showing_results)
                {
                    // also do logging
                    logger_results.log( active_minigame_index,
                                        active_minigame.name,
                                        active_minigame.success.ToString(),
                                        active_minigame.elapsed.ToString()  );

                    // then actualy show results
                    if (active_minigame.success) success_text.SetActive(true);
                    else failure_text.SetActive(true);
                    is_showing_results = true;

                    //scene_timer.Interval = 1000;
                    scene_timer.Start();
                    // this sets should_scene_advance when it expires

                }
            }

            if ( is_showing_results && should_scene_advance
                 ||   active_minigame == null )
            {
                //advance from show results
                success_text.SetActive(false);
                failure_text.SetActive(false);

                should_scene_advance = false;
                is_showing_results = false;

                if (active_minigame_index + 1 >= minigames.Count)
                // end if we're out of games
                {
                    //do end
                    Debug.Log("  The End.");
                    is_ended = true;
                    instructions_text.GetComponent<TextMesh>().text = "The\nEnd";
                    instructions_text.SetActive(true);
                }
                else// if (!is_showing_instructions)
                // show instructions for next game
                {
                    // get next game
                    active_minigame_index++;
                    Debug.Log("Starting next minigame ... " + active_minigame_index + " of " + minigames.Count);

                    active_minigame = minigames[active_minigame_index];
                    logger_results.input_name = active_minigame.get_InputName();

                    active_minigame.prestart();

                    instructions_text.GetComponent<TextMesh>().text = active_minigame.instructions;
                    instructions_text.SetActive(true);

                    is_showing_instructions = true;
                }
            }

        }

        //Debug.Log("Instructions mode: " + is_showing_instructions + " : " + active_minigame.get_button_state_from_interface());

        if (is_showing_instructions)// && should_scene_advance)
        // start next game
        {
            if (active_minigame.get_button_state_from_interface())
            {
                Debug.Log("Instructions over: Game start!");

                instructions_text.SetActive(false);

                should_scene_advance = false;
                is_showing_instructions = false;

                active_minigame = minigames[active_minigame_index];

                active_minigame.go();

            }
        }
    }