package de.miaurizius.jgame2d.entity.monster;

import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.entity.Entity;
import de.miaurizius.jgame2d.entity.item.CoinObj;
import de.miaurizius.jgame2d.entity.item.HeartObj;
import de.miaurizius.jgame2d.entity.item.PotionObj;
import de.miaurizius.jgame2d.entity.projectile.RockObj;

import java.util.Random;

public class GreenSlimeMON extends Entity {

    public GreenSlimeMON(GamePanel panel) {
        super(panel);
        type = EntityType.MONSTER;
        name = "green-slime";
        defaultSpeed = 1;
        speed = defaultSpeed;
        maxLife = 4;
        life = maxLife;
        attack = 5;
        defense = 0;
        exp = 2;
        projectile = new RockObj(panel);

        knockbackVal = 5;

        solidArea.x = 3;
        solidArea.y = 18;
        solidArea.width = 42;
        solidArea.height = 30;
        solidAreaDefaultX = solidArea.x;
        solidAreaDefaultY = solidArea.y;

        getImage();
    }

    // INTERACTION
    public void setAction() {
        if(!onPath) checkStartChasing(panel.player, 5 ,100);
        checkStopChasing(panel.player, 10, 100);
        if(onPath) {
            followPlayer();
            return;
        }
        setRandomDirection();
        checkShooting(200, 30);
    }
    public void damageReaction() {
        actionLock = 0;
        onPath = true;
    }
    public void checkDrop() {
        int i = new Random().nextInt(100)+1;
        if(i < 50) dropItem(new CoinObj(panel));
        if(i >= 50 && i < 75) dropItem(new HeartObj(panel));
        if(i >= 75 && i < 100) dropItem(new PotionObj(panel));
    }

    // SETTING THINGS UP
    public void getImage() {
        up1 = initEntitySprites("monster/greenslime_down_1");
        up2 = initEntitySprites("monster/greenslime_down_2");
        down1 = initEntitySprites("monster/greenslime_down_1");
        down2 = initEntitySprites("monster/greenslime_down_2");
        left1 = initEntitySprites("monster/greenslime_down_1");
        left2 = initEntitySprites("monster/greenslime_down_2");
        right1 = initEntitySprites("monster/greenslime_down_1");
        right2 = initEntitySprites("monster/greenslime_down_2");
    }

}
