private BrickConfig GetBrickConfigForCoords( RowConfig rowConfig, int column) { var columnPercent = column / rowConfig.numColumns; var validSpawnRuleConfigs = GetValidSpawnRuleConfigs( columnPercent, rowConfig.brickSpawnRuleConfigs.ToList()); var numColors = validSpawnRuleConfigs[0].brickColors.Length; var randomIndex = Random.Range(0, numColors); var randomColor = validSpawnRuleConfigs[0].brickColors[randomIndex]; var brickConfig = new BrickConfig { color = randomColor }; return(brickConfig); }
public Brick CreateBrick(BrickConfig brickConfig) { var brickGameObject = Instantiate(_brickPrefab); brickGameObject.name = _brickPrefab.name; var brick = brickGameObject.GetComponent <Brick>(); brick.SetSize(brickConfig.unitSize, brickConfig.width); var material = GetMaterialFromBrickColor(brickConfig.color); var weakenedMaterial = GetWeakenedMaterialFromBrickColor(brickConfig.color); brick.SetMaterial(material, weakenedMaterial); brick.Score = GetScoreFromBrickColor(brickConfig.color); brick.Color = brickConfig.color; if (_flipNextBrick) { brickGameObject.transform.Rotate(Vector3.up, 180.0f); } _flipNextBrick = !_flipNextBrick; return(brick); }