/// <summary> /// 技術ツリーに項目ラベルを追加する /// </summary> /// <param name="item">追加対象の項目</param> /// <param name="position">追加対象の位置</param> public void AddItem(ITechItem item, TechPosition position) { TechItem tech = item as TechItem; if (tech != null) { AddTechItem(tech, position); return; } TechLabel label = item as TechLabel; if (label != null) { AddLabelItem(label, position); return; } TechEvent ev = item as TechEvent; if (ev != null) { AddEventItem(ev, position); } }
public override void UpdateHoverElements(List <KSelectable> selected) { HoverTextScreen instance = HoverTextScreen.Instance; HoverTextDrawer hoverTextDrawer = instance.BeginDrawing(); hoverTextDrawer.BeginShadowBar(false); switch (currentReqState) { case PlanScreen.RequirementsState.Materials: case PlanScreen.RequirementsState.Complete: hoverTextDrawer.DrawText(UI.TOOLTIPS.NOMATERIAL.text.ToUpper(), HoverTextStyleSettings[0]); hoverTextDrawer.NewLine(26); hoverTextDrawer.DrawText(UI.TOOLTIPS.SELECTAMATERIAL, HoverTextStyleSettings[1]); break; case PlanScreen.RequirementsState.Tech: { TechItem techItem = Db.Get().TechItems.Get(currentDef.PrefabID); Tech parentTech = techItem.parentTech; hoverTextDrawer.DrawText(string.Format(UI.PRODUCTINFO_RESEARCHREQUIRED, parentTech.Name).ToUpper(), HoverTextStyleSettings[0]); break; } } hoverTextDrawer.NewLine(26); hoverTextDrawer.DrawIcon(instance.GetSprite("icon_mouse_right"), 18); hoverTextDrawer.DrawText(backStr, Styles_Instruction.Standard); hoverTextDrawer.EndShadowBar(); hoverTextDrawer.EndDrawing(); }
public void SetInfo(TechItem item) { Item = item; TechName.Text = item.Name; TechAmount.Text = $"${item.Cost}"; TechDuration.Text = $"({item.DurationTicks / 4}s)"; Shortcut.Text = item.ShortcutKey; BackColor = NormColour; if (!string.IsNullOrWhiteSpace(item.Icon)) { TechIcon.Image = Image.FromFile(StrategyGame.IconPicDir + item.Icon); } InvestmentProgress.Maximum = item.Cost; TimeProgress.Maximum = item.DurationTicks; UpdateTime(); if (Item.Unlocked) { BackColor = UnlockedColour; InvestmentProgress.Value = InvestmentProgress.Maximum; TimeProgress.Value = TimeProgress.Maximum; } }
/// <summary> /// 項目を書き出す /// </summary> /// <param name="item">項目</param> /// <param name="writer">ファイル書き込み用</param> private static void WriteTechItem(ITechItem item, StreamWriter writer) { TechItem techItem = item as TechItem; if (techItem != null) { WriteApplication(techItem, writer); return; } TechLabel labelItem = item as TechLabel; if (labelItem != null) { WriteLabel(labelItem, writer); return; } TechEvent eventItem = item as TechEvent; if (eventItem != null) { WriteEvent(eventItem, writer); } }
/// <summary> /// applicationセクションを書き出す /// </summary> /// <param name="item">技術項目</param> /// <param name="writer">ファイル書き込み用</param> private static void WriteApplication(TechItem item, StreamWriter writer) { writer.WriteLine(" # {0}", Config.ExistsKey(item.Name) ? Config.GetText(item.Name) : ""); writer.WriteLine(" application ="); writer.WriteLine(" {{ id = {0}", item.Id); writer.WriteLine(" name = {0}", item.Name); if (!string.IsNullOrEmpty(item.Desc)) { writer.WriteLine(" desc = {0}", item.Desc); } foreach (TechPosition position in item.Positions) { writer.WriteLine(" position = {{ x = {0} y = {1} }}", position.X, position.Y); } if (Game.Type == GameType.DarkestHour && !string.IsNullOrEmpty(item.PictureName)) { writer.WriteLine(" picture = \"{0}\"", item.PictureName); } writer.WriteLine(" year = {0}", item.Year); foreach (TechComponent component in item.Components) { WriteComponent(component, writer); } WriteRequired(item.AndRequiredTechs, writer); if (item.OrRequiredTechs.Count > 0) { WriteOrRequired(item.OrRequiredTechs, writer); } WriteEffects(item.Effects, writer); writer.WriteLine(" }"); }
private void AddAllReqTech(TechItem item, List <TechItem> tech) { var allTech = _game.TechTree[0].TechItems; if (item.Type == ETechType.Base) { var name = item.Name + " Constructor"; var con = allTech.FirstOrDefault(_ => _.Type == ETechType.Construction && _.Name == name); tech.Add(con); } if (item.DependsOnIds == null || item.DependsOnIds.Length == 0) { return; } var newTech = (from t in allTech where item.DependsOnIds.Contains(t.Id) && !tech.Any(_ => _.Id == t.Id) select t).ToList(); tech.AddRange(newTech); foreach (var t in newTech) { AddAllReqTech(t, tech); } }
/// <summary> /// 研究機関リストを更新する /// </summary> private void UpdateTeamList() { // 技術リストビューの選択項目がなければ研究機関リストをクリアする if (techListView.SelectedItems.Count == 0) { teamListView.BeginUpdate(); teamListView.Items.Clear(); teamListView.EndUpdate(); return; } TechItem tech = techListView.SelectedItems[0].Tag as TechItem; if (tech == null) { return; } // 研究速度リストを更新する Researches.UpdateResearchList(tech, _teamList); teamListView.BeginUpdate(); teamListView.Items.Clear(); // 項目を順に登録する int rank = 1; foreach (Research research in Researches.Items) { teamListView.Items.Add(CreateTeamListViewItem(research, rank)); rank++; } teamListView.EndUpdate(); }
public void RefreshSelectors() { if (activeRecipe != null) { MaterialSelectors.ForEach(delegate(MaterialSelector selector) { selector.gameObject.SetActive(false); }); TechItem techItem = Db.Get().TechItems.TryGet(activeRecipe.GetBuildingDef().PrefabID); if (!DebugHandler.InstantBuildMode && !Game.Instance.SandboxModeActive && techItem != null && !techItem.IsComplete()) { ResearchRequired.SetActive(true); LocText[] componentsInChildren = ResearchRequired.GetComponentsInChildren <LocText>(); componentsInChildren[0].text = UI.PRODUCTINFO_RESEARCHREQUIRED; componentsInChildren[1].text = string.Format(UI.PRODUCTINFO_REQUIRESRESEARCHDESC, techItem.parentTech.Name); componentsInChildren[1].color = Constants.NEGATIVE_COLOR; priorityScreen.gameObject.SetActive(false); } else { ResearchRequired.SetActive(false); for (int i = 0; i < activeRecipe.Ingredients.Count; i++) { MaterialSelectors[i].gameObject.SetActive(true); MaterialSelectors[i].ConfigureScreen(activeRecipe.Ingredients[i], activeRecipe); } priorityScreen.gameObject.SetActive(true); priorityScreen.gameObject.transform.SetAsLastSibling(); } } }
/// <summary> /// Select which tech will be unlocked at the end of the round /// </summary> /// <param name="tech">The tech to select</param> public void SelectTech(TechItem tech) { //Make sure this is a valid selection if (!tech.IsUnlocked && tech.IsAvailable) { selectedTech = tech; } }
// Use this for initialization void Start() { netMoney = 0; netPowerLimit = 0; netPop = 0; netAQI = 0; selectedTech = null; }
/// <summary> /// Reset all the values we keep track of for the round /// </summary> private void ResetRound() { netMoney = 0; netPowerLimit = 0; netPop = 0; netAQI = 0; selectedTech = null; }
private void OnKctTechCompleted(TechItem tech) { if (CareerEventScope.ShouldIgnore) { return; } AddTechEvent(tech); }
public void CheckGlobalUpgradesAreRecognised() { var upgrades = _target.TechItems.Where(_ => _.Name.Contains("%")).ToList(); foreach (var e in upgrades) { TechItem.IsGlobalUpgrade(e.Name).ShouldBe(true); } }
public async Task <ActionResult> userCreate([FromBody] TechItem techItem, [FromServices] DataContext context, int id) { context.Techs.Add(techItem); await context.SaveChangesAsync(); return(new ObjectResult(techItem) { StatusCode = 201 }); }
private void TryToInvestInBases(List <TechItem> consCanBuild, List <int> ourSectors) { if (ourSectors.Count >= _game.Map.Sectors.Count - 1) { return; } var found = false; var loopCount = 0; var techCons = consCanBuild.Where(_ => _.Name.Contains("Expansion") || _.Name.Contains("Supremacy") || _.Name.Contains("Tactical") || _.Name.Contains("Shipyard")).ToList(); var baseCons = consCanBuild.Where(_ => _.Name.Contains("Outpost") || _.Name.Contains("Starbase")).ToList(); if (techCons.Count == 0 && baseCons.Count == 0) { return; } // Build an Outpost/Starbase/Techbase/Shipyard while (!found && loopCount < 10) { loopCount++; TechItem con = null; if (!_flagBuiltTech && techCons.Count > 0) { con = techCons[StrategyGame.Random.Next(techCons.Count)]; } else { if (StrategyGame.RandomChance(0.5f) && baseCons.Count > 0) { con = baseCons[0]; } else if (techCons.Count > 0) { con = techCons[0]; } } if (con == null) { continue; } var remaining = con.Cost - con.AmountInvested; if (remaining <= 0) { continue; } var invested = _game.SpendCredits(Team, remaining); con.AmountInvested += invested; found = true; } }
public KCT_TechStorageItem FromTechItem(TechItem techItem) { techName = techItem.TechName; techID = techItem.TechID; progress = techItem.Progress; scienceCost = techItem.ScienceCost; startYear = techItem.StartYear; endYear = techItem.EndYear; return(this); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="tech">技術項目</param> /// <param name="team">研究機関</param> public Research(TechItem tech, Team team) { Tech = tech; Team = team; GameDate date = Researches.DateMode == ResearchDateMode.Specified ? Researches.SpecifiedDate : new GameDate(tech.Year); Days = GetTechDays(tech, team, date); EndDate = date.Plus(Days); }
/// <summary> /// 技術IDを変更する /// </summary> /// <param name="item">技術項目</param> /// <param name="id">技術ID</param> public static void ModifyTechId(TechItem item, int id) { // 値の変更前に技術項目とIDの対応付けを削除する TechIds.Remove(id); TechIdMap.Remove(id); // 値を更新する item.Id = id; // 技術項目とIDの対応付けを更新する UpdateTechIdMap(); }
public void AddTechEvent(TechItem tech) { if (CareerEventScope.ShouldIgnore || !IsEnabled) { return; } _techEvents.Add(new TechResearchEvent(KSPUtils.GetUT()) { NodeName = tech.ProtoNode.techID, YearMult = tech.YearBasedRateMult, ResearchRate = tech.BuildRate }); }
public void CheckNegativeGlobalUpgradesAreAllApplied() { var upgrades = _target.TechItems.Where(_ => _.Name.Contains("-") && _.Name.Contains("%")).ToList(); foreach (var e in upgrades) { e.ApplyGlobalUpgrade(_target); var type = TechItem.GetGlobalUpgradeType(e.Name); var amount = TechItem.GetGlobalUpgradeAmount(e.Name); _target.ResearchedUpgrades[type].ShouldBe(1 + amount); } }
/// <summary> /// 研究速度リストを更新する /// </summary> /// <param name="tech">対象技術</param> /// <param name="teams">研究機関</param> public static void UpdateResearchList(TechItem tech, IEnumerable <Team> teams) { Items.Clear(); // 研究速度を順に登録する foreach (Team team in teams) { Research research = new Research(tech, team); Items.Add(research); } // 研究日数の順にソートする Items.Sort((research1, research2) => research1.Days - research2.Days); }
/// <summary> /// 技術の研究に要する日数を取得する /// </summary> /// <param name="tech">技術項目</param> /// <param name="team">研究機関</param> /// <param name="date">開始日</param> /// <returns>研究に要する日数</returns> private static int GetTechDays(TechItem tech, Team team, GameDate date) { int offset = date.Difference(new GameDate(tech.Year)); int days = 0; foreach (TechComponent component in tech.Components) { int day = GetComponentDays(component, offset, team); offset += day; days += day; } return(days); }
/// <summary> /// 技術項目描画時の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void OnTechItemPaint(object sender, PaintEventArgs e) { Label label = sender as Label; TechLabelInfo info = label?.Tag as TechLabelInfo; TechItem techItem = info?.Item as TechItem; string s = techItem?.GetShortName(); if (string.IsNullOrEmpty(s)) { return; } Brush brush = new SolidBrush(Color.Black); e.Graphics.DrawString(s, label.Font, brush, 6, 2); brush.Dispose(); }
/// <summary> /// 技術リストビューの項目を作成する /// </summary> /// <param name="tech">技術データ</param> /// <returns>技術リストビューの項目</returns> private static ListViewItem CreateTechListViewItem(TechItem tech) { if (tech == null) { return(null); } ListViewItem item = new ListViewItem { Text = Config.GetText(tech.Name), Tag = tech }; item.SubItems.Add(IntHelper.ToString(tech.Id)); item.SubItems.Add(IntHelper.ToString(tech.Year)); item.SubItems.Add(""); return(item); }
/// <summary> /// 技術リストビューのサブ項目描画処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnTechListViewDrawSubItem(object sender, DrawListViewSubItemEventArgs e) { switch (e.ColumnIndex) { case 3: // 小研究 e.Graphics.FillRectangle( techListView.SelectedIndices.Count > 0 && e.ItemIndex == techListView.SelectedIndices[0] ? (techListView.Focused ? SystemBrushes.Highlight : SystemBrushes.Control) : SystemBrushes.Window, e.Bounds); TechItem tech = techListView.Items[e.ItemIndex].Tag as TechItem; if (tech == null) { break; } DrawTechSpecialityItems(e, tech); break; default: e.DrawDefault = true; break; } }
/// <summary> /// 技術リストビューの研究特性項目描画処理 /// </summary> /// <param name="e"></param> /// <param name="tech">技術項目</param> private void DrawTechSpecialityItems(DrawListViewSubItemEventArgs e, TechItem tech) { if (tech == null) { e.DrawDefault = true; return; } Rectangle gr = new Rectangle(e.Bounds.X + 4, e.Bounds.Y + 1, DeviceCaps.GetScaledWidth(16), DeviceCaps.GetScaledHeight(16)); Rectangle tr = new Rectangle(e.Bounds.X + DeviceCaps.GetScaledWidth(16) + 3, e.Bounds.Y + 3, e.Bounds.Width - DeviceCaps.GetScaledWidth(16) - 3, e.Bounds.Height); Brush brush = new SolidBrush( (techListView.SelectedIndices.Count > 0) && (e.ItemIndex == techListView.SelectedIndices[0]) ? (techListView.Focused ? SystemColors.HighlightText : SystemColors.ControlText) : SystemColors.WindowText); foreach (TechComponent component in tech.Components) { // 研究特性アイコンを描画する if ((component.Speciality != TechSpeciality.None) && ((int)component.Speciality - 1 < Techs.SpecialityImages.Images.Count)) { e.Graphics.DrawImage( Techs.SpecialityImages.Images[Array.IndexOf(Techs.Specialities, component.Speciality) - 1], gr); } // 研究難易度を描画する e.Graphics.DrawString(IntHelper.ToString(component.Difficulty), techListView.Font, brush, tr); // 次の項目の開始位置を計算する int offset = DeviceCaps.GetScaledWidth(32); gr.X += offset; tr.X += offset; } brush.Dispose(); }
/// <summary> /// 重複文字列リストの項目を削除する /// </summary> /// <param name="item">技術項目</param> public static void RemoveDuplicatedListItem(ITechItem item) { TechItem techItem = item as TechItem; if (techItem != null) { DecrementDuplicatedListCount(techItem.Name); DecrementDuplicatedListCount(techItem.ShortName); DecrementDuplicatedListCount(techItem.Desc); foreach (TechComponent component in techItem.Components) { DecrementDuplicatedListCount(component.Name); } return; } TechLabel labelItem = item as TechLabel; if (labelItem != null) { DecrementDuplicatedListCount(labelItem.Name); } }
public ToggleEntry(ToggleInfo toggle_info, HashedString plan_category, List <BuildingDef> building_defs, bool hideIfNotResearched) { toggleInfo = toggle_info; planCategory = plan_category; buildingDefs = building_defs; this.hideIfNotResearched = hideIfNotResearched; pendingResearchAttentions = new List <Tag>(); requiredTechItems = new List <TechItem>(); toggleImages = null; foreach (BuildingDef building_def in building_defs) { TechItem techItem = Db.Get().TechItems.TryGet(building_def.PrefabID); if (techItem == null) { requiredTechItems.Clear(); break; } if (!requiredTechItems.Contains(techItem)) { requiredTechItems.Add(techItem); } } }
/// <summary> /// 技術ツリーに技術項目を追加する /// </summary> /// <param name="item">追加対象の項目</param> /// <param name="position">追加対象の位置</param> private void AddTechItem(TechItem item, TechPosition position) { Label label = new Label { Location = new Point(DeviceCaps.GetScaledWidth(position.X), DeviceCaps.GetScaledHeight(position.Y)), BackColor = Color.Transparent, Tag = new TechLabelInfo { Item = item, Position = position }, Size = new Size(_techLabelBitmap.Width, _techLabelBitmap.Height), Region = _techLabelRegion }; // ラベル画像を設定する if (ApplyItemStatus && (QueryItemStatus != null)) { QueryItemStatusEventArgs e = new QueryItemStatusEventArgs(item); QueryItemStatus(this, e); label.Image = e.Done ? (e.Blueprint ? _blueprintDoneTechLabelBitmap : _doneTechLabelBitmap) : (e.Blueprint ? _blueprintTechLabelBitmap : _techLabelBitmap); } else { label.Image = _techLabelBitmap; } label.Click += OnItemLabelClick; label.MouseClick += OnItemLabelMouseClick; label.MouseDown += OnItemLabelMouseDown; label.MouseUp += OnItemLabelMouseUp; label.MouseMove += OnItemLabelMouseMove; label.GiveFeedback += OnItemLabelGiveFeedback; label.Paint += OnTechItemPaint; _pictureBox.Controls.Add(label); }
/// <summary> /// リンクの切れた一時キーをリストに登録する /// </summary> private static void AddUnlinkedTempKey() { foreach (ITechItem item in Groups.SelectMany(grp => grp.Items)) { if (item is TechItem) { TechItem techItem = item as TechItem; if (Config.IsTempKey(techItem.Name)) { Config.AddTempKey(techItem.Name); } if (Config.IsTempKey(techItem.ShortName)) { Config.AddTempKey(techItem.ShortName); } if (Config.IsTempKey(techItem.Desc)) { Config.AddTempKey(techItem.Desc); } foreach (TechComponent component in techItem.Components) { if (Config.IsTempKey(component.Name)) { Config.AddTempKey(component.Name); } } } else if (item is TechLabel) { TechLabel labelItem = item as TechLabel; if (Config.IsTempKey(labelItem.Name)) { Config.AddTempKey(labelItem.Name); } } } }