Ejemplo n.º 1
0
        public static void MailProcessAttackCancel(ModelMailTrade mail)
        {
            Loger.Log("Client MailProcessAttackCancel");

            GameAttackTrigger_Patch.ForceSpeed = -1f; //на всякий случай
            if (SessionClientController.Data.AttackModule != null)
            {
                SessionClientController.Data.AttackModule.Clear();
            }
            if (SessionClientController.Data.AttackUsModule != null)
            {
                SessionClientController.Data.AttackUsModule.Clear();
            }

            SessionClientController.Disconnected("OCity_GameAttacker_Dialog_ErrorMessage".Translate());
        }
Ejemplo n.º 2
0
        public void DoTab3Contents(Rect inRect)
        {
            Text.Font = GameFont.Medium;
            Widgets.Label(inRect, "OCity_Dialog_AboutMode".Translate());

            Text.Font = GameFont.Small;
            var chatAreaOuter = new Rect(inRect.x + 150f, inRect.y + 40f, inRect.width - 150f, inRect.height - 30f - 40f);

            AboutBox.Drow(chatAreaOuter);

            var rect2 = new Rect(inRect.x, inRect.y + inRect.height / 2f, 150f, inRect.height - 30f - 40f);

            Text.Font = GameFont.Small;
            List <ListableOption> list2 = new List <ListableOption>();
            ListableOption        item2 = new ListableOption_WebLink("OCity_Dialog_AutorPage".Translate(), "https://steamcommunity.com/sharedfiles/filedetails/?id=1908437382", GeneralTexture.IconForums);

            list2.Add(item2);

            rect2     = new Rect(inRect.x, inRect.y + 30f, 150f, 40f);
            Text.Font = GameFont.Small;
            list2     = new List <ListableOption>();
            item2     = new ListableOption_WebLink("OCity_Dialog_Regame".Translate(), () =>
            {
                var form             = new Dialog_Input("OCity_Dialog_DeleteData".Translate(), "OCity_Dialog_DeleteDataCheck".Translate());
                form.PostCloseAction = () =>
                {
                    if (form.ResultOK)
                    {
                        var mainCannal = SessionClientController.Data.Chats[0];
                        SessionClientController.Command((connect) =>
                        {
                            var res = connect.PostingChat(mainCannal.Id, "/killmyallplease");
                            if (res != null && res.Status == 0)
                            {
                                SessionClientController.Disconnected("OCity_Dialog_DeletedData".Translate());
                            }
                        });
                    }
                };
                Find.WindowStack.Add(form);
            }, GeneralTexture.IconDelTex);
            list2.Add(item2);

            float num = OptionListingUtility.DrawOptionListing(rect2, list2);

            GUI.BeginGroup(rect2);
            if (Current.ProgramState == ProgramState.Entry && Widgets.ButtonImage(new Rect(0f, num + 10f, 64f, 32f), LanguageDatabase.activeLanguage.icon))
            {
                List <FloatMenuOption> list3 = new List <FloatMenuOption>();
                foreach (LoadedLanguage current in LanguageDatabase.AllLoadedLanguages)
                {
                    LoadedLanguage localLang = current;
                    list3.Add(new FloatMenuOption(localLang.FriendlyNameNative, delegate
                    {
                        LanguageDatabase.SelectLanguage(localLang);
                        Prefs.Save();
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(list3));
            }
            GUI.EndGroup();

            /*
             * var rectCannals = new Rect(inRect.x, inRect.y, 100f, (float)Math.Round((decimal)(inRect.height / 2f * 10f)) / 10f);
             * Widgets.DrawBoxSolid(inRect, new Color(0.2f, 0.2f, 0));
             * Widgets.DrawBoxSolid(rectCannals, new Color(0.4f, 0.4f, 0));
             *
             *
             * Widgets.DrawBoxSolid(new Rect(inRect.x + 110f, inRect.y, inRect.width - 110f, inRect.height - 40f)
             *  , new Color(0.4f, 0, 0));
             *
             * Widgets.DrawBoxSolid(new Rect(inRect.x + 110f, inRect.y + inRect.height - 35f, inRect.width - 110f, 25f)
             *  , new Color(0, 0, 0.4f));
             *
             * Widgets.Label(inRect, "Вкладка 3");
             */
        }
Ejemplo n.º 3
0
        private static void UpdateWorld(bool firstRun = false)
        {
            lock (UpdatingWorld)
            {
                Command((connect) =>
                {
                    //собираем пакет на сервер
                    var toServ = new ModelPlayToServer()
                    {
                        UpdateTime = Data.UpdateTime, //время прошлого запроса
                    };
                    //данные сохранения игры
                    if (Data.SaveFileData != null)
                    {
                        toServ.SaveFileData = Data.SaveFileData;
                        toServ.SingleSave   = Data.SingleSave;
                        Data.SaveFileData   = null;
                    }

                    //собираем данные с планеты
                    if (!firstRun)
                    {
                        UpdateWorldController.SendToServer(toServ);
                    }

                    if (firstRun)
                    {
                        GetPlayersInfoCountRequest = 0;
                    }

                    //запрос на информацию об игроках. Можно будет ограничить редкое получение для тех кто оффлайн
                    if (Data.Chats != null && Data.Chats[0].PartyLogin != null)
                    {
                        if (Data.Players == null || Data.Players.Count == 0 ||
                            GetPlayersInfoCountRequest % 5 == 0)
                        {
                            //в начале и раз в пол минуты (5 сек между UpdateWorld * 5) получаем инфу обо всех
                            toServ.GetPlayersInfo = Data.Chats[0].PartyLogin;
                        }
                        else
                        {
                            //в промежутках о тех кто онлайн
                            toServ.GetPlayersInfo = Data.Players.Values.Where(p => p.Online).Select(p => p.Public.Login).ToList();
                        }
                        GetPlayersInfoCountRequest++;
                        //Loger.Log("Client " + My.Login + " UpdateWorld* " + (toServ.GetPlayersInfo.Count.ToString())
                        //    + " " + (toServ.GetPlayersInfo.Any(p => p == SessionClientController.My.Login) ? "1" : "0"));
                    }

                    //отправляем на сервер, получаем ответ
                    ModelPlayToClient fromServ = connect.PlayInfo(toServ);

                    //Loger.Log("Client UpdateWorld 5 ");
                    Loger.Log("Client " + My.Login + " UpdateWorld "
                              + string.Format("Отпр. свои {0}, своиDel {1}{5}. Пришло {2}, del {3}, игроков {8}, посылок {4}{6}{7}"
                                              , toServ.WObjects == null ? 0 : toServ.WObjects.Count
                                              , toServ.WObjectsToDelete == null ? 0 : toServ.WObjectsToDelete.Count
                                              , fromServ.WObjects == null ? 0 : fromServ.WObjects.Count
                                              , fromServ.WObjectsToDelete == null ? 0 : fromServ.WObjectsToDelete.Count
                                              , fromServ.Mails == null ? 0 : fromServ.Mails.Count
                                              , toServ.SaveFileData == null || toServ.SaveFileData.Length == 0 ? "" : ", сейв"
                                              , fromServ.AreAttacking ? " Атакуют!" : ""
                                              , fromServ.NeedSaveAndExit ? " Команда на отключение" : ""
                                              , fromServ.PlayersInfo == null ? "null" : fromServ.PlayersInfo.Count.ToString()
                                              ));

                    //сохраняем время актуальности данных
                    Data.UpdateTime = fromServ.UpdateTime;
                    if (!string.IsNullOrEmpty(fromServ.KeyReconnect))
                    {
                        Data.KeyReconnect = fromServ.KeyReconnect;
                    }

                    //обновляем информацию по игрокам
                    if (fromServ.PlayersInfo != null && fromServ.PlayersInfo.Count > 0)
                    {
                        foreach (var pi in fromServ.PlayersInfo)
                        {
                            if (pi.Login == null)
                            {
                                continue;
                            }
                            Data.Players[pi.Login] = new PlayerClient()
                            {
                                Public = pi
                            };
                            if (pi.Login == My.Login)
                            {
                                My        = pi;
                                Data.MyEx = Data.Players[pi.Login];
                                //Loger.Log("Client " + My.Login + " UpdateWorld* " + My.LastOnlineTime.ToString("o") + " " + DateTime.UtcNow.ToString("o")
                                //   + " " + (toServ.GetPlayersInfo.Any(p => p == My.Login) ? "1" : "0"));
                            }
                        }
                    }

                    //обновляем планету
                    UpdateWorldController.LoadFromServer(fromServ, firstRun);

                    //обновляем инфу по поселениям
                    var allWObjects = Find.WorldObjects.AllWorldObjects
                                      .Select(o => o as CaravanOnline)
                                      .Where(o => o != null)
                                      .ToList();
                    foreach (var pi in Data.Players)
                    {
                        if (pi.Value.Public.Login == My.Login)
                        {
                            continue;
                        }
                        pi.Value.WObjects = allWObjects.Where(wo => wo.OnlinePlayerLogin == pi.Key).ToList();
                    }

                    //Сохраняем и выходим
                    if (fromServ.NeedSaveAndExit)
                    {
                        if (!SessionClientController.Data.BackgroundSaveGameOff)
                        {
                            SessionClientController.SaveGameNow(false, () =>
                            {
                                SessionClientController.Disconnected("OCity_SessionCC_Shutdown_Command_ProgressSaved".Translate());
                            });
                        }
                        else
                        {
                            SessionClientController.Disconnected("OCity_SessionCC_Shutdown_Command".Translate());
                        }
                    }

                    //если на нас напали запускаем процесс
                    if (fromServ.AreAttacking && GameAttackHost.AttackMessage())
                    {
                        GameAttackHost.Get.Start(connect);
                    }
                });
            }
        }
Ejemplo n.º 4
0
        public void DoTab2Contents(Rect inRect)
        {
            Text.Font = GameFont.Medium;
            Widgets.Label(inRect, "OCity_Dialog_AboutMode".Translate());

            Text.Font = GameFont.Small;
            //var chatTextSize = Text.CalcSize(InfoTabText);
            var chatAreaOuter = new Rect(inRect.x + 150f, inRect.y + 40f, inRect.width - 150f, inRect.height - 30f - 40f);
            var chatAreaInner = new Rect(0, 0
                                         , /*inRect.width - (inRect.x + 50f)*/ chatAreaOuter.width - ListBox <string> .WidthScrollLine
                                         , 0 /*chatTextSize.y*/);

            chatAreaInner.height = Text.CalcHeight(AboutTabText, chatAreaInner.width);

            InfoScrollPosition = GUI.BeginScrollView(chatAreaOuter, InfoScrollPosition, chatAreaInner);
            GUILayout.BeginArea(chatAreaInner);
            GUILayout.TextField(AboutTabText, "Label");
            GUILayout.EndArea();
            GUI.EndScrollView();

            var rect2 = new Rect(inRect.x, inRect.y + inRect.height / 2f, 150f, inRect.height - 30f - 40f);

            Text.Font = GameFont.Small;
            List <ListableOption> list2 = new List <ListableOption>();
            ListableOption        item2 = new ListableOption_WebLink("OCity_Dialog_AutorPage".Translate(), "https://vk.com/rimworldonline", IconForums);

            list2.Add(item2);
            float num = OptionListingUtility.DrawOptionListing(rect2, list2);

            rect2     = new Rect(inRect.x, inRect.y + 30f, 150f, 40f);
            Text.Font = GameFont.Small;
            list2     = new List <ListableOption>();
            item2     = new ListableOption_WebLink("OCity_Dialog_Regame".Translate(), () =>
            {
                var form             = new Dialog_Input("OCity_Dialog_DeleteData".Translate(), "OCity_Dialog_DeleteDataCheck".Translate());
                form.PostCloseAction = () =>
                {
                    if (form.ResultOK)
                    {
                        var mainCannal = SessionClientController.Data.Chats[0];
                        SessionClientController.Command((connect) =>
                        {
                            if (connect.PostingChat(mainCannal.Id, "/killmyallpleace"))
                            {
                                SessionClientController.Disconnected("OCity_Dialog_DeletedData".Translate());
                            }
                        });
                    }
                };
                Find.WindowStack.Add(form);
            }, IconDelTex);
            list2.Add(item2);
            num = OptionListingUtility.DrawOptionListing(rect2, list2);

            /*
             * GUI.BeginGroup(rect2);
             * if (Current.ProgramState == ProgramState.Entry && Widgets.ButtonImage(new Rect(0f, num + 10f, 64f, 32f), LanguageDatabase.activeLanguage.icon))
             * {
             *  List<FloatMenuOption> list3 = new List<FloatMenuOption>();
             *  foreach (LoadedLanguage current in LanguageDatabase.AllLoadedLanguages)
             *  {
             *      LoadedLanguage localLang = current;
             *      list3.Add(new FloatMenuOption(localLang.FriendlyNameNative, delegate
             *      {
             *          LanguageDatabase.SelectLanguage(localLang);
             *          Prefs.Save();
             *      }, MenuOptionPriority.Default, null, null, 0f, null, null));
             *  }
             *  Find.WindowStack.Add(new FloatMenu(list3));
             * }
             * GUI.EndGroup();
             */

            /*
             * var rectCannals = new Rect(inRect.x, inRect.y, 100f, (float)Math.Round((decimal)(inRect.height / 2f * 10f)) / 10f);
             * Widgets.DrawBoxSolid(inRect, new Color(0.2f, 0.2f, 0));
             * Widgets.DrawBoxSolid(rectCannals, new Color(0.4f, 0.4f, 0));
             *
             *
             * Widgets.DrawBoxSolid(new Rect(inRect.x + 110f, inRect.y, inRect.width - 110f, inRect.height - 40f)
             *  , new Color(0.4f, 0, 0));
             *
             * Widgets.DrawBoxSolid(new Rect(inRect.x + 110f, inRect.y + inRect.height - 35f, inRect.width - 110f, 25f)
             *  , new Color(0, 0, 0.4f));
             *
             * Widgets.Label(inRect, "Вкладка 3");
             */
        }