Esempio n. 1
0
    private void SpawnBrick(Brick brickData)
    {
        Vector3    pos   = new Vector3(brickData.x * 16, brickData.y * -8);
        GameObject brick = Instantiate(brickPrefab, Vector3.zero, Quaternion.identity);

        brick.transform.parent        = this.gameObject.transform;
        brick.transform.localPosition = pos;
        Color color;

        if (ColorUtility.TryParseHtmlString(brickData.color, out color))
        {
            brick.GetComponent <SpriteRenderer>().color = color;
            BrickController controller = brick.GetComponent <BrickController>();
            controller.SetGameController(_gameController);
            controller.SetHitPoint(brickData.hitPoints);

            if (brickData.powerUp.name != null)
            {
                PowerUpObject pu = powerupMap[brickData.powerUp.name];

                if (pu != null)
                {
                    pu.duration        = brickData.powerUp.duration;
                    controller.powerUp = pu;
                }
            }
        }
    }