コード例 #1
0
ファイル: SlotClerk.cs プロジェクト: wayright/slotClient
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            //这个地方可以写“再按一次退出”的提示
            if (DialogBase.Actived())
            {
                DebugConsole.Log("Hide in Clerk");
                DialogBase.Hide();
            }
            else
            {
                DebugConsole.Log("Show in Clerk");
                DialogBase.Show("ESC", "Exit game?", QuitGame);
            }
            //m_escapeTimes++;
            //StartCoroutine("resetTimes");
            //if (m_escapeTimes > 1)
            //{
            //    Application.Quit();
            //}
        }

        if (!m_net.IsRunning())
        {
            return;
        }

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

        ProtoPacket packet = new ProtoPacket();

        if (m_net.RecvTryDequeue(ref packet))
        {
            m_displays.Execute(packet);
        }

        GameObject recp = GameObject.Find("Reception");

        if (recp == null)
        {
            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);
                }
            }

            // 不是Lobby,需要处理Reception消息
            // 如广播,以及store相关的
            ProtoNet net = Reception.Net();
            if (net != null)
            {
                packet = null;
                packet = new ProtoPacket();
                if (net.RecvTryDequeue(ref packet))
                {
                    switch (packet.cmdId)
                    {
                    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;

                    default:
                        break;
                    }
                }
            }
        }
    }