Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Customization

npgdev Mar 5th, 2016 68 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. public class Customization : MonoBehaviour {
  6.     Sprite[] spriteSheet;
  7.     int currentHairID, currentColorID;
  8.     Image representation;
  9.     Text agilityPointsText, strengthPointsText, intelligencePointsText, statPointsText;
  10.     public int statPointsLeft;
  11.     int agilityPoints, strengthPoints, intelligencePoints;
  12.     // Use this for initialization
  13.     void Start () {
  14.  
  15.         //Finding Points Texts
  16.         agilityPointsText = GameObject.Find("AgilityPointsText").GetComponent<Text>();
  17.         strengthPointsText = GameObject.Find("StrengthPointsText").GetComponent<Text>();
  18.         intelligencePointsText = GameObject.Find("IntelligencePointsText").GetComponent<Text>();
  19.         statPointsText = GameObject.Find("StatPointsLeftText").GetComponent<Text>();
  20.  
  21.         representation = GameObject.Find("Representation").GetComponent<Image>();
  22.         currentHairID = 0;
  23.         currentColorID = 0;
  24.         spriteSheet = Resources.LoadAll<Sprite>("RobinTutorialSS");
  25.  
  26.  
  27.         //Showing something on the statPointsText
  28.  
  29.         statPointsText.text = "Stat Points Left: " + statPointsLeft;
  30.  
  31.  
  32.     }
  33.    
  34.     public void AssignStats(string statChoice)
  35.     {
  36.         if(statPointsLeft > 0)
  37.         {
  38.             switch (statChoice)
  39.             {
  40.                 case "Agility":
  41.                     {
  42.                         statPointsLeft -= 1;
  43.                         agilityPoints += 1;
  44.  
  45.  
  46.                         agilityPointsText.text = agilityPoints.ToString();
  47.                         statPointsText.text = "Stat Points Left: " + statPointsLeft;
  48.                         break;
  49.                     }
  50.                 case "Strength":
  51.                     {
  52.                         statPointsLeft -= 1;
  53.                         strengthPoints += 1;
  54.  
  55.  
  56.                         strengthPointsText.text = strengthPoints.ToString();
  57.                         statPointsText.text = "Stat Points Left: " + statPointsLeft;
  58.                         break;
  59.                     }
  60.                 case "Intelligence":
  61.                     {
  62.                         statPointsLeft -= 1;
  63.                         intelligencePoints += 1;
  64.  
  65.  
  66.                         intelligencePointsText.text = intelligencePoints.ToString();
  67.                         statPointsText.text = "Stat Points Left: " + statPointsLeft;
  68.                         break;
  69.                     }
  70.  
  71.  
  72.             }
  73.  
  74.  
  75.  
  76.  
  77.         }
  78.  
  79.  
  80.  
  81.  
  82.  
  83.     }
  84.  
  85.     public void CreateCharacter()
  86.     {
  87.         GameObject Character = new GameObject();
  88.         Character.name = "Player";
  89.         Character.AddComponent<SpriteRenderer>();
  90.         Character.GetComponent<SpriteRenderer>().sprite = representation.sprite;
  91.         Character.AddComponent<Rigidbody2D>();
  92.         Character.GetComponent<Rigidbody2D>();
  93.         Character.GetComponent<Rigidbody2D>().gravityScale = 0;
  94.         Character.AddComponent<Player>();
  95.         Character.GetComponent<Player>().strength = strengthPoints;
  96.         Character.GetComponent<Player>().agility = agilityPoints;
  97.         Character.GetComponent<Player>().intelligence = intelligencePoints;
  98.  
  99.         Character.transform.position = new Vector3(-1, 0, 0);
  100.  
  101.     }
  102.  
  103.  
  104.  
  105.  
  106.  
  107.     public void ChangeHair()
  108.     {
  109.         if (currentHairID < 2)
  110.         {
  111.             currentHairID++;
  112.         }else if (currentHairID == 2)
  113.         {
  114.             currentHairID = 0;
  115.         }
  116.  
  117.         foreach ( Sprite S in spriteSheet)
  118.         {
  119.             if (S.name.Equals("RobinTutorialSS_" + currentColorID + currentHairID))
  120.             {
  121.                 representation.sprite = S;
  122.             }
  123.         }
  124.  
  125.     }
  126.  
  127.     public void ChangeColor()
  128.     {
  129.  
  130.         if (currentColorID < 2)
  131.         {
  132.             currentColorID++;
  133.         }
  134.         else if (currentColorID == 2)
  135.         {
  136.             currentColorID = 0;
  137.         }
  138.  
  139.         foreach (Sprite S in spriteSheet)
  140.         {
  141.             if (S.name.Equals("RobinTutorialSS_" + currentColorID + currentHairID))
  142.             {
  143.                 representation.sprite = S;
  144.             }
  145.         }
  146.  
  147.     }
  148.  
  149.  
  150. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top