-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengine.js
More file actions
35 lines (30 loc) · 1.14 KB
/
engine.js
File metadata and controls
35 lines (30 loc) · 1.14 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
var WH40K = WH40K||{}
WH40K.Engine = function (){
var self = this;
self.activeUnit = null;
self.initialize = function(){
jQuery(document).bind('ACTIVATE_UNIT', function(e, originalEvent, unit){
self.activeUnit = unit;
self.showMoveRadius(unit);
});
}
self.showMoveRadius = function(unit){
var element = jQuery('img', unit.getElement());
var offset = unit.getElement().offset();
if(typeof self.moveRadiusElement !== 'undefined'){
self.moveRadiusElement.remove();
}
self.moveRadiusElement = jQuery('<div class="circle"></div>');
unit.getElement().after(self.moveRadiusElement);
var width = parseInt(element.width() * 13);
var height = parseInt(element.height() * 13);
self.moveRadiusElement.width(width);
self.moveRadiusElement.height(height);
self.moveRadiusElement.offset({
top:
(- parseInt(height / 2)) + parseInt(element.height() / 2) + offset.top,
left:
(- parseInt(width / 2)) + parseInt(element.width() / 2) + offset.left
});
}
}