public Map(List <Puyo> lp, int xShift, int yShift) { this.xShift = xShift; this.yShift = yShift; this.elapse = 70; this.elapseCounter = 0; this.combo = 0; this.frame = 1; this.canMouve = true; this.bAnimationComboMode = false; this.bCanPuyoFirstGoDown = false; this.bCanPuyoSecondGoDown = false; this.bPuyoFirstAdded = false; this.bPuyoSecondAdded = false; this.fallingSpeed = 40; this.counter = 0; pixelElapse = 32; pixelElapseCounterFirstPuyo = 0; pixelElapseCounterSecondPuyo = 0; listOjamaPuyo = new List <int>(); for (int i = 0; i < 5; i++) { this.listOjamaPuyo.Add(0); } listePuyo = new List <Puyo>(); foreach (Puyo p in lp) { Puyo puyo = new Puyo(p.x, p.y, p.color); listePuyo.Add(puyo); } //this.listePuyo = lp; this.listePuyoToErase = new List <List <Puyo> >(); matrixPuyoColor = new int[NOMBREPUYOX, NOMBREPUYOY]; matrixPuyoSharp = new int[NOMBREPUYOX, NOMBREPUYOY]; matrixPuyoChecked = new int[NOMBREPUYOX, NOMBREPUYOY]; matrixElapseCounter = new int[NOMBREPUYOX, NOMBREPUYOY]; for (int i = 0; i < NOMBREPUYOX; i++) { for (int j = 0; j < NOMBREPUYOY; j++) { matrixPuyoColor[i, j] = -1; matrixPuyoSharp[i, j] = -1; } } listOP = new ListOjamaPuyo(); this.nbOjamaPuyo = 0; // number of OjamaPuyos that this "map" has newTurn(); }
private void newTurn() { this.puyoFirst = listePuyo.First(); this.listePuyo.RemoveAt(0); this.puyoSecond = listePuyo.First(); this.listePuyo.RemoveAt(0); this.canMouve = true; }
private int checkTheEnd(Puyo p) { int i = p.y; while (i < NOMBREPUYOY - 1 && matrixPuyoColor[p.x, i + 1] == -1) { i++; } return(i); }
private void AscendPuyo(Puyo p) { int y = checkTheEnd(p); /*Animation*/ int i = TAILLEPUYO * (y - p.y); Puyo pAux = p; AddPuyo(new Puyo(pAux.x, y, pAux.color)); }
public bool isContainedIn(Puyo puyo, List <Puyo> lp) { bool contains = false; foreach (Puyo p in lp) { if (!contains && p.x == puyo.x && p.y == puyo.y && p.color == puyo.color) { contains = true; } } return(contains); }
/* Recursive mode for searching the puyos */ private void AuxCheckPuyoErase(int i, int j, int puyoColor, List <Puyo> lp) { if (i > 0) { if (puyoColor == this.matrixPuyoColor[i - 1, j]) { Puyo p = new Puyo(i - 1, j, puyoColor); if (!isContainedIn(p, lp) && !isContainedIn(p, listePuyoToErase)) { lp.Add(p); AuxCheckPuyoErase(i - 1, j, puyoColor, lp); } } } if (i < NOMBREPUYOX - 1) { if (puyoColor == this.matrixPuyoColor[i + 1, j]) { Puyo p = new Puyo(i + 1, j, puyoColor); if (!isContainedIn(p, lp) && !isContainedIn(p, listePuyoToErase)) { lp.Add(p); AuxCheckPuyoErase(i + 1, j, puyoColor, lp); } } } if (j > 0) { if (puyoColor == this.matrixPuyoColor[i, j - 1]) { Puyo p = new Puyo(i, j - 1, puyoColor); if (!isContainedIn(p, lp) && !isContainedIn(p, listePuyoToErase)) { lp.Add(p); AuxCheckPuyoErase(i, j - 1, puyoColor, lp); } } } if (j < NOMBREPUYOY - 1) { if (puyoColor == this.matrixPuyoColor[i, j + 1]) { Puyo p = new Puyo(i, j + 1, puyoColor); if (!isContainedIn(p, lp) && !isContainedIn(p, listePuyoToErase)) { lp.Add(p); AuxCheckPuyoErase(i, j + 1, puyoColor, lp); } } } }
public void AddPuyo(Puyo puyo) { this.matrixPuyoColor[puyo.x, puyo.y] = puyo.color; }
public void CopyPuyo(Puyo p) { this.x = p.x; this.y = p.y; this.color = p.color; }