using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Ice.Extensions;

public class FootstepPlayer : MonoBehaviour {

  public int surfaceFlag;

  public AudioSource source;

  public AudioClip[] clips;

  public AudioClip[] flag1Clips;

  [Header("FX")]
  public GameObject dustFx;
  public Transform dustFxPositionLeft;
  public Transform dustFxPositionRight;

  public void AnimEventFootstep(int foot) {
    var pool = surfaceFlag == 1 ? flag1Clips : clips;
    var clip = pool.RandomElement();
    source.PlayOneShot(clip);

    if (dustFx != null) {
      var pos = foot == 0 ? dustFxPositionLeft : dustFxPositionRight;
      GameObject.Instantiate(dustFx, pos.position, Quaternion.identity);
    }
  }
}
