Пример #1
0
 public void Init(Dictionary <string, ServerModel.User> inUserDic, ServerModel.User inCurrentUser)
 {
     for (int i = 0; i < inUserDic.Count; i++)
     {
         ServerModel.User data = inUserDic.ElementAt(i).Value;
         GenerateUser(data, data == inCurrentUser);
     }
     RegistEvent();
 }
Пример #2
0
    private void GenerateUser(ServerModel.User inData, bool isPlayer = false)
    {
        Character character = Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/Character")).GetComponent <Character>();

        character.transform.SetParent(this.transform);
        character.Init(inData, isPlayer);

        _userObjects.Add(inData.name, character.gameObject);
    }
Пример #3
0
    public void Init(ServerModel.User inUserData, bool inPlayer = false)
    {
        _userData     = inUserData;
        _player       = inPlayer;
        _txtName.text = _userData.name;

        this.name = _userData.name;
        this.transform.localPosition = _userData.position;

        if (_player)
        {
            Camera.main.transform.SetParent(this.transform);
            Camera.main.transform.localPosition = new Vector3(0, 0, -10);
        }
    }
Пример #4
0
    public void OnGameStart()
    {
        string name = _userName.text;

        if (name.IsNullOrEmpty())
        {
            return;
        }

        _currentUser = new ServerModel.User()
        {
            name     = name,
            position = new Vector2(Random.Range(0, 1280) - 640, Random.Range(0, 720) - 360)
        };
        _userDic.Add(_currentUser.name, _currentUser);
        SocketIO.SocketIOComponent.Instance.Emit(ServerMethod.USER_CONNECT, _currentUser.ToJSON());
    }
Пример #5
0
    public void OnJoin()
    {
        if (_waitJoin || string.IsNullOrEmpty(_nickNameInputField.text) || _txtWaitNetwork.text != "Connected")
        {
            return;
        }

        _waitJoin             = true;
        _txtWaitNetwork.color = new Color(1, 0, 0);
        _txtWaitNetwork.text  = "Wait Join Request";

        ServerModel.User user = new ServerModel.User()
        {
            name = _nickNameInputField.text
        };
        NetworkManager.it.Emit(ServerMethod.USER_CONNECT, user.ToJSON());
    }