Jypeli 10
The simple game programming library
Surfaces.cs
Siirry tämän tiedoston dokumentaatioon.
1using System.Collections.Generic;
2using System.Linq;
3using System.Collections;
4
5namespace Jypeli
6{
10 public struct Surfaces : IEnumerable<Surface>
11 {
12 internal Surface l, r, t, b;
13
18 {
19 get { return l; }
20 }
21
26 {
27 get { return r; }
28 }
29
33 public Surface Top
34 {
35 get { return t; }
36 }
37
42 {
43 get { return b; }
44 }
45
51 public IEnumerator<Surface> GetEnumerator()
52 {
53 if ( Left != null ) yield return Left;
54 if ( Right != null ) yield return Right;
55 if ( Top != null ) yield return Top;
56 if ( Bottom != null ) yield return Bottom;
57 }
58
64 IEnumerator IEnumerable.GetEnumerator()
65 {
66 if ( Left != null ) yield return Left;
67 if ( Right != null ) yield return Right;
68 if ( Top != null ) yield return Top;
69 if ( Bottom != null ) yield return Bottom;
70 }
71
77 public IEnumerable<Surface> Get( params Direction[] directions )
78 {
79 if ( directions.Contains(Direction.Left) && Left != null ) yield return Left;
80 if ( directions.Contains(Direction.Right) && Right != null ) yield return Right;
81 if ( directions.Contains(Direction.Up) && Top != null ) yield return Top;
82 if ( directions.Contains(Direction.Down) && Bottom != null ) yield return Bottom;
83 }
84 }
85}
Tasainen tai epätasainen pinta.
Definition: Surface.cs:9
Perussuunta tasossa.
Definition: Direction.cs:47
static Direction Up
Suunta ylös.
Definition: Direction.cs:56
static Direction Right
Suunta oikealle.
Definition: Direction.cs:71
static Direction Down
Suunta alas.
Definition: Direction.cs:61
static Direction Left
Suunta vasemmalle.
Definition: Direction.cs:66
Kentän reunat.
Definition: Surfaces.cs:11
Surface r
Definition: Surfaces.cs:12
Surface Top
Yläreuna.
Definition: Surfaces.cs:34
IEnumerable< Surface > Get(params Direction[] directions)
Valikoiva enumeraattori pinnoille.
Definition: Surfaces.cs:77
Surface l
Definition: Surfaces.cs:12
Surface b
Definition: Surfaces.cs:12
Surface Right
Oikea reuna.
Definition: Surfaces.cs:26
Surface Left
Vasen reuna.
Definition: Surfaces.cs:18
Surface t
Definition: Surfaces.cs:12
Surface Bottom
Alareuna.
Definition: Surfaces.cs:42
IEnumerator< Surface > GetEnumerator()
Enumeraattori pinnoille. Mahdollistaa foreach-lauseen käytön.
Definition: Surfaces.cs:51