public static ObstacleTemplate[] CreateRandomPattern() { var patternLength = Random.Range(2, 6); var pattern = new ObstacleTemplate[patternLength]; var rndObstacle = Random.Range(3, 9); // There are six types of obstacles, starting from 3 var rndBehaviour = Random.Range(0, 4); // There four types of behaviour var rndAngle = Random.Range(0, 4); var rndDirection = Random.Range(0, 2); var direction = rndDirection > 0 ? Vector3.forward : Vector3.back; for (int i = 0; i < patternLength; i++) { pattern[i] = new ObstacleTemplate((PrefabName)rndObstacle, i * rndAngle * 30f, (BehaviourType)rndBehaviour, direction); } return(pattern); }
public void Init(ObstacleTemplate template, Color color) { _view = MiniPool.Create(template.PrefabName, new Vector3(0f, 0f, 100f)); _transform = _view.transform; _transform.localEulerAngles = new Vector3(0f, 0f, template.StartAngle); _behaviour = ObstacleUtils.GetBehaviour(template.BehaviourType); if (_behaviour != null) { _behaviour.Init(_transform, template.Direction); } IsActive = true; _scaleTimer = 0f; foreach (var renderer in _view.GetComponentsInChildren <Renderer>()) { renderer.material.SetColor("_MainColor", color); } }