Esempio n. 1
0
    void UpdateUserInfoUI()
    {
        // 大厅主窗口只刷新金币、名称、等级和头像
        LionUserInfo ui = Lobby.getInstance().UserInfo;

        // NickName
        GameObject goAvatar = GameObject.Find("BtnAvatar");
        GameObject goText   = goAvatar.transform.Find("Text").gameObject;
        Text       text     = goText.GetComponent <Text>();

        text.text = ui.Name;

        // Coins
        GameObject goCredits = GameObject.Find("BtnCredits");

        goText    = goCredits.transform.Find("Text").gameObject;
        text      = goText.GetComponent <Text>();
        text.text = Tools.CoinToString(ui.Gold);

        // Level
        GameObject goStar = GameObject.Find("xp_star");

        goText    = goStar.transform.Find("txtLevel").gameObject;
        text      = goText.GetComponent <Text>();
        text.text = ui.Level.ToString();

        //  Head
        if (ui.HeadImgUrl != "")
        {
            m_headImgUrl = ui.HeadImgUrl;
            //int headIndex = Tools.StringToInt32(m_headImgUrl);
            //StartCoroutine(Tools.LoadWWWImageToButton(ui.HeadImgUrl, "BtnHead"));
        }
        AfterUpdateProfileHeadImgUrl();
    }
Esempio n. 2
0
    void UpdateUI()
    {
        if (null == coinOnObj)
        {
            return;
        }

        coinOnObj.SetActive(m_activePage != 0);
        coinOffObj.SetActive(m_activePage == 0);

        gemOnObj.SetActive(m_activePage != 1);
        gemOffObj.SetActive(m_activePage == 1);

        onSaleOnObj.SetActive(m_activePage != 2);
        onSaleOffObj.SetActive(m_activePage == 2);

        coinTabObj.SetActive(m_activePage == 0);
        gemTabObj.SetActive(m_activePage == 1);
        onSaleTabObj.SetActive(m_activePage == 2);

        LionUserInfo ui = Lobby.getInstance().UserInfo;

        transform.Find("main").Find("top").Find("BtnCredits").Find("Text").GetComponent <Text>().text = Tools.CoinToString(ui.Gold);

        m_hasCountDown = false;
        UpdateShop();
    }
Esempio n. 3
0
    // 更新名字回调函数
    void AfterUpdateProfileName()
    {
        // 个人信息对话框
        GameObject go = GameObject.Find("InputNickName");

        if (go == null)
        {
            DebugConsole.Log("InputNickName is null");
        }
        else
        {
            InputField field = go.GetComponent <InputField>();
            field.text = m_nick;
        }

        // 主界面更新
        GameObject goAvatar = GameObject.Find("BtnAvatar");
        GameObject goText   = goAvatar.transform.Find("Text").gameObject;
        Text       text     = goText.GetComponent <Text>();

        text.text = m_nick;

        LionUserInfo ui = Lobby.getInstance().UserInfo;

        ui.Name = m_nick;
    }
Esempio n. 4
0
    public static void Show(LionUserInfo usrInfo, string str = "")
    {
        GameObject         canvas = GameObject.Find("Canvas");
        GameObject         obj    = canvas.transform.Find(DialogName).gameObject;
        DialogPersonalInfo dlg    = obj.GetComponent <DialogPersonalInfo>();

        // 以下几句注意顺序
        // 先设置用户信息
        dlg.UserInfo = usrInfo;
        dlg.DoShow(obj, str);
        dlg.UpdateUserInfo(); // 默认第一个页面
    }
Esempio n. 5
0
    public void UpdateProfileName(string nickName)
    {
        LionUserInfo ui = Lobby.getInstance().UserInfo;

        if (nickName == "" || nickName == ui.Name)
        {
            return;
        }

        StringArray sa = new StringArray();

        sa.Data.Add("Name");
        sa.Data.Add(nickName);
        m_nick = nickName;

        m_net.SendEnqueue(Constants.Lion_UpdateProfile,
                          0,
                          sa,
                          AfterUpdateProfileName);
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            if (DialogBase.Actived())
            {
                DebugConsole.Log("Hide");
                DialogBase.Hide();
            }
            else
            {
                DebugConsole.Log("Show");
                DialogBase.Show("ESC", "Are you sure to exit game?", QuitGame);
            }
        }

        if (m_broadcastMsg != "")
        {
            // 有系统消息,平移吧
            GameObject goBroadcast = GameObject.Find("BroadcastText");
            Vector3    pos         = goBroadcast.transform.localPosition;
            pos.x -= 50 * Time.deltaTime;
            goBroadcast.transform.localPosition = pos;

            // 从600~-600
            if (goBroadcast.transform.localPosition.x < -600)
            {
                m_broadcastMsg = "";
            }
        }
        else
        {
            m_broadcastMsg = Lobby.getInstance().GetBroadcast();
            if (m_broadcastMsg != "")
            {
                GameObject goBroadcast = GameObject.Find("BroadcastText");
                goBroadcast.GetComponent <Text>().text = m_broadcastMsg;
                goBroadcast.transform.localPosition    = new Vector3(600, 0, 0);
            }
        }

        if (m_net == null || !m_net.IsRunning())
        {
            // 主动结束了
            return;
        }

        if (m_net.CheckReconnect())
        {
            CheckLogin();

            DialogReconnect.Hide();
        }

        ProtoPacket packet = new ProtoPacket();

        if (m_net.RecvTryDequeue(ref packet))
        {
            DebugConsole.Log("Reception handle cmdId:" + packet.cmdId);
            switch (packet.cmdId)
            {
            case Constants.Lion_QuickLoginInfo:
            {
                Lobby.getInstance().UserInfo = (LionUserInfo)packet.proto; // 更新LionUser
                m_login = true;
                UpdateUserInfoUI();                                        // 更新大厅主界面中信息
                if (packet.callback != null)
                {
                    packet.callback();
                }
            }
            break;

            case Constants.Lion_GetProfile:
            {
                LionUserInfo usrInfo = (LionUserInfo)packet.proto;        // 更新LionUser
                if (usrInfo.UserId == Lobby.getInstance().UId)
                {
                    Lobby.getInstance().UserInfo = usrInfo;
                }
                Lobby.getInstance().QueryUserInfo = usrInfo;

                if (packet.callback != null)
                {
                    // 通常这里显示个人信息对话框
                    packet.callback();
                }
            }
            break;

            case Constants.Lion_GetTigerStat:
            {
                Lobby.getInstance().TigerStatInfo = (TigerStat)packet.proto;
                if (packet.callback != null)
                {
                    packet.callback();
                }
            }
            break;

            case Constants.Lion_GetFriendRequests:
            case Constants.Lion_GetFriends:
            {
                Lobby.getInstance().FriendIDArray = (LongArray)packet.proto;
                if (packet.callback != null)
                {
                    GetFriendSummary(packet.callback);
                }
                else
                {
                    GetFriendSummary(ShowFriendsDlg);
                }
            }
            break;

            case Constants.Lion_GetFriendSummary:
            {
                Lobby.getInstance().CurrentSummaryList = (FriendSummaryList)packet.proto;
                DebugConsole.Log("Summary count:" + Lobby.getInstance().CurrentSummaryList.Data.Count);
                if (packet.callback != null)
                {
                    packet.callback();
                }
            }
            break;

            case Constants.Lion_IgnoreFriend:
            case Constants.Lion_AcceptFriend:
            case Constants.Lion_AddFriend:
            case Constants.Lion_DeleteFriend:
            {
                Status stat = (Status)packet.proto;
                if (stat.Code == 0)        // successful
                {
                    if (packet.callback != null)
                    {
                        packet.callback();
                    }
                }
                else
                {
                    DebugConsole.Log(stat.Desc);
                }
            }
            break;

            case Constants.Lion_Redirect:
            {
                Lobby.getInstance().RedirectInfo = (RedirectResp)packet.proto;
                // 切换到游戏场景中
                //m_net.Close();
                DebugConsole.Log("Reception enter slot scene");
                Global.NextSceneName = "slot";
                SceneManager.LoadScene("loading");
            }
            break;

            case Constants.Lion_UpdateProfile:
            {
                DebugConsole.Log("Lion_UpdateProfile");
                Status stat = (Status)packet.proto;
                if (stat.Code == 0)        // successful
                {
                    if (packet.callback != null)
                    {
                        packet.callback();
                    }
                }
                else
                {
                    DebugConsole.Log(stat.Desc);
                }
            }
            break;

            case Constants.Lion_NotifyWeeklyLogin:
            {
                // 连续登录奖励
                // NotifyWeeklyLogin 返回的intvalue是0-6,0表示今天登陆了(昨天没登录)
                IntValue iv = (IntValue)packet.proto;
                DialogDailyBonus.Show(iv.Value);

                //ExplodeCoin.Show();
            }
            break;

            case Constants.Lion_TakeLoginBonus:
            {
                LongArray la = (LongArray)packet.proto;
                // la[0] 奖励金币数
                // la[1] 最终总数
                if (la.Data.Count >= 2)
                {
                    Lobby.getInstance().UserInfo.Gold = la.Data[1];
                    // 若有动画,在此添加
                    JumpAndMoveCoins(6, UpdateUserInfoUI);
                }
            }
            break;

            case Constants.Lion_NotifyFreeBonus:
            {
                // 第一次登陆的时候,数据库里面没有数据,所以返回0
                // 后端推送,倒计时剩余时间长度(毫秒),如果小于等于0,直接显示奖励
                // 免费奖励
                LongValue lv       = (LongValue)packet.proto;
                long      curEpoch = (System.DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;
                Lobby.getInstance().FreeBonusEpoch = curEpoch + lv.Value;
                UpdateCountDown();
            }
            break;

            case Constants.Lion_TakeFreeBonus:
            {
                LongArray la = (LongArray)packet.proto;
                if (la.Data.Count >= 2)
                {
                    Lobby.getInstance().UserInfo.Gold = la.Data[1];
                    // 若有动画,在此添加
                    FlyCoin(Constants.Bonus_Free);
                    UpdateUserInfoUI();
                }
            }
            break;

            case Constants.Lion_BuyItem:
            {
                Status stat = (Status)packet.proto;
                // 更新购买相关的:金币 or 背包
                DebugConsole.Log("Buy item return:" + stat.Code.ToString());
                if (stat.Code == 0)        // successful
                {
                    if (packet.callback != null)
                    {
                        packet.callback();
                    }
                }
                else
                {
                    DebugConsole.Log(stat.Desc);
                }
            }
            break;

            case Constants.Lion_Register:
            {
                Status stat = (Status)packet.proto;
                DebugConsole.Log("Register by email return:" + stat.Code.ToString());
                if (stat.Code == 0)        // successful
                {
                    if (packet.callback != null)
                    {
                        packet.callback();
                    }
                }
                else
                {
                    DebugConsole.Log(stat.Desc);
                    DialogBase.Show("Register by email", "Error:" + stat.Desc);
                }
            }
            break;

            case Constants.Lion_ModPass:
            {
                Status stat = (Status)packet.proto;
                DebugConsole.Log("Modify password return:" + stat.Code.ToString());
                if (stat.Code == 0)        // successful
                {
                    if (packet.callback != null)
                    {
                        packet.callback();
                    }
                }
                else
                {
                    DebugConsole.Log(stat.Desc);
                    DialogBase.Show("Modify password", "Error:" + stat.Desc);
                }
            }
            break;

            case Constants.Lion_RefreshGold:
            {
                LongValue lv = (LongValue)packet.proto;
                DebugConsole.Log("Refresh gold:" + lv.ToString());
                Lobby.getInstance().UserInfo.Gold = lv.Value;
                UpdateUserInfoUI();
            }
            break;

            case Constants.Lion_GetShopItems:
            {
                Lobby.getInstance().ShopList = (ShopList)packet.proto;
                DebugConsole.Log("ShopName:" + Lobby.getInstance().ShopList.ShopName);
                if (packet.callback != null)
                {
                    packet.callback();
                }
            }
            break;

            case Constants.Lion_BroadcastSystemMessage:
            {
                Tools.PlayNotification(Constants.Audio.Audio_Notification);
                StringValue sv = (StringValue)packet.proto;
                Lobby.getInstance().AddBroadcast(sv.Value);
            }
            break;

            case Constants.Lion_GetItems:
            {
                //
                Lobby.getInstance().UserItemList = (UserItemList)packet.proto;

                if (packet.callback != null)
                {
                    packet.callback();
                }
                else
                {
                    DialogBag.Show(null);
                }
            }
            break;

            case Constants.Reconnect:
            {
                // 展示重连对话框,直到重连成功
                if (packet.msgId == 1)
                {
                    ProtoNet.WriteLog("Reconnecting...");
                    // 3s后Display中重连
                    m_net.CheckReconnect(3);
                    DialogReconnect.Show();
                }
            }
            break;

            case Constants.Error:
            {
                // 展示错误
                Status stat = (Status)packet.proto;
                string err  = "Error:" + stat.Code.ToString() + "-" + stat.Desc;
                DialogBase.Show("ERROR", err);
            }
            break;

            default:
            {
                DebugConsole.Log("Reception invalid cmdId:" + packet.cmdId);
            }
            break;
            }
        }
    }
Esempio n. 7
0
    public void UpdateUserInfo()
    {
        if (null == inputNickNameObj)
        {
            return;
        }

        LionUserInfo ui = m_userInfo;

        // 区分自己和他人
        bool isSelf = m_userInfo.UserId == Lobby.getInstance().UId;

        // NickName
        if (isSelf)
        {
            valNickNameObj.SetActive(false);
            inputNickNameObj.SetActive(true);
            InputField field = inputNickNameObj.GetComponent <InputField>();
            field.text = ui.Name;
        }
        else
        {
            inputNickNameObj.SetActive(false);
            valNickNameObj.SetActive(true);
            valNickNameObj.GetComponent <Text>().text = ui.Name;
        }

        // Level
        GameObject.Find("valLevel").GetComponent <Text>().text = ui.Level.ToString();

        // Coins
        GameObject.Find("valCoins").GetComponent <Text>().text = Tools.CoinToString(ui.Gold);

        // Location
        GameObject.Find("valLocation").GetComponent <Text>().text = ui.Location;

        // Like
        GameObject.Find("valLike").GetComponent <Text>().text = ui.Praise.ToString();

        // UUID
        GameObject.Find("valUId").GetComponent <Text>().text = ui.UserId.ToString();

        // 头像
        //if (ui.HeadImgUrl != "")
        {
            GameObject goSrc = DialogSelectAvatar.GetHeadObject(ui.HeadImgUrl);;

            if (goSrc != null)
            {
                GameObject goDest =
                    DialogPersonalInfo.GetInstance().transform.Find("main").
                    transform.Find("BtnUpAvatar").gameObject;
                goDest.GetComponent <Image>().sprite = goSrc.GetComponent <Image>().sprite;
            }
            else
            {
                GameObject goHeadDefault = GameObject.Find("BtnAvatar").transform.Find("BtnHeadDefault").gameObject;
                GameObject goDest        =
                    DialogPersonalInfo.GetInstance().transform.Find("main").
                    transform.Find("BtnUpAvatar").gameObject;
                goDest.GetComponent <Image>().sprite = goHeadDefault.GetComponent <Image>().sprite;
            }
        }

        Reception recp = GameObject.Find("Reception").GetComponent <Reception>();

        recp.GetTigerStatInfo(m_userInfo.UserId, UpdateTigerStatUI);
    }