diff --git a/core/assets/sprites/spell/darkspell.png b/core/assets/sprites/spell/darkspell.png new file mode 100644 index 0000000..5039b53 Binary files /dev/null and b/core/assets/sprites/spell/darkspell.png differ diff --git a/core/assets/sprites/wizard/darkwizard_m.png b/core/assets/sprites/wizard/darkwizard_m.png new file mode 100644 index 0000000..67c35e3 Binary files /dev/null and b/core/assets/sprites/wizard/darkwizard_m.png differ diff --git a/core/assets/sprites/wizard/darkwizard_w.png b/core/assets/sprites/wizard/darkwizard_w.png new file mode 100644 index 0000000..b1835bf Binary files /dev/null and b/core/assets/sprites/wizard/darkwizard_w.png differ diff --git a/core/src/com/dungeoncrawler/model/DungeonGenerator.java b/core/src/com/dungeoncrawler/model/DungeonGenerator.java index 56ac363..53dfdc9 100644 --- a/core/src/com/dungeoncrawler/model/DungeonGenerator.java +++ b/core/src/com/dungeoncrawler/model/DungeonGenerator.java @@ -313,7 +313,7 @@ public class DungeonGenerator { Entity temp; - int id = (int) (Math.random() * 13); + int id = (int) (Math.random() * 14); switch(id){ case 0: temp = new Archer(xPos, yPos, lvl); @@ -360,6 +360,9 @@ public class DungeonGenerator { case 12: temp = new Naturewizard(xPos, yPos, lvl); break; + case 13: + temp = new Darkwizard(xPos, yPos, lvl); + break; default: temp = null; } diff --git a/core/src/com/dungeoncrawler/model/entities/Darkwizard.java b/core/src/com/dungeoncrawler/model/entities/Darkwizard.java new file mode 100644 index 0000000..6ec51e4 --- /dev/null +++ b/core/src/com/dungeoncrawler/model/entities/Darkwizard.java @@ -0,0 +1,106 @@ +/* + * 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 com.dungeoncrawler.model.entities; + +import com.dungeoncrawler.StaticMath; +import com.dungeoncrawler.model.Entity; + +/** + * + * @author jonathan + */ +public class Darkwizard extends Entity{ + + int counter; + final int minRange; + final int maxRange; + final int attackSpeed; + + public Darkwizard(float xPos, float yPos, int lvl) { + super(xPos, yPos, lvl); + + this.maxhp = 80*lvl; + this.hp = this.maxhp; + this.direction = 1; + this.dmg = 10*lvl; + this.id = 24; + this.type = 1; + minRange = 140; + maxRange = 170; + attackSpeed = 70; // higher = slower + counter = 0; + // TODO: Sinnvolle Werte finden + + direction = 1; + } + + @Override + public boolean move(int xPosPlayer, int yPosPlayer) { + if(!isToDelete()){ + + double alpha = StaticMath.calculateAngle((int) this.xPos, (int) this.yPos, xPosPlayer + 32, yPosPlayer + 32); + int distance = (int) StaticMath.calculateDistance((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer, alpha); + + if(distance >= minRange && distance <= maxRange && counter % attackSpeed == 0){ + return true; + } + else{ + movementX = (int) (3 * Math.cos(alpha)); + movementY = (int) (3 * Math.sin(alpha)); + + if(distance < 144){ + movementX *= -1; + movementY *= -1; + } + else if(distance >= minRange && distance <= maxRange){ + movementX = 0; + movementY = 0; + } + + + xPos += movementX; + yPos += movementY; + } + + if(alpha >= Math.PI / -2 && alpha <= Math.PI / 2){ + setDirection(1); + } + else{ + setDirection(0); + } + + counter++; + } + + return false; + } + + @Override + public Entity shoot(int xPosPlayer, int yPosPlayer){ + Spell a = null; + + if(!isToDelete()){ + double alpha = StaticMath.calculateAngle((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer); + + a = new Spell(this.xPos + 32, this.yPos + 32, this.lvl,(int) this.dmg, 25, true); + int tempX = (int) (5 * Math.cos(alpha)); + int tempY = (int) (5 * Math.sin(alpha)); + + a.setMovementX(tempX); + a.setMovementY(tempY); + a.setAngle(alpha); + + if((alpha >= 0 && alpha <= Math.PI / 2) || (alpha <= 2 * Math.PI && alpha >= 2 * Math.PI - Math.PI / 2)){ + setDirection(1); + } + else{ + setDirection(0); + } + } + + return a; + } +} diff --git a/core/src/com/dungeoncrawler/view/GameScreen.java b/core/src/com/dungeoncrawler/view/GameScreen.java index f7d0210..9230e12 100644 --- a/core/src/com/dungeoncrawler/view/GameScreen.java +++ b/core/src/com/dungeoncrawler/view/GameScreen.java @@ -396,6 +396,14 @@ public class GameScreen { tx[0] = new Texture("sprites/spell/naturespell.png"); entitySprites[i] = new EntitySprite(tx, 16, 16); break; + case 24: + tx[0] = new Texture("sprites/wizard/darkwizard_"+gender+".png"); + entitySprites[i] = new EntitySprite(tx, 64, 64); + break; + case 25: + tx[0] = new Texture("sprites/spell/darkspell.png"); + entitySprites[i] = new EntitySprite(tx, 16, 16); + break; } entitySprites[i].update((int) e.getxPos() + 32, (int) e.getyPos() + 32);