private void Update() { if (MapController.isPlaying) { var Sections = MapController.getSections(); if (Sections.Count > 0) { MapSection currentSection = MapUtil.getCurrentSection(); if (currentSection.beats.Count != 0) { if (Time.time > beatTimer) { MapBeatEntry CurrentBeatEntry = currentSection.beats[0]; // Debug.Log("note, BPM: " + (currentSection.bpm / 60)); Beat beat = BeatFactory.GetBeat(CurrentBeatEntry.type); PlayerDirection pDirection = BeatUtil.GetPlayerDirectionFromString(CurrentBeatEntry.direction); BeatPooled beatInstance = beat.GetNewInstance(pDirection); beatInstance.gameObject.SetActive(true); currentSection.beats.RemoveAt(0); // Check Burst if (currentSection.beats.Count > 1) { MapBeatEntry NextBeatEntry = currentSection.beats[1]; if (!NextBeatEntry.burst) { beatTimer = Time.time + (1 / (currentSection.bpm / 60)); } } } } else { SectionEnd(); } } else { SectionEnd(); } mapTimer += Time.deltaTime; } }
public void Init(Transform _target, string beatType, PlayerDirection _direction) { beat = BeatFactory.GetBeat(beatType); currentSection = MapUtil.getCurrentSection(); KeyToPress = BeatUtil.GetKeyCodeFromDirection(_direction); canBePresssed = false; target = _target; direction = _direction; lifeTime = 0f; transform.rotation = _target.rotation; SpriteRenderer spr = GetComponent <SpriteRenderer>(); spr.color = _target.GetComponent <SpriteRenderer>().color; }