Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class LevelSelectHandler : MonoBehaviour {
- private LevelSelectController LSC = null;
- public string thisDoorsLevel = "Level1"; /// <summary>
- /// This is for the Level Selection Stuff
- /// Not required for the New Game button or Continue Game Button
- /// or the Level Arrow Stuff
- /// </summary>
- public int thisDoorsLevelNumber = 1; /// <summary>
- /// This is for the Level Selection Stuff
- /// Not required for the New Game button or Continue Game Button
- /// or the Level Arrow Stuff
- /// </summary>
- // Use this for initialization
- public Sprite spriteNewGame;
- public Sprite spriteContinueGame;
- public Sprite spriteLevelNext;
- public Sprite spriteLevelBack;
- public Sprite spritePlay;
- public GUITexture textureNewGame = new GUITexture();
- public GUITexture textureContinueGame = new GUITexture();
- public GUITexture textureLevelNext = new GUITexture();
- public GUITexture textureLevelBack = new GUITexture();
- public GUITexture texturePlay = new GUITexture();
- public GUIStyle NewGameButton = new GUIStyle();
- public GUIStyle ContinueGameButton = new GUIStyle();
- public GUIStyle LevelNextButton = new GUIStyle();
- public GUIStyle LevelBackButton = new GUIStyle();
- public GUIStyle PlayButton = new GUIStyle();
- public int buttonHeight;
- public int buttonWidth;
- public int levelButtonWidth;
- public int levelButtonHeight;
- public Texture2D texture2DFromSprite(Sprite sprite)
- {
- //if (sprite.rect.width != sprite.texture.width) {
- Texture2D newText = new Texture2D ((int)sprite.rect.width, (int)sprite.rect.height);
- Color[] newColors = sprite.texture.GetPixels ((int)sprite.textureRect.x,
- (int)sprite.textureRect.y,
- (int)sprite.textureRect.width,
- (int)sprite.textureRect.height);
- newText.SetPixels (newColors);
- newText.Apply ();
- return newText;
- //} else {
- //return sprite.texture;
- //}
- }
- void Start()
- {
- textureNewGame = new GUITexture();
- textureContinueGame = new GUITexture();
- textureLevelNext = new GUITexture();
- textureLevelBack = new GUITexture();
- texturePlay = new GUITexture();
- newGameButton = new GUIStyle();
- ContinueGameButton = new GUIStyle();
- LevelNextButton = new GUIStyle();
- LevelBackButton = new GUIStyle();
- PlayButton = new GUIStyle();
- textureNewGame.texture = texture2DFromSprite (spriteNewGame);
- textureContinueGame.texture = texture2DFromSprite (spriteContinueGame);
- textureLevelNext.texture = texture2DFromSprite (spriteLevelNext);
- textureLevelBack.texture = texture2DFromSprite (spriteLevelBack);
- texturePlay.texture = texture2DFromSprite (spritePlay);
- //The GUIStyle Textures are Setup Below
- NewGameButton.normal.background = textureNewGame.texture as Texture2D;
- ContinueGameButton.normal.background = textureContinueGame.texture as Texture2D;
- LevelNextButton.normal.background = textureLevelNext.texture as Texture2D;
- LevelBackButton.normal.background = textureLevelBack.texture as Texture2D;
- PlayButton.normal.background = texturePlay.texture as Texture2D;
- }
- // Update is called once per frame
- void Update () {
- }
- void OnGUI()
- {
- if (GUI.Button (RelativeRect.GetExact (25, 20, buttonWidth, buttonHeight, true), "", NewGameButton)) {
- Debug.Log ("Clicked New Game");
- }
- if (GUI.Button (RelativeRect.GetExact (25, 30, buttonWidth, buttonHeight, true), "", ContinueGameButton)) {
- Debug.Log ("This is stupid");
- }
- if (GUI.Button (RelativeRect.GetExact (25,40,levelButtonWidth,levelButtonHeight,true),"",LevelBackButton))
- {
- Debug.Log ("Back 1 Level");
- }
- if (GUI.Button (RelativeRect.GetExact (65, 40, levelButtonWidth, levelButtonHeight, true), "", LevelNextButton)) {
- Debug.Log ("Forward 1 Level");
- }
- }
- void OnMouseDown()
- {
- /*if (gameObject.tag == "NewGame") {
- Debug.Log ("New Game Started");
- LSC.NewGame ();
- }
- if (gameObject.tag == "LevelDoor") {
- if (thisDoorsLevel != null) {
- Debug.Log ("You click this!");
- LSC.LoadSpecificLevel (thisDoorsLevel, thisDoorsLevelNumber);
- //hi
- }
- }
- if (gameObject.tag == "ContinueButton") {
- LSC.ContinueCurrentLevel ();
- }
- if (gameObject.tag == "LevelUpButton") {
- thisDoorsLevelNumber += 1;
- }
- if (gameObject.tag == "LevelDownButton") {
- if (thisDoorsLevelNumber > 1) {
- thisDoorsLevelNumber -= 1;
- }
- }*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment