1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = Object.setPrototypeOf ||
|
4 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
6 | return function (d, b) {
|
7 | extendStatics(d, b);
|
8 | function __() { this.constructor = d; }
|
9 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
10 | };
|
11 | })();
|
12 | Object.defineProperty(exports, "__esModule", { value: true });
|
13 | var Entity_1 = require("./../Entity");
|
14 | var Enum_1 = require("./../Tool/Enum");
|
15 |
|
16 |
|
17 |
|
18 | var Hitbox = (function (_super) {
|
19 | __extends(Hitbox, _super);
|
20 |
|
21 | |
22 |
|
23 |
|
24 | function Hitbox() {
|
25 | var _this = _super.call(this) || this;
|
26 | |
27 |
|
28 |
|
29 |
|
30 | _this.hit = 0;
|
31 | _this.setProps({
|
32 | type: Enum_1.Enum.TYPE.GHOST,
|
33 | group: Enum_1.Enum.GROUP.ENTITIES,
|
34 | owner: null,
|
35 | gravityFactor: 0,
|
36 | multipleHit: false,
|
37 | oncePerHit: true,
|
38 | maxHit: 1
|
39 | });
|
40 | _this.signals.beginCollision.add(_this.onCollision.bind(_this));
|
41 | return _this;
|
42 | }
|
43 |
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 | Hitbox.prototype.onCollision = function (otherName, other) {
|
50 | var result = this.onHit(otherName, other);
|
51 | if (result) {
|
52 | this.hit++;
|
53 | if (this.hit >= this.props.maxHit) {
|
54 | this.kill();
|
55 | }
|
56 | }
|
57 | };
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | Hitbox.prototype.onHit = function (name, target) {
|
65 | return true;
|
66 | };
|
67 | return Hitbox;
|
68 | }(Entity_1.Entity));
|
69 | exports.Hitbox = Hitbox;
|