Revision 4535,
1.3 KB
checked in by dezhidki, 8 years ago
(diff) |
Uusi versio:
- Tason luonti valmis
- Piirtojärjestys toimii
- Palikoiden lisääminen ja muokkaus toimii
- Esivalmistelut liikkumista varten
|
Rev | Line | |
---|
[4535] | 1 | |
---|
| 2 | namespace CastleMaster.Physics |
---|
| 3 | { |
---|
| 4 | public class BoundingRectangle |
---|
| 5 | { |
---|
| 6 | private float x0, z0, x1, z1; |
---|
| 7 | private BoundingRectangleOwner owner; |
---|
| 8 | |
---|
| 9 | public BoundingRectangle(float x0, float z0, float x1, float z1, BoundingRectangleOwner owner) |
---|
| 10 | { |
---|
| 11 | this.owner = owner; |
---|
| 12 | this.x0 = x0; |
---|
| 13 | this.z0 = z0; |
---|
| 14 | this.x1 = x1; |
---|
| 15 | this.z1 = z1; |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | public float XLeft { get { return x0; } } |
---|
| 19 | |
---|
| 20 | public float XRight { get { return x1; } } |
---|
| 21 | |
---|
| 22 | public float ZFar { get { return z0; } } |
---|
| 23 | |
---|
| 24 | public float ZNear { get { return z1; } } |
---|
| 25 | |
---|
| 26 | public BoundingRectangleOwner Owner { get { return owner; } } |
---|
| 27 | |
---|
| 28 | public BoundingRectangle Update(float x0, float z0, float x1, float z1) |
---|
| 29 | { |
---|
| 30 | this.x0 = x0; |
---|
| 31 | this.z0 = z0; |
---|
| 32 | this.x1 = x1; |
---|
| 33 | this.z1 = z1; |
---|
| 34 | |
---|
| 35 | return this; |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | public bool Intersects(float x0, float z0, float x1, float z1) |
---|
| 39 | { |
---|
| 40 | if (x0 >= this.x1 && x1 <= this.x0 && z0 >= this.z1 && z1 <= this.z0) return false; |
---|
| 41 | return true; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | public bool Intersects(BoundingRectangle br) |
---|
| 45 | { |
---|
| 46 | return Intersects(br.x0, br.z0, br.x1, br.z1); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | } |
---|
| 50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.