public tnCamerasSet GetData(int i_Id) { tnCamerasSet data = null; m_Data.TryGetValue(i_Id, out data); return(data); }
// LOGIC public void Initialize(string i_DatabasePath) { tnCamerasDatabase database = Resources.Load <tnCamerasDatabase>(i_DatabasePath); if (database != null) { foreach (string id in database.keys) { tnCameraSetDescriptor cameraSetDescriptor = database.GetCameraSet(id); if (cameraSetDescriptor != null) { int hash = StringUtils.GetHashCode(id); tnCamerasSet cameraSet = new tnCamerasSet(cameraSetDescriptor); m_Data.Add(hash, cameraSet); } } } else { LogManager.LogWarning(this, "Database not loaded."); } }
public override void OnEnter() { tnMatchSettingsModule module = GameModulesManager.GetModuleMain <tnMatchSettingsModule>(); if (module != null) { int gameModeId = module.gameModeId; tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId); if (gameModeData != null) { int camerasSetId = gameModeData.camerasSetId; tnCamerasSet camerasSet = tnGameData.GetCameraSetMain(camerasSetId); if (camerasSet != null) { int stadiumId = module.stadiumId; tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId); if (stadiumData != null) { GameObject cameraPrefab = camerasSet.GetCamera(stadiumData.cameraId); if (cameraPrefab != null) { if (storeResult != null && !storeResult.IsNone) { storeResult.Value = cameraPrefab.gameObject; } } } } } } Finish(); }
private void CreateCamera() { GameObject spawnPointGo = GameObject.Find(s_Camera_SpawnPoint_Name); Vector3 spawnPointPosition = (spawnPointGo != null) ? spawnPointGo.transform.position : Vector3.zero; spawnPointPosition.z = -15f; tnMatchSettingsModule matchSettingsModule = GameModulesManager.GetModuleMain <tnMatchSettingsModule>(); if (matchSettingsModule == null) { return; } int gameModeId = matchSettingsModule.gameModeId; tnGameModeData gameModeData = tnGameData.GetGameModeDataMain(gameModeId); if (gameModeData == null) { return; } int cameraSetId = gameModeData.camerasSetId; tnCamerasSet cameraSet = tnGameData.GetCameraSetMain(cameraSetId); if (cameraSet == null) { return; } int stadiumId = matchSettingsModule.stadiumId; tnStadiumData stadiumData = tnGameData.GetStadiumDataMain(stadiumId); if (stadiumData == null) { return; } GameObject cameraPrefab = cameraSet.GetCamera(stadiumData.cameraId); if (cameraPrefab == null) { return; } m_GameCameraGO = Instantiate <GameObject>(cameraPrefab); m_GameCameraGO.name = "GameCamera"; m_GameCameraGO.tag = "GameCamera"; tnGameCamera gameCamera = m_GameCameraGO.GetComponent <tnGameCamera>(); if (gameCamera != null) { gameCamera.SetPosition(spawnPointPosition); } else { m_GameCameraGO.transform.position = spawnPointPosition; } m_GameCameraGO.transform.rotation = Quaternion.identity; }