Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- utworzyc skrypt LevelNumber
- wkleic do niego to:
- //odtad
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public static class LevelNumber
- {
- // Start is called before the first frame update
- public static int roomCount { get; set; }
- }
- //dotad
- utworzyc skrypt GetLevelNumber i wkleic do niego to:
- //odtad
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using System;
- using UnityEngine.UI;
- public class GetLevelNumber : MonoBehaviour
- {
- [SerializeField] private InputField RoomCountInputField;
- private int val;
- // Start is called before the first frame update
- void Awake()
- {
- LevelNumber.roomCount = 5;
- }
- // Update is called once per frame
- public void LoadScene()
- {
- LevelNumber.roomCount = TextToInt(RoomCountInputField.text);
- if (LevelNumber.roomCount > 0 && LevelNumber.roomCount < 50)
- {
- LevelNumber.roomCount = TextToInt(RoomCountInputField.text);
- SceneManager.LoadScene("SampleScene");
- }
- else
- {
- RoomCountInputField.text = "Podaj liczbe od 1 do 50";
- }
- }
- public int TextToInt(string _input)
- {
- val = 0;
- string inputFieldText = _input;
- if (Int32.TryParse(inputFieldText, out val))
- {
- val = Convert.ToInt32(inputFieldText);
- return val;
- }
- else
- {
- return 0;
- }
- }
- }
- //dotad
- Przypisac do jakiegos obiektu na scenie i pRzeniesc input field w inspektorze
- dodac placeholder text 5
- w generate level:
- w metodzie Awake() na samym koncu:
- {
- Instantiate(levelEnder, new Vector3( startPosX-1, 0.5f, startPosY+endDoorX), Quaternion.identity);
- Instantiate(levelEnder, new Vector3(startPosX-1, 0.5f, startPosY + endDoorX+1), Quaternion.identity);
- //sa tu 2 bo korzystalam ze scian, mozna dodac 1 obiekt ale troche wiekszy.
- //dodac mu kolizje zeby jak ziomek w niego wszedl to koniec levelu, przeszedles gre beng i powrut do poczontku XD
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement