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

public class character_builder : MonoBehaviour {
    public Sprite[] maleTorsoes;
    public Sprite[] maleFaces;
    public Sprite[] maleSkulls;

    public Sprite[] femaleTorsoes;
    public Sprite[] femaleFaces;
    public Sprite[] femaleSkulls;

    public SpriteRenderer torso;
    public SpriteRenderer skull;
    public SpriteRenderer face;
    public SpriteRenderer bench;


	// Use this for initialization
	void Awake () {
        
        if (Random.Range(0, 100) <= 50)
        {
            NoCharacter();
        }
        else
        {
            RandomCharacter();
        }
        bench.sortingOrder -= (int)(transform.position.z * 10);

    }

    void NoCharacter()
    {
        torso.enabled = false;
        skull.enabled = false;
        face.enabled = false;
    }

    void RandomCharacter()
    {
        bool male = Random.Range(0, 2) == 0;

        Sprite[] torsoes = null;
        Sprite[] faces = null;
        Sprite[] skulls = null;
        if (male)
        {
            torsoes = maleTorsoes;
            faces = maleFaces;
            skulls = maleSkulls;
        }
        else
        {
            torsoes = femaleTorsoes;
            faces = femaleFaces;
            skulls = femaleSkulls;
        }

        torso.sprite = torsoes[Random.Range(0, torsoes.Length)];
        skull.sprite = skulls[Random.Range(0, skulls.Length)];
        face.sprite = faces[Random.Range(0, faces.Length)];

        torso.sortingOrder -= (int)(transform.position.z*10);
        skull.sortingOrder -= (int)(transform.position.z*10);
        face.sortingOrder -= (int)(transform.position.z*10);
        
    }
	
	// Update is called once per frame
	void Update () {
		
	}
}
