예제 #1
0
        static GameClient()
        {
            Client = ScriptManager.Interface.CreateClient();

            // Init RakNet objects
            clientInterface = RakPeerInterface.GetInstance();
            clientInterface.SetOccasionalPing(true);

            socketDescriptor      = new SocketDescriptor();
            socketDescriptor.port = 0;

            if (clientInterface.Startup(1, socketDescriptor, 1) != StartupResult.RAKNET_STARTED)
            {
                Logger.LogError("RakNet failed to start!");
            }

            // Init debug info on screen
            var screenSize = GUCView.GetScreenSize();

            abortInfo = new GUCVisual((screenSize.Y - 300) / 2, 150, 300, 40);
            abortInfo.SetBackTexture("Menu_Choice_Back.tga");
            GUCVisualText visText = abortInfo.CreateText("Verbindung unterbrochen!");

            visText.SetColor(ColorRGBA.Red);

            devInfo = new GUCVisual();
            for (int pos = 0; pos < 0x2000; pos += devInfo.zView.FontY() + 5)
            {
                var t = devInfo.CreateText("", 0x2000, pos, true);
                t.Format = GUCVisualText.TextFormat.Right;
            }
            devInfo.Show();
        }
예제 #2
0
        protected override void OnCreate()
        {
            base.OnCreate();
            var screenSize = GUCView.GetScreenSize();

            Back.SetPos((screenSize.X - 900) / 2, (screenSize.Y - 480) / 2);
            Back.SetSize(900, 480);

            Back.CreateTextCenterX("Login", 100);

            _TbName = AddTextBox("Accountname:", "Name deines Accounts eingeben.", 200, 200, OnActivate);


            _TbPw = AddTextBox("Passwort:", "Passwort deines Accounts eingeben.", 250, 200, OnActivate, true);

            _TbPw2 = AddTextBox("Passwort wdh.:", "Passwort deines Accounts wiederholen.", 300, 200, OnActivate, true);

            AddButton("erstellen", "Die Erstellung des Accounts ausführen", 350, OnActivate);

            AddButton("Zurück", "Die Erstellung des Accounts abbrechen", 400, () => ChancelSelected?.Invoke(this));

            _LbErrorText = Back.CreateTextCenterX("", 400);
            _LbErrorText.SetColor(ColorRGBA.Red);
        }
예제 #3
0
 public ErrorScreen()
 {
     _Text = Back.CreateTextCenterX("...", 50);
     _Text.SetColor(ColorRGBA.Red);
     Back.CreateTextCenterX("mit Esc schließen.", 150);
 }
예제 #4
0
        internal static void Update()
        {
            int            counter = 0;
            ServerMessages msgType;
            Packet         packet;

            // Receive packets
            while ((packet = clientInterface.Receive()) != null)
            {
                try
                {
                    receivedBytes += packet.length;

                    packetReader.Load(packet.data, (int)packet.length);
                    msgType = (ServerMessages)packetReader.ReadByte();
                    ReadMessage(msgType, packetReader);

                    counter++;
                    if (counter >= 1000)
                    {
                        counter = 0;
                        Logger.Log("1000 Pakete hintereinander");
                    }
                }
                catch (Exception e)
                {
                    if (packet.length >= 1)
                    {
                        Logger.LogError("{0}: {1}: {2}\n{3}", (ServerMessages)packet.data[0], e.Source, e.Message, e.StackTrace);
                    }
                    else
                    {
                        Logger.LogError("{0}: {1}\n{2}", e.Source, e.Message, e.StackTrace);
                    }
                }
                finally
                {
                    clientInterface.DeallocatePacket(packet);
                }
            }

            #region Debug Info

            // update only every second
            if (infoTimer.IsReady)
            {
                int ping = clientInterface.GetLastPing(clientInterface.GetSystemAddressFromIndex(0));

                if (isDisconnected)
                {
                    abortInfo.Texts[0].Text = "Verbindung geschlossen!";
                    abortInfo.Show();
                }
                else if (isConnected)
                {
                    if (ping > 300 || ping < 0)
                    {
                        abortInfo.Show();
                    }
                    else
                    {
                        abortInfo.Hide();
                    }
                }

                // update ping text on screen
                int           devIndex = 0;
                GUCVisualText pingText = devInfo.Texts[devIndex++];
                pingText.Text = string.Format("Ping: {0}ms", ping);
                ColorRGBA color;
                if (ping <= 120)
                {
                    color = new ColorRGBA((byte)(40 + 180 * ping / 120), 220, 40);
                }
                else if (ping <= 220)
                {
                    color = new ColorRGBA(220, (byte)(220 - 180 * (ping - 100) / 120), 40);
                }
                else
                {
                    color = new ColorRGBA(220, 40, 40);
                }
                pingText.SetColor(color);

                long          fps     = Hooks.hGame.LastElapsedTicks > 0 ? TimeSpan.TicksPerSecond / Hooks.hGame.LastElapsedTicks : 999;
                GUCVisualText fpsText = devInfo.Texts[devIndex++];
                fpsText.Text = "FPS: " + fps;
                if (fps < 10)
                {
                    color = new ColorRGBA(220, 40, 40);
                }
                else if (fps < 40)
                {
                    color = new ColorRGBA(220, (byte)(40 + 180 * (fps - 10) / 30), 40);
                }
                else if (fps < 90)
                {
                    color = new ColorRGBA((byte)(220 - 180 * (fps - 40) / 50), 220, 40);
                }
                else
                {
                    color = new ColorRGBA(40, 220, 40);
                }
                fpsText.SetColor(color);

                devInfo.Texts[devIndex++].Text = "Spike: " + Hooks.hGame.SpikeLongest / TimeSpan.TicksPerMillisecond + "ms";

                // update kB/s text on screen
                int kbs = (int)(receivedBytes);
                devInfo.Texts[devIndex++].Text = ("Net received: " + kbs + "B/s");
                kbs = (int)(sentBytes);
                devInfo.Texts[devIndex++].Text = ("Net Sent: " + kbs + "B/s");
                receivedBytes = 0;
                sentBytes     = 0;

                if (World.Current != null)
                {
                    devIndex = 8;
                    devInfo.Texts[devIndex++].Text = World.Current.VobCount + " Vobs";
                    devInfo.Texts[devIndex++].Text = Client.guidedIDs.Count + " guided";

                    devInfo.Texts[devIndex++].Text = "Weather: " + World.Current.WeatherCtrl.CurrentWeight + " " + World.Current.Clock.Time.ToString(false);
                    devInfo.Texts[devIndex++].Text = "Barrier: " + World.Current.BarrierCtrl.CurrentWeight + " " + World.Current.BarrierCtrl.EndWeight;

                    devInfo.Texts[devIndex++].Text = "VobSounds: " + SoundHandler.VobSoundCount;
                    devInfo.Texts[devIndex++].Text = "PosSounds: " + SoundHandler.PosSoundCount;

                    //if (NPC.Hero != null)
                    //    devInfo.Texts[devIndex++].Text =  NPC.Hero.Movement.ToString();
                }
            }

            #endregion
        }
예제 #5
0
 public void SetTitle(string text, ColorRGBA color)
 {
     titleText.Text = text;
     titleText.SetColor(color);
 }