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