using Darkmatter.Core;
using UnityEngine;

namespace Darkmatter.Domain
{
    public class OtherPlatformRule : IPlatformRule
    {
        int danger = 2;
        public void Execute(IPlatform platform)
        {
            foreach (var piece in platform.platformPiece)
            {
                piece.gameObject.SetActive(true);
                piece.GetComponent<Renderer>().material = platform.safeMaterial;
                piece.tag = "Safe";
            }

            for (int i = 0; i < danger; i++)
            {
                GameObject deadPlatform = platform.platformPiece[Random.Range(0, platform.platformPiece.Count)];
                deadPlatform.GetComponent<Renderer>().material = platform.deathMaterial;
                deadPlatform.tag = "Death";
            }
            platform.platformPiece[Random.Range(0, platform.platformPiece.Count)].gameObject.SetActive(false);
        }
    }
}
