using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Player))]
public class PlayerInput : MonoBehaviour
{

    Player player;

    void Start()
    {
        player = GetComponent<Player>();
    }

    void Update()
    {
        Vector2 directionalInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        player.SetDirectionalInput(directionalInput);

        if (Input.GetKeyDown(KeyCode.Space))
        {
            player.OnJumpInputDown();
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            player.OnJumpInputUp();
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            player.weapon.weaponType = 1;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            player.weapon.weaponType = 2;
        }
        if (Input.GetMouseButtonDown(0))
        {
            player.weapon.Fire(player.spriteRenderer.flipX ? Vector2.left : Vector2.right);
        }
    }
}
