-
Notifications
You must be signed in to change notification settings - Fork 1
/
Territory.js
executable file
·48 lines (38 loc) · 1.24 KB
/
Territory.js
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
var Rect2D = require('./Rect2D').Rect2D;
var Plane = require('./Plane').Plane;
var Logger = require('./Logger');
var Vector2D = require('./LGVector').Vector2D;
var Territory = function(offset, player)
{
this.player = player;
this.boundary = new Rect2D(1000);
this.boundary.min.addVector(offset);
this.boundary.max.addVector(offset);
this.objects = [];
this.directions = [];
this.runway = new Vector2D();
this.runway.x = this.boundary.min.x + this.boundary.getWidth() * 0.5;
this.runway.y = this.boundary.min.y + this.boundary.getHeight() * 0.4;
this.isPlaneInside = function(plane)
{
//Logger.log(JSON.stringify(plane.position) + " testing against " + JSON.stringify(this.boundary));
return this.boundary.isPointInside(plane.position);
};
this.updateInteractions = function()
{
//Logger.log("Length: " + this.objects.length);
for (var i = this.objects.length - 1; i >= 0; i--)
{
var obj = this.objects[i];
for(var j = 0;j < this.directions.length;j++)
{
//Logger.log("D ID: " + this.directions[j].plane_id + " P ID: " + obj.id);
var intId = parseInt(this.directions[j].plane_id);
if(intId == obj.id)
obj.waypoint = this.directions[j].waypoint;
}
obj.update();
}
}
};
exports.Territory = Territory;