Coverage Summary for Class: LocateQuest (com.mygdx.game.Quests)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| LocateQuest | 100% (1/1) | 100% (4/4) | 96.3% (26/27) |
1 package com.mygdx.game.Quests; 2 3 import com.badlogic.gdx.math.Vector2; 4 import com.mygdx.game.Entitys.Player; 5 6 import static com.mygdx.utils.Constants.TILE_SIZE; 7 8 /** 9 * Competed once the player has gone to a specific position 10 */ 11 public class LocateQuest extends Quest { 12 private final Vector2 loc; 13 private float radius; 14 15 public LocateQuest() { 16 super(); 17 name = "Find a chest"; 18 description = "North east"; 19 reward = 100; 20 loc = new Vector2(); 21 radius = -1; 22 } 23 24 /** 25 * The loc to go to and radius that the play has to be in to completed it 26 * 27 * @param pos location to find 28 * @param r leeway in completion 29 */ 30 public LocateQuest(Vector2 pos, float r) { 31 this(); 32 loc.set(pos); 33 radius = r * r; 34 pos.scl(1 / TILE_SIZE).sub(50, 50); // centres on 0, 0 35 description = ""; 36 if (pos.y > 0) { 37 description += "North "; 38 } else if (pos.y < 0) { 39 description += "South "; 40 } 41 if (pos.x > 0) { 42 description += "East"; 43 } else if (pos.x < 0) { 44 description += "West"; 45 } 46 47 } 48 49 @Override 50 public boolean checkCompleted(Player p) { 51 if (radius == -1) { 52 return false; 53 } 54 Vector2 delta = p.getPosition().cpy(); 55 delta.sub(loc); 56 float l = delta.len2(); 57 isCompleted = l < radius; 58 return isCompleted; 59 } 60 61 public Vector2 getLocation() { 62 return loc; 63 } 64 }