package entity;

import environnement.Coordonnees;
import environnement.HitBox;
import static jeu.Jeu.getGameCharacter;

public class Bat extends Monster{
    private int directionZ = 1; //meme principe que direction pour x
    private final double vitesseMaxZ = 1000;
        
    public Bat(Coordonnees c,int atkStt,int nbLP){
        super(c, 1000, 20, 30, atkStt, nbLP);
        coordInit = coord;
        monsterType = "bat_fly";
    }

    public void deplacements(){

        double delta = Math.pow(10, -3);

        //oscillement selon z
        if (coordInit.getZ()-coord.getZ() >= 50){
            directionZ = 1;
        }
        else if (coordInit.getZ()-coord.getZ() <= -50){
            directionZ = -1;
        }

        //oscillement selon x
        if (coord.getX() < 0)direction = 1;
        else if (coord.getX() >= 1000)direction = -1;

        //actualisation des coordonnees
        double newX = coord.getX() + direction*vitesseMax*delta;
        double newZ = coord.getZ() + directionZ*vitesseMaxZ*delta;
        coord = new Coordonnees(newX, newZ);
    }

    public void attaque(){
        if (HitBox.collision(hitBox, getGameCharacter().getHitBox()) && getGameCharacter().nbFramesInvincible == 0){
            getGameCharacter().setNbLifePoints(Math.max(getGameCharacter().getNbLifePoints()-attackStat, 0));
            getGameCharacter().nbFramesInvincible = getGameCharacter().nbMaxFramesInvicible;
        }
    }
}
