Пример #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        int newType = (int)type - 1;

        if (newType > 0)
        {
            switch ((BRICK_TYPE)newType)
            {
            case BRICK_TYPE.MID:
                sprite.color = Color.yellow;
                type         = (BRICK_TYPE)newType;
                break;

            case BRICK_TYPE.SOFT:
                sprite.color = Color.red;
                type         = (BRICK_TYPE)newType;
                break;
            }
        }
        else
        {
            boxCollider.isTrigger = true;
            sprite.enabled        = false;
        }
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        boxCollider = GetComponent <BoxCollider2D>();
        sprite      = GetComponent <SpriteRenderer>();
        type        = (BRICK_TYPE)Mathf.FloorToInt(Random.Range(1f, 4f));

        switch (type)
        {
        case BRICK_TYPE.HARD:
            sprite.color = Color.green;
            break;

        case BRICK_TYPE.MID:
            sprite.color = Color.yellow;
            break;

        case BRICK_TYPE.SOFT:
            sprite.color = Color.red;
            break;

        default:
            break;
        }
    }
Пример #3
0
 void assignCorrectBrickType()
 {
     if(isExploding)
     {
         brickType = BRICK_TYPE.EXPLODING;
     } else if (isInvisible)
     {
         brickType = BRICK_TYPE.INVISIBLE;
     } else if(!IsBreakable)
     {
         brickType = BRICK_TYPE.INDESTRUCTIBLE;
     } else if (maxHits == 3){
         brickType = BRICK_TYPE.NORMAL_3_HIT;
     } else if (maxHits == 2){
         brickType = BRICK_TYPE.NORMAL_2_HIT;
     } else if (maxHits == 1){
         brickType = BRICK_TYPE.NORMAL_1_HIT;
     }
     Debug.Log(brickType);
 }