Ejemplo n.º 1
0
    //保存头像回调
    private void OnMsgSaveHeadPhoto(Request request)
    {
        MsgGetHeadPhoto msgGetHeadPhoto = new MsgGetHeadPhoto();

        NetManager.Send(msgGetHeadPhoto);
        Debug.Log("保存头像成功!");
    }
Ejemplo n.º 2
0
    //显示
    public override void OnShow(params object[] para)
    {
        //设置声音
        if (PlayerPrefs.GetString(Const.IsOnVolume) == "")
        {
            PlayerPrefs.SetString(Const.IsOnVolume, "true");
            PlayerPrefs.Save();
        }
        if (PlayerPrefs.GetString(Const.IsOnVolume) == "true")
        {
            AudioListener.volume = PlayerPrefs.GetFloat(Const.Volume);
        }
        if (PlayerPrefs.GetString(Const.IsOnVolume) == "false")
        {
            AudioListener.volume = 0f;
        }

        //寻找组件
        _setBtn             = skin.transform.Find("SetBtn").GetComponent <Button>();
        _headPhoto          = skin.transform.Find("PlayerInfo/HeadPhoto").GetComponent <Image>();
        _playerName         = skin.transform.Find("PlayerInfo/PlayerName").GetComponent <Text>();
        _playerIntroduction = skin.transform.Find("PlayerInfo/PlayerIntroduction").GetComponent <Text>();
        _enterGameBtn       = skin.transform.Find("EnterGameBtn").GetComponent <Button>();
        _handbookBtn        = skin.transform.Find("HandbookBtn").GetComponent <Button>();
        _altarBtn           = skin.transform.Find("AltarBtn").GetComponent <Button>();
        _friendBtn          = skin.transform.Find("FriendBtn").GetComponent <Button>();
        _sendBtn            = skin.transform.Find("ChatWindow/SendBtn").GetComponent <Button>();
        _input        = skin.transform.Find("ChatWindow/InputField").GetComponent <InputField>();
        _modifyBtn    = skin.transform.Find("PlayerInfo/ModifyBtn").GetComponent <Button>();
        _modifyInput  = _playerIntroduction.transform.Find("InputField").GetComponent <InputField>();
        _worldContent = skin.transform.Find("ChatWindow/WorldChat/Scroll View/Viewport/Content").gameObject;


        //监听
        _enterGameBtn.onClick.AddListener(OnEnterGameClick);
        _handbookBtn.onClick.AddListener(OnHandbookClick);
        _altarBtn.onClick.AddListener(OnAltarClick);
        _friendBtn.onClick.AddListener(OnFriendClick);
        _sendBtn.onClick.AddListener(OnSendClick);
        _modifyBtn.onClick.AddListener(OnModifyClick);
        _setBtn.onClick.AddListener(OnSetClick);
        skin.transform.Find("PlayerInfo/HeadPhoto").GetComponent <Button>().onClick.AddListener(OnHeadPhotoClick);
        //设置用户名
        _playerName.text = GameMain.id;

        //网络协议监听
        NetManager.AddMsgListener("MsgGetPlayerIntroduction", OnMsgGetPlayerIntroduction);
        NetManager.AddMsgListener("MsgSavePlayerIntroduction", OnMsgSavePlayerIntroduction);
        NetManager.AddMsgListener("MsgSendMessageToWord", OnMsgSendMessageToWord);
        NetManager.AddMsgListener("MsgGetHeadPhoto", OnMsgGetHeadPhoto);
        NetManager.AddMsgListener("MsgSaveHeadPhoto", OnMsgSaveHeadPhoto);
        //获取个人数据库中玩家信息
        MsgGetPlayerIntroduction msgGetPlayerIntroduction = new MsgGetPlayerIntroduction();

        NetManager.Send(msgGetPlayerIntroduction);
        MsgGetHeadPhoto msgGetHeadPhoto = new MsgGetHeadPhoto();

        NetManager.Send(msgGetHeadPhoto);
    }
Ejemplo n.º 3
0
    //获取头像回调
    private void OnMsgGetHeadPhoto(Request request)
    {
        MsgGetHeadPhoto msgGetHeadPhoto = MsgGetHeadPhoto.Parser.ParseFrom(request.Msg);

        _headPhotoName = "HeadPhoto" + msgGetHeadPhoto.HeadPhoto;
        Texture2D texture = ABManager.Instance.LoadRes <Texture2D>("texture", _headPhotoName);

        _headPhoto.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
    }