Beispiel #1
0
    public void Recv(JsonData JsonObject)
    {
        String str = "Level : " + Convert.ToInt32(JsonObject["level"].ToString()) + " / Exp : " + Convert.ToInt32(JsonObject["exp"].ToString());

        NetWWW.INSTANCE().MessageBox(str);
        Debug.Log(str);
    }
Beispiel #2
0
    public void ClickLogin()
    {
        WebLogin Login = new WebLogin();

        Login.id       = loginIdText.GetComponent <Text>().text;
        Login.password = loginPwText.text;

        NetWWW.INSTANCE().Send(Login, true);
    }
Beispiel #3
0
    public void Recv(JsonData JsonObject)
    {
        NetWWW.INSTANCE().MessageBox("Session Update Success");
        Debug.Log("Session Update Success");

        // 받은 session키, accountno 저장
        NetWWW.INSTANCE().session   = JsonObject["session"].ToString();
        NetWWW.INSTANCE().accountno = Convert.ToInt32(JsonObject["accountno"].ToString());
    }
Beispiel #4
0
    public void Recv(JsonData JsonObject)
    {
        ///Globals.INSTANCE.nowstage = 1;
        ///Application.LoadLevel("StageA");
        ///
        NetWWW.INSTANCE().MessageBox("Login Success");
        Debug.Log("Login Success");

        // 받은 session키, accountno 저장
        NetWWW.INSTANCE().session   = JsonObject["session"].ToString();
        NetWWW.INSTANCE().accountno = Convert.ToInt32(JsonObject["accountno"].ToString());
    }
Beispiel #5
0
    public void ClickSignup()
    {
        WebRegister Reg = new WebRegister();

        Reg.id       = signupIdText.GetComponent <Text>().text;
        Reg.password = signupPwText.text;
        Reg.name     = signupNameText.GetComponent <Text>().text;
        Reg.org      = signupOrgText.GetComponent <Text>().text;
        Reg.orgpos   = signupOrgposText.GetComponent <Text>().text;

        if (Reg.password.Equals(signupPwconText.text))
        {
            NetWWW.INSTANCE().Send(Reg, true);
        }
        else
        {
            GameObject.Find("SignUpErr").GetComponent <Text>().text = "비밀번호가 일치하지 않습니다.";
        }
    }
Beispiel #6
0
    public static NetWWW INSTANCE()
    {
        // 인스턴스가 없을 경우 찾아봄. (유니티 객체이므로 유니티 함수로 찾음)
        if (null == _instance)
        {
            _instance = FindObjectOfType(typeof(NetWWW)) as NetWWW;
        }

        // 위 시도에서도 못찾으면 유니티 객체 동적 생성
        // 먼저 비어있는 GameObject를 생성한다. 사실 객체 이름은 크게 중요하지 않음
        // 그리고 빈 오브젝트에 이 네트워크 클래스를 스크립트로 연동! <
        // 이건 스크립트 파일을 객체에 드래그 해서 붙이는 과정과 같음
        if (null == _instance)
        {
            GameObject obj = new GameObject(typeof(NetWWW).ToString());
            _instance = obj.AddComponent <NetWWW>();
        }

        return(_instance);
    }
Beispiel #7
0
 public void Recv(JsonData JsonObject)
 {
     NetWWW.INSTANCE().MessageBox("Stage Clear");
     Debug.Log("Stage Clear");
 }
Beispiel #8
0
 public void Recv(JsonData JsonObject)
 {
     NetWWW.INSTANCE().MessageBox("Register Success");
     Debug.Log("Register Success");
 }
Beispiel #9
0
    void OnGUI()
    {
        if (_bMsgbox)
        {
            GUI.Box(new Rect(Screen.width / 4, Screen.height / 4, Screen.width / 2, Screen.height / 2), _szMsg);
            if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height - Screen.height / 4, 100, 50), "OK"))
            {
                _bMsgbox    = false;
                GUI.enabled = true;
            }
            GUI.enabled = false;
        }
        else
        {
            GUI.enabled = !_bBlockinput;
        }

        GUI.Box(new Rect(10, 10, 150, 180), "Loader Menu");
        {
            if (GUI.Button(new Rect(20, 40, 130, 20), "회원가입"))
            {
                // MonoBehaviour를 상속받지 않은 일반 클래스
                // C#의 모든 객체는 동적할당해야 사용 가능. 할당된 객체는 Garbage Collector에 의해 자동으로 파괴
                WebRegister Reg = new WebRegister();

                Reg.id       = this.id;
                Reg.password = this.password;

                // 내부에서 코루틴 함수 호출
                NetWWW.INSTANCE().Send(Reg, true);
                // TODO: !!주의!! 유니티 코루틴 사용 시 참고 사항
                // 이 부분에서 STartCoroutine()을 직접 호출해선 안됨.
                // 1. 코루틴 종료가 늦어지거나 설계상의 문제로 종료되지 않을 경우, 메모리 정리를 하지 않기 때문에 가끔씩 튐
                // 2. 양적으로 많아지면 매 프레임마다 다 들려야 하므로 느려짐
                // -> 라이브에서는 해당 예제처럼 객체들을 각각의 패킷으로 여기고 직렬화하여 직렬화하여 순차적으로 전송해야함 (디자인 패턴 중 Command Pattern 참고)
            }
            if (GUI.Button(new Rect(20, 40 + 30, 130, 20), "로그인"))
            {
                WebLogin Login = new WebLogin();

                Login.id       = this.id;
                Login.password = this.password;

                NetWWW.INSTANCE().Send(Login, true);
            }
            if (GUI.Button(new Rect(20, 40 + 60, 130, 20), "유저 정보"))
            {
                WebUserInfo Info = new WebUserInfo();

                Info.accountno = this.accountno;
                Info.session   = this.session;

                NetWWW.INSTANCE().Send(Info, true);
            }

            if (GUI.Button(new Rect(20, 40 + 90, 130, 20), "세션 갱신"))
            {
                WebSession Session = new WebSession();

                Session.accountno = this.accountno;
                Session.session   = this.session;

                NetWWW.INSTANCE().Send(Session, true);
            }

            if (GUI.Button(new Rect(20, 40 + 120, 130, 20), "스테이지 클리어"))
            {
                WebStageClear Clear = new WebStageClear();

                Clear.accountno = this.accountno;
                Clear.session   = this.session;
                Clear.stageid   = this.stageid;

                NetWWW.INSTANCE().Send(Clear, true);
            }
        }

        GUI.enabled = true;
    }