public override void Update(GameTime gameTime) { textboxHandler.Update(); textboxtext1 = textboxHandler.getTextbox(0).getText(); textboxtext2 = textboxHandler.getTextbox(1).getText(); prevmouseState = mouseState; mouseState = Mouse.GetState(); mouseX = mouseState.X; mouseY = mouseState.Y; //종료버튼 클릭 if (mouseState.LeftButton == ButtonState.Pressed && prevmouseState.LeftButton == ButtonState.Released) { if (new Rectangle(1120, 30, 84, 90).Contains(mouseX, mouseY)) { if (isHelp) { isHelp = !isHelp; } else { game.Exit(); } } } //시작버튼 클릭 if (mouseState.LeftButton == ButtonState.Pressed && prevmouseState.LeftButton == ButtonState.Released) { if (new Rectangle(400, 600, 101, 109).Contains(mouseX, mouseY)) { GameScene.isMode = true; count = !count; } } if (mouseState.RightButton == ButtonState.Pressed && prevmouseState.RightButton == ButtonState.Released) { if (new Rectangle(400, 600, 101, 109).Contains(mouseX, mouseY)) { GameScene.isMode = false; if (!textboxtext1.Equals("")) { String insert = "select * from bread where id ='" + textboxtext1 + "' and pw ='" + textboxtext2 + "'"; MySqlCommand cmd = new MySqlCommand(insert, Game1.conn); cmd.ExecuteNonQuery(); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { GameScene.player.Point = Int32.Parse(rdr["point"].ToString()); GameScene.player.BreadCount = Int32.Parse(rdr["bread"].ToString()); } rdr.Close(); } count = !count; } } //게임방법버튼 클릭 if (mouseState.LeftButton == ButtonState.Pressed && prevmouseState.LeftButton == ButtonState.Released) { if (new Rectangle(640, 600, 102, 109).Contains(mouseX, mouseY)) { isHelp = !isHelp; } } if (count) { counter += gameTime.ElapsedGameTime.TotalSeconds; if (counter >= 3) { count = !count; Scene.targetScreen = Scenes.GameScene; } } base.Update(gameTime); }
public override void Update(GameTime gameTime) { prevmouseState = mouseState; mouseState = Mouse.GetState(); mouseX = mouseState.X; mouseY = mouseState.Y; if (isRank) { if (mouseState.LeftButton == ButtonState.Pressed && prevmouseState.LeftButton == ButtonState.Released) { Scene.targetScreen = Scenes.MenuScene; isRank = false; isFIrst = false; } } if (mouseState.LeftButton == ButtonState.Pressed && prevmouseState.LeftButton == ButtonState.Released) { if (new Rectangle(1140, 0, 60, 60).Contains(mouseX, mouseY)) { Scene.targetScreen = Scenes.GameScene; } } if (mouseState.LeftButton == ButtonState.Pressed && prevmouseState.LeftButton == ButtonState.Released) { if (new Rectangle(400, 200, 400, 80).Contains(mouseX, mouseY)) { if (!textboxtext1.Equals("")) { String insert = "select * from bread where id ='" + textboxtext1 + "'"; MySqlCommand cmd = new MySqlCommand(insert, Game1.conn); cmd.ExecuteNonQuery(); MySqlDataReader rdr = cmd.ExecuteReader(); if (!rdr.Read()) { if (!textboxtext1.Equals("")) { rdr.Close(); insert = "insert into bread(id, bread, point, pw) values('" + textboxtext1 + "', " + GameScene.player.BreadCount + "," + GameScene.player.Point + ",'" + textboxtext2 + "');"; cmd = new MySqlCommand(insert, Game1.conn); cmd.ExecuteNonQuery(); GameScene.player.BreadCount = 0; GameScene.player.Point = 0; } } if (!rdr.IsClosed) { rdr.Close(); } } isRank = true; } } if (mouseState.LeftButton == ButtonState.Pressed && prevmouseState.LeftButton == ButtonState.Released) { if (new Rectangle(400, 360, 400, 80).Contains(mouseX, mouseY)) { Scene.targetScreen = Scenes.MenuScene; } } if (mouseState.LeftButton == ButtonState.Pressed && prevmouseState.LeftButton == ButtonState.Released) { if (new Rectangle(400, 480, 400, 80).Contains(mouseX, mouseY)) { Scene.targetScreen = Scenes.GameScene; } } textboxHandler.Update(); textboxtext1 = textboxHandler.getTextbox(0).getText(); textboxtext2 = textboxHandler.getTextbox(1).getText(); }