Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        Transform noteHolder = GameObject.Find("Notes").transform;

        RhythmTracker rt = GameObject.FindGameObjectWithTag("MusicSource").GetComponent <RhythmTracker>();
        int           n  = rt.GetNoteCount();

        for (int i = 0; i < n; i++)
        {
            GameObject note;
            if (!rt.NoteIsEnemy(i))
            {
                note = Instantiate(notePrefab, transform.position, Quaternion.identity);
            }
            else
            {
                note = Instantiate(enemyNotePrefab, transform.position, Quaternion.identity);
            }

            note.transform.parent = noteHolder;
            note.SetActive(true);

            ScrollingNote sn = note.GetComponent <ScrollingNote>();
            if (sn != null)
            {
                sn.isEnemy = rt.NoteIsEnemy(i);
                sn.notePos = i;
            }
        }
    }
Exemple #2
0
    void Start()
    {
        rhythm      = GetComponent <RhythmTracker>();
        musicPlayer = GetComponent <AudioSource>();
        float loopStartTime = loopStartMeasure * timeSignature * 60f / rhythm.beatsPerMinute;

        loopEndTime = loopEndMeasure * timeSignature * 60f / rhythm.beatsPerMinute;
        loopDelta   = loopEndTime - loopStartTime;
    }
    void Awake()
    {
        // Singleton behavior
        if (instance != null)
        {
            Destroy(this);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(this);
        }

        // Set the main audio loop
        m_LoopAudioSource = new GameObject().AddComponent <AudioSource>();
        m_LoopAudioSource.gameObject.name  = "MainTracking";
        m_LoopAudioSource.transform.parent = transform;
        m_LoopAudioSource.loop             = true;
        m_LoopAudioSource.playOnAwake      = false;
        m_LoopAudioSource.volume           = 0;
        AudioClip silentClip = AudioClip.Create("100bpm-Silent", 423360, 1, 44100, false);

        m_LoopAudioSource.clip = silentClip;

        // If we're providing forewarnings on an offset, create a new child object with a
        // similarly set up audio source. This one will start right away, while the other will
        // start on after the offset time has passed.
        if (m_AdvancedNotificationOffset > 0)
        {
            m_OffsetAudioSource = new GameObject().AddComponent <AudioSource>();
            m_OffsetAudioSource.gameObject.name  = "OffsetTracking";
            m_OffsetAudioSource.transform.parent = transform;
            m_OffsetAudioSource.loop             = true;
            m_OffsetAudioSource.playOnAwake      = false;
            m_OffsetAudioSource.clip             = m_LoopAudioSource.clip;
            m_OffsetAudioSource.volume           = 0;
        }

        // Initialize list of target samples
        m_HitList = new List <int>();
        // Fill list with the the samples that represent target downbeats.
        for (int i = 0; i < m_SubDivisions; i++)
        {
            m_HitList.Add(m_LoopAudioSource.clip.samples / m_SubDivisions * i);
        }

        // Apply the tempo specified in the inspector.
        SetTempo(m_InitialTempo);

        // If PlayOnAwake is enabled, queue it up so Play() actually happens on the first frame. After everything's initialized and all subscriptions in
        // Start() and Awake() functions have been made. Otherwise, first beats will be intermittently skipped, depending on the order of initialization.
        if (m_PlayOnAwake)
        {
            StartCoroutine(PlayDelayedByFrame());
        }
    }
 public override void OnAwake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemple #5
0
    void Start()
    {
        vertical_speed = 0;
        current_speed = 1f;

        player_object = player.gameObject;

        start_moving = false;

        timer = FindObjectOfType(typeof(Timer)) as Timer;

        rhythm_tracker = FindObjectOfType(typeof(RhythmTracker)) as RhythmTracker;
    }
Exemple #6
0
 void Start()
 {
     home = transform.position;
     rt   = GameObject.FindGameObjectWithTag("MusicSource").GetComponent <RhythmTracker>();
     UpdatePos();
 }
Exemple #7
0
 void Start()
 {
     rhythmTracker = canvas.GetComponent <RhythmTracker>();
     footMotionData.AddFirst(0f);
     StartCoroutine(CheckSpeed());
 }
Exemple #8
0
 private void Start()
 {
     playerManager = FindObjectOfType <PlayerManager>();
     enemyStatsSO  = FindObjectOfType <Enemy>().enemyStatSO;
     rhythmTracker = GetComponent <RhythmTracker>();
 }
Exemple #9
0
 // Use this for initialization
 void Start()
 {
     rhythm_tracker = FindObjectOfType(typeof(RhythmTracker)) as RhythmTracker;
 }