/// <summary> /// Constructor for Class Sea. /// </summary> /// <param name="game">The Game class for DrawableGameComponent.</param> /// <param name="map">The Sea to be copied.</param> public Sea(Game game, Sea map) : base(game) { path = map.path; WidthPerTile = map.WidthPerTile; HeightPerTile = map.HeightPerTile; totalNodeX = map.totalNodeX; totalNodeY = map.totalNodeY; Tile = new Node[totalNodeY][]; for (int i = 0; i < totalNodeY; i++) { Tile[i] = new Node[totalNodeX]; for (int j = 0; j < totalNodeX; j++) { Tile[i][j] = new Node(map.getNode(i,j)); } } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if ((startCoutingTime == true) && (timeSpan.TotalSeconds > 0) && (finishFlag != 1)) timeSpan -= gameTime.ElapsedGameTime; //update timer if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { switch (_GameState) { case GameState.MainMenu: { // Bagian Menu Utama this.Exit(); break; } case GameState.Setting: { // Bagian Setting _GameState = GameState.MainMenu; break; } case GameState.Help: { // Bagian Help _GameState = GameState.MainMenu; break; } case GameState.ChoosePlay: { // Bagian Pilih jenis permainan _GameState = GameState.MainMenu; break; } case GameState.ChooseLevel: { // Bagian Pilih Level _GameState = GameState.ChoosePlay; break; } case GameState.HumanPlay: { // Bagian Player _GameState = GameState.ChooseLevel; MediaPlayer.Play(mainsound); break; } case GameState.ComputerPlay: { // Bagian Computer _GameState = GameState.ChooseLevel; MediaPlayer.Play(mainsound); break; } case GameState.GameOver: { // Bagian Game Over _GameState = GameState.ChooseLevel; MediaPlayer.Play(mainsound); break; } default: break; } } else { // TODO: Add your update logic here switch (_GameState) { case GameState.MainMenu: { // Bagian Menu Utama startCoutingTime = false; TouchCollection touchStateMain = TouchPanel.GetState(); if ((!touchflag) && (touchStateMain.Count > 0)) { // Kalau ditouch touchflag = true; touchTimer = 5; foreach (TouchLocation t in touchStateMain) { if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= menuPlay.X) && ((t.Position.X <= menuPlay.X + menuPlay.Width))) && ((t.Position.Y >= menuPlay.Y) && ((t.Position.Y <= menuPlay.Y + menuPlay.Height)))) { // Jika menyentuh menu tertentu _GameState = GameState.ChoosePlay; } if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= menuSetting.X) && ((t.Position.X <= menuSetting.X + menuSetting.Width))) && ((t.Position.Y >= menuSetting.Y) && ((t.Position.Y <= menuSetting.Y + menuSetting.Height)))) { // Jika menyentuh menu tertentu _GameState = GameState.Setting; } else if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= menuHelp.X) && ((t.Position.X <= menuHelp.X + menuHelp.Width))) && ((t.Position.Y >= menuHelp.Y) && ((t.Position.Y <= menuHelp.Y + menuHelp.Height)))) { // Jika menyentuh menu tertentu helpCount = 0; _GameState = GameState.Help; } } } else { if (touchTimer == 0) { touchflag = false; } else { touchTimer--; } } break; } case GameState.Help: { // Bagian Help if (startCoutingTime == false) { startCoutingTime = true; timeSpan = TimeSpan.FromMilliseconds(180000); } TouchCollection touchStateMain = TouchPanel.GetState(); if ((!touchflag) && (touchStateMain.Count > 0)) { // Kalau di-touch touchflag = true; touchTimer = 5; foreach (TouchLocation t in touchStateMain) { if ((t.State == TouchLocationState.Pressed) && (t.Position.X >= 720) && (t.Position.X <= 800) && (t.Position.Y >= 400) && (t.Position.Y <= 480)) { helpCount++; if (helpCount == 7) _GameState = GameState.MainMenu; } else if ((t.State == TouchLocationState.Pressed) && (t.Position.X >= 560) && (t.Position.X <= 640) && (t.Position.Y >= 400) && (t.Position.Y <= 480)) { if (helpCount > 0) helpCount--; } } } else { if (touchTimer == 0) { touchflag = false; } else { touchTimer--; } } break; } case GameState.ChoosePlay: { // Bagian Pilih jenis permainan startCoutingTime = false; TouchCollection touchStateMain = TouchPanel.GetState(); if ((!touchflag) && (touchStateMain.Count > 0)) { // Kalau ditouch touchflag = true; touchTimer = 5; foreach (TouchLocation t in touchStateMain) { if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= menuHuman.X) && ((t.Position.X <= menuHuman.X + menuHuman.Width))) && ((t.Position.Y >= menuHuman.Y) && ((t.Position.Y <= menuHuman.Y + menuHuman.Height)))) { // Jika menyentuh menu tertentu play = GameType.Human; _GameState = GameState.ChooseLevel; } else if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= menuComputer.X) && ((t.Position.X <= menuComputer.X + menuComputer.Width))) && ((t.Position.Y >= menuComputer.Y) && ((t.Position.Y <= menuComputer.Y + menuComputer.Height)))) { // Jika menyentuh menu tertentu play = GameType.Computer; _GameState = GameState.ChooseLevel; } } } else { if (touchTimer == 0) { touchflag = false; } else { touchTimer--; } } break; } case GameState.ChooseLevel: { // Bagian Pilih Level if (loading != null) { if (loading.ThreadState == ThreadState.Stopped) { state = 0; moveTimer = 0; posiawal = bestpath.ElementAt(state).PosisiAwal; posiakhir = bestpath.ElementAt(state).PosisiAkhir; _GameState = GameState.ComputerPlay; loading = null; } } else if (animatescrolling) { if (touchxakhir > touchxawal) { statescreen += 20; if (statescreen > statescreenawal + 800) { statescreen = statescreenawal + 800; animatescrolling = false; } } else if (touchxakhir < touchxawal) { statescreen -= 20; if (statescreen < statescreenawal - 800) { statescreen = statescreenawal - 800; animatescrolling = false; } } } else { startCoutingTime = false; TouchCollection touchStateMain = TouchPanel.GetState(); if ((!touchflag) && (touchStateMain.Count > 0)) { foreach (TouchLocation t in touchStateMain) { if (t.State == TouchLocationState.Pressed) { touchxawal = (int)t.Position.X; statescreenawal = statescreen; scrollflag = false; } else if (t.State == TouchLocationState.Moved) { Debug.WriteLine(statescreen); if ((!scrollflag)&&(Math.Abs(t.Position.X - touchxawal) > 20)) scrollflag = true; else if (scrollflag) { statescreen = (int)t.Position.X - touchxawal + statescreenawal; } } else if (t.State == TouchLocationState.Released) { if (scrollflag) { if (Math.Abs(t.Position.X - touchxawal) > 200) { if ((statescreenawal != 0) && ((int)t.Position.X > touchxawal)) { animatescrolling = true; touchxakhir = (int)t.Position.X; } else if ((statescreenawal != ((mapLevel.Count / 18) * -800)) && ((int)t.Position.X < touchxawal)) { animatescrolling = true; touchxakhir = (int)t.Position.X; } else { statescreen = statescreenawal; } } else { statescreen = statescreenawal; } } else { for (int k = 0; k <= mapLevel.Count / 18; ++k) { int tempbatas2 = (k == (mapLevel.Count / 18)) ? mapLevel.Count % 18 : 18; for (int j = 0; j <= tempbatas2 / 6; ++j) { int tempbatas = (j == (mapLevel.Count / 6)) ? mapLevel.Count % 6 : 6; for (int i = 0; i < tempbatas; ++i) { if (((t.Position.X >= (k * 800) + statescreen + 60 + i * 115) && ((t.Position.X <= (k * 800) + statescreen + 60 + i * 115 + 100))) && ((t.Position.Y >= 110 + j * 110) && ((t.Position.Y <= 110 + j * 110 + 100)))) { // Jika menyentuh menu tertentu level = (k * 18) + j * 6 + i + 1; //ditambah 1 karena level mulai dari 1, bukan dari 0 if (level <= maxLevel) { MediaPlayer.Play(playsound); map = new Sea(this, widthPerTile, heightPerTile, sizeX, sizeY, mapLevel[level]); map.Initialize(); map.LoadContent(out boats); if (play == GameType.Human) { lockboat = -1; timeSpan = TimeSpan.FromMilliseconds(1000); _GameState = GameState.HumanPlay; } else if (play == GameType.Computer) { loading = new Thread(new ParameterizedThreadStart(getPath)); loading.Start(flagpath); countLoader = 0; } } } } } } } } } } else { if (touchTimer == 0) { touchflag = false; } else { touchTimer--; } } } break; } case GameState.HumanPlay: { // Bagian Player if (startCoutingTime == false) { startCoutingTime = true; timeSpan = TimeSpan.FromMilliseconds(map.TIME); } if (timeSpan.TotalSeconds == 0) { _GameState = GameState.GameOver; } if (finishFlag == 1) { int x = (int)boats.ElementAt(0).Position.X; int y = (int)boats.ElementAt(0).Position.Y; if (x != (widthPerTile * (sizeX + 1)) - boats.ElementAt(0).Size.X) { x += speed; if (x > (widthPerTile * (sizeX + 1)) - (int)boats.ElementAt(0).Size.X) x = (widthPerTile * (sizeX + 1)) - (int)boats.ElementAt(0).Size.X; boats.ElementAt(0).Position = new Vector2(x, y); } else { if (level == maxLevel) { maxLevel++; } finishPopUp = 1; //Finish touch listener TouchCollection touchStateMain = TouchPanel.GetState(); if ((!touchflag) && (touchStateMain.Count > 0)) { touchflag = true; touchTimer = 5; foreach (TouchLocation t in touchStateMain) { if ((t.State == TouchLocationState.Pressed) && (t.Position.X >= 120) && (t.Position.X <= 200) && (t.Position.Y >= 320) && (t.Position.Y <= 400)) { //replay finishFlag = 0; finishPopUp = 0; moveCount = 0; moveTimer = 0; startCoutingTime = false; map = new Sea(this, widthPerTile, heightPerTile, sizeX, sizeY, mapLevel[level]); map.Initialize(); map.LoadContent(out boats); } if ((t.State == TouchLocationState.Pressed) && (t.Position.X >= 220) && (t.Position.X <= 300) && (t.Position.Y >= 320) && (t.Position.Y <= 400)) { //choose level MediaPlayer.Play(mainsound); _GameState = GameState.ChooseLevel; } if ((t.State == TouchLocationState.Pressed) && (t.Position.X >= 320) && (t.Position.X <= 400) && (t.Position.Y >= 320) && (t.Position.Y <= 400)) { //next level if (level != mapLevel.Count()) { level++; finishFlag = 0; finishPopUp = 0; moveCount = 0; moveTimer = 0; startCoutingTime = false; map = new Sea(this, widthPerTile, heightPerTile, sizeX, sizeY, mapLevel[level]); map.Initialize(); map.LoadContent(out boats); } else { MediaPlayer.Play(mainsound); _GameState = GameState.ChooseLevel; } } } } else { if (touchTimer == 0) touchflag = false; else touchTimer--; } } } else { TouchCollection touchStateMain = TouchPanel.GetState(); if ((!touchflag) && (touchStateMain.Count > 0)) { foreach (TouchLocation t in touchStateMain) { if ((lockboat!=-1)&&(t.State == TouchLocationState.Released)) { boats.ElementAt(lockboat).Position = new Vector2((int)((boats.ElementAt(lockboat).Position.X + (widthPerTile / 2)) / widthPerTile) * widthPerTile, (int)((boats.ElementAt(lockboat).Position.Y + (heightPerTile / 2)) / heightPerTile) * heightPerTile); if ((boats.ElementAt(lockboat).Arah == Boat.Orientation.Left) || (boats.ElementAt(lockboat).Arah == Boat.Orientation.Right)) { for (int k = 0; k < (int)(boats.ElementAt(lockboat).Size.X / widthPerTile); ++k) { map.SetStatus((int)(boats.ElementAt(lockboat).Position.X / widthPerTile) + k, (int)(boats.ElementAt(lockboat).Position.Y / heightPerTile), 1); } posAkhirX = (int)(boats.ElementAt(lockboat).Position.X / widthPerTile); int temp = Math.Abs(posAkhirX - posAwalX); moveCount += temp; } else if ((boats.ElementAt(lockboat).Arah == Boat.Orientation.Top) || (boats.ElementAt(lockboat).Arah == Boat.Orientation.Bottom)) { for (int k = 0; k < (int)(boats.ElementAt(lockboat).Size.Y / heightPerTile); ++k) { map.SetStatus((int)(boats.ElementAt(lockboat).Position.X / widthPerTile), (int)(boats.ElementAt(lockboat).Position.Y / heightPerTile) + k, 1); } posAkhirY = (int)(boats.ElementAt(lockboat).Position.Y / heightPerTile); int temp = Math.Abs(posAkhirY - posAwalY); moveCount += temp; } if (lockboat == 0) { posAkhirX += (int)(boats.ElementAt(lockboat).Size.X / widthPerTile); if (posAkhirX == sizeX) { waktuAwal = TimeSpan.FromMilliseconds(map.TIME); waktuAwal = waktuAwal - timeSpan; finishTime = String.Format("{0}:{1:D2}", waktuAwal.Minutes, waktuAwal.Seconds + 1); finishFlag = 1; currentscore = (300 - moveCount) + (timeSpan.Minutes) * 60 + (timeSpan.Seconds) * 10; if (currentscore > highscore[level - 1]) highscore[level - 1] = currentscore; } } lockboat = -1; } else if (t.State == TouchLocationState.Moved) { if (lockboat == -1) { bool cek = true; int count = 0; foreach (Boat boat in boats) { if ((cek) && ((t.Position.X >= boat.Position.X) && (t.Position.X <= boat.Position.X + boat.Size.X)) && ((t.Position.Y >= boat.Position.Y) && (t.Position.Y <= boat.Position.Y + boat.Size.Y))) { posAwalX = (int)(boat.Position.X) / widthPerTile; posAwalY = (int)(boat.Position.Y) / widthPerTile; cek = false; lockboat = count; offx = (int)(boat.Position.X - t.Position.X); offy = (int)(boat.Position.Y - t.Position.Y); minscroll = -1; maxscroll = 6; if ((boats.ElementAt(lockboat).Arah == Boat.Orientation.Left) || (boats.ElementAt(lockboat).Arah == Boat.Orientation.Right)) { for (int k = 0; k < (int)(boats.ElementAt(lockboat).Size.X / widthPerTile); ++k) { map.SetStatus((int)(boats.ElementAt(lockboat).Position.X / widthPerTile) + k, (int)(boats.ElementAt(lockboat).Position.Y / heightPerTile), 0); } } else if ((boats.ElementAt(lockboat).Arah == Boat.Orientation.Top) || (boats.ElementAt(lockboat).Arah == Boat.Orientation.Bottom)) { for (int k = 0; k < (int)(boats.ElementAt(lockboat).Size.Y / heightPerTile); ++k) { map.SetStatus((int)(boats.ElementAt(lockboat).Position.X / widthPerTile), (int)(boats.ElementAt(lockboat).Position.Y / heightPerTile) + k, 0); } } } count++; } } else { int max = sizeX * widthPerTile; if ((boats.ElementAt(lockboat).Arah == Boat.Orientation.Left) || (boats.ElementAt(lockboat).Arah == Boat.Orientation.Right)) { if ((t.Position.X + offx >= 0) && (t.Position.X + offx <= (max - boats.ElementAt(lockboat).Size.X))) { if (((int)((t.Position.X + offx + (widthPerTile / 2)) / widthPerTile) > minscroll) && ((int)((t.Position.X + offx + boats.ElementAt(lockboat).Size.X - (widthPerTile / 2)) / widthPerTile) < maxscroll) && (map.GetStatus((int)((t.Position.X + offx + (widthPerTile / 2)) / widthPerTile), (int)(boats.ElementAt(lockboat).Position.Y / heightPerTile)) == 0) && (map.GetStatus((int)((t.Position.X + offx + boats.ElementAt(lockboat).Size.X - (widthPerTile / 2)) / widthPerTile), (int)(boats.ElementAt(lockboat).Position.Y / heightPerTile)) == 0)) boats.ElementAt(lockboat).Position = new Vector2(t.Position.X + offx, boats.ElementAt(lockboat).Position.Y); else if (t.Position.X + offx < boats.ElementAt(lockboat).Position.X) { colsound.CreateInstance().Play(); minscroll = (int)((t.Position.X + offx + (widthPerTile / 2)) / widthPerTile); } else if (t.Position.X + offx > boats.ElementAt(lockboat).Position.X) { colsound.CreateInstance().Play(); maxscroll = (int)((t.Position.X + offx + (widthPerTile / 2)) / widthPerTile); } } } else if ((boats.ElementAt(lockboat).Arah == Boat.Orientation.Top) || (boats.ElementAt(lockboat).Arah == Boat.Orientation.Bottom)) { if ((t.Position.Y + offy >= 0) && (t.Position.Y + offy <= (max - boats.ElementAt(lockboat).Size.Y))) { if (((int)((t.Position.Y + offy + (heightPerTile / 2)) / heightPerTile) > minscroll) && ((int)((t.Position.Y + offy + boats.ElementAt(lockboat).Size.Y - (heightPerTile / 2)) / heightPerTile) < maxscroll) && (map.GetStatus((int)(boats.ElementAt(lockboat).Position.X / widthPerTile), (int)(t.Position.Y + offy + (heightPerTile / 2)) / heightPerTile) == 0) && (map.GetStatus((int)(boats.ElementAt(lockboat).Position.X / widthPerTile), (int)(t.Position.Y + offy + boats.ElementAt(lockboat).Size.Y - (heightPerTile / 2)) / heightPerTile) == 0)) boats.ElementAt(lockboat).Position = new Vector2(boats.ElementAt(lockboat).Position.X, t.Position.Y + offy); else if (t.Position.Y + offy < boats.ElementAt(lockboat).Position.Y) { colsound.CreateInstance().Play(); minscroll = (int)((t.Position.Y + offy + (heightPerTile / 2)) / heightPerTile); } else if (t.Position.Y + offy > boats.ElementAt(lockboat).Position.Y) { colsound.CreateInstance().Play(); maxscroll = (int)((t.Position.Y + offy + boats.ElementAt(lockboat).Size.Y - (heightPerTile / 2)) / heightPerTile); } } } } } } } else { if (touchTimer == 0) { touchflag = false; } else { touchTimer--; } } } break; } case GameState.ComputerPlay: { // Bagian Computer if (loading != null) { if (loading.ThreadState == ThreadState.Stopped) { state = 0; moveTimer = 0; posiawal = bestpath.ElementAt(state).PosisiAwal; posiakhir = bestpath.ElementAt(state).PosisiAkhir; loading = null; } } else if (finishFlag == 1) { int x = (int)boats.ElementAt(0).Position.X; int y = (int)boats.ElementAt(0).Position.Y; if (x != (widthPerTile * (sizeX + 1)) - boats.ElementAt(0).Size.X) { x += speed; if (x > (widthPerTile * (sizeX + 1)) - (int)boats.ElementAt(0).Size.X) x = (widthPerTile * (sizeX + 1)) - (int)boats.ElementAt(0).Size.X; boats.ElementAt(0).Position = new Vector2(x, y); } else { finishPopUp = 1; //Finish touch listener TouchCollection touchStateMain = TouchPanel.GetState(); if ((!touchflag) && (touchStateMain.Count > 0)) { touchflag = true; touchTimer = 5; foreach (TouchLocation t in touchStateMain) { if ((t.State == TouchLocationState.Pressed) && (t.Position.X >= 120) && (t.Position.X <= 200) && (t.Position.Y >= 270) && (t.Position.Y <= 350)) { //replay finishFlag = 0; finishPopUp = 0; moveCount = 0; map = new Sea(this, widthPerTile, heightPerTile, sizeX, sizeY, mapLevel[level]); map.Initialize(); map.LoadContent(out boats); state = 0; moveTimer = 0; posiawal = bestpath.ElementAt(state).PosisiAwal; posiakhir = bestpath.ElementAt(state).PosisiAkhir; } if ((t.State == TouchLocationState.Pressed) && (t.Position.X >= 220) && (t.Position.X <= 300) && (t.Position.Y >= 270) && (t.Position.Y <= 350)) { //choose level MediaPlayer.Play(mainsound); _GameState = GameState.ChooseLevel; } if ((t.State == TouchLocationState.Pressed) && (t.Position.X >= 320) && (t.Position.X <= 400) && (t.Position.Y >= 270) && (t.Position.Y <= 350)) { //next level if (level < maxLevel) { level++; finishFlag = 0; finishPopUp = 0; moveCount = 0; moveTimer = 0; startCoutingTime = false; map = new Sea(this, widthPerTile, heightPerTile, sizeX, sizeY, mapLevel[level]); map.Initialize(); map.LoadContent(out boats); loading = new Thread(new ParameterizedThreadStart(getPath)); loading.Start(flagpath); countLoader = 0; } else { MediaPlayer.Play(mainsound); _GameState = GameState.ChooseLevel; } } } } else { if (touchTimer == 0) touchflag = false; else touchTimer--; } } } else if (state < bestpath.Count()) { moveTimer++; if (moveTimer == 1) { moveTimer = 0; if (posiawal == posiakhir) { state++; moveCount++; if (state < bestpath.Count()) { posiawal = bestpath.ElementAt(state).PosisiAwal; posiakhir = bestpath.ElementAt(state).PosisiAkhir; } else { finishFlag = 1; } } else if (posiawal.Y == posiakhir.Y) { if (posiawal.X < posiakhir.X) posiawal.X = (posiawal.X + speed > posiakhir.X)? posiakhir.X : posiawal.X + speed; else posiawal.X = (posiawal.X - speed < posiakhir.X) ? posiakhir.X : posiawal.X - speed; } else if (posiawal.X == posiakhir.X) { if (posiawal.Y < posiakhir.Y) posiawal.Y = (posiawal.Y + speed > posiakhir.Y) ? posiakhir.Y : posiawal.Y + speed; else posiawal.Y = (posiawal.Y - speed < posiakhir.Y) ? posiakhir.Y : posiawal.Y - speed; } if (state < bestpath.Count()) boats.ElementAt(bestpath.ElementAt(state).Boat).Position = posiawal; } } break; } case GameState.GameOver: { TouchCollection touchStateMain = TouchPanel.GetState(); if ((!touchflag) && (touchStateMain.Count > 0)) { // Kalau di-touch touchflag = true; touchTimer = 5; foreach (TouchLocation t in touchStateMain) { if ((t.State == TouchLocationState.Pressed) && (t.Position.X >= 720) && (t.Position.X <= 800) && (t.Position.Y >= 400) && (t.Position.Y <= 480)) { _GameState = GameState.ChooseLevel; } } } else { if (touchTimer == 0) touchflag = false; else touchTimer--; } break; } case GameState.Setting: { TouchCollection touchStateMain = TouchPanel.GetState(); if ((!touchflag) && (touchStateMain.Count > 0)) { touchflag = true; touchTimer = 5; foreach (TouchLocation t in touchStateMain) { if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= pathButton.X) && ((t.Position.X <= pathButton.X + pathButton.Width))) && ((t.Position.Y >= pathButton.Y) && ((t.Position.Y <= pathButton.Y + pathButton.Height)))) { // Jika menyentuh menu tertentu flagpath += 1; flagpath %= 2; } else if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= defPos.X) && ((t.Position.X <= defPos.X + defPos.Width))) && ((t.Position.Y >= defPos.Y) && ((t.Position.Y <= defPos.Y + defPos.Height)))) { // Jika menyentuh menu tertentu screenflag = 3; speed = 7; flagpath = 1; switch (screenflag) { case 0: { widthPerTile = 60; heightPerTile = 60; break; } case 1: { widthPerTile = 80; heightPerTile = 60; break; } case 2: { widthPerTile = 60; heightPerTile = 80; break; } case 3: { widthPerTile = 80; heightPerTile = 80; break; } case 4: { widthPerTile = 100; heightPerTile = 80; break; } case 5: { widthPerTile = 120; heightPerTile = 80; break; } default: break; } } else if (((t.State == TouchLocationState.Moved) || (t.State == TouchLocationState.Pressed)) && ((t.Position.X >= 130) && ((t.Position.X <= 130 + 425))) && ((t.Position.Y >= 183) && ((t.Position.Y <= 183 + 60)))) { screenflag = ((int)t.Position.X - 100) / 80; switch (screenflag) { case 0: { widthPerTile = 60; heightPerTile = 60; break; } case 1: { widthPerTile = 80; heightPerTile = 60; break; } case 2: { widthPerTile = 60; heightPerTile = 80; break; } case 3: { widthPerTile = 80; heightPerTile = 80; break; } case 4: { widthPerTile = 100; heightPerTile = 80; break; } case 5: { widthPerTile = 120; heightPerTile = 80; break; } default: break; } } else if (((t.State == TouchLocationState.Moved) || (t.State == TouchLocationState.Pressed)) && ((t.Position.X >= 130) && ((t.Position.X <= 130 + 425))) && ((t.Position.Y >= 333) && ((t.Position.Y <= 333 + 60)))) { speed = (((int)t.Position.X - 120) / 40) + 4; } else if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= 60) && ((t.Position.X <= 60 + 60))) && ((t.Position.Y >= 183) && ((t.Position.Y <= 183 + 60)))) { if (screenflag > 0) { screenflag--; switch (screenflag) { case 0: { widthPerTile = 60; heightPerTile = 60; break; } case 1: { widthPerTile = 80; heightPerTile = 60; break; } case 2: { widthPerTile = 60; heightPerTile = 80; break; } case 3: { widthPerTile = 80; heightPerTile = 80; break; } case 4: { widthPerTile = 100; heightPerTile = 80; break; } case 5: { widthPerTile = 120; heightPerTile = 80; break; } default: break; } } } else if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= 565) && ((t.Position.X <= 565 + 60))) && ((t.Position.Y >= 183) && ((t.Position.Y <= 183 + 60)))) { if (screenflag < 5) { screenflag++; switch (screenflag) { case 0: { widthPerTile = 60; heightPerTile = 60; break; } case 1: { widthPerTile = 80; heightPerTile = 60; break; } case 2: { widthPerTile = 60; heightPerTile = 80; break; } case 3: { widthPerTile = 80; heightPerTile = 80; break; } case 4: { widthPerTile = 100; heightPerTile = 80; break; } case 5: { widthPerTile = 120; heightPerTile = 80; break; } default: break; } } } else if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= 60) && ((t.Position.X <= 60 + 60))) && ((t.Position.Y >= 333) && ((t.Position.Y <= 333 + 60)))) { if (speed > 4) { speed--; } } else if ((t.State == TouchLocationState.Pressed) && ((t.Position.X >= 565) && ((t.Position.X <= 565 + 60))) && ((t.Position.Y >= 333) && ((t.Position.Y <= 333 + 60)))) { if (speed < 14) { speed++; } } } } else { if (touchTimer == 0) touchflag = false; else touchTimer--; } break; } default: break; } } base.Update(gameTime); }