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

public class PlayerRun : MonoBehaviour
{
    public enum Player { One, Two, Three}
    [SerializeField] private Player player;
    Rigidbody2D PlayerRigidbody;
    int succRep = 0;
    Vector3 movement;
    private bool reqInput = false;
    void Awake()
    {
        PlayerRigidbody = GetComponent<Rigidbody2D>();
        Debug.Log(reqInput);
    }

    void FixedUpdate()
    {
        Debug.Log(Input.GetAxis("Horizontal"));
        Dash();
    }

    void Dash()
    {
        float v = 0;
        float d = 1;
        float p3 = 0;
        float p3s = 0;
        int DashDoneP1 = 50;
        int DashDoneP2 = 50;
        int DashDoneP3 = 50;


        switch (player)
        {
            case Player.One:
                v = Input.GetAxisRaw("Horizontal2");

                break;
            case Player.Two:
                v = Input.GetAxisRaw("RightJoystickX2");
                d = -1;

                break;
            case Player.Three:
                v = Input.GetAxisRaw("AB2");
                p3 = -0.1f;
                d = 0;
                p3s = 0.018f;

                break;
            default:
                break;
        }
        

        if ((v <= -0.8f && !reqInput) || (v >= 0.8f && reqInput))
        {
            reqInput = !reqInput;
            gameObject.transform.position += new Vector3(0.15f * d, p3, 0);
            gameObject.transform.localScale += new Vector3(p3s, p3s, 0);
        }
        else if ((v <= -0.8f && reqInput) || (v >= 0.8f && !reqInput))
        {
            //gameObject.transform.position += new Vector3(0.05f, 0, 0);
            succRep = 0;
        }
    }
    void OnTriggerEnter2D(Collider2D col)
    {
        enabled = false;
    }
}
