Ejemplo n.º 1
0
        private static void StartGame()
        {
            Main.PlaySound(10);
            string text = WorldSelect.WorldName();

            if (text == null)
            {
                UI.main.SetMenu(MenuMode.WORLD_SIZE);
                return;
            }
            UI.main.SetMenu(MenuMode.STATUS_SCREEN);
            Main.worldName = text;
            WorldGen.playWorld();
        }
Ejemplo n.º 2
0
        public static void Draw(WorldView view)
        {
            Rectangle rect = default(Rectangle);

            rect.X      = (view.viewWidth >> 1) - 190;
            rect.Y      = 210;
            rect.Width  = 380;
            rect.Height = 168;
            Main.DrawRect(451, rect, 64);
            Color c    = Color.White;
            int   num  = (view.viewWidth >> 1) - 100;
            int   num2 = 230;
            bool  flag = UI.main.CanPlayOnline();

            if (cursorY == 0)
            {
                view.ui.DrawInventoryCursor(num, num2, 1.0);
            }
            else
            {
                c = (flag ? Color.White : new Color(128, 128, 128, 255));
                SpriteSheet <_sheetSprites> .Draw(451, num, num2, c);
            }
            if (UI.main.isOnline)
            {
                SpriteSheet <_sheetSprites> .Draw(202, num + 10, num2 + 10, c);
            }
            UI.DrawStringLC(UI.fontSmall, Lang.menu[6], num + 60, num2 + 26, c);
            num2 += 64;
            if (cursorY == 1)
            {
                view.ui.DrawInventoryCursor(num, num2, 1.0);
            }
            else
            {
                c = ((flag && UI.main.isOnline) ? Color.White : new Color(128, 128, 128, 255));
                SpriteSheet <_sheetSprites> .Draw(451, num, num2, c);
            }
            if (UI.main.isInviteOnly)
            {
                SpriteSheet <_sheetSprites> .Draw(202, num + 10, num2 + 10, c);
            }
            UI.DrawStringLC(UI.fontSmall, Lang.menu[7], num + 60, num2 + 26, c);
            string text = (WorldSelect.WorldName() != null) ? Lang.menu[10] : Lang.menu[11];
            float  num3 = 1f;

            if (cursorY != 2)
            {
                c = new Color(240, 240, 240, 240);
            }
            else
            {
                num3 *= 1f + UI.cursorAlpha * 0.1f;
                c     = new Color(UI.cursorColor.A, UI.cursorColor.A, 100, 255);
            }
            Vector2 pivot = UI.MeasureString(UI.fontBig, text);

            pivot.X *= 0.5f;
            pivot.Y *= 0.5f;
            UI.DrawStringScaled(pos: new Vector2(view.viewWidth >> 1, 454f), font: UI.fontBig, s: text, c: c, pivot: pivot, scale: num3);
        }
Ejemplo n.º 3
0
        public static void ClientLoop()
        {
            Thread.CurrentThread.SetProcessorAffinity(5);
            Init();
            UI.main.player.hostile = false;
            UI.main.player.NetClone(UI.main.netPlayer);
            for (int i = 0; i < 8; i++)
            {
                if (i != UI.main.myPlayer)
                {
                    Main.player[i].active = 0;
                }
            }
            WorldGen.clearWorld();
            if (UI.main.menuMode == MenuMode.NETPLAY)
            {
                Main.netMode = 1;
                try
                {
                    if (isJoiningRemoteInvite)
                    {
                        isJoiningRemoteInvite = false;
                        session = NetworkSession.JoinInvited(gamersWaitingToJoinInvite);
                        gamersWaitingToJoinInvite.Clear();
                        gamersWhoReceivedInvite.Clear();
                    }
                    else
                    {
                        session = NetworkSession.Join(WorldSelect.Session());
                    }
                }
                catch (Exception)
                {
                    UI.Error(Lang.menu[5], Lang.inter[21], rememberPreviousMenu: true);
                    UI.main.menuType = MenuType.MAIN;
                    Main.netMode     = 0;
                    disconnect       = true;
                    stopSession      = true;
                    goto IL_028d;
                }
                hookEvents = true;
                while (!disconnect && session != null)
                {
                    switch (clientState)
                    {
                    case ClientState.JOINING:
                        UI.main.FirstProgressStep(3, Lang.menu[8]);
                        clientState = ClientState.WAITING_FOR_PLAYER_ID;
                        break;

                    case ClientState.WAITING_FOR_PLAYER_ID:
                        if (UI.main.progress <= 0.999f)
                        {
                            UI.main.progress = UI.main.progress + 0.001f;
                        }
                        break;

                    case ClientState.WAITING_FOR_PLAYER_DATA_REQ:
                        if (UI.main.progress <= 0.999f)
                        {
                            UI.main.progress = UI.main.progress + 0.001f;
                        }
                        break;

                    case ClientState.RECEIVED_PLAYER_DATA_REQ:
                        UI.main.NextProgressStep(Lang.menu[73]);
                        clientState = ClientState.WAITING_FOR_WORLD_INFO;
                        break;

                    case ClientState.WAITING_FOR_WORLD_INFO:
                        if (UI.main.progress <= 0.999f)
                        {
                            UI.main.progress = UI.main.progress + 0.001f;
                        }
                        break;

                    case ClientState.WAITING_FOR_TILE_DATA:
                        if (clientStatusMax > 0)
                        {
                            if (clientStatusCount >= clientStatusMax)
                            {
                                clientStatusMax   = 0;
                                clientStatusCount = 0;
                                UI.main.progress  = 1f;
                            }
                            else
                            {
                                UI.main.statusText = Lang.inter[44];
                                UI.main.progress   = (float)clientStatusCount / (float)clientStatusMax;
                            }
                        }
                        break;
                    }
                    Thread.Sleep(0);
                }
                clientStatusCount = 0;
                clientStatusMax   = 0;
                stopSession       = true;
            }
            goto IL_028d;
IL_028d:
            sessionThread = null;
        }