using UnityEngine;

public class IsleSettings : MonoBehaviour {

    [HideInInspector] public bool hasApplied = false;

	public void ApplySettings() {
        transform.position = Vector3.zero;
        Transform[] children = GetComponentsInChildren<Transform>();
        for(int i = 1; i < children.Length; i++) {
            if (children[i].name[0] == '_') {
                children[i].tag = "Ground";
            }
            children[i].gameObject.AddComponent<MeshCollider>();
            if (children[i].name == "ColliderNage") {
                DestroyImmediate(children[i].gameObject.GetComponent<MeshRenderer>());
                MeshCollider meshColliderNage = children[i].GetComponent<MeshCollider>();
                meshColliderNage.convex = true;
                meshColliderNage.isTrigger = true;
                children[i].localPosition = -25.6f * Vector3.forward;
                children[i].tag = "Water";
            } else if (children[i].name.Contains("BoutonPupitre")) {
                children[i].gameObject.AddComponent<ButtonPupitre>();
            } else if (children[i].name.Contains("Bouton")) {
                children[i].gameObject.AddComponent<ButtonGrotte>();
            } else if (children[i].name.Contains("Interupt")) {
                children[i].gameObject.AddComponent<Interupt>();
            }
        }
        hasApplied = true;
    }
}
