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

public class characterAssignment : MonoBehaviour {

    public Animator animator;

    public RuntimeAnimatorController[] anims;
    public int whichPlayer = 1;
    public int whichAnimator = 1;

    // Use this for initialization
    void Start()
    {
        whichAnimator = PlayerPrefs.GetInt("animator_P" + whichPlayer, whichAnimator);
        PlayerPrefs.SetInt("animator_P" + whichPlayer, whichAnimator);

        animator.runtimeAnimatorController = anims[whichAnimator];
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire1_P" + whichPlayer))
        {
            if(whichAnimator==anims.Length-1)
            {
                whichAnimator = 0;
            }
            else
            {
                whichAnimator += 1;
            }
           animator.runtimeAnimatorController = anims[whichAnimator];
           PlayerPrefs.SetInt("animator_P"+whichPlayer,whichAnimator);
        }
        if (Input.GetButtonDown("Fire2_P" + whichPlayer))
        {
            if (whichAnimator == 0)
            {
                whichAnimator = anims.Length - 1;
            }
            else
            {
                whichAnimator -= 1;
            }
            animator.runtimeAnimatorController = anims[whichAnimator];
            PlayerPrefs.SetInt("animator_P" + whichPlayer, whichAnimator);
        }

    }
}
