void OnDestroy() { this._player.Shutdown(); this._cameraSystem.Shutdown(); this._obstaclelSystem.Shutdown(); this._player = null; this._cameraSystem = null; this._obstaclelSystem = null; UGame.EventManager.StopListening(EventNames.PAUSE_GAME, PauseGame); UGame.EventManager.StopListening(EventNames.RESUME_GAME, ResumeGame); UGame.EventManager.StopListening(EventNames.PLAYER_PASS_OBSTACLE, PlayerPassObstacle); UGame.EventManager.StopListening(EventNames.GMAE_OVER, GameOver); }
// Your custom code here void Start() { _player = new Player(); _player.Init(); _obstaclelSystem = new ObstacleSystem(); _obstaclelSystem.Init(); _obstaclelSystem.PlayerTrans = _player.PlayerTrans; _cameraSystem = new CameraSystem(); _cameraSystem.Init(_player.PlayerTrans); UGame.EventManager.StartListening(EventNames.PLAYER_PASS_OBSTACLE, PlayerPassObstacle); UGame.EventManager.StartListening(EventNames.PAUSE_GAME, PauseGame); UGame.EventManager.StartListening(EventNames.RESUME_GAME, ResumeGame); UGame.EventManager.StartListening(EventNames.GMAE_OVER, GameOver); GameData.Instance.UserData.Score = 0; Score = GameData.Instance.UserData.Score; }