private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("帐号、密码不能为空!"); return; } SqlConnection con = new SqlConnection(); con.ConnectionString = @"server=DESKTOP-URK2BE5\SQLEXPRESS;database=Sonic;integrated security=true"; try { con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "select * from Player where name = '" + textBox1.Text + "'"; SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (!dr.HasRows) { MessageBox.Show("帐号不存在!"); } else { if (textBox2.Text == dr.GetString(2)) { 主界面 f3 = new 主界面(this, dr.GetString(0), dr.GetString(1)); this.Hide(); f3.Show(); } else { MessageBox.Show("密码错误!"); } } dr.Close(); con.Close(); return; } catch (SqlException SQL) { MessageBox.Show(SQL.Message); return; } }
public 游戏(主界面 f, String id, int g, int pr1, int pr2, int pr3, int l, int o) { InitializeComponent(); fmain = f; ID = id; goal = g; prop1 = pr1; prop2 = pr2; prop3 = pr3; level = l; ord = o; p1 = brr1.Location; p2 = brr2.Location; p3 = brr3.Location; //背景初始化 back[0] = new Bitmap[2]; back[0][0] = new Bitmap(Properties.Resources.场景1_1); back[0][1] = new Bitmap(Properties.Resources.场景1_2); back[1] = new Bitmap[2]; back[1][0] = new Bitmap(Properties.Resources.场景2_1); back[1][1] = new Bitmap(Properties.Resources.场景2_2); back[2] = new Bitmap[2]; back[2][0] = new Bitmap(Properties.Resources.场景3_1); back[2][1] = new Bitmap(Properties.Resources.场景3_2); //人物右初始化 Bitmap[] rbmp = { new Bitmap(Properties.Resources.走__1_), new Bitmap(Properties.Resources.走__2_), new Bitmap(Properties.Resources.走__3_), new Bitmap(Properties.Resources.走__4_), new Bitmap(Properties.Resources.走__5_), new Bitmap(Properties.Resources.走__6_), new Bitmap(Properties.Resources.跑__1_), new Bitmap(Properties.Resources.跑__2_), new Bitmap(Properties.Resources.跑__3_), new Bitmap(Properties.Resources.跑__4_), new Bitmap(Properties.Resources.状态1__1_), new Bitmap(Properties.Resources.状态1__2_), new Bitmap(Properties.Resources.状态1__3_), new Bitmap(Properties.Resources.状态1__4_), new Bitmap(Properties.Resources.状态1__5_), new Bitmap(Properties.Resources.状态2), new Bitmap(Properties.Resources.跳__1_), new Bitmap(Properties.Resources.跳__2_), new Bitmap(Properties.Resources.跳__3_), new Bitmap(Properties.Resources.跳__4_), new Bitmap(Properties.Resources.跳__5_), new Bitmap(Properties.Resources.跳__6_), new Bitmap(Properties.Resources.跳__5_), new Bitmap(Properties.Resources.跳__4_), new Bitmap(Properties.Resources.跳__3_), new Bitmap(Properties.Resources.跳__2_), new Bitmap(Properties.Resources.跳__11_), }; foreach (Bitmap i in rbmp) { i.MakeTransparent(Color.White); } for (int i = 1; i <= 5; i++) { rrole[i - 1] = new Bitmap[lim[i]]; } for (int i = 0; i < rbmp.Length; i++) { if (i < 6) { rrole[0][i] = rbmp[i]; } else if (i < 10) { rrole[1][i - 6] = rbmp[i]; } else if (i < 15) { rrole[2][i - 10] = rbmp[i]; } else if (i < 16) { rrole[3][i - 15] = rbmp[i]; } else { rrole[4][i - 16] = rbmp[i]; } } Bitmap[] lbmp = { new Bitmap(Properties.Resources.走__7_), new Bitmap(Properties.Resources.走__8_), new Bitmap(Properties.Resources.走__9_), new Bitmap(Properties.Resources.走__10_), new Bitmap(Properties.Resources.走__11_), new Bitmap(Properties.Resources.走__12_), new Bitmap(Properties.Resources.跑__5_), new Bitmap(Properties.Resources.跑__6_), new Bitmap(Properties.Resources.跑__7_), new Bitmap(Properties.Resources.跑__8_), new Bitmap(Properties.Resources.状态1_2__1_), new Bitmap(Properties.Resources.状态1_2__2_), new Bitmap(Properties.Resources.状态1_2__3_), new Bitmap(Properties.Resources.状态1_2__4_), new Bitmap(Properties.Resources.状态1_2__5_), new Bitmap(Properties.Resources.状态2_2), new Bitmap(Properties.Resources.跳__11_), new Bitmap(Properties.Resources.跳__2_), new Bitmap(Properties.Resources.跳__3_), new Bitmap(Properties.Resources.跳__4_), new Bitmap(Properties.Resources.跳__5_), new Bitmap(Properties.Resources.跳__6_), new Bitmap(Properties.Resources.跳__5_), new Bitmap(Properties.Resources.跳__4_), new Bitmap(Properties.Resources.跳__3_), new Bitmap(Properties.Resources.跳__2_), new Bitmap(Properties.Resources.跳__1_), }; foreach (Bitmap i in lbmp) { i.MakeTransparent(Color.White); } for (int i = 1; i <= 5; i++) { lrole[i - 1] = new Bitmap[lim[i]]; } for (int i = 0; i < lbmp.Length; i++) { if (i < 6) { lrole[0][i] = lbmp[i]; } else if (i < 10) { lrole[1][i - 6] = lbmp[i]; } else if (i < 15) { lrole[2][i - 10] = lbmp[i]; } else if (i < 16) { lrole[3][i - 15] = lbmp[i]; } else { lrole[4][i - 16] = lbmp[i]; } } foreach (Bitmap i in rmid) { i.MakeTransparent(Color.White); } foreach (Bitmap i in lmid) { i.MakeTransparent(Color.White); } foreach (Bitmap i in rbrr) { i.MakeTransparent(Color.White); } foreach (Bitmap i in lbrr) { i.MakeTransparent(Color.White); } leftlim = brr1.Location.X + brr3.Size.Width; rightlim = brr2.Location.X; }