change multiple scene system to dynamic indoor scene
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class BuildingManager : MonoBehaviour
|
||||
{
|
||||
public bool IsOpen { get; set; }
|
||||
public bool IsInside { get; set; }
|
||||
|
||||
private string _address;
|
||||
public IndoorSO Indoor;
|
||||
|
||||
public void BuildingInteract(IndoorSO indoor)
|
||||
{
|
||||
IsOpen = CheckIsOpen(indoor.OpenHoursFrom, indoor.OpenHoursTo);
|
||||
if (!IsInside)
|
||||
{
|
||||
EnterBuilding(indoor);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExitBuilding();
|
||||
}
|
||||
}
|
||||
|
||||
private void EnterBuilding(IndoorSO indoor)
|
||||
{
|
||||
if(IsOpen)
|
||||
{
|
||||
Indoor = indoor;
|
||||
IsInside = true;
|
||||
GameManager.Instance.Scene.Change("indoor");
|
||||
}
|
||||
}
|
||||
|
||||
public void ExitBuilding()
|
||||
{
|
||||
GameManager.Instance.Scene.Change("city");
|
||||
}
|
||||
|
||||
private bool CheckIsOpen(int from, int to)
|
||||
{
|
||||
return GameManager.Instance.Time.CurrentTime.Hours >= from
|
||||
&& GameManager.Instance.Time.CurrentTime.Hours <= to;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebdd79e4ca65877429c8e85a1f0a1bf3
|
||||
@@ -13,7 +13,9 @@ public class GameManager : MonoBehaviour
|
||||
private SceneManager _sceneManager;
|
||||
private TimeSystem _timeSystem;
|
||||
private InGameMouseHandler _gameMouseHandler;
|
||||
private BuildingManager _buildingManager;
|
||||
|
||||
public BuildingManager BuildingSystem => _buildingManager;
|
||||
public InputSystem Input => _inputSystem;
|
||||
public SceneManager Scene => _sceneManager;
|
||||
public TimeSystem Time => _timeSystem;
|
||||
@@ -30,6 +32,7 @@ public class GameManager : MonoBehaviour
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
_buildingManager = new BuildingManager();
|
||||
_inputSystem = new InputSystem();
|
||||
_sceneManager = new SceneManager();
|
||||
_timeSystem = new TimeSystem();
|
||||
|
||||
@@ -9,10 +9,8 @@ public class SceneManager
|
||||
UnityEngine.SceneManagement.SceneManager.sceneLoaded += SceneManager_sceneLoaded;
|
||||
}
|
||||
|
||||
public void Change(string sceneName,string spawnLocationName)
|
||||
public void Change(string sceneName)
|
||||
{
|
||||
_spawnLocationName = spawnLocationName;
|
||||
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user