private void Start() { var interObj = new ListExecuteObject(); //foreach (var item in interObj) //{ // print(item); //} //var goodBonusComparer = new GoodBonusComparer(); ////var objects = FindObjectsOfType<GoodBonus>().ToList(); ////objects.Sort(goodBonusComparer); ////foreach (var item in objects) ////{ //// print($"{item.name} - {item.point} points"); ////} ////var bonus = GameObject.Find("Point 4").GetComponent<GoodBonus>(); //var objects = FindObjectsOfType<GoodBonus>().Distinct(new GoodBonusesEqualityComparer()); //foreach (var item in objects) //{ // print($"{item.name}"); //} for (int i = 0; i < interObj.Count; i++) { print($"{interObj[i]}"); } }
private void Awake() { _interactiveObject = new ListExecuteObject(); var _refernce = new Reference(); PlayerBase player = null; if (PlayerType == PlayerType.Ball) { player = _refernce.PlayerBall; } _cameraController = new CameraController(player.transform, _refernce.MainCamera.transform); _interactiveObject.AddExecuteObject(_cameraController); if (Application.platform == RuntimePlatform.WindowsEditor) { _inputController = new InputController(player); _interactiveObject.AddExecuteObject(_inputController); } _displayEndGame = new DisplayEndGame(_refernce.EndGame, _refernce.RestartButton); _displayBonuses = new DisplayBonuses(_refernce.Bonuse); _displayVictory = new DisplayVictory(_refernce.Victory, _refernce.RestartButton); foreach (var obj in _interactiveObject) { if (obj is BadBonus badBonus) { badBonus.OnCaughtPlayerChange += CaughtPlayer; badBonus.OnCaughtPlayerChange += _displayEndGame.GameOver; } if (obj is GoodBonus goodBonus) { goodBonus.OnPointChange += AddBonus; } if (obj is TrapBonus trapBonus) { trapBonus.OnPoint += AddForce; } if (obj is VictoryPosition victoryPosition) { CaughtPlayer(); _displayVictory.GameOver(); } } _refernce.RestartButton.onClick.AddListener(RestartGame); _refernce.RestartButton.gameObject.SetActive(false); }