/// <summary> /// For a single tech node, update the texture based on whether we can research it, are researching it, or what level it is /// </summary> /// <param name="player"></param> /// <param name="nodePath"></param> /// <param name="type"></param> /// <param name="level"></param> /// <param name="tier"></param> void UpdateNodeTexture(PlayerData player, string nodePath, ResearchType type, int level, bool tier) { var node = GetNode <TextureRect>(nodePath); // if the player is currently researching this ResearchType but doesn't have this level yet, set it to Researched if (player.TechBeingResearched == type && player.TechLevel[type] < level) { node.Texture = textureResearching; } else { bool techResearched = player.HasTech(type, level); bool techAvailableToResearch = player.CanResearch(type, level); // if we aren't researching any techs, set this texture based // on if we can research it orr not if (player.TechBeingResearched == ResearchType.None && !techResearched && techAvailableToResearch) { if (tier) { node.Texture = textureTier2; } else { node.Texture = textureTier3; } } else { node.Texture = textureDisabled; } } }
/// <summary> /// Complete tech research, increase our level and signal listeners /// </summary> /// <param name="type">The type of research completed</param> private void TechResearchComplete(ResearchType type) { // rev our tech level TechLevel[type]++; Signals.PublishPlayerResearchCompletedEvent(this, type); AddScore(ScoreType.ResearchComplete); }
public static AbstractNetwork CreateNetworkByType(ModelType mt, String rName, ResearchType rType, GenerationType gType, Dictionary <ResearchParameter, object> rParams, Dictionary <GenerationParameter, object> genParams, AnalyzeOption AnalyzeOptions, ContainerMode mode) { ModelTypeInfo[] info = (ModelTypeInfo[])mt.GetType().GetField(mt.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false); Type t = Type.GetType(info[0].Implementation); Type[] constructTypes = new Type[] { typeof(String), typeof(ResearchType), typeof(GenerationType), typeof(Dictionary <ResearchParameter, object>), typeof(Dictionary <GenerationParameter, object>), typeof(AnalyzeOption), typeof(ContainerMode) }; object[] invokeParams = new object[] { rName, rType, gType, rParams, genParams, AnalyzeOptions, mode }; return((AbstractNetwork)t.GetConstructor(constructTypes).Invoke(invokeParams)); }
private Ship(ShipType type, Resources cost, int speed, ResearchType engineResearchType) : base(type, cost) { _baseSpeed = speed; _speedResearch = engineResearchType; float factor = 0.0f; switch (engineResearchType) { case ResearchType.ImpulseDrive: factor = 0.5f; break; case ResearchType.HyperspaceDrive: factor = 0.3f; break; case ResearchType.CombustionDrive: factor = 0.1f; break; case ResearchType.Unknown: factor = 0.0f; break; default: throw new ArgumentException("Must be Impulse, Combustion or Hyperspace", nameof(engineResearchType)); } _speedBonus = (int)(speed * factor); }
private IActionResult SaveResearchTypeAsync(ResearchType item) { //Check that Value/Name is unique if (_context.ResearchType.AsNoTracking().FirstOrDefault(x => x.Value == item.Value && x.ResearchTypeId != item.ResearchTypeId) != null) { return(BadRequest("Duplicate entry/value found.")); } var exiting = _context.ResearchType.FirstOrDefault(x => x.ResearchTypeId == item.ResearchTypeId); if (exiting == null) { //ADD HelperExtensions.ClearIdentityValue(ref item); HelperExtensions.ClearNullableInts(ref item); _context.ResearchType.Add(item); return(Created(item)); } else { //UPDATE _context.Entry(exiting).CurrentValues.SetValues(item); return(Updated(exiting)); } }
public CreateResearchWindow(ResearchType rt) { researchType = rt; InitializeComponent(); InitializeGeneralGroup(); }
public ResearchTypes() { ResearchType item = new ResearchType("alpha", RESEARCH.TYPES.ALPHA.NAME, RESEARCH.TYPES.ALPHA.DESC, Assets.GetSprite("research_type_alpha_icon"), new Color(0.596078455f, 0.6666667f, 0.9137255f), new Recipe.Ingredient[1] { new Recipe.Ingredient("Dirt".ToTag(), 100f) }, 600f, "research_center_kanim", new string[1] { "ResearchCenter" }, RESEARCH.TYPES.ALPHA.RECIPEDESC); Types.Add(item); ResearchType item2 = new ResearchType("beta", RESEARCH.TYPES.BETA.NAME, RESEARCH.TYPES.BETA.DESC, Assets.GetSprite("research_type_beta_icon"), new Color(0.6f, 0.384313732f, 0.5686275f), new Recipe.Ingredient[1] { new Recipe.Ingredient("Water".ToTag(), 25f) }, 1200f, "research_center_kanim", new string[1] { "AdvancedResearchCenter" }, RESEARCH.TYPES.BETA.RECIPEDESC); Types.Add(item2); ResearchType item3 = new ResearchType("gamma", RESEARCH.TYPES.GAMMA.NAME, RESEARCH.TYPES.GAMMA.DESC, Assets.GetSprite("research_type_gamma_icon"), new Color32(240, 141, 44, byte.MaxValue), null, 2400f, "research_center_kanim", new string[1] { "CosmicResearchCenter" }, RESEARCH.TYPES.GAMMA.RECIPEDESC); Types.Add(item3); }
public ActionResult Create(newResearch data) { VisitDate visit = db.visits.Include(v => v.researches).Where(v => v.ID == data.visitID).First(); if (visit == null) { return(RedirectToAction("Index", "Pacients")); } Pacient pacient = db.pacients.Where(p => p.visits.Any(v => v.ID == data.visitID)).First(); if (pacient == null) { return(RedirectToAction("Index", "Pacients")); } if (ModelState.IsValid) { ResearchType type = db.researchTypes.Where(a => a.ID == data.research.type.ID).First(); data.research.type = type; visit.researches.Add(data.research); db.SaveChanges(); return(PartialView("/views/Researches/pacientDetails.cshtml", data.research)); } return(PartialView("/views/Researches/pacientCreate.cshtml", data)); }
/// <summary> /// Creates a research of specified type using metadata information of enumeration value. /// </summary> /// <param name="rt">Type of research to create.</param> /// <returns>Newly created research.</returns> public static AbstractResearch CreateResearchByType(ResearchType rt) { ResearchTypeInfo[] info = (ResearchTypeInfo[])rt.GetType().GetField(rt.ToString()).GetCustomAttributes(typeof(ResearchTypeInfo), false); Type t = Type.GetType(info[0].Implementation, true); return((AbstractResearch)t.GetConstructor(Type.EmptyTypes).Invoke(new Object[0])); }
public void StartResearch(ResearchType type) { // start a new tech research and apply any existing science we have saved up TechBeingResearched = type; TechResearchProgress = Resources.Science; Resources.Science = 0; }
void OnPlayerStartResearch(int num, ResearchType type) { if (PlayersManager.Instance.Me.Num == num) { RPC.Instance.SendPlayerStartResearch(num, type); } }
private void SaveGeneralInfo(string dirName, Guid researchID, string researchName, ResearchType rType, ModelType mType, int realizationCount, UInt32 size, Double edges, Dictionary <ResearchParameter, object> rp, Dictionary <GenerationParameter, object> gp) { string fileName = dirName + Path.DirectorySeparatorChar + "general"; using (StreamWriter w = new StreamWriter(fileName + ".txt")) { w.WriteLine("Research Info"); w.WriteLine("ResearchID - " + researchID); w.WriteLine("ResearchName - " + researchName); w.WriteLine("ResearchType - " + rType); w.WriteLine("ModelType - " + mType); w.WriteLine("RealizationCount - " + realizationCount); w.WriteLine("Date - " + DateTime.Now); w.WriteLine("Size - " + size); w.WriteLine("Edges - " + edges); } SaveResearchParameters(fileName, rp); SaveGenerationParameters(fileName, gp); }
/// <summary> /// Returns list of generation parameters which are required for specified research. /// </summary> /// <param name="id">ID of research.</param> /// <returns>List of generation parameters.</returns> public static List <GenerationParameter> GetRequiredGenerationParameters(ResearchType rt, ModelType mt, GenerationType gt) { List <GenerationParameter> gp = new List <GenerationParameter>(); if (rt == ResearchType.Collection || rt == ResearchType.Structural) { return(gp); } if (gt == GenerationType.Static) { gp.Add(GenerationParameter.AdjacencyMatrix); return(gp); } ModelTypeInfo[] info = (ModelTypeInfo[])mt.GetType().GetField(mt.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false); Type t = Type.GetType(info[0].Implementation, true); RequiredGenerationParameter[] rRequiredGenerationParameters = (RequiredGenerationParameter[])t.GetCustomAttributes(typeof(RequiredGenerationParameter), true); for (int i = 0; i < rRequiredGenerationParameters.Length; ++i) { GenerationParameter g = rRequiredGenerationParameters[i].Parameter; if (g != GenerationParameter.AdjacencyMatrix) { gp.Add(g); } } return(gp); }
/// <summary> /// Retrieves available model types for specified research type. /// </summary> /// <param name="rt">Research type.</param> /// <returns>List of available model types.</returns> public static List <ModelType> GetAvailableModelTypes(ResearchType rt) { ResearchTypeInfo[] info = (ResearchTypeInfo[])rt.GetType().GetField(rt.ToString()).GetCustomAttributes(typeof(ResearchTypeInfo), false); Type t = Type.GetType(info[0].Implementation, true); return(AvailableModelTypes(t)); }
public ActionResult CreateByDate(newResearch data) { Pacient pacient = db.pacients.Include(p => p.visits.Select(v => v.researches)).Include(p => p.doctor).Where(p => p.ID == data.pacientID).First(); if (pacient == null) { return(RedirectToAction("Index", "Pacients")); } VisitDate visit = pacient.visits.Where(v => v.date == data.initialDate).FirstOrDefault(); if (visit != null) { ResearchType type = db.researchTypes.Where(a => a.ID == data.research.type.ID).First(); data.research.type = type; visit.researches.Add(data.research); db.SaveChanges(); return(PartialView("/views/Researches/pacientDetails.cshtml", data.research)); } else { ResearchType type = db.researchTypes.Where(a => a.ID == data.research.type.ID).First(); data.research.type = type; visit = new VisitDate(); visit.doctorID = pacient.doctor.ID; visit.date = data.initialDate; visit.researches = new List <Research>(); visit.researches.Add(data.research); pacient.visits.Add(visit); db.SaveChanges(); return(PartialView("/views/Researches/pacientDetails.cshtml", data.research)); } //return PartialView("/views/Research/pacientCreate.cshtml", data); }
private void FillResearchesTable() { researchesTable.Rows.Clear(); parametersTable.Rows.Clear(); ResearchType rt = GetCurrentResearchType(); ModelType mt = GetCurrentModelType(); Dictionary <int, List <Guid> > r = StatSessionManager.GetFilteredResultsByGroups(rt, mt); Color c = Color.WhiteSmoke; foreach (int i in r.Keys) { foreach (Guid id in r[i]) { int newRowIndex = researchesTable.Rows.Add(id, StatSessionManager.GetResearchName(id), StatSessionManager.GetResearchRealizationCount(id).ToString(), StatSessionManager.GetResearchNetworkSize(id).ToString()); DataGridViewRow row = researchesTable.Rows[newRowIndex]; row.DefaultCellStyle.BackColor = c; } c = (c == Color.WhiteSmoke) ? Color.LightGray : Color.WhiteSmoke; } }
public List <Descriptor> GetDescriptors(GameObject go) { List <Descriptor> list = new List <Descriptor>(); ResearchType researchType = Research.Instance.GetResearchType(TypeID); list.Add(new Descriptor(string.Format(UI.UISIDESCREENS.FABRICATORSIDESCREEN.EFFECTS.RESEARCHPOINT, researchType.name), string.Format(UI.UISIDESCREENS.FABRICATORSIDESCREEN.EFFECTS.RESEARCHPOINT, researchType.description), Descriptor.DescriptorType.Effect, false)); return(list); }
private void SaveResearchInfo(Guid researchID, string researchName, ResearchType rType, ModelType mType, int realizationCount) { throw new NotImplementedException(); }
public CreateEditResearchWindow(DialogType dt, ResearchType rt) { dType = dt; rType = rt; InitializeComponent(); InitializeTexts(); }
public List <Type> GetBehaviours(ResearchType researchType) { if (!researchBehaviours.ContainsKey(researchType)) { researchBehaviours.Add(researchType, new List <Type>()); } return(researchBehaviours[researchType]); }
public CreateEditResearchWindow(DialogType dt, ResearchType rt) { dType = dt; rType = rt; InitializeComponent(); InitializeTexts(); }
public ActionResult DeleteConfirmed(int id) { ResearchType researchType = db.researchTypes.Find(id); db.researchTypes.Remove(researchType); db.SaveChanges(); return(RedirectToAction("Index")); }
private void ShowCreateResearchDialog(ResearchType researchType) { CreateResearchWindow createResearchWnd = new CreateResearchWindow(researchType) { Owner = this }; createResearchWnd.ShowDialog(); if (!(createResearchWnd.DialogResult.HasValue && createResearchWnd.DialogResult.Value)) { return; } researchDraw = FactoryReserchDraw.CreateResearchDraw(researchType, LabSessionManager.GetResearchModelType()); Start.Visibility = Visibility.Visible; Start.IsEnabled = true; Save.Visibility = Visibility.Visible; Save.IsEnabled = true; AddResearchToTable(); FillParametersTable(); researchDraw.SetStatisticsParameters(); if (researchType == ResearchType.Basic) { Initial.Visibility = Visibility.Visible; Initial.IsEnabled = false; Final.Visibility = Visibility.Visible; Final.IsEnabled = false; Next.Visibility = Visibility.Visible; Next.IsEnabled = false; Previous.Visibility = Visibility.Visible; Previous.IsEnabled = false; Grid.SetColumn(Save, 5); } else { Initial.Visibility = Visibility.Collapsed; Final.Visibility = Visibility.Collapsed; Next.Visibility = Visibility.Collapsed; Previous.Visibility = Visibility.Collapsed; ChartData = null; Grid.SetColumn(Save, 1); } Start.Content = "Start"; mainCanvas.Children.Clear(); if (LabSessionManager.GetResearchType() == ResearchType.Basic && (LabSessionManager.GetResearchModelType() == ModelType.RegularHierarchic || LabSessionManager.GetResearchModelType() == ModelType.NonRegularHierarchic)) { Flat.Visibility = System.Windows.Visibility.Visible; Flat.IsEnabled = false; } else { Flat.Visibility = System.Windows.Visibility.Hidden; } }
public override void StartResearch() { ValidateResearchParameters(); StatusInfo = new ResearchStatusInfo(ResearchStatus.Running, 0); Logger.Write("Research ID - " + ResearchID.ToString() + ". Research - " + ResearchName + ". STARTED COLLECTION RESEARCH."); MatrixPath mp = ((MatrixPath)ResearchParameterValues[ResearchParameter.InputPath]); List <MatrixPath> matrixes = new List <MatrixPath>(); Debug.Assert((File.GetAttributes(mp.Path) & FileAttributes.Directory) == FileAttributes.Directory); foreach (string fn in Directory.GetFiles(mp.Path, "*.txt")) { MatrixPath m = new MatrixPath(); m.Path = fn; m.Size = mp.Size; matrixes.Add(m); } ResearchType rt = ResearchType.Basic; // subresearch type is not supported and is always Basic subResearches = new List <AbstractResearch>(); foreach (MatrixPath m in matrixes) { AbstractResearch r = AbstractResearch.CreateResearchByType(rt); r.ResearchName = ResearchName + "_" + Path.GetFileNameWithoutExtension(m.Path); r.GenerationType = GenerationType.Static; r.ModelType = ModelType; Debug.Assert(r.GenerationParameterValues.ContainsKey(GenerationParameter.AdjacencyMatrix)); r.GenerationParameterValues[GenerationParameter.AdjacencyMatrix] = m; r.AnalyzeOption = AnalyzeOption; string storageString = Storage.StorageString; // depracate sql storage /*if (Storage.GetStorageType() != StorageType.SQLStorage) * {*/ storageString += ResearchName; if (!Directory.Exists(storageString)) { Directory.CreateDirectory(storageString); } //} r.Storage = AbstractResultStorage.CreateStorage(Storage.GetStorageType(), storageString); r.OnUpdateResearchStatus += method; subResearches.Add(r); } if (subResearches.Count() != 0) { ++currentResearchIndex; subResearches[currentResearchIndex].StartResearch(); } }
public Research(string name, string description, string imageName, ResearchType reserachType, bool disabled, int duration) { this.name = name; this.description = description; this.reserachType = reserachType; this.disabled = disabled; this.duration = duration; LoadImage(imageName); }
public ResearchCompleted(ResearchType research, TopicType? topic) { this.topic = topic; AddControl(new Border(30, 48, 224, 140, ColorScheme.Green, Backgrounds.Research, 0)); AddControl(new Label(88, Label.Center, "Research Completed", Font.Large, ColorScheme.Green)); AddControl(new Label(105, Label.Center, research.Metadata().Name, Font.Large, ColorScheme.White)); AddControl(new Button(146, 64, 80, 14, "OK", ColorScheme.Green, Font.Normal, EndModal)); AddControl(new Button(146, 176, 80, 14, "VIEW REPORTS", ColorScheme.Green, Font.Normal, OnViewReports)); }
public void SetInfo(ResearchType type, int level) { Type = type; Level = level; int cost = Constants.ResearchCosts[type][level - 2]; DialogText = $"{defaultText}\n\nCost: {cost}"; }
protected override void OnSpawn() { base.OnSpawn(); Research.Instance.AddResearchPoints(TypeID, 1f); ResearchType researchType = Research.Instance.GetResearchType(TypeID); PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Research, researchType.name, base.transform, 1.5f, false); Util.KDestroyGameObject(base.gameObject); }
//private static List<List<EdgesAddedOrRemoved>> steps; public static void CreateResearch(ResearchType researchType) { CustomLogger.VisualMode = true; existingResearch = AbstractResearch.CreateResearchByType(researchType); existingResearch.ModelType = GetAvailableModelTypes()[0]; existingResearch.ResearchName = "Default"; existingResearch.VisualMode = true; existingResearch.GenerationType = GenerationType.Random; }
public ConfirmNewResearchProject(ResearchType researchType, Action<ResearchProject> action) { this.researchType = researchType; this.action = action; AddControl(new Border(30, 45, 230, 140, ColorScheme.LightMagenta, Backgrounds.Research, 7)); AddControl(new Label(72, Label.Center, researchType.Metadata().Name, Font.Large, ColorScheme.LightMagenta)); AddControl(new Button(145, 61, 82, 16, "START PROJECT", ColorScheme.Purple, Font.Normal, OnStartProject)); AddControl(new Button(145, 176, 82, 16, "CANCEL", ColorScheme.Purple, Font.Normal, EndModal)); }
private void SaveGeneralInfo(Guid researchID, string researchName, ResearchType rType, ModelType mType, int realizationCount, UInt32 size, Double edges, Dictionary <ResearchParameter, object> rp, Dictionary <GenerationParameter, object> gp) { Worksheet sheet = GetNextWorksheet(); sheet.Name = "General"; int lastRow = sheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell).Row; sheet.Columns[1].ColumnWidth = 30; sheet.Columns[2].ColumnWidth = 40; sheet.Columns[2].HorizontalAlignment = XlHAlign.xlHAlignLeft; sheet.Cells[lastRow, 1] = "Research Info"; sheet.Cells[lastRow, 1].EntireRow.Font.Bold = true; ++lastRow; sheet.Cells[lastRow, 1] = "ResearchID"; sheet.Cells[lastRow, 2] = researchID.ToString(); ++lastRow; sheet.Cells[lastRow, 1] = "ResearchName"; sheet.Cells[lastRow, 2] = researchName; ++lastRow; sheet.Cells[lastRow, 1] = "ResearchType"; sheet.Cells[lastRow, 2] = rType.ToString(); ++lastRow; sheet.Cells[lastRow, 1] = "ModelType"; sheet.Cells[lastRow, 2] = mType.ToString(); ++lastRow; sheet.Cells[lastRow, 1] = "RealizationCount"; sheet.Cells[lastRow, 2] = realizationCount; ++lastRow; sheet.Cells[lastRow, 1] = "Date"; sheet.Cells[lastRow, 2] = DateTime.Now.ToString(); ++lastRow; sheet.Cells[lastRow, 1] = "Size"; sheet.Cells[lastRow, 2] = size; ++lastRow; sheet.Cells[lastRow, 1] = "Edges"; sheet.Cells[lastRow, 2] = edges; SaveResearchParameters(sheet, rp); SaveGenerationParameters(sheet, gp); }
void OnTechPressed(ResearchType type, int level) { var player = PlayersManager.Instance.Me; if (player.TechBeingResearched == ResearchType.None && player.CanResearch(type, level)) { researchPopup.SetInfo(type, level); researchPopup.PopupCentered(); } }
public NonRegularHierarchicNetwork(String rName, ResearchType rType, GenerationType gType, Dictionary <ResearchParameter, object> rParams, Dictionary <GenerationParameter, object> genParams, AnalyzeOption analyzeOpts, ContainerMode mode) : base(rName, rType, gType, rParams, genParams, analyzeOpts, mode) { networkGenerator = new NonRegularHierarchicNetworkGenerator(mode); networkAnalyzer = new NonRegularHierarchicNetworkAnalyzer(this); }
public ActionResult Edit([Bind(Include = "ID,name,description")] ResearchType researchType) { if (ModelState.IsValid) { db.Entry(researchType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(researchType)); }
public CreateEditResearchWindow(DialogType dt, ResearchType rt, Guid id) { Debug.Assert(SessionManager.ResearchExists(id)); Debug.Assert(SessionManager.GetResearchType(id) == rt); dType = dt; rType = rt; researchId = id; InitializeComponent(); InitializeTexts(); }
/// <summary> /// Retrieves available analyze options for specified research type and model type. /// </summary> /// <param name="rt">Research type.</param> /// <param name="mt">Model type.</param> /// <returns>Available analyze options.</returns> /// <note>Analyze option is available for research, if it is available /// both for research type and model type.</note> public static AnalyzeOption GetAvailableAnalyzeOptions(ResearchType rt, ModelType mt) { ResearchTypeInfo[] rInfo = (ResearchTypeInfo[])rt.GetType().GetField(rt.ToString()).GetCustomAttributes(typeof(ResearchTypeInfo), false); Type researchType = Type.GetType(rInfo[0].Implementation, true); AvailableAnalyzeOption rAvailableOptions = ((AvailableAnalyzeOption[])researchType.GetCustomAttributes(typeof(AvailableAnalyzeOption), true))[0]; ModelTypeInfo[] mInfo = (ModelTypeInfo[])mt.GetType().GetField(mt.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false); Type modelType = Type.GetType(mInfo[0].Implementation, true); AvailableAnalyzeOption mAvailableOptions = ((AvailableAnalyzeOption[])modelType.GetCustomAttributes(typeof(AvailableAnalyzeOption), true))[0]; return rAvailableOptions.Options & mAvailableOptions.Options; }
protected string ResearchToString(ResearchType type) { switch (type) { case ResearchType.Speed: return "tốc độ"; case ResearchType.Attack: return "chỉ số tấn công"; case ResearchType.Defense: return "chỉ số phòng thủ"; default: return ""; } }
public static ResearchProject Create(ResearchType researchType) { var averageHoursToComplete = researchType.Metadata().AverageHoursToComplete; var deviation = averageHoursToComplete / 2; var hoursToComplete = GameState.Current.Random.Next( averageHoursToComplete - deviation, averageHoursToComplete + deviation); return new ResearchProject { ResearchType = researchType, ScientistsAllocated = 0, HoursToComplete = hoursToComplete, HoursCompleted = 0 }; }
private static IEnumerable<ResearchType> GatherCompletedResearch(ResearchType research) { yield return research; var metadata = research.Metadata(); if (metadata.AdditionalResearchResults != null) foreach (var additionalResearch in metadata.AdditionalResearchResults) yield return additionalResearch; if (metadata.LotteryResearchResults == null) yield break; var remainingLotteryResults = metadata.LotteryResearchResults.Except(GameState.Current.Data.CompletedResearch).ToList(); if (remainingLotteryResults.Count == 0) yield break; var randomIndex = GameState.Current.Random.Next(0, remainingLotteryResults.Count); yield return remainingLotteryResults[randomIndex]; }
private static void CompleteResearch(Base @base, ResearchType research) { var previouslyAvailableResearch = @base.AvailableResearchProjects; var previouslyAvailableProduction = @base.AvailableManufactureProjects; var previouslyAvailableTopics = GameState.Current.Data.AvailableTopics; RecordCompletedResearch(research); var newTopics = GameState.Current.Data.AvailableTopics.Except(previouslyAvailableTopics); NotfiyResearchCompleted(research, newTopics.Cast<TopicType?>().FirstOrDefault()); var newResearchTypes = @base.AvailableResearchProjects.Except(previouslyAvailableResearch).ToList(); NotifyWeCanNowResearch(@base, newResearchTypes); var newProduction = @base.AvailableManufactureProjects.Except(previouslyAvailableProduction).ToList(); if (newProduction.Any()) NotifyWeCanNowProduce(@base, newProduction); }
public Research CreateResearch(ResearchType type, ISession session) { if (this.Village[BuildingType.Smithy] < 0) throw new TribalWarsException("Chưa xây viện nghiên cứu"); ResearchPrice price = Research.GetPrice(type, this.Village[type] + 1, this.Village[BuildingType.Smithy]); if (this.Village[ResourcesType.Wood] < price.Wood || this.Village[ResourcesType.Iron] < price.Iron || this.Village[ResourcesType.Clay] < price.Clay) throw new TribalWarsException("Không đủ tài nguyên"); Research research = new Research(); research.Village = this.Village; research.Type = type; switch (type) { case ResearchType.Speed: research.Level = this.MaxSpeedLevel + 1; break; case ResearchType.Attack: research.Level = this.MaxAttackLevel + 1; break; case ResearchType.Defense: research.Level = this.MaxDefenseLevel + 1; break; default: break; } Research lastResearch = (from r in this.Village.Researches orderby r.ID descending select r).FirstOrDefault<Research>(); if (lastResearch == null) research.Start = DateTime.Now; else research.Start = lastResearch.End; research.End = research.Start.AddMilliseconds(price.Time); this.Village[ResourcesType.Wood] -= price.Wood; this.Village[ResourcesType.Iron] -= price.Iron; this.Village[ResourcesType.Clay] -= price.Clay; this.Village.Researches.Add(research); session.Save(research); session.Update(this.Village); return research; }
private static void RecordCompletedResearch(ResearchType research) { var completedResearch = GameState.Current.Data.CompletedResearch; var newlyCompletedResearch = GatherCompletedResearch(research).Except(completedResearch).ToList(); completedResearch.AddRange(newlyCompletedResearch); var researchScore = newlyCompletedResearch.Sum(item => item.Metadata().Points); GameState.Current.Data.ThisMonthsScore += researchScore; }
/// <summary> /// Retrieves available model types for specified research type. /// </summary> /// <param name="rt">Research type.</param> /// <returns>List of available model types.</returns> public static List<ModelType> GetAvailableModelTypes(ResearchType rt) { ResearchTypeInfo[] info = (ResearchTypeInfo[])rt.GetType().GetField(rt.ToString()).GetCustomAttributes(typeof(ResearchTypeInfo), false); Type t = Type.GetType(info[0].Implementation, true); return AvailableModelTypes(t); }
/// <summary> /// Returns list of generation parameters which are required for specified research. /// </summary> /// <param name="id">ID of research.</param> /// <returns>List of generation parameters.</returns> public static List<GenerationParameter> GetRequiredGenerationParameters(ResearchType rt, ModelType mt, GenerationType gt) { List<GenerationParameter> gp = new List<GenerationParameter>(); if (rt == ResearchType.Collection || rt == ResearchType.Structural) return gp; if (gt == GenerationType.Static) { gp.Add(GenerationParameter.AdjacencyMatrix); return gp; } ModelTypeInfo[] info = (ModelTypeInfo[])mt.GetType().GetField(mt.ToString()).GetCustomAttributes(typeof(ModelTypeInfo), false); Type t = Type.GetType(info[0].Implementation, true); RequiredGenerationParameter[] rRequiredGenerationParameters = (RequiredGenerationParameter[])t.GetCustomAttributes(typeof(RequiredGenerationParameter), true); for (int i = 0; i < rRequiredGenerationParameters.Length; ++i) { GenerationParameter g = rRequiredGenerationParameters[i].Parameter; if (g != GenerationParameter.AdjacencyMatrix) gp.Add(g); } return gp; }
/// <summary> /// Returns list of research parameters which are required for specified research. /// </summary> /// <param name="id">ID of research.</param> /// <returns>List of research parameters.</returns> public static List<ResearchParameter> GetRequiredResearchParameters(ResearchType rt) { ResearchTypeInfo[] info = (ResearchTypeInfo[])rt.GetType().GetField(rt.ToString()).GetCustomAttributes(typeof(ResearchTypeInfo), false); Type t = Type.GetType(info[0].Implementation, true); List<ResearchParameter> rp = new List<ResearchParameter>(); RequiredResearchParameter[] rRequiredResearchParameters = (RequiredResearchParameter[])t.GetCustomAttributes(typeof(RequiredResearchParameter), true); for (int i = 0; i < rRequiredResearchParameters.Length; ++i) rp.Add(rRequiredResearchParameters[i].Parameter); return rp; }
private void SaveResearchInfo(Guid researchID, string researchName, ResearchType rType, ModelType mType, int realizationCount, UInt32 size, Double edges) { WorksheetPart worksheetPart = workbook.AddNewPart<WorksheetPart>(); Sheet researchInfoSheet = new Sheet() { Id = workbook.GetIdOfPart(worksheetPart), SheetId = 1, Name = "Research Info" }; /*IRow rowID = researchInfoSheet.CreateRow(0); rowID.CreateCell(0).SetCellValue("ResearchID"); rowID.CreateCell(1).SetCellValue(researchID.ToString()); IRow rowName = researchInfoSheet.CreateRow(1); rowName.CreateCell(0).SetCellValue("ResearchName"); rowName.CreateCell(1).SetCellValue(researchName); IRow rowType = researchInfoSheet.CreateRow(2); rowType.CreateCell(0).SetCellValue("ResearchType"); rowType.CreateCell(1).SetCellValue(rType.ToString()); IRow rowModel = researchInfoSheet.CreateRow(3); rowModel.CreateCell(0).SetCellValue("ModelType"); rowModel.CreateCell(1).SetCellValue(mType.ToString()); IRow rowRCount = researchInfoSheet.CreateRow(4); rowRCount.CreateCell(0).SetCellValue("RealizationCount"); rowRCount.CreateCell(1).SetCellValue(realizationCount); IRow rowDate = researchInfoSheet.CreateRow(5); rowDate.CreateCell(0).SetCellValue("Date"); rowDate.CreateCell(1).SetCellValue(DateTime.Now.ToString()); IRow rowSize = researchInfoSheet.CreateRow(6); rowSize.CreateCell(0).SetCellValue("Size"); rowSize.CreateCell(1).SetCellValue(size); IRow rowEdges = researchInfoSheet.CreateRow(7); rowEdges.CreateCell(0).SetCellValue("Edges"); rowEdges.CreateCell(1).SetCellValue(edges);*/ }
private void OnClickResearchType(ResearchType researchType) { new ConfirmNewResearchProject(researchType, OnNewResearchProject).DoModal(this); }
private List<CMSResearch> GetCMSResearchDocuments(LatestResearchModel latestResearchModel, UserSettings userSettings, ResearchType researchType = ResearchType.MARKET_UPDATE) { var researchLookup = new ResearchLookup(); researchLookup.ReserchType = researchType; researchLookup.Category = latestResearchModel.Category; if (!string.IsNullOrEmpty(latestResearchModel.Tags)) { var tags = latestResearchModel.Tags.Split(','); researchLookup.Tags = tags.Length > 0 ? tags : new[] { latestResearchModel.Tags }; } researchLookup.RecordCount = latestResearchModel.Count.HasValue ? latestResearchModel.Count.Value : 20; researchLookup.Language = GetLanguage(userSettings.Language); researchLookup.StartDate = latestResearchModel.StartDate; researchLookup.EndDate = latestResearchModel.EndDate; var researchServiceAddress = WebservicesConfig.Webservices["Research"].Settings["URL"].Value; var researchServiceSoapClient = researchServiceAddress.Contains("https://") ? new ResearchServiceSoapClient("ResearchServiceSoapHttps", researchServiceAddress) : new ResearchServiceSoapClient("ResearchServiceSoap", researchServiceAddress); var latestResearchBlotter = researchServiceSoapClient.GetLatestResearch(null, _token, researchLookup); if (latestResearchBlotter != null) { return latestResearchBlotter.Output.OrderByDescending(e => e.LastUpdatedDate).ToList(); } return new List<CMSResearch>(); }
private void SaveGeneralInfo(Guid researchID, string researchName, ResearchType rType, ModelType mType, int realizationCount, UInt32 size, Double edges, Dictionary<ResearchParameter, object> rp, Dictionary<GenerationParameter, object> gp) { Worksheet sheet = GetNextWorksheet(); sheet.Name = "General"; int lastRow = sheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell).Row; sheet.Columns[1].ColumnWidth = 30; sheet.Columns[2].ColumnWidth = 40; sheet.Columns[2].HorizontalAlignment = XlHAlign.xlHAlignLeft; sheet.Cells[lastRow, 1] = "Research Info"; sheet.Cells[lastRow, 1].EntireRow.Font.Bold = true; ++lastRow; sheet.Cells[lastRow, 1] = "ResearchID"; sheet.Cells[lastRow, 2] = researchID.ToString(); ++lastRow; sheet.Cells[lastRow, 1] = "ResearchName"; sheet.Cells[lastRow, 2] = researchName; ++lastRow; sheet.Cells[lastRow, 1] = "ResearchType"; sheet.Cells[lastRow, 2] = rType.ToString(); ++lastRow; sheet.Cells[lastRow, 1] = "ModelType"; sheet.Cells[lastRow, 2] = mType.ToString(); ++lastRow; sheet.Cells[lastRow, 1] = "RealizationCount"; sheet.Cells[lastRow, 2] = realizationCount; ++lastRow; sheet.Cells[lastRow, 1] = "Date"; sheet.Cells[lastRow, 2] = DateTime.Now.ToString(); ++lastRow; sheet.Cells[lastRow, 1] = "Size"; sheet.Cells[lastRow, 2] = size; ++lastRow; sheet.Cells[lastRow, 1] = "Edges"; sheet.Cells[lastRow, 2] = edges; SaveResearchParameters(sheet, rp); SaveGenerationParameters(sheet, gp); }
private void ShowCreateResearchDialog(ResearchType rt) { CreateEditResearchWindow d = new CreateEditResearchWindow(DialogType.Create, rt); d.ShowDialog(this); if (d.DialogResult == DialogResult.OK) AddResearchToTable(d.ResultResearchId); }
private void AddResearch(ResearchType type) { // creating a default research of specified type Guid id = SessionManager.CreateResearch(type); SessionManager.AddResearchUpdateHandler(id, CurrentResearch_OnResearchUpdateStatus); researchIDs.Add(id); // adding a new row for created research int newRowIndex = researchesTable.Rows.Add(); selectedIndex = newRowIndex; FillResearchInformation(id); researchesTable.CurrentCell = researchesTable.Rows[newRowIndex].Cells["nameColumn"]; researchesTable.BeginEdit(true); }
/// <summary> /// Returns filtered researches by specified research type and model type. /// </summary> /// <param name="rt">Research type.</param> /// <param name="mt">Model type.</param> /// <returns>Groups of research ids.</returns> public static Dictionary<int, List<Guid>> GetFilteredResultsByGroups(ResearchType rt, ModelType mt) { Dictionary<int, List<Guid>> result = new Dictionary<int, List<Guid>>(); foreach (int i in existingResultsByGroups.Keys) { Guid id = existingResultsByGroups[i].First(); if (existingResults[id].ResearchType == rt && existingResults[id].ModelType == mt) result.Add(i, existingResultsByGroups[i]); } return result; }
private static void NotfiyResearchCompleted(ResearchType research, TopicType? topic) { GameState.Current.Notifications.Enqueue(() => new ResearchCompleted(research, topic).DoModal(GameState.Current.ActiveScreen)); }
/// <summary> /// Creates a research of specified type using metadata information of enumeration value. /// </summary> /// <param name="rt">Type of research to create.</param> /// <returns>Newly created research.</returns> private static AbstractResearch CreateResearchFromType(ResearchType rt) { ResearchTypeInfo[] info = (ResearchTypeInfo[])rt.GetType().GetField(rt.ToString()).GetCustomAttributes(typeof(ResearchTypeInfo), false); Type t = Type.GetType(info[0].Implementation, true); return (AbstractResearch)t.GetConstructor(Type.EmptyTypes).Invoke(new object[0]); }
/// <summary> /// Creates a research and adds to existingResearches. /// </summary> /// <param name="researchType">The type of research to create.</param> /// <param name="modelType">The model type of research to create.</param> /// <param name="researchName">The name of research.</param> /// <param name="storage">The storage type for saving results of analyze.</param> /// <param name="storageString">Connection string or file path for data storage.</param> /// <param name="tracingPath">Path, if tracing is on, and empty string otherwise.</param> /// <returns>ID of created Research.</returns> public static Guid CreateResearch(ResearchType researchType, ModelType modelType, string researchName, StorageType storage, string storageString, GenerationType generationType, string tracingPath) { AbstractResearch r = AbstractResearch.CreateResearchByType(researchType); existingResearches.Add(r.ResearchID, r); r.ModelType = modelType; r.ResearchName = researchName; r.Storage = AbstractResultStorage.CreateStorage(storage, storageString); r.GenerationType = generationType; r.TracingPath = tracingPath; return r.ResearchID; }
public static ResearchPrice GetPrice(ResearchType type, int level, int smithy) { int key = (int)type + (level * 1000) + (smithy * 1000000); return Research.ResearchPrices[key]; }
public bool CanResearch(ResearchType type, int level) { if (this.Village[BuildingType.Smithy] == 0) return false; ResearchPrice price = Research.GetPrice(type, level, this.Village[BuildingType.Smithy]); return (price.Wood < this.Village[ResourcesType.Wood] && price.Clay < this.Village[ResourcesType.Clay] && price.Iron < this.Village[ResourcesType.Iron]); }
/// <summary> /// Creates a default research and adds to existingResearches. /// </summary> /// <param name="researchType">The type of research to create.</param> /// <returns>ID of created Research.</returns> public static Guid CreateResearch(ResearchType researchType) { AbstractResearch r = AbstractResearch.CreateResearchByType(researchType); existingResearches.Add(r.ResearchID, r); r.ModelType = GetAvailableModelTypes(r.ResearchID)[0]; r.ResearchName = "Default"; r.Storage = AbstractResultStorage.CreateStorage(StorageType.XMLStorage, RandNetSettings.StorageDirectory); r.TracingPath = ""; return r.ResearchID; }
/// <summary> /// Creates a default research and adds to existingResearches. /// </summary> /// <param name="researchType">The type of research to create.</param> /// <returns>ID of created Research.</returns> public static Guid CreateResearch(ResearchType researchType) { AbstractResearch r = CreateResearchFromType(researchType); existingResearches.Add(r.ResearchID, r); r.ModelType = GetAvailableModelTypes(r.ResearchID)[0]; r.ResearchName = "Default"; r.Storage = CreateStorage(StorageType.XMLStorage, ExplorerSettings.StorageDirectory); r.TracingPath = ""; InitializeExtendedInformationForResearch(r.ResearchID); return r.ResearchID; }
/// <summary> /// Creates a research and adds to existingResearches. /// </summary> /// <param name="researchType">The type of research to create.</param> /// <param name="modelType">The model type of research to create.</param> /// <param name="researchName">The name of research.</param> /// <param name="storage">The storage type for saving results of analyze.</param> /// <param name="storageString">Connection string or file path for data storage.</param> /// <param name="tracingPath">Path, if tracing is on, and empty string otherwise.</param> /// <returns>ID of created Research.</returns> public static Guid CreateResearch(ResearchType researchType, ModelType modelType, string researchName, StorageType storage, string storageString, GenerationType generationType, string tracingPath) { AbstractResearch r = CreateResearchFromType(researchType); existingResearches.Add(r.ResearchID, r); r.ModelType = modelType; r.ResearchName = researchName; r.Storage = CreateStorage(storage, storageString); r.GenerationType = generationType; r.TracingPath = tracingPath; InitializeExtendedInformationForResearch(r.ResearchID); return r.ResearchID; }