using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; using UnityEngine.UI; // This is used for character creation only // public class ChooseCharLook : MonoBehaviour { // set these in inspector public Sprite[] headOptions; public Sprite[] faceOptions; public Sprite[] legOptions; public float red; public float green; public float blue; private int curHead; private int curFace; private int curLegs; private setAppearance playerLooks; // note: bodies do not go here, this is character customization void Start () { playerLooks = GameObject.Find ("CharacterDisplay").GetComponent<setAppearance>(); // Access setAppearance object from characterDisplay curFace = 0; curHead = 0; curLegs = 0; red = 128; green = 128; blue = 128; updateLooks (); } // Called every time something is changed public void updateLooks(){ playerLooks.setFace(faceOptions[curFace]); playerLooks.setHead(headOptions[curHead]); playerLooks.setLegs(legOptions[curLegs]); playerLooks.refresh(); playerLooks.creationDone (); } // Next face option, user must click next button public void nextFace(){ if (curFace >= faceOptions.Length-1) { curFace = 0; } else { curFace++; } if (curFace != 7) { curHead = 0; } updateLooks (); } // Next head option, user must click next button public void nextHead(){ if (curHead >= headOptions.Length-1) { curHead = 0; } else { curHead++; } if (curHead >= headOptions.Length - 5) { curFace = 7; } updateLooks (); } // Next legs option, user must click next button public void nextLegs(){ if (curLegs >= legOptions.Length - 1) { curLegs = 0; } else { curLegs++; } updateLooks (); } //sets random appearance (Head, Face, Legs) public void randomAppearance() { curHead = Random.Range(0, 2); curFace = Random.Range(0, 7); curLegs = Random.Range(0, 9); playerLooks.addColor(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f)); updateLooks(); } // Sets red in r,g,b color for player using slider public void setRed(float newValue){ red = (newValue); playerLooks.addColor (red, green, blue); } // Sets green in r,g,b color for player using slider public void setGreen(float newValue){ green = (newValue); playerLooks.addColor (red, green, blue); } // Sets blue in r,g,b color for player using slider public void setBlue(float newValue){ blue = (newValue); playerLooks.addColor (red, green, blue); } }