Example #1
0
        public void Send(String msg, String nick)
        {
            st = login.stream;
            String From = nick;
            String IP   = AddressFamily.InterNetwork.ToString();
            var    m    = new Msg_Info()
            {
                Message = msg, From = From, IP = IP, MsgTime = "[" + DateTime.UtcNow + "]"
            };
            var msgJson = JsonConvert.SerializeObject(m);
            var g       = msgJson.Length + "?";

            while (g.Length < 4)
            {
                g = "0" + g;
            }
            Byte[] data = System.Text.Encoding.ASCII.GetBytes(g + msgJson);
            try
            {
                st.Write(data, 0, data.Length);
            }
            catch (IOException)
            {
                WindowPopup popup = new WindowPopup();

                popup.ShowDialog();
            }
        }
Example #2
0
    async Task LoadGame()
    {
        Debug.Log("Loading game data...");

        try
        {
            await GameStatics.LoadedGame.Load(GameStatics.GameGuid);

            Debug.Log("Loading game data to variables");
            Player.PlayerGender                  = GameStatics.LoadedGame.PlayerGender;
            GameFlow.Days                        = GameStatics.LoadedGame.Days;
            GameFlow.InDebt                      = GameStatics.LoadedGame.InDebt;
            Player.Money                         = GameStatics.LoadedGame.Money;
            BorrowMoney.DailyPayments            = GameStatics.LoadedGame.BorrowedMoney;
            BorrowMoney.maxMoneyAvalibleToBorrow = GameStatics.LoadedGame.BorrowLimit;
            StorylineManager.StorylinesSeen      = GameStatics.LoadedGame.StorylinesSeen;
            StorylineManager.Storylines.FindAll(storyline => (storyline.DayOfTrigger > 0 && storyline.DayOfTrigger <= GameFlow.Days) || StorylineManager.StorylinesSeen.Contains(storyline.Name)).ForEach(storyline => storyline.RunStoryline(PopupManager)); // Redo all storyline actions
            GameFlow.SetWeather(GameStatics.LoadedGame.Weather);
            Shop.ShopItems.ForEach(shopItem => { for (int i = 0; i < GameStatics.LoadedGame.ShopItemLevels[shopItem.Name]; i++)
                                                 {
                                                     shopItem.Upgrade();
                                                 }
                                   });
            FlowerBedManager.transform.GetComponentsInChildren <FlowerBed>().ToList().ForEach(flowerbed => flowerbed.UpdateFlowerbedState(GameStatics.LoadedGame.FlowerBedStates[flowerbed.id]));
            Debug.Log("Variables set!");

            Debug.Log("Game data loaded!");

            StartCoroutine(NextDayScreen.ShowScreen(GameStatics.LoadedGame.Days));
        }
        catch (Exception e)
        {
            Debug.LogError("Failed to load game save");
            Debug.LogError(e);

            Canvas OverlayCanvas = new GameObject().AddComponent <Canvas>();
            OverlayCanvas.gameObject.AddComponent <GraphicRaycaster>();
            OverlayCanvas.renderMode = RenderMode.ScreenSpaceOverlay;
            WindowPopup windowPopup = Instantiate(WindowPopup, OverlayCanvas.transform);
            windowPopup.queuedPopup      = false;
            windowPopup.TitleText.text   = "Looks like we ran into an error!";
            windowPopup.DetailsText.text = e.Message + "\nLook in the log files for more information and maybe make a Github issue.";
            windowPopup.callbackAction   = () => SceneManager.LoadScene("Main Menu");
            windowPopup.transform.GetChild(0).GetComponent <RectTransform>().offsetMin = new Vector2(100, 50);
            windowPopup.transform.GetChild(0).GetComponent <RectTransform>().offsetMax = new Vector2(-100, -50);
            windowPopup.gameObject.SetActive(true);
        }
    }