-
Notifications
You must be signed in to change notification settings - Fork 0
/
BarreLongue.cs
63 lines (59 loc) · 1.79 KB
/
BarreLongue.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace Tetris
{
class BarreLongue : Barre
{
public BarreLongue()
{
this.emplacement = new List<int>() { 4, 5, 6, 7 };
this.couleur = new SolidColorBrush(Couleurs[r.Next(Couleurs.Count)]);
}
public override void Tourner(ref Barre barre, ref Table grille)
{
// Sauvegarde des précédents emplacements
List<int> emplacements = new List<int>();
Barre b = new BarreL();
int precposition = position;
foreach (var emp in barre.emplacement)
{
emplacements.Add(emp);
}
b.emplacement = emplacements;
if (position == 0)
{
if (this.emplacement[0] - 9 > 0)
{
this.emplacement[0] -= 9;
this.emplacement[2] += 9;
this.emplacement[3] += 18;
position++;
}
}
else
{
if (this.emplacement[2] - 9 > 0 && this.emplacement[3] - 18 > 0)
{
this.emplacement[0] += 9;
this.emplacement[2] -= 9;
this.emplacement[3] -= 18;
position = 0;
}
}
// Vérification que le déménagement est correct
if (grille.EmplacementDispo(this))
{
grille.write(ref b.emplacement, this);
}
else
{
this.emplacement = b.emplacement;
this.position = precposition;
}
}
}
}