#pragma strict
private
var secretKey=
"hashcode"
;
private
var formNick =
""
;
private
var formPassword =
""
;
private
var formEmail =
"541416005@qq.com"
;
private
var formyzm =
""
;
var formText =
""
;
var CheckUserURL =
"http://localhost/checkuser.php"
; //检测帐户
var RegisterURL =
"http://localhost/register.php"
;//注册
var imageURL =
"http://localhost/image.php"
;//生成验证码的php文件
var hash =
"hashcode"
;
var reg:boolean =
false
;
public
var tu:GUITexture;
private
var textrect = Rect (10, 150, 500, 500);
function Start()
{
LoadImage();
}
function OnGUI() {
if
(reg==
false
)
{
tu.enabled =
true
;
GUI.Label( Rect (10, 10, 80, 20),
"Your name:"
);
GUI.Label( Rect (10, 30, 80, 20),
"Your pass:"
);
GUI.Label( Rect (10, 50, 80, 20),
"yanzhengma:"
);
formNick = GUI.TextField ( Rect (90, 10, 100, 20), formNick );
formPassword = GUI.TextField ( Rect (90, 30, 100, 20), formPassword );
formyzm = GUI.TextField(Rect(90,50,100,20),formyzm);
if
( GUI.Button ( Rect (10, 120, 100, 20) ,
"Try login"
) ){
Login();
}
if
( GUI.Button ( Rect (220, 120, 100, 20) ,
"Chanage Pic"
) ){
LoadImage();
}
if
( GUI.Button ( Rect (120, 120, 100, 20) ,
"Register"
) ){
reg=
true
;
}
}
if
(reg==
true
)
{
tu.enabled =
false
;
GUI.Label( Rect (10, 10, 80, 20),
"Your name:"
);
GUI.Label( Rect (10, 30, 80, 20),
"Your pass:"
);
GUI.Label( Rect (10, 50, 80, 20),
"Your Email:"
);
formNick = GUI.TextField ( Rect (90, 10, 100, 20), formNick );
formPassword = GUI.TextField ( Rect (90, 30, 100, 20), formPassword );
formEmail = GUI.TextField ( Rect (90, 50, 200, 20), formEmail );
if
( GUI.Button ( Rect (10, 120, 100, 20) ,
"Login"
) ){
}
if
( GUI.Button ( Rect (120, 120, 100, 20) ,
"Register"
) ){
Register();
}
}GUI.TextArea( textrect, formText );
}
function LoadImage()
{
var form =
new
WWWForm();
form.AddField(
"act"
,
"62"
);
var w = WWW(imageURL, form);
yield w;
if
(w.error !=
null
) {
print(w.error);
}
else
{
print(
"Test ok"
);
tu.texture = w.texture;
w.Dispose();
}
}
function Login() {
var form =
new
WWWForm();
form.AddField(
"hash"
, hash );
form.AddField(
"name"
, formNick );
form.AddField(
"password"
, formPassword );
form.AddField(
"yzm"
,formyzm);
var w = WWW(CheckUserURL, form);
yield w;
if
(w.error !=
null
) {
print(w.error);
}
else
{
print(
"Test ok"
);
formText = w.text;
w.Dispose();
if
(formText==
"密码正确,欢迎登录"
)
{
Application.LoadLevel(1);
}
}
formNick =
""
;
formPassword =
""
;
formyzm =
""
;
}
function Register()
{
var form =
new
WWWForm();
form.AddField(
"hash"
, hash );
form.AddField(
"name"
, formNick );
form.AddField(
"password"
, formPassword );
form.AddField(
"email"
, formEmail);
var w = WWW(RegisterURL, form);
yield w;
if
(w.error !=
null
) {
print(w.error);
}
else
{
print(
"Register ok"
);
w.Dispose();
}
formNick =
""
;
formPassword =
""
;
formyzm =
""
;
}