예제 #1
0
    public void OnLoginClick()
    {
        Debug.Log("login click");
        bool login = true;

        acct = GameObject.Find("AccountField").GetComponent <InputField>().text;
        psw  = GameObject.Find("PasswordField").GetComponent <InputField>().text;

        //需重构成焦点转移后判定并提示
        if (String.IsNullOrEmpty(acct) || String.IsNullOrEmpty(psw))
        {
            login = false;
            MessageShow("输入栏不能为空");
            //UnityEditor.EditorUtility.DisplayDialog("Warning", "Input Field can't be empty", "Ok");
            GameObject.Find("PasswordField").GetComponent <InputField>().text = null;
        }

        if (login)
        {
            var info = new Account {
                Id = acct, Password = psw
            };
            Client.Instance.Send(RequestType.Login, Proto.Serialize(info));
            //SceneManager.LoadSceneAsync(1);
        }
    }
예제 #2
0
    public void ReturnLobby()
    {
        var info = new JoinOrLeaveRoom {
            UserId = User.Id, RoomId = User.RoomId
        };

        Client.Instance.Send(RequestType.LeaveRoom, Proto.Serialize(info));
        SceneManager.LoadSceneAsync(1);
    }
예제 #3
0
    public void EnterRoom(GameObject sender)
    {
        var index   = sender.name[4] - '0' - 1;
        var room_id = RoomList.List[index].Id;
        var info    = new JoinOrLeaveRoom {
            UserId = User.Id, RoomId = room_id
        };

        Client.Instance.Send(RequestType.EnterRoom, Proto.Serialize(info));
    }
예제 #4
0
    public void CreateRoom()
    {
        var room = GameObject.Find("RoomName").GetComponent <InputField>();
        var list = new List <PlayerInfo>();

        list.Add(new PlayerInfo {
            Id = User.Id, Nickname = User.Nickname
        });
        var info = new RoomInfo {
            Id = 0, Name = room.text, Players = list
        };

        Client.Instance.Send(RequestType.CreateRoom, Proto.Serialize(info));
        //Debug.Log("Create Room Request");
    }
예제 #5
0
        public static void HandleRecv(ref Proto proto)
        {
            switch (proto)
            {
            case Resp.MapServerMap msm: {
                var md = Resp.MapDump.Deserialize(CompressionHelper.DecompressBytes(msm.MapData));

                foreach (var npc in md.NPCs.OrderBy(x => x.Settings.NPCName))
                {
                    if (npc.Settings.LOS > 0)
                    {
                        npc.Settings.NPCName += $" (LOS={npc.Settings.LOS})";
                        npc.Settings.LOS      = 0;
                    }

                    string x;
                    switch (npc.Settings.Sprite)
                    {
                    case 0: x = "invisible"; break;

                    case 10: x = "pokeball"; break;

                    default: x = $"<unknown({npc.Settings.Sprite})>"; break;
                    }
                    Log($"{npc.Settings.NPCName} ({npc.ID}): {x} at {{{npc.x}x{npc.y}x{npc.z}}} Enabled={npc.Settings.Enabled}");

                    // npc.Settings.Enabled = false;
                }

                int removed = md.NPCs.RemoveAll(x => x.Settings.Sprite == 9);
                Log($"Removed {removed} cut trees");

                msm.MapData = CompressionHelper.CompressBytes(Proto.Serialize(md));
                Log("Edited mapdata!");
                return;
            }
            }

            Log($"<< {proto._Name} {ToJsonString(proto)}");
        }
예제 #6
0
    public void OnSignupClick()
    {
        Debug.Log("Signup click");

        bool signUp = true;

        acct = GameObject.Find("accountField").GetComponent <InputField>().text;
        psw  = GameObject.Find("passwordField").GetComponent <InputField>().text;
        ncn  = GameObject.Find("nicknameField").GetComponent <InputField>().text;

        //需重构成焦点转移后判定并提示
        if (String.IsNullOrEmpty(acct) || String.IsNullOrEmpty(psw) || String.IsNullOrEmpty(ncn))
        {
            signUp = false;
            MessageShow("输入栏不能为空");
            //UnityEditor.EditorUtility.DisplayDialog("Warning", "Input Field can't be empty", "Ok");
        }
        else if (GameObject.Find("passwordAField").GetComponent <InputField>().text != psw)
        {
            signUp = false;
            MessageShow("两次密码输入不一致");
        }

        if (signUp)
        {
            var info = new UserInfo {
                Account = acct, Password = psw, Nickname = ncn
            };
            Client.Instance.Send(RequestType.Regist, Proto.Serialize(info));
            ////注册成功返回登陆界面
            //if(UnityEditor.EditorUtility.DisplayDialog("Prompt", "Registration success", "Ok"))
            //{
            //    JumpLoginPanel();
            //}
        }
    }