public void MineGem() { if (m_ClosestVisibleGem != null) { RockInfo rockInfo = m_ClosestVisibleGem.GetComponent <RockInfo>(); if (rockInfo) { rockInfo.IsBeingMined = m_IsMiningGem; } } }
IEnumerator PlaceExistingObjects() { LoadingscreenManager t_loadingscreenManager = LoadingscreenManager.Instance; UIManager t_uiManager = UIManager.Instance; TreeInfo t_treeInfoArray = _dataReferences.FindElement <TreeInfo>(_treeDataArrayID); BuildingInfo t_buildingInfoArray = _dataReferences.FindElement <BuildingInfo>("BUILDING_DATA"); RockInfo t_rockInfoArray = _dataReferences.FindElement <RockInfo>(_rockDataArrayID); if (t_treeInfoArray != null) { if (t_treeInfoArray.Trees.Count > 0) { t_loadingscreenManager.OpenLoadingscreen("Placing Trees."); } for (int i = 0; i < t_treeInfoArray.Trees.Count; i++) { t_uiManager.LoadingBar.value = t_uiManager.LoadingBar.maxValue * i / t_treeInfoArray.Trees.Count; GameObject t_obj = Instantiate(_treeGen.obj[UnityEngine.Random.Range(0, _treeGen.obj.Length)], t_treeInfoArray.Trees[i].Position, t_treeInfoArray.Trees[i].Rotation); Trees.Add(t_obj); if (i % (t_treeInfoArray.Trees.Count / 50) == 0 && i != 0) { yield return(new WaitForSecondsRealtime(0.01f)); } } t_uiManager.LoadingBar.value = 0; } if (t_rockInfoArray != null) { if (t_rockInfoArray.Rocks.Count > 0) { t_loadingscreenManager.OpenLoadingscreen("Placing Rocks."); } for (int i = 0; i < t_rockInfoArray.Rocks.Count; i++) { t_uiManager.LoadingBar.value = t_uiManager.LoadingBar.maxValue * i / t_rockInfoArray.Rocks.Count; GameObject t_obj = Instantiate(_rockGen.obj[UnityEngine.Random.Range(0, _rockGen.obj.Length)], t_rockInfoArray.Rocks[i].Position, t_rockInfoArray.Rocks[i].Rotation); Trees.Add(t_obj); if (i % (t_rockInfoArray.Rocks.Count / 50) == 0 && i != 0) { yield return(new WaitForSecondsRealtime(0.01f)); } } t_uiManager.LoadingBar.value = 0; } if (t_buildingInfoArray != null) { if (t_buildingInfoArray.Buildings.Count > 0) { t_loadingscreenManager.OpenLoadingscreen("Placing Buildings."); } for (int i = 0; i < t_buildingInfoArray.Buildings.Count; i++) { t_uiManager.LoadingBar.value = t_uiManager.LoadingBar.maxValue * i / t_buildingInfoArray.Buildings.Count; GameObject t_obj = Instantiate(_player.prefab, t_buildingInfoArray.Buildings[i].Position, t_buildingInfoArray.Buildings[i].Rotation); Buildings.Add(t_obj); yield return(new WaitForSecondsRealtime(0.01f)); } t_uiManager.LoadingBar.value = 0; } if (t_loadingscreenManager != null) { t_loadingscreenManager.CloseLoadingscreen(); } yield return(null); }
private IEnumerator PlaceRocks(Orientation p_orientation, Transform p_position) { LoadingscreenManager t_loadingscreenManager = LoadingscreenManager.Instance; UIManager t_uiManager = UIManager.Instance; RockInfo t_rockInfoArray = null; if (_dataReferences != null) { t_rockInfoArray = _dataReferences.FindElement <RockInfo>(_rockDataArrayID); } if (t_rockInfoArray == null && _dataReferences != null) { _dataReferences.AddElement <RockInfo>(_rockDataArrayID); t_rockInfoArray = _dataReferences.FindElement <RockInfo>(_rockDataArrayID); } if (t_loadingscreenManager != null) { t_loadingscreenManager.OpenLoadingscreen("Generating World."); } for (int i = 0; i < _rockGen.amount; i++) { if (i % (_rockGen.amount / 25) == 0 && i != 0) { yield return(new WaitForSecondsRealtime(0.01f)); } if (t_loadingscreenManager != null) { t_uiManager.LoadingBar.value = t_uiManager.LoadingBar.maxValue * i / _rockGen.amount; } GameObject t_tree = _rockGen.obj[UnityEngine.Random.Range(0, _rockGen.obj.Length)]; Vector2 t_spawnPosV2 = UnityEngine.Random.insideUnitCircle * _rockGen.radius; Vector3 t_spawnPos = new Vector3(t_spawnPosV2.x, 0, t_spawnPosV2.y); Vector3 t_offset = p_position.position + t_spawnPos; Vector3 t_axis = new Vector3(); if (p_orientation == Orientation.Up) { t_axis = Vector3.up; } if (p_orientation == Orientation.Down) { t_axis = Vector3.down; } RaycastHit t_hit; if (Physics.Raycast(t_offset, t_axis, out t_hit)) { Vector3 t_finalSpawnPos = t_hit.point; if (!t_hit.collider.CompareTag("Tree") && !t_hit.collider.CompareTag("Rock")) { _rocks.Add(Instantiate(t_tree, t_finalSpawnPos, Quaternion.identity)); if (t_rockInfoArray != null) { t_rockInfoArray.Rocks.Add(new Rock(t_finalSpawnPos, Quaternion.identity, t_tree)); } } } } if (t_rockInfoArray != null) { t_rockInfoArray.Save(); } if (t_loadingscreenManager != null) { t_loadingscreenManager.CloseLoadingscreen(); } yield return(null); }