public async Task <IActionResult> EditProposalExample(string scenarioId, string proposalId, AddProposalExampleModel model) { var scenario = await ScenarioModel.GetAsync(AppSettings.DefaultRepo, scenarioId); if (scenario == null) { return(NotFound()); } var proposalExample = scenario.Proposals?.FirstOrDefault(i => i.ProposalId == proposalId); if (proposalExample == null) { return(NotFound()); } using (await LockingService.LockAsync()) { await BaseContentsModel.SaveContentsAsync(proposalExample.Id, AppSettings.DefaultRepo, model.Contents); await ChangesService.Get(AppSettings.DefaultRepo).PushChangesAsync(); } dynamic parameters = new ExpandoObject(); parameters.scenarioId = scenarioId; parameters.proposalId = proposalId; return(RedirectToAction(actionName: nameof(ViewProposalExample), routeValues: parameters)); }
public async Task <IActionResult> EditProposalExample(string scenarioId, string proposalId) { var scenario = await ScenarioModel.GetAsync(AppSettings.DefaultRepo, scenarioId); if (scenario == null) { return(NotFound()); } var proposalExample = scenario.Proposals?.FirstOrDefault(i => i.ProposalId == proposalId); if (proposalExample == null) { return(NotFound()); } await scenario.GetContentsAsync(); await proposalExample.GetContentsAsync(); var model = new AddProposalExampleModel(); model.Scenario = scenario; model.ProposalId = proposalId; model.Contents = proposalExample.Contents; this.ViewBag.FormAction = "EditProposalExample"; return(View("EditProposalExample", model)); }
public ActionResult Finish() { ScenarioModel scenario = this.TempData["Scenario"] != null ? (ScenarioModel)this.TempData["Scenario"] : null; List <Witness> witness = this.TempData["Witness"] != null ? (List <Witness>) this.TempData["Witness"] : null; TheEndModel theEnd = new TheEndModel(); try { theEnd = ChallengeSolverBusiness.GetInstance().FindWhoIsTheKiller(scenario, witness); } catch (Exception e) { Error("Assassino não encontrado!"); return(View(theEnd)); } if (theEnd == null || theEnd.Killers == null || theEnd.Killers.Count == 0) { Error("Assassino não encontrado!"); } else { Success("Assassino(s) encontrado(s)!"); } return(View(theEnd)); }
/// <summary> /// 读取剧本 /// </summary> /// <param name="scriptName"></param> /// <returns></returns> public bool LoadScenario(string scriptName, bool txt = true) { ScenarioModel model = ModelManager.models.Get <ScenarioModel>(); IScenario scenario = model.Get(scriptName, txt); if (scenario == null) { return(false); } ScenarioAction action = new ScenarioAction(currentAction) { debugInfo = debugInfo }; Type[] executorTypes = GameAction.GetDefaultExecutorTypesForScenarioAction().ToArray(); action.LoadExecutors(executorTypes); if (!action.LoadScenario(scenario)) { Debug.LogError(action.error); action.Dispose(); return(false); } currentAction = action; if (debugInfo) { Debug.LogFormat("GameDirector Load Scenario: {0}", scenario.name); } return(true); }
private void SelectInternal(ScenarioModel model) { if (SelectedModelChanging != null) { SelectedModelChanging?.Invoke( model, new ScenarioChangingEventArgs() { Apply = () => { if (model != null) { model.Checked = true; } BindSwitchSettings(model); SelectedModel = model; SelectedModelChanged?.Invoke(model); } }); } else { if (model != null) { model.Checked = true; } BindSwitchSettings(model); SelectedModel = model; SelectedModelChanged?.Invoke(model); } }
public void reset() { selectedScenario = null; selectedPersona = null; energyConsumption.reset(); currentState = State.READY; }
public static void ApplyToScenario(Scenario scenario, ScenarioModel command, IMapper mapper) { scenario.Id = (command.Id != Guid.Empty ? command.Id : scenario.Id); scenario.Name = command.Name; scenario.CampaignPriorityRounds = mapper.Map <CampaignPriorityRounds>(command.CampaignPriorityRounds); var oldPasses = new List <PassReference>(); scenario.Passes.ForEach(item => oldPasses.Add(item)); scenario.Passes.Clear(); foreach (var passModel in command.Passes) { var oldPass = oldPasses.Find(item => item.Id == passModel.Id); if (oldPass == null) // New pass { var pass = MapToPassReference(passModel); scenario.Passes.Add(pass); } else { ApplyToPassReference(oldPass, passModel); scenario.Passes.Add(oldPass); } } }
public static List <ScenarioModel> ReadScenariosFromDisk(string assetsDirectory, string routeGuid, bool inGame, bool inArchive) { var scenarioList = new List <ScenarioModel>(); int routeId = RoutesCollectionDataAccess.GetRouteId(routeGuid); if (routeId <= 0) { Log.Trace($"Cannot find RouteId for {routeGuid} No scenarios retrieved {Converters.LocationToString(inGame,inArchive)}", LogEventType.Message); return(scenarioList); } DirectoryInfo path = new DirectoryInfo($"{assetsDirectory}{routeGuid}\\Scenarios\\"); if (Directory.Exists(path.FullName)) { DirectoryInfo[] scenarioPathList = path.GetDirectories("*", SearchOption.TopDirectoryOnly); foreach (var scenarioDir in scenarioPathList) { var scenario = new ScenarioModel(); scenario.ScenarioGuid = scenarioDir.Name; scenario.RouteId = routeId; var scenarioPropertiesPath = $"{scenarioDir}\\ScenarioProperties.xml"; if (File.Exists(scenarioPropertiesPath)) { if (inGame) { scenario.IsValidInGame = true; } if (inArchive) { scenario.IsValidInArchive = true; } var properties = ScenarioPropertiesDataAccess.ReadScenarioNameAndClass(scenarioPropertiesPath, scenario.ScenarioGuid); scenario.ScenarioTitle = properties.ScenarioTitle; scenario.ScenarioClass = properties.ScenarioClass; } else { scenario.ScenarioTitle = ScenarioPropertiesDataAccess.GetInvalidScenarioTitle(scenario.ScenarioGuid); if (inGame) { scenario.IsValidInGame = false; } if (inArchive) { scenario.IsValidInArchive = false; } } scenarioList.Add(scenario); } } return(scenarioList); }
public void addInfoToCard(ScenarioModel scenario) { this.scenario = scenario; this.title.text = scenario.name; this.image.sprite = Resources.Load <Sprite>(scenario.imagePath); this.image.color = Color.white; }
public ActionResult Run(ScenarioModel model) { var scenario = scenarioService.GetScenarioById(model.Id); long executionId = hatcheryService.RunScenario(scenario); return(RedirectToAction("Scenario", "Report", new { id = executionId })); }
public ServiceConfigViewModel(ScenarioModel scenario) { if (scenario != null) { if (scenario.Map != null) { try { Width = scenario.Map[0].Width; Height = scenario.Map[0].Height; if (scenario.Map[0].Substrate != null) { Background = new ImageBrush(Helpers.Imaging.ImageManager.BitmapToBitmapImage(scenario.Map[0].Substrate)); } } catch (NullReferenceException) { Width = 800; Height = 600; Background = Brushes.LightCoral; } } if (scenario.Services != null) { _servicesOnMap = new ObservableCollection <ServiceModel>(scenario.Services); if (_servicesOnMap.Count > 0) { _generator.Init(_servicesOnMap.Max(s => s.Id)); } } } }
public async Task <IActionResult> EditScenario(string id, ScenarioModel model) { var map = await MapModel.GetAsync(AppSettings.DefaultRepo); var mapScenario = map.FindScenario(id); if (mapScenario != null) { mapScenario.Title = model.Title; mapScenario.Summary = model.Summary; using (await LockingService.LockAsync()) { await map.SaveAsync(); await ScenarioModel.SaveContentsAsync(id, AppSettings.DefaultRepo, model.Contents); await ChangesService.Get(AppSettings.DefaultRepo).PushChangesAsync(); } } dynamic parameters = new ExpandoObject(); parameters.id = id; return(RedirectToAction(nameof(ViewScenario), parameters)); }
private List <Witness> CreateWitness(WitnessFileDownload response, ScenarioModel scenario) { List <Witness> lWitness = new List <Witness>(); List <ResponseFile> responseF = response.Scenario; for (int i = 0; i < responseF.Count(); i++) { //for(int i=0; i< response.responses.Count; i++) try { { lWitness.Add(new Witness() { Killer = new Killer() { Gun = scenario.Guns.Where(g => g.Name == responseF[i].Gun).FirstOrDefault(), Local = scenario.Locals.Where(l => l.Name == responseF[i].Local).FirstOrDefault(), Suspect = scenario.Suspects.Where(s => s.Name == responseF[i].Suspect).FirstOrDefault() } }); } } catch (Exception e) { lWitness = null; } } return(lWitness); }
public AiArea(ScenarioModel parent, AiZone zone, BlockReference blockRef, int index) : base(parent) { Zone = zone; BlockReference = blockRef; BlockIndex = index; }
public Simulation(ScenarioModel scenario) { if (scenario == null) { throw new ArgumentNullException("scenario is null"); } //System.Threading.Timer t = new System.Threading.Timer(new System.Threading.TimerCallback((o) => Step()), null, 0, (long)STEP_TIME_MS); _scenario = scenario; RoadGraph = new Graph <WayPoint, PathFigure>(); if (_scenario.RoadGraph != null) { foreach (var node in _scenario.RoadGraph.Nodes) { RoadGraph.Add(node); } foreach (var edge in _scenario.RoadGraph.Edges) { var pathGeom = PathGeometry.CreateFromGeometry(PathGeometry.Parse(edge.Data)); RoadGraph.AddEdge(edge.Start, edge.End, pathGeom.Figures.First()); } } _analisisCollector = new Analisis.AnalisisCollector(); _map = _scenario.Map; _start = _scenario.StartTime; _end = _scenario.EndTime; _simulationTime = _scenario.StartTime; Init(STEP_TIME_MS); }
public AiStartingLocation(ScenarioModel parent, BlockReference blockRef, int index, string sectionKey) : base(parent) { SectionKey = sectionKey; BlockReference = blockRef; BlockIndex = index; }
public async Task <DependantResourceModel> MarkScenario( ScenarioModel scenarioModel ) { if (scenarioModel.ToBeDeleted) { throw new ResourceAlreadyMarkedException( $"Cannot mark {scenarioModel}, it is already marked!" ); } scenarioModel.ToBeDeleted = true; scenarioModel.ReadOnly = true; var response = await _httpService.PutAsync( $"http://{_baseUrl}/scenarios/{scenarioModel.ScenarioId}/marks", scenarioModel ); response.ThrowExceptionIfNotSuccessfulResponse( new FailedToUpdateResourceException( await response.FormatRequestAndResponse( $"Failed to update scenario {scenarioModel} from scenario-svc!" ) ) ); return(new DependantResourceModel( ResourceTypeEnum.Scenario, scenarioModel.ScenarioId )); }
public TriggerVolumeComponentManager(ScenarioModel scenario) : base(scenario) { sceneNode = new TreeItemModel { Header = "trigger volumes", IsChecked = true }; TriggerVolumes = new ObservableCollection <BoxManipulator3D>(); }
public ScenarioRepository(ScenarioModel context) { this.context = context; this.context.Configuration.ProxyCreationEnabled = false; this.context.Configuration.LazyLoadingEnabled = false; #if DEBUG this.context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); #endif }
public void SetScenario(ScenarioModel scenario) { this.scenario = scenario; var fileName = $"{scenario.ScenarioTag.FileName()}.{scenario.ScenarioTag.ClassName}"; TabModel.ToolTip = fileName; TabModel.Header = Utils.GetFileName(fileName); }
public static ScenarioModel CreateScenarioModel(string folder_id, string name, string description) { string folder = ApiHelper.FindFolderById(folder_id, PathHelper.GetRepoPath()); string ret = Command.CreateScenario(name, folder, description); folder = ApiHelper.FindFolderById(ret, PathHelper.GetRepoPath()); ScenarioModel rett = ApiHelper.GetScenarioInfoModel(ret, folder); return(rett); }
private void PrepareName([NotNull] ScenarioModel scenario, [NotNull, ItemNotNull] HashSet <string> names) { if (names.Contains(scenario.Name)) { scenario.Name = scenario.Name + $"-{scenario.Id}"; return; } names.Add(scenario.Name); }
public static List <ScenarioModel> ReadPackedListScenariosFromDisk(string assetsDirectory, string routeGuid, bool inGame, bool inArchive) { var scenarioList = new List <ScenarioModel>(); int routeId = RoutesCollectionDataAccess.GetRouteId(routeGuid); if (routeId <= 0) { Log.Trace($"Cannot find RouteId for {routeGuid} No scenarios retrieved {Converters.LocationToString(inGame,inArchive)}", LogEventType.Message); return(scenarioList); } DirectoryInfo path = new DirectoryInfo($"{assetsDirectory}{routeGuid}\\"); if (Directory.Exists(path.FullName)) { FileInfo[] apFiles = path.GetFiles("*.ap", SearchOption.TopDirectoryOnly); foreach (var file in apFiles) { // We cannot use the ZipAccess method here, because all logic but be in scope of the using statement for the archive using (ZipArchive archive = ZipFile.OpenRead(file.FullName)) { var entries = archive.Entries; var filteredEntries = entries.Where(x => x.FullName.EndsWith("ScenarioProperties.xml")).ToList(); foreach (var entry in filteredEntries) { var scenario = new ScenarioModel(); scenario.IsPacked = true; scenario.Pack = file.Name; scenario.RouteId = routeId; if (inGame) { scenario.IsValidInGame = true; } if (inArchive) { scenario.IsValidInArchive = true; } scenario.ScenarioGuid = entry.FullName.Substring(10, 36); var scenarioProperties = ScenarioPropertiesDataAccess.ReadPackedScenarioNameAndClass(entry, scenario.ScenarioGuid); scenario.ScenarioTitle = scenarioProperties.ScenarioTitle; scenario.ScenarioClass = scenarioProperties.ScenarioClass; scenarioList.Add(scenario); } } } } return(scenarioList); }
private ExcelReportGrid ScenarioDetailsGrid(RunModel run, ScenarioModel scenario, int maxColumnsCount, DateTime reportDate) { var grid = new ExcelReportGrid(); grid.MaxColumnCount = maxColumnsCount; var row1 = new ExcelReportRow(); row1.Cells.Add(new ExcelReportCell() { Value = "Report Date", Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.HeaderStyle.Name }); row1.Cells.Add(new ExcelReportCell() { Value = string.Format(CultureInfo.InvariantCulture, "{0:dd MMMM yyyy} - {0:HH:mm:ss}", reportDate), Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.HeaderStyle.Name }); grid.HeaderRows.Add(row1); var row2 = new ExcelReportRow(); row2.Cells.Add(new ExcelReportCell() { Value = "Run Name", Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name }); row2.Cells.Add(new ExcelReportCell() { Value = run.Description, Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name }); grid.BodyRows.Add(row2); var row3 = new ExcelReportRow(); row3.Cells.Add(new ExcelReportCell() { Value = "Run Id", Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name }); row3.Cells.Add(new ExcelReportCell() { Value = run.Id, Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name }); grid.BodyRows.Add(row3); var row4 = new ExcelReportRow(); row4.Cells.Add(new ExcelReportCell() { Value = "Scenario Name", Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name }); row4.Cells.Add(new ExcelReportCell() { Value = scenario.Name, Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name }); grid.BodyRows.Add(row4); return(grid); }
private void BindSwitchSettings(ScenarioModel model) { foreach (UserControl userControl in grid.Children) { if (userControl.DataContext != model) { ((ScenarioModel)userControl.DataContext).Checked = false; } } switchSetting.DataContext = model; }
private void startScenarioFlowBasedOn(ScenarioModel selectedScenario) { if (selectedScenario is NoScenarioModel) { startScenarioHappyFlow(); } else { startScenarioBadFlow(); } }
internal PaletteEditorWindow(ScenarioModel scenario, string paletteKey) : this() { this.scenario = scenario; this.paletteKey = paletteKey; context = new MetaContext(scenario.Xml, scenario.ScenarioTag.CacheFile, scenario.ScenarioTag, scenario.MetadataStream); Reload(); DataContext = this; }
public void Remove(ScenarioModel item) { if (!item.IsScenario) return; if (!item.HasWorkspace) return; Context.ScenarioWorkspaces.Remove(item.ScenarioWorkspace); item.ScenarioWorkspace = null; }
private void Start() { gameState = FindObjectOfType <Game>().getGameState(); energyConsumption = gameState.getEnergyConsumption(); activeScenarioModel = fetchSelectedScenarioModelIf(!sceneSettings.getIsDebugMode()); enableInformationPointsIf((activeScenarioModel is NoScenarioModel)); activeScenario = determineActiveScenario(); player.disablePlayerControls(); displayIntroduction(); }
public ActionResult Upsert(ScenarioModel model) { if (!ModelState.IsValid) { CompleteScenarioModel(model); return(View("EditScenario", model)); } var scenario = mapper.Map <ScenarioModel, Scenario>(model); scenarioService.Upsert(scenario); return(RedirectToAction("Index")); }
public List <Witness> DeserializeJsonFileWitness(Stream file, ScenarioModel scenario) { /* Get contents to string */ string str = (new StreamReader(file)).ReadToEnd(); /* Deserializes string into object */ WitnessFileDownload response = JsonConvert.DeserializeObject <WitnessFileDownload>(str); /* Create objects from the deserialized json */ return(CreateWitness(response, scenario)); }
public ObjectPlacement InsertPlacement(int index, ScenarioModel scenario, string paletteKey) { var placement = new ObjectPlacement(scenario, paletteKey); Definition.Placements.Insert(index, placement); TreeItems.Insert(index, new TreeItemModel { Header = placement.GetDisplayName(), IsChecked = true, Tag = null }); Elements.Insert(index, null); return(placement); }
public ScenarioWorkspace Add(ScenarioModel item) { if (!item.IsScenario) return null; if (item.HasWorkspace) return null; // scenario id numbers are negative in this view model var scenario = Context.Scenarios.Find(Math.Abs(item.ID)); if (scenario == null) return null; ScenarioWorkspace detail = new ScenarioWorkspace(); detail.Scenario = scenario; item.ScenarioWorkspace = detail; detail.UserID = Context.UserName; detail.Default(Context.UserName); detail.Approve(Context.UserName); Context.ScenarioWorkspaces.Add(detail); return detail; }