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

public class CharacterColor : MonoBehaviour
{
    public Sprite regularHead, turnedHead;

	public SpriteRenderer[] arms, sleeves;
	public SpriteRenderer shirt, pants, hair, head;

	public void SetColors(Color skinColor, Color sleevesColor, Color shirtColor, Color pantsColor, Color hairColor)
	{
		for (int i = 0; i < arms.Length; i++)
			arms[i].color = skinColor;

		for (int i = 0; i < sleeves.Length; i++)
			sleeves[i].color = sleevesColor;

        head.color = skinColor;
		shirt.color = shirtColor;
		pants.color = pantsColor;
		hair.color = hairColor;
	}

    public void TurnHead(bool turn)
    {
        head.sprite = (turn) ? turnedHead : regularHead;
    }

    public void FlipCharacter(bool left)
    {
        for (int i = 0; i < arms.Length; i++)
            arms[i].flipX = !left;

        for (int i = 0; i < sleeves.Length; i++)
            sleeves[i].flipX = !left;

        head.flipX = !left;
        shirt.flipX = !left;
        pants.flipX = !left;
        hair.flipX = !left;
    }

    public void SetSortingOrder(int multiplier)
    {
		for (int i = 0; i < arms.Length; i++)
			arms[i].sortingOrder += 5 * multiplier;

		for (int i = 0; i < sleeves.Length; i++)
			sleeves[i].sortingOrder += 5 * multiplier;

        head.sortingOrder += 5 * multiplier;
		shirt.sortingOrder += 5 * multiplier;
		pants.sortingOrder += 5 * multiplier;
		hair.sortingOrder += 5 * multiplier;
    }
}
