private void ugor() { Szamol(); jump--; lebeg = true; if (jump == 0) { gravitacio = true; } Blok TLeftBlok; Blok TRightBlok; Blok BLeftBlok; Blok BRightBlok; if (ButtomGrid - 3 < 0) { TLeftBlok = new Blok_levego(); TRightBlok = new Blok_levego(); } else { TLeftBlok = level.BlokList[ButtomGrid - 3][LeftGrid]; TRightBlok = level.BlokList[ButtomGrid - 3][RightGrid]; } BLeftBlok = level.BlokList[ButtomGrid][LeftGrid]; BRightBlok = level.BlokList[ButtomGrid][RightGrid]; //Fejelésre aktiválódó blokk if (TLeftBlok.Trukkos == 2) { TLeftBlok.Aktivalt = true; trukkos(ButtomGrid - 3, LeftGrid); } if (TRightBlok.Trukkos == 2) { TRightBlok.Aktivalt = true; trukkos(ButtomGrid - 3, RightGrid); } //Fejelés if (TLeftBlok.Szilard || TRightBlok.Szilard) { Objektum.Margin = new Thickness(ObjectLeft, (ButtomGrid - 2) * Bloksize + 1, 0, 0); //0.4 = 2 * 0.2 Music.PlayJump(); jump = 0; gravitacio = true; return; } //Pálya fölé ugrás if (ObjectTop > 1) { Objektum.Margin = new Thickness(ObjectLeft, ObjectTop - Sebesseg / 1.5 / 2, 0, 0); Music.PlayJump(); } }
private void LoadMap(string[] nev) { int o = 0; while (o < 10) { string sor = nev[o]; string[] blok = sor.Split(';'); if (o == 0) { hossz = blok.Length; } int i = 0; List <Blok> sorlista = new List <Blok>(); foreach (string item in blok) { if (o == 0) { ColumnDefinition a = new ColumnDefinition(); a.Width = new GridLength(Meretezes.blok); racs.ColumnDefinitions.Add(a); } if (item == "k") { Blok b = new Blok_ko(o, i); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "f") { Blok b = new Blok_fold(o, i); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "l") { Blok b = new Blok_levego(o, i); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "c") { Blok b = new Blok_checkpoint(o, i); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "t") { Blok b = new Blokk_trukkosFold(o, i); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "e") { Blok b = new BlokTrukkos(o, i, new Blok_fold(), new Blok_levego(), 2); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "a") { Blok b = new BlokTrukkos(o, i, new Blok_ko(), new Blok_levego(), 2); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "m") { Blok b = new BlokTrukkos(o, i, new Blok_levego(), new Blok_fold(), 2); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "h") { Blok b = new Blokk_trukkosKo(o, i); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "1") { Blok b = new Blok_vege(o, i, 1); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "2") { Blok b = new Blok_vege(o, i, 2); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "3") { Blok b = new Blok_vege(o, i, 3); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } else if (item == "4") { Blok b = new Blok_vege(o, i, 4); Border c = b.border(); racs.Children.Add(c); sorlista.Add(b); } i++; } BlokList.Add(sorlista); o++; } }
private void Jobbra_mozog() { Szamol(); jobbra = false; double LevelLeft = grid.Margin.Left; Blok RightBlok; if (ButtomGrid - 1 < 0 || LeftGrid + 1 == level.BlokList[ButtomGrid].Count) { RightBlok = new Blok_levego(); } else if (lebeg) { RightBlok = level.BlokList[ButtomGrid][LeftGrid + 1]; } else { RightBlok = level.BlokList[ButtomGrid - 1][LeftGrid + 1]; } Blok RightBlokUP; if (ButtomGrid - 2 < 0 || LeftGrid + 1 == level.BlokList[ButtomGrid].Count) { RightBlokUP = new Blok_levego(); } else if (lebeg) { RightBlokUP = level.BlokList[ButtomGrid - 1][LeftGrid + 1]; } else { RightBlokUP = level.BlokList[ButtomGrid - 2][LeftGrid + 1]; } Blok RightBlokUPUP; if (ButtomGrid - 3 < 0 || LeftGrid + 1 == level.BlokList[ButtomGrid].Count) { RightBlokUPUP = new Blok_levego(); } else if (lebeg) { RightBlokUPUP = level.BlokList[ButtomGrid - 2][LeftGrid + 1]; } else { RightBlokUPUP = level.BlokList[ButtomGrid - 3][LeftGrid + 1]; } #region csapda if (lebeg) { if (ObjectLeft - Sebesseg < LeftGrid * Bloksize && (!RightBlok.Aktivalt || !RightBlokUP.Aktivalt || !RightBlokUPUP.Aktivalt) && (RightBlok.Trukkos != 2 || RightBlokUP.Trukkos != 2 || RightBlokUPUP.Trukkos != 2)) { RightBlok.Aktivalt = true; RightBlokUP.Aktivalt = true; RightBlokUPUP.Aktivalt = true; if (RightBlok.Trukkos == 8 || RightBlokUP.Trukkos == 8 || RightBlokUPUP.Trukkos == 8) { Character.SavePosition(ObjectLeft, ObjectTop, grid.Margin.Left); } if (RightBlok.Trukkos == 9 || RightBlokUP.Trukkos == 9 || RightBlokUPUP.Trukkos == 9) { NextLevel(); } if (RightBlok.Trukkos == 3 || RightBlokUP.Trukkos == 3 || RightBlokUPUP.Trukkos == 3) { Meghaltal(); } trukkos(ButtomGrid, LeftGrid + 1); trukkos(ButtomGrid - 1, LeftGrid + 1); trukkos(ButtomGrid - 2, LeftGrid + 1); } } else { if (ObjectLeft - Sebesseg < LeftGrid * Bloksize && (!RightBlok.Aktivalt || !RightBlokUP.Aktivalt) && (RightBlok.Trukkos != 2 || RightBlokUP.Trukkos != 2)) { RightBlok.Aktivalt = true; RightBlokUP.Aktivalt = true; if (RightBlok.Trukkos == 8 || RightBlokUP.Trukkos == 8) { Character.SavePosition(ObjectLeft, ObjectTop, grid.Margin.Left); } if (RightBlok.Trukkos == 9 || RightBlokUP.Trukkos == 9) { NextLevel(); } if (RightBlok.Trukkos == 3 || RightBlokUP.Trukkos == 3) { Meghaltal(); } trukkos(ButtomGrid - 1, LeftGrid + 1); trukkos(ButtomGrid - 2, LeftGrid + 1); } } #endregion if (lebeg) { if (ObjectRight + Sebesseg > (LeftGrid + 1) * Bloksize && (RightBlok.Szilard || RightBlokUP.Szilard || RightBlokUPUP.Szilard)) { Objektum.Margin = new Thickness(((LeftGrid + 1) * Bloksize) - 1 - Objektum.Width, ObjectTop, 0, 0); return; } } else { if (ObjectRight + Sebesseg > (LeftGrid + 1) * Bloksize && (RightBlok.Szilard || RightBlokUP.Szilard)) { Objektum.Margin = new Thickness(((LeftGrid + 1) * Bloksize) - 1 - Objektum.Width, ObjectTop, 0, 0); return; } } if (ObjectRight > Meretezes.ablakhossz - Meretezes.ablakhossz / 4 - LevelLeft && (LevelLeft * -1) + Sebesseg < ((level.BlokList[ButtomGrid].Count) * Bloksize) - Meretezes.ablakhossz) { grid.Margin = new Thickness(LevelLeft - Sebesseg, 0, 0, 0); Objektum.Margin = new Thickness(ObjectLeft + Sebesseg, ObjectTop, 0, 0); } else if (ObjectRight < Meretezes.ablakhossz - 100 - LevelLeft) { Objektum.Margin = new Thickness(ObjectLeft + Sebesseg, ObjectTop, 0, 0); } }
private void Balra_mozog() { Szamol(); balra = false; double LevelLeft = grid.Margin.Left; Blok LeftBlok; if (ButtomGrid - 1 < 0 || LeftGrid - 1 < 0) { LeftBlok = new Blok_levego(); } else if (lebeg) { LeftBlok = level.BlokList[ButtomGrid][LeftGrid - 1]; } else { LeftBlok = level.BlokList[ButtomGrid - 1][LeftGrid - 1]; } Blok LeftBlokUP; if (ButtomGrid - 2 < 0 || LeftGrid - 1 < 0) { LeftBlokUP = new Blok_levego(); } else if (lebeg) { LeftBlokUP = level.BlokList[ButtomGrid - 1][LeftGrid - 1]; } else { LeftBlokUP = level.BlokList[ButtomGrid - 2][LeftGrid - 1]; } Blok LeftBlokUPUP; if (ButtomGrid - 3 < 0 || LeftGrid - 1 < 0) { LeftBlokUPUP = new Blok_levego(); } else if (lebeg) { LeftBlokUPUP = level.BlokList[ButtomGrid - 2][LeftGrid - 1]; } else { LeftBlokUPUP = level.BlokList[ButtomGrid - 3][LeftGrid - 1]; } #region csapda if (lebeg) { if (ObjectLeft - Sebesseg < LeftGrid * Bloksize && (!LeftBlok.Aktivalt || !LeftBlokUP.Aktivalt || !LeftBlokUPUP.Aktivalt) && (LeftBlok.Trukkos != 2 || LeftBlokUP.Trukkos != 2 || LeftBlokUPUP.Trukkos != 2)) { LeftBlok.Aktivalt = true; LeftBlokUP.Aktivalt = true; LeftBlokUPUP.Aktivalt = true; if (LeftBlok.Trukkos == 8 || LeftBlokUP.Trukkos == 8 || LeftBlokUPUP.Trukkos == 8) { Character.SavePosition(ObjectLeft, ObjectTop, grid.Margin.Left); } if (LeftBlok.Trukkos == 9 || LeftBlokUP.Trukkos == 9 || LeftBlokUPUP.Trukkos == 9) { NextLevel(); } if (LeftBlok.Trukkos == 3 || LeftBlokUP.Trukkos == 3 || LeftBlokUPUP.Trukkos == 3) { Meghaltal(); } trukkos(ButtomGrid - 1, LeftGrid - 1); trukkos(ButtomGrid - 2, LeftGrid - 1); trukkos(ButtomGrid, LeftGrid - 1); } } else { if (ObjectLeft - Sebesseg < LeftGrid * Bloksize && (!LeftBlok.Aktivalt || !LeftBlokUP.Aktivalt) && (LeftBlok.Trukkos != 2 || LeftBlokUP.Trukkos != 2)) { LeftBlok.Aktivalt = true; LeftBlokUP.Aktivalt = true; if (LeftBlok.Trukkos == 8 || LeftBlokUP.Trukkos == 8) { Character.SavePosition(ObjectLeft, ObjectTop, grid.Margin.Left); } if (LeftBlok.Trukkos == 9 || LeftBlokUP.Trukkos == 9 || LeftBlokUPUP.Trukkos == 9) { NextLevel(); } if (LeftBlok.Trukkos == 3 || LeftBlokUP.Trukkos == 3 || LeftBlokUPUP.Trukkos == 3) { Meghaltal(); } trukkos(ButtomGrid - 1, LeftGrid - 1); trukkos(ButtomGrid - 2, LeftGrid - 1); } } #endregion if (lebeg) { if (ObjectLeft - Sebesseg < LeftGrid * Bloksize && (LeftBlok.Szilard || LeftBlokUP.Szilard || LeftBlokUPUP.Szilard)) { Objektum.Margin = new Thickness(LeftGrid * Bloksize + 1, ObjectTop, 0, 0); return; } } else { if (ObjectLeft - Sebesseg < LeftGrid * Bloksize && (LeftBlok.Szilard || LeftBlokUP.Szilard)) { Objektum.Margin = new Thickness(LeftGrid * Bloksize + 1, ObjectTop, 0, 0); return; } } if (ObjectLeft - 50 < LevelLeft * -1) { return; } else if (ObjectLeft > 30) { Objektum.Margin = new Thickness(ObjectLeft - Sebesseg, ObjectTop, 0, 0); } }