public void SkipToBeat(float beat, float distancePerBeat) { this.currentBeat = beat; this.lastBeat = beat; // Destroy bars on screen // for (int count = 0; count < bars.Count; count++) { bars[count].gameObject.SetActive(false); GameObject.Destroy(bars[count].gameObject); } bars = new List <BeatBar>(); // Create new bars to match current beat // float currentZ = spawnAtZ; int barCount = 0; while (currentZ > destroyAtZ) { BeatBar bar = GameObject.Instantiate(BeatMap.BarPrefab, null).GetComponent <BeatBar>(); Vector3 barPosition = new Vector3(0, 0, spawnAtZ); barPosition.z = currentZ; bar.SetBeatNumber((int)beat - barCount); bar.transform.position = barPosition; bars.Add(bar); currentZ -= distancePerBeat; barCount++; } }
void Start() { beatBar = GameObject.Find("BeatBar").GetComponent <BeatBar>(); sync = GameObject.Find("Sync").GetComponent <Sync>(); sheet = GameObject.Find("Sheet").GetComponent <Sheet>(); startPos = GameObject.Find("StartPos").GetComponent <Transform>(); notePosY = sync.scrollSpeed; noteStartPosY = sync.scrollSpeed * 3.0f; }
public override void Initialize() { base.Initialize(); RythmBanner rythmBanner = new RythmBanner(new Vector2(0, 0)); GameState.Instance.GetCurrentScene().AddEntity(rythmBanner); Bar = new BeatBar(new Vector2(GameState.Instance.GetCurrentScene().GetWindowWidth() / 2, GameState.Instance.GetVar <int>("BEAT_Y"))); GameState.Instance.GetCurrentScene().AddEntity(Bar); //Bar.LoadContent(); }
private void BeatBar_OnTimeMouseDown(object sender, TimeSpan e) { if ((Keyboard.Modifiers & ModifierKeys.Control) != 0) { RemoveClosestBeat(e); } else { Beats.Add(e); Beats.Sort(); } BeatBar.InvalidateVisual(); }
public void Update() { if (DEBUG) { Debug.LogWarning("Current beat - " + currentBeat); } // Increment or Decrement the current beat // if (!rewinding) { currentBeat += beatsPerSecond * Time.deltaTime; } else { currentBeat -= beatsPerSecond * Time.deltaTime; } // Next beat has started // if ((int)(currentBeat + BeatMap.beatsToReachPlayer) > lastBeatBarPlaced) { lastBeatBarPlaced = (int)(currentBeat + BeatMap.beatsToReachPlayer); // Create new bar // BeatBar newBar = GameObject.Instantiate(BeatMap.BarPrefab).GetComponent <BeatBar>(); if (!rewinding) { Vector3 spawnPosition = new Vector3(0, 0, spawnAtZ); newBar.transform.position = spawnPosition; newBar.SetBeatNumber((int)(currentBeat + BeatMap.beatsToReachPlayer)); if (DEBUG) { Debug.Log("Creating bar for beat # - " + newBar.GetBeatNumber()); } newBar.transform.SetParent(BarContainer.transform); bars.Add(newBar); // Destory old bars // List <BeatBar> barsToDestroy = new List <BeatBar>(); foreach (BeatBar bar in bars) { if (bar.transform.position.z < destroyAtZ) { barsToDestroy.Add(bar); } } for (int count = 0; count < barsToDestroy.Count; count++) { barsToDestroy[count].gameObject.SetActive(false); bars.Remove(barsToDestroy[count]); GameObject.Destroy(barsToDestroy[count].gameObject); } } else { Vector3 spawnPosition = new Vector3(0, 0, destroyAtZ); newBar.transform.position = spawnPosition; newBar.SetBeatNumber((int)currentBeat); bars.Add(newBar); // Destroy bars // List <BeatBar> barsToDestroy = new List <BeatBar>(); foreach (BeatBar bar in bars) { if (bar.transform.position.z > spawnAtZ) { barsToDestroy.Add(bar); } } for (int count = 0; count < barsToDestroy.Count; count++) { barsToDestroy[count].gameObject.SetActive(false); bars.Remove(barsToDestroy[count]); GameObject.Destroy(barsToDestroy[count].gameObject); } } } }