-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnomaly.java
More file actions
101 lines (84 loc) · 2.09 KB
/
Copy pathAnomaly.java
File metadata and controls
101 lines (84 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package GameObjects;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
/**
* Created by Shadilan on 07.10.2015.
*/
public class Anomaly implements GameObject {
private int Width=100;
private int Height=100;
private int X;
private int Y;
private int Power=100;
private Image img;
private GameObject owner=null;
private ArrayList<Spirit> Spirits;
//private ArrayList<int> Codes;
public Anomaly(int x,int y){
X=x;
Y=y;
img=new BufferedImage(100,100,BufferedImage.TYPE_INT_ARGB);
Graphics graphics = img.getGraphics();
graphics.setColor(Color.YELLOW);
graphics.drawOval(0, 0, Width-1, Height-1);
Spirits=new ArrayList<Spirit>();
}
@Override
public Image draw() {
return img;
}
@Override
public int GetX() {
return X;
}
@Override
public int GetY() {
return Y;
}
@Override
public int GetWidth() {
return Width;
}
@Override
public int GetHeight() {
return Height;
}
@Override
public int GetRadius() {
return 50;
}
@Override
public void Tick(World world) {
if (owner==null && Spirits.size()<10) {
if (Math.random() * 10000 < 10) {
int sx = (int) (Math.random() * 400 - 200);
int sy = (int) (Math.random() * 400 - 200);
//Ïðîâåðèòü íå ïåðåñå÷åíèå ñ äðóãèìè Äóõàìè
Spirit spr = new Spirit(sx + X, sy + Y, this);
Spirits.add(spr);
world.AddObject(spr);
}
}
}
@Override
public void destroy(World world) {
}
@Override
public void Action(World world, GameObject actor) {
}
@Override
public String GetType() {
return "Anomaly";
}
public GameObject GetOwner(){
return owner;
}
public void SetOwner(GameObject owner){
this.owner=owner;
}
public void RemoveSpirit(Spirit spirit){
spirit.SetOwner(null);
Spirits.remove(spirit);
}
}