RuneHive-Game
Loading...
Searching...
No Matches
CircleArea.java
Go to the documentation of this file.
1package com.runehive.game.world.position.impl;
2
3import com.runehive.game.world.position.Area;
4import com.runehive.game.world.position.Position;
5
6/**
7 * The location type that models any area in a circle or oval shape.
8 *
9 * @author lare96 <http://github.com/lare96>
10 */
11public class CircleArea extends Area {
12
13 private final String name;
14
15 private final int x;
16
17 private final int y;
18
19 private final int z;
20
21 private final int radius;
22
23 public CircleArea(String name, int x, int y, int radius) {
24 this(name, x, y, 0, radius);
25 }
26
27 public CircleArea(String name, int x, int y, int height, int radius) {
28 this.name = name;
29 this.x = x;
30 this.y = y;
31 this.z = height;
32 this.radius = radius;
33 }
34
35 public int getHeight() {
36 return z;
37 }
38
39 public String getName() {
40 return name;
41 }
42
43 public int getRadius() {
44 return radius;
45 }
46
47 public int getX() {
48 return x;
49 }
50
51 public int getY() {
52 return y;
53 }
54
55 @Override
56 public boolean inArea(Position position) {
57 if (position.getHeight() != z) {
58 return false;
59 }
60 return Math.pow((position.getX() - x), 2) + Math.pow((position.getY() - y), 2) <= Math.pow(radius, 2);
61 }
62
63 @Override
65 return null;
66 }
67
68}
Handles checking if mobs are in a certain area.
Definition Area.java:13
Represents a single tile on the game world.
Definition Position.java:14
CircleArea(String name, int x, int y, int height, int radius)
CircleArea(String name, int x, int y, int radius)