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

public class ShellActions : MonoBehaviour
{
    private MovementManager movementManager;
    private Shell onShell;
    private Shell offShell;
    // Start is called before the first frame update
    void Start()
    {
        movementManager = GetComponent<MovementManager>();
        onShell = new Shell("On");
        offShell = new Shell("Off");
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        onShell.ShellEnabled(movementManager.hasShell);
        offShell.ShellEnabled(!movementManager.hasShell);
    }

    public void Place()
    {
        float offSetX = movementManager.directionRight ? 60 : -60;
        Vector3 playerPosition = new Vector3(movementManager.transform.position.x + offSetX , movementManager.transform.position.y - 30, movementManager.transform.position.z - 1);
        offShell.SetPosition(playerPosition, movementManager.directionRight ? 1 : -1);
        onShell.ShellEnabled(false);
        offShell.ShellEnabled(true);
        offShell.PlaySound();
    }

    public void Hide()
    {
        Vector3 playerPosition = new Vector3(movementManager.transform.position.x, movementManager.transform.position.y - 30, movementManager.transform.position.z - 1);
        offShell.SetPosition(playerPosition, movementManager.directionRight ? 1 : -1);
        onShell.ShellEnabled(false);
        offShell.ShellEnabled(true);
    }

    public void RemoveHide()
    {
        onShell.ShellEnabled(true);
        offShell.ShellEnabled(false);
    }

    public void Take()
    {
        onShell.ShellEnabled(true);
        offShell.ShellEnabled(false);
    }
    


}
