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 p2_1 = require("p2");
|
14 | var Entity_1 = require("./../Entity");
|
15 | var _1 = require("./../Tool/");
|
16 |
|
17 |
|
18 |
|
19 | var Wall = (function (_super) {
|
20 | __extends(Wall, _super);
|
21 | function Wall() {
|
22 | return _super !== null && _super.apply(this, arguments) || this;
|
23 | }
|
24 |
|
25 | |
26 |
|
27 |
|
28 |
|
29 | Wall.prototype.initialize = function (props) {
|
30 | this.setProps({
|
31 | gravityFactor: 0,
|
32 | box: _1.Enum.BOX.RECTANGLE,
|
33 | type: _1.Enum.TYPE.STATIC,
|
34 | group: _1.Enum.GROUP.GROUND
|
35 | });
|
36 | _super.prototype.initialize.call(this, props);
|
37 | };
|
38 |
|
39 | |
40 |
|
41 |
|
42 |
|
43 |
|
44 | Wall.prototype.isConstrainedByDirection = function (entity) {
|
45 | return !this.resolveDirectionConstraint(this.props.directionConstraint, this.props.x, this.props.y, this.props.width, this.props.height, entity);
|
46 | };
|
47 | |
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | Wall.prototype.resolveDirectionConstraint = function (directionConstraint, x, y, width, height, entity) {
|
58 | switch (directionConstraint) {
|
59 | case "upper": return entity.props.y < y;
|
60 | case "lower": return entity.last.y > entity.props.y && entity.props.y + entity.props.height > y && (entity.props.y + (entity.props.height / 2)) >= (y + height);
|
61 | default: return true;
|
62 | }
|
63 | };
|
64 | return Wall;
|
65 | }(Entity_1.Entity));
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | Wall.wallMaterial = new p2_1.Material(Wall.generateId());
|
71 | exports.Wall = Wall;
|