Beispiel #1
0
    private void OnTriggerEnter(Collider other)
    {
        Obstacle obstacle = other.GetComponent <Obstacle>();

        //не виконувати далі, якщо на об'єкті other немає скрипта Obstacle
        if (obstacle == null)
        {
            return;
        }

        //
        List <int> playerKeys         = PlayerData.Keys;
        List <int> obstacleKeysOrigin = obstacle.Keys;
        List <int> obstacleKeys       = PrepareForComparison(obstacleKeysOrigin);

        //спрацює якщо ключі збігаються
        if (SomeMath.ComparisonLists(playerKeys, obstacleKeys))
        {
            OnOvercameObstacle?.Invoke();
        }
        //спрацює якщо ключі не збігаються
        else
        {
            OnDidNotOvercameObstacle?.Invoke();
            OnDidNotOvercameObstacleWithList?.Invoke(SomeMath.CommonListItems(playerKeys, obstacleKeysOrigin));
        }
    }