Advertisement
moinularif

Game Manager

May 18th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.41 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. using UnityEngine.UI;
  5.  
  6.  
  7.  
  8. public class GameManager : MonoBehaviour {
  9.  
  10.  
  11.     public static string PlayerName, PlayerSchool;
  12.     public static long PlayerID;
  13.     public static int PlayerScore;
  14.  
  15.     public int IdSize = 0;
  16.     public int ApplicationLevel;
  17.  
  18.     public GameObject InputName;
  19.     public GameObject InputID;
  20.     public GameObject InputSchoolName;
  21.  
  22.     // Use this for initialization
  23.     void Start()
  24.     {
  25.  
  26.         PlayerName = "";
  27.         PlayerID = 0;
  28.         PlayerSchool = "";
  29.  
  30.     }
  31.  
  32.    
  33.  
  34.     public void OnClick()
  35.     {
  36.  
  37.  
  38.        string tempID = InputID.GetComponent<Text>().text;
  39.        bool isNumeric = long.TryParse(tempID, out PlayerID);
  40.        long InputNameLength = InputName.GetComponent<Text>().text.Length;
  41.        long InputSchoolLenth = InputSchoolName.GetComponent<Text>().text.Length;
  42.    
  43.        
  44.  
  45.         // Validation
  46.  
  47.        if (isNumeric && tempID.Length == IdSize && InputNameLength > 0 && InputSchoolLenth > 0 && InputName.GetComponent<Text>().text != "Please Type in Correct Format" && InputSchoolName.GetComponent<Text>().text != "Please Type in Correct Format")
  48.        {
  49.            PlayerID = Convert.ToInt64(tempID);
  50.            PlayerName = InputName.GetComponent<Text>().text;
  51.            PlayerSchool = InputSchoolName.GetComponent<Text>().text;
  52.            Application.LoadLevel(ApplicationLevel);
  53.        }
  54.  
  55.        if (tempID.Length > IdSize || tempID.Length < IdSize || !isNumeric || InputID.GetComponent<Text>().text == "Please Type Correct ID")
  56.        {
  57.            InputID.GetComponent<Text>().text = "Please Type Correct ID";
  58.            InputID.GetComponent<Text>().color = Color.red;
  59.        }
  60.  
  61.        if (InputNameLength == 0 || InputName.GetComponent<Text>().text == "Please Type in Correct Format" )
  62.        {
  63.            InputName.GetComponent<Text>().text = "Please Type in Correct Format";
  64.            InputName.GetComponent<Text>().color = Color.red;
  65.        }
  66.  
  67.        if (InputSchoolLenth == 0 || InputSchoolName.GetComponent<Text>().text == "Please Type in Correct Format")
  68.        {
  69.            InputSchoolName.GetComponent<Text>().text = "Please Type in Correct Format";
  70.            InputSchoolName.GetComponent<Text>().color = Color.red;
  71.        }
  72.  
  73.        
  74.        
  75.  
  76.         Debug.Log(PlayerName);
  77.         Debug.Log(PlayerID);
  78.         Debug.Log(PlayerSchool);
  79.        
  80.    
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement