using UnityEngine;
using System.Collections;

// Ein Eintrag für jedes Sprite.
public enum SnakeTailPart {
  SnakeTail,
  SnakeTailShort,
  SnakeCurveLeft,
  SnakeCurveRight,
  SnakeTailEnd
}
public class SnakeTailSpriteSelector : MonoBehaviour {

  // Referenzen auf die jeweiligen Sprites
  public GameObject snakeTailSprite;
  public GameObject snakeTailShortSprite;
  public GameObject snakeCurveLeftSprite;
  public GameObject snakeCurveRightSprite;
  public GameObject snakeTailEndSprite;

  private SnakeTailPart activePart = SnakeTailPart.SnakeTail;

  // Zeigt nur das gewählte Sprite an
  public void ShowSnakeTailPart(SnakeTailPart part) {
    snakeTailSprite.SetActive(part == SnakeTailPart.SnakeTail);
    snakeTailShortSprite.SetActive(part == SnakeTailPart.SnakeTailShort);
    snakeCurveLeftSprite.SetActive(part == SnakeTailPart.SnakeCurveLeft);
    snakeCurveRightSprite.SetActive(part == SnakeTailPart.SnakeCurveRight);
    snakeTailEndSprite.SetActive(part == SnakeTailPart.SnakeTailEnd);
    activePart = part;
  }

  public bool IsCurve {
    get {
      return activePart == SnakeTailPart.SnakeCurveLeft
        || activePart == SnakeTailPart.SnakeCurveRight;
    }
  }

  public bool IsShort {
    get { return activePart == SnakeTailPart.SnakeTailShort; }
  }

  public void DisableOnDeath() {
    Animator snakeTailEndAnimator = snakeTailEndSprite.GetComponent<Animator>();
    snakeTailEndAnimator.SetTrigger("SnakeDied");
  }
}
