Esempio n. 1
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);
    }
Esempio n. 2
0
    //获得简介回调
    private void OnMsgGetPlayerIntroduction(Request request)
    {
        MsgGetPlayerIntroduction msgGetPlayerIntroduction = MsgGetPlayerIntroduction.Parser.ParseFrom(request.Msg);

        _playerIntroduction.text = msgGetPlayerIntroduction.PlayerIntroduction;
    }