void Start() { SoundManager.instance.PlayMusic(); foreach (Unit u in units) { RhythmEngine.GetTagged().AddMarching(u); } }
void Start() { RhythmEngine rm = RhythmEngine.GetTagged(); foreach (Unit unit in units) { rm.AddMarching(unit); } if (boss != null) { rm.SetBoss(boss); } }
void Update() { for (int i = units.Count - 1; i >= 0; --i) { Unit u = units[i]; if (u.transform.localPosition.x < 1.0f) { RhythmEngine.GetTagged().RemoveMarching(u); u.Kill(despawnDelta); units.RemoveAt(i); } } if (units.Count == 0) { SceneManager.LoadScene("Lose"); } }
void Update() { if (Time.time >= Constants.Level1Duration) { if (isBossAdded) { return; } if (boss != null) { boss.EnterLevel(); RhythmEngine.GetTagged().SetBoss(boss); isBossAdded = true; print("Added boss, great success!"); } else { print("Boss not attached to this GameObject, ignoring"); } return; } if (ProgressUpdated != null) { float passed = SoundManager.instance.GetCurrentTime(); float progress = passed / Constants.Level1Duration * 100; ProgressUpdated(progress, EventArgs.Empty); } // Movement Vector3 movement = new Vector3(speed.x * direction.x, speed.y * direction.y, 0); movement *= Time.deltaTime; transform.Translate(movement); // Move the camera if (isLinkedToCamera) { Camera.main.transform.Translate(movement); } // 4 - Loop if (isLooping) { // Get the first object. // The list is ordered from left (x position) to right. SpriteRenderer firstChild = backgroundPart.FirstOrDefault(); if (firstChild != null) { // Check if the child is already (partly) before the camera. // We test the position first because the IsVisibleFrom // method is a bit heavier to execute. if (firstChild.transform.position.x < Camera.main.transform.position.x) { // If the child is already on the left of the camera, // we test if it's completely outside and needs to be // recycled. if (firstChild.IsVisibleFrom(Camera.main) == false) { // Get the last child position. SpriteRenderer lastChild = backgroundPart.LastOrDefault(); Vector3 lastPosition = lastChild.transform.position; Vector3 lastSize = (lastChild.bounds.max - lastChild.bounds.min); // Set the position of the recyled one to be AFTER // the last child. // Note: Only work for horizontal scrolling currently. firstChild.transform.position = new Vector3(lastPosition.x + lastSize.x, firstChild.transform.position.y, firstChild.transform.position.z); // Set the recycled child to the last position // of the backgroundPart list. backgroundPart.Remove(firstChild); backgroundPart.Add(firstChild); } } } } }