Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class Customization : MonoBehaviour {
- Sprite[] spriteSheet;
- int currentHairID, currentColorID;
- Image representation;
- Text agilityPointsText, strengthPointsText, intelligencePointsText, statPointsText;
- public int statPointsLeft;
- int agilityPoints, strengthPoints, intelligencePoints;
- // Use this for initialization
- void Start () {
- //Finding Points Texts
- agilityPointsText = GameObject.Find("AgilityPointsText").GetComponent<Text>();
- strengthPointsText = GameObject.Find("StrengthPointsText").GetComponent<Text>();
- intelligencePointsText = GameObject.Find("IntelligencePointsText").GetComponent<Text>();
- statPointsText = GameObject.Find("StatPointsLeftText").GetComponent<Text>();
- representation = GameObject.Find("Representation").GetComponent<Image>();
- currentHairID = 0;
- currentColorID = 0;
- spriteSheet = Resources.LoadAll<Sprite>("RobinTutorialSS");
- //Showing something on the statPointsText
- statPointsText.text = "Stat Points Left: " + statPointsLeft;
- }
- public void AssignStats(string statChoice)
- {
- if(statPointsLeft > 0)
- {
- switch (statChoice)
- {
- case "Agility":
- {
- statPointsLeft -= 1;
- agilityPoints += 1;
- agilityPointsText.text = agilityPoints.ToString();
- statPointsText.text = "Stat Points Left: " + statPointsLeft;
- break;
- }
- case "Strength":
- {
- statPointsLeft -= 1;
- strengthPoints += 1;
- strengthPointsText.text = strengthPoints.ToString();
- statPointsText.text = "Stat Points Left: " + statPointsLeft;
- break;
- }
- case "Intelligence":
- {
- statPointsLeft -= 1;
- intelligencePoints += 1;
- intelligencePointsText.text = intelligencePoints.ToString();
- statPointsText.text = "Stat Points Left: " + statPointsLeft;
- break;
- }
- }
- }
- }
- public void CreateCharacter()
- {
- GameObject Character = new GameObject();
- Character.name = "Player";
- Character.AddComponent<SpriteRenderer>();
- Character.GetComponent<SpriteRenderer>().sprite = representation.sprite;
- Character.AddComponent<Rigidbody2D>();
- Character.GetComponent<Rigidbody2D>();
- Character.GetComponent<Rigidbody2D>().gravityScale = 0;
- Character.AddComponent<Player>();
- Character.GetComponent<Player>().strength = strengthPoints;
- Character.GetComponent<Player>().agility = agilityPoints;
- Character.GetComponent<Player>().intelligence = intelligencePoints;
- Character.transform.position = new Vector3(-1, 0, 0);
- }
- public void ChangeHair()
- {
- if (currentHairID < 2)
- {
- currentHairID++;
- }else if (currentHairID == 2)
- {
- currentHairID = 0;
- }
- foreach ( Sprite S in spriteSheet)
- {
- if (S.name.Equals("RobinTutorialSS_" + currentColorID + currentHairID))
- {
- representation.sprite = S;
- }
- }
- }
- public void ChangeColor()
- {
- if (currentColorID < 2)
- {
- currentColorID++;
- }
- else if (currentColorID == 2)
- {
- currentColorID = 0;
- }
- foreach (Sprite S in spriteSheet)
- {
- if (S.name.Equals("RobinTutorialSS_" + currentColorID + currentHairID))
- {
- representation.sprite = S;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement