SHARE
TWEET

Untitled

a guest Dec 11th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. utworzyc skrypt LevelNumber
  2.  
  3.  
  4. wkleic do niego to:
  5. //odtad
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using UnityEngine;
  9.  
  10. public static class LevelNumber
  11. {
  12.     // Start is called before the first frame update
  13.     public static int roomCount { get; set; }
  14.  
  15.  
  16.  
  17.  
  18.  
  19. }
  20.  
  21. //dotad
  22.  
  23. utworzyc skrypt GetLevelNumber i wkleic do niego to:
  24.  
  25.  
  26. //odtad
  27. using System.Collections;
  28. using System.Collections.Generic;
  29. using UnityEngine;
  30. using UnityEngine.SceneManagement;
  31. using System;
  32. using UnityEngine.UI;
  33.  
  34.  
  35. public class GetLevelNumber : MonoBehaviour
  36. {
  37.  
  38.     [SerializeField] private InputField RoomCountInputField;
  39.  
  40.     private int val;
  41.     // Start is called before the first frame update
  42.     void Awake()
  43.     {
  44.         LevelNumber.roomCount = 5;
  45.        
  46.     }
  47.  
  48.     // Update is called once per frame
  49.  
  50.  
  51.    public void LoadScene()
  52.  
  53.     {
  54.         LevelNumber.roomCount = TextToInt(RoomCountInputField.text);
  55.  
  56.         if (LevelNumber.roomCount > 0 && LevelNumber.roomCount < 50)
  57.         {
  58.             LevelNumber.roomCount = TextToInt(RoomCountInputField.text);
  59.             SceneManager.LoadScene("SampleScene");
  60.         }
  61.  
  62.         else
  63.  
  64.         {
  65.             RoomCountInputField.text = "Podaj liczbe od 1 do 50";
  66.         }
  67.     }
  68.  
  69.  
  70.  
  71.     public int TextToInt(string _input)
  72.     {
  73.  
  74.         val = 0;
  75.         string inputFieldText = _input;
  76.         if (Int32.TryParse(inputFieldText, out val))
  77.         {
  78.             val = Convert.ToInt32(inputFieldText);
  79.             return val;
  80.  
  81.  
  82.         }
  83.         else
  84.         {
  85.             return 0;
  86.  
  87.         }
  88.  
  89.        
  90.      
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.     }
  98.  
  99.  
  100.  
  101. }
  102.  
  103.  
  104. //dotad
  105.  
  106.  
  107. Przypisac do jakiegos obiektu na scenie i pRzeniesc input field w inspektorze
  108. dodac placeholder text 5
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. w generate level:
  116.  
  117. w metodzie Awake() na samym koncu:
  118.  
  119. {
  120.  
  121.  
  122.         Instantiate(levelEnder, new Vector3( startPosX-1, 0.5f, startPosY+endDoorX), Quaternion.identity);
  123.         Instantiate(levelEnder, new Vector3(startPosX-1, 0.5f, startPosY + endDoorX+1), Quaternion.identity);
  124.     //sa tu 2 bo korzystalam ze scian, mozna dodac 1 obiekt ale troche wiekszy.
  125.     //dodac mu kolizje zeby jak ziomek w niego wszedl to koniec levelu, przeszedles gre beng i powrut do poczontku XD
  126.    
  127.  
  128.  
  129. }
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