예제 #1
0
    void OnNicknameSetAckHandler(C2G.NicknameSet packet, C2G.NicknameSetAck ack)
    {
        switch (ack.result)
        {
        case pe_NicknameResult.Success:
            Network.PlayerInfo.nickname = packet.nickname;

            if (is_change)
            {
                Tooltip.Instance.ShowMessageKey("NicknameChanged");
                GameMain.Instance.UpdatePlayerInfo();
            }
            Network.PlayerInfo.UseGoodsValue(pe_GoodsType.token_gem, price);

            if (Tutorial.Instance.Completed == false)
            {
                parent.Close(true, true);
            }
            else
            {
                base.OnClose();
            }

            if (is_change == false && m_callback != null)
            {
                m_callback();
            }

            if (Network.ChatServer.IsConnected == true)
            {
                Network.ChatServer.ChangeNickname(packet.nickname);
            }
            else
            {
                ChattingMain.Instance.Init();
            }

            break;

        default:
            Tooltip.Instance.ShowMessageKey("NicknameNotAvailable");
            break;
        }
    }
예제 #2
0
    public void OnClickChange()
    {
        int len = m_InputMessage.text.Length;

        if (m_InputMessage.text.All(t => char.IsLetterOrDigit(t)) == false || len < NicknameMin || len > NicknameMax)
        {
            Tooltip.Instance.ShowMessageKey("NicknameNotAvailable");
            return;
        }

        if (is_change && Network.PlayerInfo.GetGoodsValue(pe_GoodsType.token_gem) < price)
        {
            Tooltip.Instance.ShowMessageKey(string.Format("NotEnough{0}", pe_GoodsType.token_gem));
            return;
        }

        C2G.NicknameSet packet = new C2G.NicknameSet();
        packet.nickname = m_InputMessage.text;
        Network.GameServer.JsonAsync <C2G.NicknameSet, C2G.NicknameSetAck>(packet, OnNicknameSetAckHandler);
    }