void Awake() { var levelsFolder = GameObject.Find("Levels"); if (levelsFolder == null) { Debug.Log($"{nameof(BeatLayerSwitchObserver)}: Couldn't find Levels object"); Destroy(this); return; } var menuSystemObj = GameObject.Find("_MenuSystem"); if (menuSystemObj != null) { _menuSystem = menuSystemObj.GetComponent <MenuSystem>(); } else { Debug.Log($"{nameof(BeatLayerSwitchObserver)}: Couldn't find _MenuSystem object"); } _bossGate = levelsFolder.GetComponentInChildren <BossGate>(); var beatswitches = levelsFolder.GetComponentsInChildren <BeatLayerSwitch>(); var colorSpheres = beatswitches.Select(b => b.colorSphere); if (_menuSystem != null) { colorSpheres = colorSpheres.Where(c => c != _menuSystem.colorSphere); } _beatSwitchColorSpheres = colorSpheres.ToArray(); }
public static void TeleportToBeatLayerSwitch(BossGate bossGate) { var player = Globals.player.GetComponent <MyCharacterController>(); player.SetVelocity(Vector2.zero); player.PlacePlayerCharacter(bossGate.transform.position, true); bossGate.CheatUse(); }