using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace FLUMPv1._0
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
login login = new login();
con.Text += Environment.NewLine + "Initializing login screen";
login.Show();
if (File.Exists("SD.txt") == false)
con.Text += Environment.NewLine + "Creating save data";
if (File.Exists("QD.txt") == false)
con.Text += Environment.NewLine + "Creating quest data";
if (File.Exists("BD.txt") == false)
con.Text += Environment.NewLine + "Creating bag data";
TextWriter test = new StreamWriter("SD.txt");
if (File.Exists("SD.txt") == false)
test.WriteLine
// username
("username");
test.WriteLine
// level
("1");
test.WriteLine
// money
("0");
test.WriteLine
// xp
("0");
test.WriteLine
// attrbiute
("none");
test.Close();
TextWriter test2 = new StreamWriter("QD.txt");
if (File.Exists("QD.txt") == false)
test2.WriteLine
// Quest 1
("0");
test2.WriteLine
// Quest 2
("0");
test2.WriteLine
// Quest 3
("0");
test2.WriteLine
// Quest 4
("0");
test2.WriteLine
// Quest 5
("0");
test2.WriteLine
// Quest 6
("0");
test2.WriteLine
// Quest 7
("0");
test2.WriteLine
// Quest 8
("0");
test2.WriteLine
// Quest 9
("0");
test2.WriteLine
// Quest 10
("0");
test2.Close();
TextWriter bd = new StreamWriter("BD.txt");
if (File.Exists("BD.txt") == false)
bd.WriteLine
// Apple
("0");
bd.WriteLine
// Potion
("0");
bd.WriteLine
// Super potion
("0");
bd.WriteLine
// Antidote
("0");
bd.WriteLine
// Farcaster
("0");
bd.Close();
}
}
}and here is my code for the login form...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace FLUMPv1._0
{
public partial class login : Form
{
public login()
{
InitializeComponent();
}
string[] username;
game game = new game();
private void login_Load(object sender, EventArgs e)
{
TextReader sc = new StreamReader("SD.txt");
username = new string[1];
username[0] = sc.ReadLine();
sc.Close();
Form1 form1 = (Form1) Application.OpenForms["Form1"];
if (this.Visible == true)
form1.con.Text += Environment.NewLine + "Login screen initialized";
if (File.Exists("SD.txt") == true)
form1.con.Text += Environment.NewLine + "Save data file found";
if (File.Exists("QD.txt") == true)
form1.con.Text += Environment.NewLine + "Quest data file found";
if (File.Exists("BD.txt") == true)
form1.con.Text += Environment.NewLine + "Bag data file found";
if (File.Exists("SD.txt") == false)
form1.con.Text += Environment.NewLine + "Error: Save data file not found";
if (File.Exists("QD.txt") == false)
form1.con.Text += Environment.NewLine + "Error: Quest data file not found";
if (File.Exists("BD.txt") == false)
form1.con.Text += Environment.NewLine + "Error: Bag data file not found";
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Visible = false;
button1.Visible = false;
button2.Visible = false;
textBox2.Visible = true;
button3.Visible = true;
button4.Visible = true;
}
private void button3_Click(object sender, EventArgs e)
{
Form1 form1 = (Form1) Application.OpenForms ["Form1"];
TextWriter create = new StreamWriter("SD.txt");
create.WriteLine
// username
(textBox2.Text.ToString());
create.WriteLine
// level
("1");
create.WriteLine
// money
("0");
create.WriteLine
// xp
("0");
create.WriteLine
// attrbiute
("none");
create.Close();
form1.con.Text += Environment.NewLine + "Created account '"
+ textBox2.Text + "' successfully";
textBox1.Visible = true;
button1.Visible = true;
button2.Visible = true;
textBox2.Visible = false;
button3.Visible = false;
button4.Visible = false;
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Visible = true;
button1.Visible = true;
button2.Visible = true;
textBox2.Visible = false;
button3.Visible = false;
button4.Visible = false;
}
private void timer1_Tick(object sender, EventArgs e)
{
TextReader nr = new StreamReader("SD.txt");
username[0] = (nr.ReadLine());
nr.Close();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == username[0])
game.Show();
if (textBox1.Text == username[0])
this.Close();
}
}
}I am sorry it took uup so much room but it was the only way i could show you.
Thanks,
Wolfy87.

Help




Back to top












