public void Initialize(ScenarioController controller, LayersChunkData data, int index)
    {
        _controller = controller;
        // get difficulty platforms amount
        _minimumDifficulty = data.LowerDifficulty;
        _maximumDifficulty = data.UpperDifficulty;

        int amount = Random.Range(4, 6);

        _halfHorizontalSpace = amount * 0.4f;
        _halfVerticalSpace   = amount * 0.1f;

        List <PlatformConfig> platforms = new List <PlatformConfig>();

        // if different, get a random amount between the two
        if (_minimumDifficulty <= _maximumDifficulty)
        {
            int diff = _maximumDifficulty - _minimumDifficulty;
            for (int i = 0; i <= diff; i++)
            {
                PlatformDifficulty difficulty = (_minimumDifficulty + i);
                platforms.AddRange(_controller.GetPlatformsByDifficulty(difficulty));
            }
        }

        // instantiate platforms between the position constrains
        _platformDistances = new Vector2(_halfHorizontalSpace, _halfVerticalSpace) * 2.0f / (amount - 1);
        int totalPlatformsAmount = platforms.Count;

        for (int i = 0; i < amount; i++)
        {
            var randomPlatform = platforms[Random.Range(0, totalPlatformsAmount)];
            var platform       = Instantiate(randomPlatform.Asset, transform);
            platform.transform.localPosition = GetPlatformPosition(amount);
            BasePlatformLogic logic = platform.GetComponent <BasePlatformLogic>();
            logic.Initialize(this);
            if (logic.IsTrap)
            {
                platforms.Remove(randomPlatform);
                totalPlatformsAmount--;
            }
        }

        _index          = index;
        gameObject.name = "Layer_" + index;
    }
 public List <PlatformConfig> GetPlatformsByDifficulty(PlatformDifficulty difficulty)
 {
     return(_catalogue.Platforms.FindAll(x => x.Difficulty == difficulty));
 }
 public int GetPlatformAmountByDifficulty(PlatformDifficulty difficulty)
 {
     return(_catalogue.LayerData.Find(x => x.Difficulty == difficulty).Amount);
 }