<commit_before>﻿using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
//using UnityEngine.SceneManagement;

public class MicrogameController : MonoBehaviour
{
	public static MicrogameController instance;


	public ControlScheme controlScheme;
	public int beatDuration;
	public string command;
	public bool defaultVictory, canEndEarly;
	public AudioClip musicClip;

	public bool debugMusic, debugCommand, debugTimer, debugTimerTick;
	[Range(1, ScenarioController.MAX_SPEED)]
	public int debugSpeed;
	public GameObject debugObjects;

	private bool victory, victoryDetermined;
	private Transform commandTransform;

	public enum ControlScheme
	{
		Touhou,
		Mouse
	}

	void Awake()
	{
		instance = this;

		if (ScenarioController.instance == null)
		{
			//Debug Mode Start (scene open by itself)
			ScenarioController.beatLength = 60f / 130f;
			Time.timeScale = ScenarioController.getSpeedMult(debugSpeed);

			debugObjects = Instantiate(debugObjects, Vector3.zero, Quaternion.identity) as GameObject;

			MicrogameTimer.instance = debugObjects.transform.FindChild("UI Camera").FindChild("Timer").GetComponent<MicrogameTimer>();
			MicrogameTimer.instance.beatsLeft = (float)beatDuration;
			if (!debugTimer)
				MicrogameTimer.instance.disableDisplay = true;
			if (debugTimerTick)
				MicrogameTimer.instance.invokeTick();

			victory = defaultVictory;
			victoryDetermined = false;

			if (debugMusic && musicClip != null)
			{
				AudioSource source = debugObjects.transform.FindChild("Music").GetComponent<AudioSource>();
				source.clip = musicClip;
				source.pitch = ScenarioController.getSpeedMult(debugSpeed);
				source.Play();
			}

			Transform UICam = debugObjects.transform.FindChild("UI Camera");
			commandTransform = UICam.FindChild("Command");
			UICam.gameObject.SetActive(true);
			if (debugCommand)
			{
				commandTransform.gameObject.SetActive(true);
				commandTransform.FindChild("Text").GetComponent<TextMesh>().text = command;
			}

			if (controlScheme == ControlScheme.Mouse)
				Cursor.visible = true;
		}
		else
		{
			//Normal Start
			ScenarioController.instance.scenarioCamera.tag = "Camera";
			Camera.main.GetComponent<AudioListener>().enabled = false;
			SceneManager.SetActiveScene(gameObject.scene);

			MicrogameTimer.instance.beatsLeft = ScenarioController.instance.getBeatsRemaining();
			MicrogameTimer.instance.gameObject.SetActive(true);<commit_msg>Add Debug Simulate Delay to MicrogameController<commit_after>﻿using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
//using UnityEngine.SceneManagement;

public class MicrogameController : MonoBehaviour
{
	public static MicrogameController instance;


	public ControlScheme controlScheme;
	public int beatDuration;
	public string command;
	public bool defaultVictory, canEndEarly;
	public AudioClip musicClip;

	public bool debugMusic, debugCommand, debugTimer, debugTimerTick, debugSimulateDelay;
	[Range(1, ScenarioController.MAX_SPEED)]
	public int debugSpeed;
	public GameObject debugObjects;

	private bool victory, victoryDetermined;
	private Transform commandTransform;

	public enum ControlScheme
	{
		Touhou,
		Mouse
	}

	void Awake()
	{
		instance = this;

		if (ScenarioController.instance == null)
		{
			//Debug Mode Start (scene open by itself)
			ScenarioController.beatLength = 60f / 130f;
			Time.timeScale = ScenarioController.getSpeedMult(debugSpeed);

			debugObjects = Instantiate(debugObjects, Vector3.zero, Quaternion.identity) as GameObject;

			MicrogameTimer.instance = debugObjects.transform.FindChild("UI Camera").FindChild("Timer").GetComponent<MicrogameTimer>();
			MicrogameTimer.instance.beatsLeft = (float)beatDuration + (debugSimulateDelay ? 1f : 0f);
			if (!debugTimer)
				MicrogameTimer.instance.disableDisplay = true;
			if (debugTimerTick)
				MicrogameTimer.instance.invokeTick();

			victory = defaultVictory;
			victoryDetermined = false;

			if (debugMusic && musicClip != null)
			{
				AudioSource source = debugObjects.transform.FindChild("Music").GetComponent<AudioSource>();
				source.clip = musicClip;
				source.pitch = ScenarioController.getSpeedMult(debugSpeed);
				if (!debugSimulateDelay)
					source.Play();
				else
					AudioHelper.playScheduled(source, ScenarioController.beatLength);
			}

			Transform UICam = debugObjects.transform.FindChild("UI Camera");
			commandTransform = UICam.FindChild("Command");
			UICam.gameObject.SetActive(true);
			if (debugCommand)
			{
				commandTransform.gameObject.SetActive(true);
				commandTransform.FindChild("Text").GetComponent<TextMesh>().text = command;
			}

			if (controlScheme == ControlScheme.Mouse)
				Cursor.visible = true;
		}
		else
		{
			//Normal Start
			ScenarioController.instance.scenarioCamera.tag = "Camera";
			Camera.main.GetComponent<AudioListener>().enabled = false;
			SceneManager.SetActiveScene(gameObject.scene);

			MicrogameTimer.instance.beatsLeft = ScenarioController.instance.getBeatsRemaining();
			MicrogameTimer.instance.gameObject.SetActive(true);
{'fraction_non_alphanumeric': 0.09791459781529295, 'fraction_numerical': 0.0031777557100297915, 'mean_word_length': 5.067469879518073, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1879823', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1416, 'n_words': 291}