// Start is called before the first frame update void Start() { _worldController = WorldController.GetWorldController; _soundManager = _worldController._soundManager; if (_rubble.GetComponentInChildren <MeshRenderer>().material.name.Contains("Dirt")) { _rockType = RockScript.Type.Dirt; } else if (_rubble.GetComponentInChildren <MeshRenderer>().material.name.Contains("LooseRock")) { _rockType = RockScript.Type.LooseRock; } else if (_rubble.GetComponentInChildren <MeshRenderer>().material.name.Contains("SolidRock")) { _rockType = RockScript.Type.HardRock; } UnitTask tempTask = new UnitTask { _location = _rubble.transform.position, _taskType = UnitTask.TaskType.ClearRubble, _targetRubble = this, _requiredTool = Unit.UnitTool.Shovel, _taskDescription = "Clearing rubble" }; TaskList.AddTaskToGlobalTaskList(tempTask); if (_energyCrystal) { if (_rockType == RockScript.Type.Dirt) { _objectAmount = 1; } else if (_rockType == RockScript.Type.LooseRock) { _objectAmount = 2; } else if (_rockType == RockScript.Type.HardRock) { _objectAmount = 3; } _stateSwichWait = _brakeTime / _objectAmount; _stateSwichTime = _brakeTime - _stateSwichWait; } else { if ((_objectAmount = Random.Range(_minDropedObject, _maxDropedObject)) != 0) { _stateSwichWait = _brakeTime / _objectAmount; _stateSwichTime = _brakeTime - _stateSwichWait; } } }
public void ChangeTexture(RockScript.Type rockType) { if (rockType == RockScript.Type.Dirt) { _rubble.GetComponentInChildren <MeshRenderer>().material = _dirt; } else if (rockType == RockScript.Type.LooseRock) { _rubble.GetComponentInChildren <MeshRenderer>().material = _looseRock; } else if (rockType == RockScript.Type.HardRock) { _rubble.GetComponentInChildren <MeshRenderer>().material = _hardRock; } }