private void ApplyRandomTrait(Worker worker)
	{
		Traits component = worker.GetComponent<Traits>();
		List<string> list = new List<string>();
		foreach (DUPLICANTSTATS.TraitVal gENESHUFFLERTRAIT in DUPLICANTSTATS.GENESHUFFLERTRAITS)
		{
			DUPLICANTSTATS.TraitVal current = gENESHUFFLERTRAIT;
			if (!component.HasTrait(current.id))
			{
				list.Add(current.id);
			}
		}
		Trait trait = null;
		if (list.Count > 0)
		{
			string id = list[Random.Range(0, list.Count)];
			trait = Db.Get().traits.TryGet(id);
			worker.GetComponent<Traits>().Add(trait);
			InfoDialogScreen infoDialogScreen = (InfoDialogScreen)GameScreenManager.Instance.StartScreen(ScreenPrefabs.Instance.InfoDialogScreen.gameObject, GameScreenManager.Instance.ssOverlayCanvas.gameObject, GameScreenManager.UIRenderTarget.ScreenSpaceOverlay);
			string text = string.Format(UI.GENESHUFFLERMESSAGE.BODY_SUCCESS, worker.GetProperName(), trait.Name, trait.GetTooltip());
			infoDialogScreen.SetHeader(UI.GENESHUFFLERMESSAGE.HEADER).AddPlainText(text);
			SetConsumed(true);
		}
		else
		{
			InfoDialogScreen infoDialogScreen2 = (InfoDialogScreen)GameScreenManager.Instance.StartScreen(ScreenPrefabs.Instance.InfoDialogScreen.gameObject, GameScreenManager.Instance.ssOverlayCanvas.gameObject, GameScreenManager.UIRenderTarget.ScreenSpaceOverlay);
			string text2 = string.Format(UI.GENESHUFFLERMESSAGE.BODY_FAILURE, worker.GetProperName());
			infoDialogScreen2.SetHeader(UI.GENESHUFFLERMESSAGE.HEADER).AddPlainText(text2);
		}
	}
        private static void WriteData(int day, ReportData data)
        {
            string reportsPath      = System.Reflection.Assembly.GetAssembly(typeof(ExportDailyReports_OptionsMenuScreen_OnPrefabInit)).Location;
            string reportsFile      = Path.Combine(Path.GetDirectoryName(SaveLoader.GetActiveSaveFilePath()), Path.GetFileNameWithoutExtension(SaveLoader.GetActiveSaveFilePath()) + "_" + day + "_General" + ".csv");
            string reportsPowerFile = Path.Combine(Path.GetDirectoryName(SaveLoader.GetActiveSaveFilePath()), Path.GetFileNameWithoutExtension(SaveLoader.GetActiveSaveFilePath()) + "_" + day + "_Power" + ".csv");

            try
            {
                WriteCSV(reportsFile, data.dataGeneral, data.headersGeneral);

                WriteCSV(reportsPowerFile, data.dataPower, data.headersPower);

                InfoDialogScreen infoDialogScreen = (InfoDialogScreen)GameScreenManager.Instance.StartScreen(ScreenPrefabs.Instance.InfoDialogScreen.gameObject, GameScreenManager.Instance.ssOverlayCanvas.gameObject);
                infoDialogScreen.SetHeader("Export Daily Reports").AddPlainText("Daily reports exported.");
                infoDialogScreen.Show();
            }
            catch (Exception e)
            {
                Debug.LogError(e);
                InfoDialogScreen infoDialogScreen = (InfoDialogScreen)GameScreenManager.Instance.StartScreen(ScreenPrefabs.Instance.InfoDialogScreen.gameObject, GameScreenManager.Instance.ssOverlayCanvas.gameObject);
                infoDialogScreen.SetHeader("Export Daily Reports").AddPlainText("Error exporting daily reports:\n" + e.ToString());
                infoDialogScreen.Show();
            }
        }
Пример #3
0
    private void OnClickRead()
    {
        InfoDialogScreen infoDialogScreen = (InfoDialogScreen)GameScreenManager.Instance.StartScreen(ScreenPrefabs.Instance.InfoDialogScreen.gameObject, GameScreenManager.Instance.ssOverlayCanvas.gameObject, GameScreenManager.UIRenderTarget.ScreenSpaceOverlay);

        infoDialogScreen.SetHeader(base.gameObject.GetComponent <KSelectable>().GetProperName());
        if (BeenClicked)
        {
            infoDialogScreen.AddPlainText(BeenSearched);
        }
        else
        {
            BeenClicked = true;
            if (base.gameObject.name == "GeneShuffler")
            {
                Game.Instance.unlocks.Unlock("neuralvacillator");
            }
            if (base.gameObject.name == "PropDesk")
            {
                string text = Game.Instance.unlocks.UnlockNext("emails");
                if (text != null)
                {
                    string str = "SEARCH" + UnityEngine.Random.Range(1, 6);
                    infoDialogScreen.AddPlainText(Strings.Get("STRINGS.UI.USERMENUACTIONS.READLORE.SEARCH_COMPUTER_SUCCESS." + str));
                    infoDialogScreen.AddOption(UI.USERMENUACTIONS.READLORE.GOTODATABASE, OpenCodex(text));
                }
                else
                {
                    string str2 = "SEARCH" + UnityEngine.Random.Range(1, 8);
                    infoDialogScreen.AddPlainText(Strings.Get("STRINGS.UI.USERMENUACTIONS.READLORE.SEARCH_COMPUTER_FAIL." + str2));
                }
            }
            else if (base.gameObject.name == "GeneShuffler" || base.gameObject.name == "MassiveHeatSink")
            {
                string text2 = Game.Instance.unlocks.UnlockNext("researchnotes");
                if (text2 != null)
                {
                    string str3 = "SEARCH" + UnityEngine.Random.Range(1, 3);
                    infoDialogScreen.AddPlainText(Strings.Get("STRINGS.UI.USERMENUACTIONS.READLORE.SEARCH_TECHNOLOGY_SUCCESS." + str3));
                    infoDialogScreen.AddOption(UI.USERMENUACTIONS.READLORE.GOTODATABASE, OpenCodex(text2));
                }
                else
                {
                    string str4 = "SEARCH1";
                    infoDialogScreen.AddPlainText(Strings.Get("STRINGS.UI.USERMENUACTIONS.READLORE.SEARCH_OBJECT_FAIL." + str4));
                }
            }
            else if (base.gameObject.name == "PropReceptionDesk")
            {
                Game.Instance.unlocks.Unlock("email_pens");
                infoDialogScreen.AddPlainText(UI.USERMENUACTIONS.READLORE.SEARCH_ELLIESDESK);
                infoDialogScreen.AddOption(UI.USERMENUACTIONS.READLORE.GOTODATABASE, OpenCodex("email_pens"));
            }
            else if (base.gameObject.name == "PropFacilityDesk")
            {
                Game.Instance.unlocks.Unlock("journal_magazine");
                infoDialogScreen.AddPlainText(UI.USERMENUACTIONS.READLORE.SEARCH_STERNSDESK);
                infoDialogScreen.AddOption(UI.USERMENUACTIONS.READLORE.GOTODATABASE, OpenCodex("journal_magazine"));
            }
            else if (base.gameObject.name == "HeadquartersComplete")
            {
                Game.Instance.unlocks.Unlock("pod_evacuation");
                infoDialogScreen.AddPlainText(UI.USERMENUACTIONS.READLORE.SEARCH_POD);
                infoDialogScreen.AddOption(UI.USERMENUACTIONS.READLORE.GOTODATABASE, OpenCodex("pod_evacuation"));
            }
            else if (base.gameObject.name == "PropFacilityDisplay")
            {
                Game.Instance.unlocks.Unlock("display_prop1");
                infoDialogScreen.AddPlainText(UI.USERMENUACTIONS.READLORE.SEARCH_DISPLAY);
                infoDialogScreen.AddOption(UI.USERMENUACTIONS.READLORE.GOTODATABASE, OpenCodex("display_prop1"));
            }
            else if (base.gameObject.name == "PropFacilityDisplay2")
            {
                Game.Instance.unlocks.Unlock("display_prop2");
                infoDialogScreen.AddPlainText(UI.USERMENUACTIONS.READLORE.SEARCH_DISPLAY);
                infoDialogScreen.AddOption(UI.USERMENUACTIONS.READLORE.GOTODATABASE, OpenCodex("display_prop2"));
            }
            else if (base.gameObject.name == "PropFacilityDisplay3")
            {
                Game.Instance.unlocks.Unlock("display_prop3");
                infoDialogScreen.AddPlainText(UI.USERMENUACTIONS.READLORE.SEARCH_DISPLAY);
                infoDialogScreen.AddOption(UI.USERMENUACTIONS.READLORE.GOTODATABASE, OpenCodex("display_prop3"));
            }
            else if (base.gameObject.name == "PropFacilityGlobeDroors")
            {
                Game.Instance.unlocks.Unlock("journal_newspaper");
                infoDialogScreen.AddPlainText(Strings.Get("STRINGS.UI.USERMENUACTIONS.READLORE.SEARCH_CABINET"));
                infoDialogScreen.AddOption(UI.USERMENUACTIONS.READLORE.GOTODATABASE, OpenCodex("journal_newspaper"));
            }
            else
            {
                string text3 = Game.Instance.unlocks.UnlockNext("journals");
                if (text3 != null)
                {
                    string str5 = "SEARCH" + UnityEngine.Random.Range(1, 6);
                    infoDialogScreen.AddPlainText(Strings.Get("STRINGS.UI.USERMENUACTIONS.READLORE.SEARCH_OBJECT_SUCCESS." + str5));
                    infoDialogScreen.AddOption(UI.USERMENUACTIONS.READLORE.GOTODATABASE, OpenCodex(text3));
                }
                else
                {
                    string str6 = "SEARCH1";
                    infoDialogScreen.AddPlainText(Strings.Get("STRINGS.UI.USERMENUACTIONS.READLORE.SEARCH_OBJECT_FAIL." + str6));
                }
            }
        }
    }
        private static void OnExportDailyReports()
        {
            bool error = false;

            if (ReportManager.Instance == null)
            {
                return;
            }
            List <DailyReport> dailyReports = ReportManager.Instance.reports;

            if (dailyReports == null)
            {
                return;
            }

            ReportData data = new ReportData();

            foreach (var report in dailyReports)
            {
                try
                {
                    //Debug.Log(report.day);

                    AddValueCycle("Cycle", report.day, data.dataGeneral, data.headersGeneral);
                    AddValueCycle("Cycle", report.day, data.dataPower, data.headersPower);


                    foreach (KeyValuePair <ReportManager.ReportType, ReportManager.ReportGroup> reportGroup in ReportManager.Instance.ReportGroups)
                    {
                        ReportManager.ReportEntry entry = report.GetEntry(reportGroup.Key);

                        bool showLine = true;
                        if (entry.accumulate == 0f)
                        {
                            showLine = reportGroup.Value.reportIfZero;
                        }

                        if (reportGroup.Value.isHeader)
                        {
                            //CreateHeader(reportGroup.Value);
                        }
                        else if (showLine)
                        {
                            CreateOrUpdateLine(entry, reportGroup.Value, report.day, data);
                        }
                        else
                        {
                            string columnName = (entry.context == null ? reportGroup.Value.stringKey : entry.context);
                            //Debug.Log("Hidden data: "+ columnName);
                        }
                    }
                }
                catch (Exception e)
                {
                    error = true;
                    Debug.LogError(e);
                    InfoDialogScreen infoDialogScreen = (InfoDialogScreen)GameScreenManager.Instance.StartScreen(ScreenPrefabs.Instance.InfoDialogScreen.gameObject, GameScreenManager.Instance.ssOverlayCanvas.gameObject);
                    infoDialogScreen.SetHeader("Export Daily Reports").AddPlainText("Error exporting daily reports:\n" + e.ToString());
                    infoDialogScreen.Show();
                    break;
                }
            }

            if (!error)
            {
                data.headersPower.Sort((f1, f2) =>
                {
                    if (f1.Equals("Cycle"))
                    {
                        return(-1);                                                     // Cycle is the first column
                    }
                    return(f1.CompareTo(f2));
                }
                                       );

                WriteData(dailyReports.Count, data);
            }

            data.dataGeneral.Clear();
            data.dataPower.Clear();

            data.headersGeneral.Clear();
            data.headersPower.Clear();
        }