using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Shell
{
    private SpriteRenderer renderer;
    private Collider2D[] collider2D;
    private Transform transform;

    public Shell(string type)
    {
        transform = GameObject.Find(type + "Shell").transform;
        collider2D = transform.GetComponents<Collider2D>();
        renderer = transform.GetComponent<SpriteRenderer>();
    }

    public void ShellEnabled(bool param)
    {
        renderer.enabled = param;
        foreach (var collider in collider2D)
        {
            collider.enabled = param;
        }

    }

    public void SetPosition( Vector3 position, int direction )
    {
        transform.position = position;
        transform.localScale = new Vector3(direction, transform.localScale.y, transform.localScale.z);
    }

    public void PlaySound()
    {
        transform.GetComponent<AudioSource>().Play();
    }

}
