// add a new feature to list public void addFeature(string featureName) { features.Add(featureName); ResearchData rd = new ResearchData(); dataDict[featureName] = rd; }
public void Deserialize(ResearchData rd) { level = rd.level; purchased_upgrades = rd.upgrades; managed = rd.managed; unlocked = rd.unlocked; DataRecovery(); }
public override void setData(GetReport_ReturnType returnData) { base.setData(returnData); string[] strArray = new string[] { ResearchData.getResearchName(returnData.genericData1), " : ", SK.Text("Reports_Research_Level", "Level"), " : ", (returnData.genericData2 + 1).ToString() }; base.lblSecondaryText.Text = string.Concat(strArray); base.lblSubTitle.Text = SK.Text("Reports_Research_Complete", "Research Complete"); base.btnUtility.Text.Text = SK.Text("GENERIC_Research", "Research"); base.btnUtility.Visible = true; }
public bool CheckResearchData(ResearchData researchData) { for (int i = 0; i < researchDatas.Length; i++) { if (researchDatas[i] == researchData) { return(researchs[i]); } } return(false); }
public void SelectToilet(int type) { toiletData = achievementManager.GetResearchDatas()[type]; playerController.enabled = true; playerController.SetIsInput(true); toiletObject = Instantiate(toiletData.Prefab, playerControllerObject.transform.position, Quaternion.identity); toiletObject.transform.SetParent(playerControllerObject.transform); toiletObject.transform.localPosition = new Vector3(0.0f, 0.5f, 0.0f); playerController.SetToiletObject(toiletObject); targetObject = GameObject.Find("TargetPoint"); toiletSelectCanvas.SetActive(false); isPlay = true; }
private void btnBuyVillage_Click() { if (this.buyVillageButton.Active) { if (GameEngine.Instance.World.canUserOwnMoreVillages() && GameEngine.Instance.World.isUserVillage(InterfaceMgr.Instance.getSelectedMenuVillage())) { int selectedVillage = InterfaceMgr.Instance.SelectedVillage; if (selectedVillage >= 0) { double villageGoldCost = GameEngine.Instance.LocalWorldData.villageGoldCost; double num3 = GameEngine.Instance.World.calcVillageDistance(InterfaceMgr.Instance.getSelectedMenuVillage(), selectedVillage) * GameEngine.Instance.LocalWorldData.villageCostDistanceMultiplier; villageGoldCost *= num3 + 1.0; if (GameEngine.Instance.World.getCurrentGold() >= villageGoldCost) { int num4 = 0; if (GameEngine.Instance.LocalWorldData.Alternate_Ruleset != 1) { num4 = ResearchData.getVillageBuyHonourCost(GameEngine.Instance.World.numVillagesOwned()); if (((num4 > 0) && GameEngine.Instance.World.FourthAgeWorld) && (GameEngine.Instance.World.numVillagesOwned() < GameEngine.Instance.World.MostAge4Villages)) { num4 = 0; } } if ((num4 <= 0) || (GameEngine.Instance.World.getCurrentHonour() >= num4)) { InterfaceMgr.Instance.openBuyVillageWindow(selectedVillage, true); } else { MyMessageBox.Show(SK.Text("EmptyVillagePanel_Not_Enough_Honour", "Not enough honour"), SK.Text("EmptyVillagePanel_Buy_Village_Error", "Buy Village Error")); } } else { MyMessageBox.Show(SK.Text("EmptyVillagePanel_Not_Enough_Gold", "Not enough gold"), SK.Text("EmptyVillagePanel_Buy_Village_Error", "Buy Village Error")); } } else { MyMessageBox.Show(SK.Text("EmptyVillagePanel_Not_Enough_Gold", "Not enough gold"), SK.Text("EmptyVillagePanel_Buy_Village_Error", "Buy Village Error")); } } else { MyMessageBox.Show(SK.Text("EmptyVillagePanel_No_More_Villages", "You cannot own more villages."), SK.Text("EmptyVillagePanel_Buy_Village_Error", "Buy Village Error")); } } }
// Use this for initialization void Start() { researchData = new ResearchData(); SetColonyResearch(researchData.GetNextColonyResearch()); SetMetropolyResearch(researchData.GetNextMetropolyResearch()); progressBar.SetStep(researchData.getSize() / 2); researchGoals = researchData.getSize() / 2; if (myAudioSource != null) { myAudioSource.clip = myAudioClip; myAudioSource.loop = true; myAudioSource.Play(); } }
public NotebookData(NotebookConfig config) : base(config) { // Add an empty string for every character foreach (char _ in config.Acronym) { acronymNotes.Add(""); } // Unlock each initial item foreach (ItemID item in config.InitiallyUnlockedItems) { UnlockItem(item); } research = new ResearchData(config); observations = new ObservationsData(config); concepts = new ConceptsData(config); testAndMetrics = new TestAndMetricsData(config); reports = new ReportsData(config); }
public void updateResearchTime(ResearchData data) { int width = -1; if ((data != null) && (data.researchingType >= 0)) { DateTime time = VillageMap.getCurrentServerTime(); TimeSpan span = (TimeSpan)(data.research_completionTime - time); int totalSeconds = (int)span.TotalSeconds; TimeSpan span2 = data.calcResearchTime(data.research_pointCount - 1, GameEngine.Instance.World.UserCardData, GameEngine.Instance.LocalWorldData); if (GameEngine.Instance.LocalWorldData.Alternate_Ruleset == 1) { span2 = new TimeSpan(span2.Ticks / 2L); } int num3 = (int)span2.TotalSeconds; if ((num3 == 30) && (GameEngine.Instance.World.getTutorialStage() == 5)) { num3 = 11; } this.images[6] = GFXLibrary.tab_3b_normal; this.images[7] = GFXLibrary.tab_3b_selected; this.tabControl1.addOverlayImages(3, GFXLibrary.tab_3c_normal, GFXLibrary.tab_3c_selected, 0xff); width = 3 + ((0x2c * (num3 - totalSeconds)) / num3); this.tabControl1.setOverlayWidth(3, width); this.refresh = true; } else { this.images[6] = GFXLibrary.tab_3_normal; this.images[7] = GFXLibrary.tab_3_selected; this.tabControl1.addOverlayImages(3, null, null, 0xff); } this.tabControl1.updateImageArray(this.images); if (width != this.lastWidth) { this.refresh = true; } this.lastWidth = width; }
public void updateBasedOnResearchData(ResearchData data, bool localForce) { if (data != null) { this.lastData = data; this.lastDataQueued = this.lastData; if (this.lastData.researchingType >= 0) { this.lastDataQueued = data.copyAndAdd(data.researchingType, false); if (data.research_queueEntries != null) { foreach (int num in data.research_queueEntries) { this.lastDataQueued = this.lastDataQueued.copyAndAdd(num, true); } } } this.applyData(data); if (((this.lastData != data) || this.forceUpdate) || localForce) { int num2 = this.startResearchScrollBar.Value; if (!this.startResearchScrollBar.Visible) { num2 = 0; } this.init(); this.forceUpdate = false; this.applyData(data); this.startResearchScrollBar.Value = num2; this.scrollBarMoved(); } } }
public void updateResearchTime(ResearchData data) { int width = -1; if ((data != null) && (data.researchingType >= 0)) { DateTime time = VillageMap.getCurrentServerTime(); TimeSpan span = (TimeSpan) (data.research_completionTime - time); int totalSeconds = (int) span.TotalSeconds; TimeSpan span2 = data.calcResearchTime(data.research_pointCount - 1, GameEngine.Instance.World.UserCardData, GameEngine.Instance.LocalWorldData); if (GameEngine.Instance.LocalWorldData.Alternate_Ruleset == 1) { span2 = new TimeSpan(span2.Ticks / 2L); } int num3 = (int) span2.TotalSeconds; if ((num3 == 30) && (GameEngine.Instance.World.getTutorialStage() == 5)) { num3 = 11; } this.images[6] = GFXLibrary.tab_3b_normal; this.images[7] = GFXLibrary.tab_3b_selected; this.tabControl1.addOverlayImages(3, GFXLibrary.tab_3c_normal, GFXLibrary.tab_3c_selected, 0xff); width = 3 + ((0x2c * (num3 - totalSeconds)) / num3); this.tabControl1.setOverlayWidth(3, width); this.refresh = true; } else { this.images[6] = GFXLibrary.tab_3_normal; this.images[7] = GFXLibrary.tab_3_selected; this.tabControl1.addOverlayImages(3, null, null, 0xff); } this.tabControl1.updateImageArray(this.images); if (width != this.lastWidth) { this.refresh = true; } this.lastWidth = width; }
public void researchDataChanged(ResearchData data) { if ((data != null) && this.researchPanel.isVisible()) { this.researchPanel.updateBasedOnResearchData(data, true); } }
public ResearchData OnResearch() { if (playerCount > 3) return null; if (myInfo.Money >= 100 && !myInfo.Researched.Contains("írás")) { ResearchData cmd = new ResearchData() { WhatToResearch = "írás" }; myInfo.Money -= 100; return cmd; } return null; }
private ResearchData researchIfPossible(string name, int cost, string depedency = null) { if (myInfo.Money >= cost && !myInfo.Researched.Contains(name)) { if (depedency == null) { ResearchData cmd = new ResearchData() { WhatToResearch = name }; return cmd; } else { if (myInfo.Researched.Contains(depedency)) { ResearchData cmd = new ResearchData() { WhatToResearch = name }; return cmd; } } } return null; }
private void applyData(ResearchData data) { int researchType = -1; int level = 0; this.researchAllowed = true; int num3 = data.research_points; if (data.research_queueEntries != null) { num3 -= data.research_queueEntries.Length; } if (data.researchingType >= 0) { if (!GameEngine.Instance.World.isAccountPremium() || !data.canDoMoreResearch()) { this.researchAllowed = false; } DateTime time = VillageMap.getCurrentServerTime(); if ((this.selectedQueueSlot >= 0) && ((data.research_queueEntries == null) || (this.selectedQueueSlot >= data.research_queueEntries.Length))) { this.selectedQueueSlot = -1; } if (this.selectedQueueSlot < 0) { TimeSpan span = (TimeSpan) (data.research_completionTime - time); int secsLeft = (int) (span.TotalSeconds + 0.5); if (secsLeft < 0) { secsLeft = 0; } this.timeProgressText.Text = SK.Text("Research_Completed_In", "Completed In") + " : " + VillageMap.createBuildTimeString(secsLeft); this.timeProgressText.Visible = true; if (GameEngine.Instance.World.isResearchLagging()) { this.timeProgressText.Text = this.timeProgressText.Text + " (" + SK.Text("Research_Lagging", "Research Overdue, Please wait") + ")"; } TimeSpan span2 = data.calcResearchTime(data.research_pointCount - 1, GameEngine.Instance.World.UserCardData, GameEngine.Instance.LocalWorldData); if (GameEngine.Instance.LocalWorldData.Alternate_Ruleset == 1) { span2 = new TimeSpan(span2.Ticks / 2L); } int totalSeconds = (int) span2.TotalSeconds; if (totalSeconds < 1) { totalSeconds = 1; } if ((totalSeconds == 30) && (GameEngine.Instance.World.getTutorialStage() == 5)) { totalSeconds = 11; } double curValue = span.TotalSeconds; if (curValue < 0.0) { curValue = 0.0; } curValue = totalSeconds - curValue; if (curValue < 0.0) { curValue = 0.0; } this.timeProgressBar.setValues(curValue, (double) totalSeconds); this.currentResearchCancelButton.Text.Text = SK.Text("GENERIC_Cancel", "Cancel"); researchType = data.researchingType; level = data.research[data.researchingType]; } else { TimeSpan span3 = (TimeSpan) (data.research_completionTime - time); if (this.selectedQueueSlot > 0) { for (int i = 0; i < this.selectedQueueSlot; i++) { TimeSpan span4 = data.calcResearchTime(data.research_pointCount + i, GameEngine.Instance.World.UserCardData, GameEngine.Instance.LocalWorldData); if (GameEngine.Instance.LocalWorldData.Alternate_Ruleset == 1) { span4 = new TimeSpan(span4.Ticks / 2L); } span3 += span4; } } int num8 = (int) (span3.TotalSeconds + 0.5); if (num8 < 0) { num8 = 0; } this.timeProgressText.Text = SK.Text("Research_Starts_In", "Starts In") + " : " + VillageMap.createBuildTimeString(num8); this.timeProgressText.Visible = true; this.timeProgressBar.setValues(0.0, 0.0); researchType = data.research_queueEntries[this.selectedQueueSlot]; level = 0; this.currentResearchCancelButton.Text.Text = SK.Text("Research_Remove_From_Queue", "Remove From Queue"); } this.currentResearchCancelButton.Enabled = true; } else { TimeSpan span5 = data.calcResearchTime(data.research_pointCount, GameEngine.Instance.World.UserCardData, GameEngine.Instance.LocalWorldData); if (GameEngine.Instance.LocalWorldData.Alternate_Ruleset == 1) { span5 = new TimeSpan(span5.Ticks / 2L); } int num9 = (int) span5.TotalSeconds; this.currentResearchCancelButton.Enabled = false; this.timeProgressText.Text = SK.Text("Research_Next_Duration", "Next Research Duration") + " : " + VillageMap.createBuildTimeString(num9); this.timeProgressBar.setValues(0.0, 0.0); } if (this.tooltipToShow >= 0) { researchType = this.tooltipToShow / 0x3e8; level = (this.tooltipToShow % 0x3e8) - 1; } if (researchType >= 0) { this.currentResearchInfoBoxHeadingText.Visible = true; this.currentResearchInfoBoxHeadingText.Text = ResearchData.getResearchName(researchType); this.currentResearchText.Text = this.currentResearchInfoBoxHeadingText.Text; this.currentResearchText.Visible = true; this.currentResearchImage.Image = (Image) this.getIllustration(researchType); if (this.currentResearchImage.Image != null) { this.currentResearchImage.Visible = true; } else { this.currentResearchImage.Visible = false; } this.currentResearchInfoBoxRow1Text.Text = ResearchData.getDescriptionText(researchType, level); this.currentResearchInfoBoxRow2Text.Text = ""; this.currentResearchInfoBoxRow3Text.Text = ResearchData.getEffectText(researchType, level, GameEngine.Instance.World.ThirdAgeWorld, GameEngine.Instance.World.FourthAgeWorld, GameEngine.Instance.LocalWorldData.Alternate_Ruleset == 1, GameEngine.Instance.LocalWorldData); this.currentResearchInfoBoxRow1Text.Visible = true; this.currentResearchInfoBoxRow2Text.Visible = this.dragOverlay.Visible; this.currentResearchInfoBoxRow3Text.Visible = this.dragOverlay.Visible; this.currentResearchBackgroundImage.Visible = true; this.currentResearchBackgroundImage2.Visible = false; if ((Program.mySettings.LanguageIdent == "tr") && ((((researchType == 14) || (researchType == 0x42)) || ((researchType == 0x2e) || (researchType == 0x29))) || ((researchType == 0x2b) || (researchType == 0x2a)))) { this.currentResearchText.Font = FontManager.GetFont("Arial", 8f, FontStyle.Regular); } else if ((Program.mySettings.LanguageIdent == "pl") && (((researchType == 14) || (researchType == 0x25)) || ((researchType == 0x2d) || (researchType == 50)))) { this.currentResearchText.Font = FontManager.GetFont("Arial", 8f, FontStyle.Regular); } else if ((Program.mySettings.LanguageIdent == "it") && (((researchType == 0x11) || (researchType == 0x43)) || (researchType == 0x29))) { this.currentResearchText.Font = FontManager.GetFont("Arial", 8f, FontStyle.Regular); } else if ((Program.mySettings.LanguageIdent == "pt") && ((((researchType == 0) || (researchType == 0x27)) || ((researchType == 0x11) || (researchType == 0x42))) || ((((researchType == 0x40) || (researchType == 10)) || ((researchType == 0x2b) || (researchType == 0x2c))) || ((researchType == 0x2d) || (researchType == 0x2e))))) { this.currentResearchText.Font = FontManager.GetFont("Arial", 8f, FontStyle.Regular); } else if ((Program.mySettings.LanguageIdent == "pt") && ((researchType == 0x22) || (researchType == 0x2a))) { this.currentResearchText.Font = FontManager.GetFont("Arial", 7.5f, FontStyle.Regular); } else { this.currentResearchText.Font = FontManager.GetFont("Arial", 10f, FontStyle.Regular); } } else { this.currentResearchBackgroundImage2.Visible = true; this.currentResearchBackgroundImage.Visible = false; this.currentResearchInfoBoxRow1Text.Visible = false; this.currentResearchInfoBoxRow2Text.Visible = false; this.currentResearchInfoBoxRow3Text.Visible = false; this.currentResearchText.Visible = false; this.currentResearchImage.Visible = false; this.currentResearchInfoBoxHeadingText.Text = SK.Text("Research_No_Current", "No current research"); } this.pointsText.Text = SK.Text("Research_Research_Points", "Research Points") + " : " + num3.ToString(); NumberFormatInfo nFI = GameEngine.NFI; if (num3 <= 0) { this.researchAllowed = false; } double num10 = data.calcPointGoldCost(GameEngine.Instance.World.UserCardData, GameEngine.Instance.LocalWorldData); this.buyPointText.Text = num10.ToString("N", nFI); if (num10 <= GameEngine.Instance.World.getCurrentGold()) { this.buyPointButton.Enabled = true; } else { this.buyPointButton.Enabled = false; } this.queuedResearchImage1.Visible = false; this.queuedResearchImage2.Visible = false; this.queuedResearchImage3.Visible = false; this.queuedResearchImage4.Visible = false; this.queuedResearchImage5.Visible = false; this.queuedResearchImage6.Visible = false; this.queuedResearchImage7.Visible = false; this.queuedResearchButton1.Enabled = false; this.queuedResearchButton2.Enabled = false; this.queuedResearchButton3.Enabled = false; this.queuedResearchButton4.Enabled = false; this.queuedResearchButton5.Enabled = false; this.queuedResearchButton6.Enabled = false; this.queuedResearchButton7.Enabled = false; if (((data.research_queueEntries != null) && (data.research_queueEntries.Length > 0)) && (data.researchingType >= 0)) { for (int j = 0; j < data.research_queueEntries.Length; j++) { CustomSelfDrawPanel.CSDImage image = null; CustomSelfDrawPanel.CSDButton button = null; switch (j) { case 0: image = this.queuedResearchImage1; button = this.queuedResearchButton1; break; case 1: image = this.queuedResearchImage2; button = this.queuedResearchButton2; break; case 2: image = this.queuedResearchImage3; button = this.queuedResearchButton3; break; case 3: image = this.queuedResearchImage4; button = this.queuedResearchButton4; break; case 4: image = this.queuedResearchImage5; button = this.queuedResearchButton5; break; case 5: image = this.queuedResearchImage6; button = this.queuedResearchButton6; break; case 6: image = this.queuedResearchImage7; button = this.queuedResearchButton7; break; } image.Visible = true; image.Image = (Image) this.getIllustration(data.research_queueEntries[j]); image.Size = new Size(image.Size.Width / 2, image.Size.Height / 2); image.CustomTooltipID = 0x12e; image.CustomTooltipData = j; button.Enabled = true; button.ImageNorm = (Image) GFXLibrary.research_border_research_ill_normal; button.ImageOver = (Image) GFXLibrary.research_border_research_ill_over; button.ImageClick = (Image) GFXLibrary.research_border_research_ill_over; button.CustomTooltipID = 0x12e; button.CustomTooltipData = j; } } if (this.selectedQueueSlot >= 0) { CustomSelfDrawPanel.CSDButton button2 = null; switch (this.selectedQueueSlot) { case 0: button2 = this.queuedResearchButton1; break; case 1: button2 = this.queuedResearchButton2; break; case 2: button2 = this.queuedResearchButton3; break; case 3: button2 = this.queuedResearchButton4; break; case 4: button2 = this.queuedResearchButton5; break; case 5: button2 = this.queuedResearchButton6; break; case 6: button2 = this.queuedResearchButton7; break; } button2.ImageNorm = (Image) GFXLibrary.border_research_ill_selected_normal; button2.ImageOver = (Image) GFXLibrary.border_research_ill_selected_normal; button2.ImageClick = (Image) GFXLibrary.border_research_ill_selected_normal; } if (GameEngine.Instance.World.isAccountPremium()) { this.queuedResearchNoPremiumText.Visible = false; } else { this.queuedResearchNoPremiumText.Visible = true; } }
public void updateEmptyVillageText(int selectedVillage) { bool flag = false; bool flag2 = false; if (GameEngine.Instance.World.isSpecial(selectedVillage) && GameEngine.Instance.World.isAttackableSpecial(selectedVillage)) { bool flag3 = this.isTallTreasureChestPanel(selectedVillage); if (flag3 != this.wasTall) { this.init(selectedVillage); flag = true; } flag2 = flag3; } if (!flag && GameEngine.Instance.LocalWorldData.AIWorld) { bool flag4 = false; switch (GameEngine.Instance.World.getSpecial(selectedVillage)) { case 7: case 9: case 11: case 13: flag4 = true; break; default: flag4 = false; break; } if (flag4 != this.wasAiShort) { this.init(selectedVillage); } } NumberFormatInfo nFI = GameEngine.NFI; this.m_selectedVillage = selectedVillage; this.buyVillageButton.Enabled = true; this.attackButton_AI.Enabled = true; this.scoutButton_AI.Enabled = true; this.scoutButton_Resources.Enabled = true; this.treasureCastleTimeoutLabel.Visible = false; this.backGround_AI.Visible = false; this.backGround_Enemy.Visible = false; this.backGround_Resources.Visible = false; this.backGround_Charter.Visible = false; this.special = false; this.invasionLabel.Visible = false; this.backGround_AI.removeWikiLink(this.wikiLink); this.wikiLink = null; int type = GameEngine.Instance.World.getSpecial(selectedVillage); if (SpecialVillageTypes.IS_TREASURE_CASTLE(type)) { this.wikiLink = this.backGround_AI.addWikiLink(0x31); } else if ((type == 15) || (type == 0x11)) { this.wikiLink = this.backGround_AI.addWikiLink(50); } if (!GameEngine.Instance.World.isSpecial(selectedVillage)) { this.backGround_Charter.Visible = true; this.backGround_Charter.updateHeading(SK.Text("EmptyVillagePanel_Available_Village", "New Village Charter")); this.backGround_Charter.updatePanelTypeFromVillageID(selectedVillage); this.backGround_Charter.stretchBackground(); base.Parent.Invalidate(); double villageGoldCost = GameEngine.Instance.LocalWorldData.villageGoldCost; double num4 = GameEngine.Instance.World.calcVillageDistance(InterfaceMgr.Instance.getSelectedMenuVillage(), selectedVillage) * GameEngine.Instance.LocalWorldData.villageCostDistanceMultiplier; villageGoldCost *= num4 + 1.0; int numOwnedVillages = GameEngine.Instance.World.numVillagesOwned(); int num6 = (int)villageGoldCost; num6 *= numOwnedVillages; villageGoldCost = num6; this.goldLabel.Text = ((int)villageGoldCost).ToString("N", nFI); WorldData localWorldData = GameEngine.Instance.LocalWorldData; Point point = GameEngine.Instance.World.getVillageLocation(InterfaceMgr.Instance.OwnSelectedVillage); Point point2 = GameEngine.Instance.World.getVillageLocation(selectedVillage); double d = ((point.X - point2.X) * (point.X - point2.X)) + ((point.Y - point2.Y) * (point.Y - point2.Y)); d = Math.Sqrt(d) * ((localWorldData.CaptainsMoveSpeed * localWorldData.gamePlaySpeed) * ResearchData.CaptainTimes[GameEngine.Instance.World.UserResearchData.Research_Courtiers]); d *= CardTypes.getArmySpeed(GameEngine.Instance.World.UserCardData); string str = VillageMap.createBuildTimeString((int)d); this.travelTimeLabel.Text = str; this.travelTimeLabel.CustomTooltipID = 0x4e20; this.travelTimeLabel.CustomTooltipData = (int)d; int num8 = 0; if (GameEngine.Instance.LocalWorldData.Alternate_Ruleset != 1) { num8 = ResearchData.getVillageBuyHonourCost(numOwnedVillages); if (((num8 > 0) && GameEngine.Instance.World.FourthAgeWorld) && (numOwnedVillages < GameEngine.Instance.World.MostAge4Villages)) { num8 = 0; } } if (num8 > 0) { this.honourImage.Visible = true; this.honourLabel.Visible = true; this.honourLabel.Text = num8.ToString("N", nFI); } else { this.honourImage.Visible = false; this.honourLabel.Visible = false; } } else { this.special = true; if (GameEngine.Instance.World.isAttackableSpecial(selectedVillage)) { this.backGround_AI.Visible = true; this.backGround_AI.updateHeading(GameEngine.Instance.World.getVillageNameOrType(selectedVillage)); this.backGround_AI.updatePanelTypeFromVillageID(selectedVillage); if (SpecialVillageTypes.IS_TREASURE_CASTLE(type)) { if (GameEngine.Instance.World.isCapital(InterfaceMgr.Instance.OwnSelectedVillage)) { this.attackButton_AI.Enabled = false; } if (flag2) { this.updateTreasureCastleTimeout(); this.treasureCastleTimeoutLabel.Visible = true; this.attackButton_AI.Enabled = false; } } } else if ((type >= 100) && (type <= 0xc7)) { this.backGround_Resources.Visible = true; this.backGround_Resources.updateHeading(GameEngine.Instance.World.getVillageNameOrType(selectedVillage)); this.backGround_Resources.updatePanelTypeFromVillageID(selectedVillage); this.scoutButton_Resources.Enabled = false; } else { this.backGround_Enemy.Visible = true; if (type == 30) { switch (GameEngine.Instance.World.getAIInvasionMarkerState(selectedVillage)) { case 0: this.backGround_Enemy.updateHeading(SK.Text("Invasion_None", "No Invasion Sighted")); break; case 1: { this.backGround_Enemy.updateHeading(SK.Text("Invasion_Planned", "Invasion Sighted")); DateTime time = GameEngine.Instance.World.getNextAIInvasionDate(selectedVillage); if (time != DateTime.MinValue) { TimeSpan span = (TimeSpan)(time - VillageMap.getCurrentServerTime()); this.invasionLabel.Visible = true; this.invasionLabel.Text = VillageMap.createBuildTimeString((int)span.TotalSeconds); } break; } case 2: this.backGround_Enemy.updateHeading(SK.Text("Invasion_Inprogress", "Invasion In Progress")); break; } } else { this.backGround_Enemy.updateHeading(GameEngine.Instance.World.getVillageNameOrType(selectedVillage)); } this.backGround_Enemy.updatePanelTypeFromVillageID(selectedVillage); } if (!GameEngine.Instance.World.isScoutableSpecial(selectedVillage) || GameEngine.Instance.World.isCapital(InterfaceMgr.Instance.OwnSelectedVillage)) { this.scoutButton_AI.Enabled = false; this.scoutButton_Resources.Enabled = false; } else { this.scoutButton_AI.Enabled = true; this.scoutButton_Resources.Enabled = true; } } }
public ResearchData OnResearch() { if (myPlayer.Money >= 100 && !myPlayer.Researched.Contains("írás")) { ResearchData cmd = new ResearchData(); cmd.WhatToResearch = "írás"; myPlayer.Money -= 100; return cmd; } if (myPlayer.Money >= 300 && !myPlayer.Researched.Contains("bíróság") && myPlayer.Researched.Contains("írás")) { ResearchData cmd = new ResearchData(); cmd.WhatToResearch = "bíróság"; myPlayer.Money -= 300; return cmd; } return null; }
public static Dictionary <ButtonFunction, Dictionary <string, Research.Research> > ParseResearch(string filepath, ContentManager cm) { if (!File.Exists(filepath)) { return(null); } Dictionary <ButtonFunction, Dictionary <string, Research.Research> > dic = new Dictionary <ButtonFunction, Dictionary <string, Research.Research> >(); StreamReader sr = new StreamReader(filepath); string line = ""; var temp_data = new ResearchData(); List <KeyValuePair <Researchables, float> > res = new List <KeyValuePair <Researchables, float> >(); ButtonFunction bf = ButtonFunction.R1; while ((line = sr.ReadLine()) != null) { if (line.StartsWith("ButtonName")) { string[] split = line.Split('\t'); bf = (ButtonFunction)Enum.Parse(typeof(ButtonFunction), split[1]); } else if (line.StartsWith("ResearchName")) { string[] split = line.Split('\t'); temp_data.Name = split[1]; } else if (line.StartsWith("Cost")) { string[] split = line.Split('\t'); temp_data.ResearchTime = (float)Convert.ToDouble(split[1]); } else if (line.StartsWith("Texture")) { string[] split = line.Split('\t'); temp_data.Texture = cm.Load <Texture2D>(split[1]); } else if (line.StartsWith("Researchables")) { while ((line = sr.ReadLine()) != "RE") { string[] split = line.Split('\t'); res.Add(new KeyValuePair <Researchables, float>((Researchables)Enum.Parse(typeof(Researchables), split[0]), (float)Convert.ToDouble(split[1]))); } temp_data.Modifiers = new List <KeyValuePair <Researchables, float> >(res); if (!dic.ContainsKey(bf)) { dic.Add(bf, new Dictionary <string, Research.Research>()); dic[bf].Add(temp_data.Name, new Research.Research(temp_data)); } else { dic[bf].Add(temp_data.Name, new Research.Research(temp_data)); } res.Clear(); } } return(dic); }
// analyze data from CSV files and detect anomalies by given plugin public void analyzeData(String normalFlightPath, String newFlightPath, String anomalyDetPath) { // append feature names to files and save in resources folder string featuresStr = ""; int i; for (i = 0; i < features.Count - 1; i++) { featuresStr += features[i] + ","; } featuresStr += features[i]; string s; StreamReader normalFlightFile = new StreamReader(normalFlightPath); String pathReg = @"..\..\..\Resources\regFlightWithFeatures.csv"; StreamWriter normalFlightFile1 = new StreamWriter(pathReg); normalFlightFile1.WriteLine(featuresStr); while ((s = normalFlightFile.ReadLine()) != null) { normalFlightFile1.WriteLine(s); } normalFlightFile.Close(); normalFlightFile1.Close(); s = ""; StreamReader newFlightFile = new StreamReader(newFlightPath); String pathNew = @"..\..\..\Resources\newFlightWithFeatures.csv"; StreamWriter newFlightFile1 = new StreamWriter(pathNew); newFlightFile1.WriteLine(featuresStr); while ((s = newFlightFile.ReadLine()) != null) { newFlightFile1.WriteLine(s); } newFlightFile.Close(); newFlightFile1.Close(); // load dll Assembly asm = Assembly.LoadFile(anomalyDetPath); Type detectorType = asm.GetType("Detector.Detector"); // create instance of the Detector class from dll object detector = Activator.CreateInstance(detectorType); // load and analyze data from CSV files MethodInfo loadFlightData = detectorType.GetMethod("loadFlightData"); loadFlightData.Invoke(detector, new object[] { pathReg, pathNew, CorrThreshold }); // learn correlated features, plot models, anomalies MethodInfo getCorrFeature = detectorType.GetMethod("getCorrFeature"); MethodInfo getAnnotation = detectorType.GetMethod("getAnnotation"); MethodInfo isFeatureAnomalous = detectorType.GetMethod("isFeatureAnomalous"); int len = dataDict[features[0]].DataPoints.Count; // iterate through feature names foreach (String featureName in features) { ResearchData rd = dataDict[featureName]; // get correlative feature String correlated = getCorrFeature.Invoke(detector, new object[] { featureName }) as String; rd.Correlated = correlated; // if a correlative feature exists if (correlated != null) { float minX = 0, minY = 0, maxX = 0, maxY = 0; for (i = 0; i < len; i++) { // get x,y values float x = getValue(i, featureName), y = getValue(i, correlated); // check if point is anomalous bool isAnom = (bool)isFeatureAnomalous.Invoke(detector, new object[] { i, featureName }); if (isAnom) { // if anomalous add to anomalies, add null to other correlation points rd.CorrPoints.Add(null); rd.Anomalies.Add(new ScatterPoint(x, y, 2)); // add timestep to anomalies rd.AnomaliesTimesteps.Add(i); } else { // if not anomalous add to correlation points, add null to anomalous points rd.CorrPoints.Add(new ScatterPoint(x, y, 2)); rd.Anomalies.Add(null); } // update min/max x,y values if (x < minX) { minX = x; } else if (x > maxX) { maxX = x; } if (y < minY) { minY = y; } else if (y > maxY) { maxY = y; } } // get and set annotation for feature Annotation annot = getAnnotation.Invoke(detector, new object[] { featureName }) as Annotation; rd.PlotAnnotation = annot; // set min/max x,y values rd.MinX = minX; rd.MaxX = maxX; rd.MinY = minY; rd.MaxY = maxY; } } // delete any memory allocated by plugin MethodInfo deleteAH = detectorType.GetMethod("deleteAnomalyHelper"); deleteAH.Invoke(detector, null); }