/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package net.kirauks.minigames.brickbreaker.elements;

import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import net.kirauks.minigames.brickbreaker.Game;

/**
 *
 * @author Karl
 */
public class Bloc extends Parent{
    public static final double SIZE = 40d;
    public static final double THICKNESS = 15d;
    
    public enum BlocType{
        BLUE(25, Color.BLUE, true, false),
        RED(50, Color.RED, true, false),
        GREEN(75, Color.GREEN, true, false),
        YELLOW(100, Color.YELLOW, true, false),
        SOLID(0, Color.GRAY, false, false),
        NULL(0, Game.COLOR_BACKGROUND, false, true);
        
        private final Color color;
        private final boolean breakable;
        private final boolean traversable;
        private int breakScore;
        private BlocType(int breakScore, Color color, boolean breakable, boolean traversable){
            this.breakScore = breakScore;
            this.color = color;
            this.breakable = breakable;
            this.traversable = traversable;
        }
    }
    
    private final BlocType type;
    private final Node view;
    private boolean destoyed;
    
    public Bloc(BlocType type){
        this.type = type;
        this.destoyed = false;
        
        Rectangle rectangle = new Rectangle(SIZE, THICKNESS);
        rectangle.setStroke(this.type.color);
        
        this.view = rectangle;
        this.getChildren().add(this.view);
    }
    
    public BlocType getType(){
        return this.type;
    }
    public int getScoreValue(){
        return this.type.breakScore;
    }
    
    public boolean destroyed(){
        return this.destoyed;
    }
    
    public boolean traversable(){
        return this.type.traversable;
    }
    public boolean breakable(){
        return this.type.breakable;
    }
    
    public void destroy(){
        if(this.type.breakable){
            this.view.setVisible(false);
            this.destoyed = true;
        }
    }
}

@@ -233,16 +233,56 @@
 ments;%0A%0A
+import javafx.animation.FadeTransition;%0A
 import j
@@ -397,16 +397,45 @@
 tangle;%0A
+import javafx.util.Duration;%0A
 import n
@@ -2217,64 +2217,229 @@
 his.
-view.setVisible(false);%0A            this.destoyed = true
+destoyed = true;%0A            FadeTransition fade = new FadeTransition(Duration.millis(300));%0A            fade.setNode(this.view);%0A            fade.setFromValue(1d);%0A            fade.setToValue(0d);%0A            fade.play()
 ;%0A  

Add fade transition to blocs destroy