public double CalculateIndividualGrowth(StageResult result) { var growth = 0.0; //Stage placement growth += CalculateStagePlacementBonus(result); //Overall classification growth += CalculateOverallClassificationBonus(result); //Jerseybonus growth += CalculateJerseyBonus(result); //Red number growth += CalculateRedNumberBonus(result); //Late arrival growth += CalculateLateArrivalPenalty(result); //Sprint/mountain points growth += CalculateSprintAndMountainPointsBonus(result); //Team time trial growth += CalculateTeamTimeTrialBonus(result); return(growth); }
protected override void DisplayResult(StageResult result) { if (_userMesh != null && _scoreMesh != null && _coinMesh != null && _timeMesh != null && _lifeMesh != null) { UpdateScoreBoard(_userMesh, _scoreMesh, _coinMesh, _timeMesh, _lifeMesh); } switch (result) { case StageResult.Worst: OpenResultPanel(0); break; case StageResult.Worse: OpenResultPanel(1); if (_note_Negative != null) { StartCoroutine(DisplayPlusLife(_note_Negative.gameObject, _lifeMesh, SFXSoundType.ClickNegative, Identifier.Negative)); } break; case StageResult.Bad: OpenResultPanel(2); break; } }
public void TestMethod2() { var processorTypes = ReflectionHelper.GetAllTypes(new[] { this.GetType().Assembly }, t => !t.IsAbstract && !t.IsInterface && typeof(IStageProcessor <ImportStages>).IsAssignableFrom(t)) .ToList(); var instances = processorTypes.Select(x => Activator.CreateInstance(x, new Action(() => { })) as StageProcessor) .OrderByDescending(o => o.Stage) .ToList(); var seed = new Func <ImportContext, Task <StageResultContext> >(async c => { var result = await c.SourceContext.Source; return(new StageResultContext(null, c, null)); }); var stageResult = new StageResult(new RamRepository()); var resultcontext = new StageResultContext(stageResult, null, null); var sourceContext = new SourceContext(() => Task.FromResult(resultcontext)); var context = new ImportContext(sourceContext, null); //var stageContext = new ImportContext(null, context); var del = instances.Aggregate(seed, (f, next) => new Func <ImportContext, Task <StageResultContext> >(async c => { var result = await c.SourceContext.Source; ////var result = await this.GetResultAsync(context); if (result.IsCompleted) { return(result); } var nextSourceContext = new SourceContext(() => next.GetResultAsync(c)); return(await f(new ImportContext(nextSourceContext, new TargetContext()))); //throw new NotImplementedException(); })); var res = del(context); }
private static StageResult GetStageResult(Team team, Stage stage) { var stageResult = new StageResult { StageNumber = stage.Number, StageName = stage.Name, MaxNumberOfPoints = stage.Points.Count, TotalValue = 0, PointResults = new List <PointResult>() }; foreach (var pointVisited in team.VisitedPoints) { var point = stage.Points.FirstOrDefault(p => p.PointId == pointVisited.PointId); if (point != null) { stageResult.PointResults.Add(new PointResult { Name = point.Name, Value = point.Value, Latitude = point.Latitude, Longitude = point.Longitude }); stageResult.TotalValue += point.Value; } } return(stageResult); }
private bool IsStageTransitionTakingPlace() { StageResult stageResult = activeStage.EvaluationResult(); return(dungeonResult == DungeonResult.Undefined && stageResult == StageResult.Completed); }
private static TeamResult GetTeamResult(Race race, Team team) { var retVal = new TeamResult { TeamNumber = team.Number, TeamName = team.Name, Category = team.Category, NumberOfStages = 0, TotalValue = 0, EndTime = team.FinishTime, NumberOfPoints = 0, StageResults = new List <StageResult>() }; foreach (var stage in race.Stages) { StageResult stageResult = GetStageResult(team, stage); var numberOfPointsToCompleteStage = stage.MimimumPointsToCompleteStage ?? race.MinimumPointsToCompleteStage; if (stageResult.NumberOfPoints >= numberOfPointsToCompleteStage) { retVal.NumberOfStages += 1; retVal.TotalValue += stageResult.TotalValue; retVal.NumberOfPoints += stageResult.NumberOfPoints; } retVal.StageResults.Add(stageResult); } SettleFinishTime(race, team, retVal); retVal.StageResults = retVal.StageResults.OrderBy(stage => stage.StageNumber).ToList(); return(retVal); }
public SceneData(StageResult stageResult, StageData stageData, bool interAdsWasShown, bool needUnloadAtlasOnWin) { this.stageResult = stageResult; this.stageData = stageData; this.interAdsWasShown = interAdsWasShown; this.needUnloadAtlasOnWin = needUnloadAtlasOnWin; }
protected virtual StageResult Save(FileInfo file, List <TRecord> records) { Contract.Requires(records != null); if (records.Count == 0) { Error("0 records found to write to file {0}.", file.FullName); return(StageResult.INPUT_ERROR); } StageResult r = StageResult.OUTPUT_ERROR; if (!CompressOutputFile) { using (FileStream fs = new FileStream(file.FullName, FileMode.Create)) using (StreamWriter sw = new StreamWriter(fs)) { r = WriteFileStream(this, sw, records, WriterOptions); } } else { using (FileStream fs = new FileStream(file.FullName, FileMode.Create)) using (GZipStream gzs = new GZipStream(fs, CompressionMode.Compress)) using (StreamWriter sw = new StreamWriter(gzs)) { r = WriteFileStream(this, sw, records, WriterOptions); } } return(r); }
public void StageFailure(StageResult result) { stageResult = result; OnTimerActivate = false; AudioManager.Instance.PlaySFXSound(SFXSoundType.Failure); LevelReformEvent(); LevelSceneManager.Instance.LoadSceneByFade(SceneLevel.Score, CanvasType.Failure, BGMSoundType.Failure); }
public StageResultContext(StageResult result, ImportContext importContext, IStageProcessor stageProcessor) { this.ImportContext = importContext; this.StageProcessor = stageProcessor; this.Result = result; //var stageContext = new StageImportContext(result, importContext); //this._lazyResult = new Lazy<Task<StageResultContext>>(new Func<Task<StageResultContext>>(() => stageProcessor.GetResultAsync(stageContext))); }
protected virtual void AddStageResult(Stage stage, StageResult result) { StageResult r; r = _stageResults.TryGetValue(stage, out r) ? r | result : result; _stageResults[stage] = r; }
private static double CalculateSprintAndMountainPointsBonus(StageResult result) { //Not applicable if DNF if (!result.RiderCompletedStage) { return(0); } return(3000 * (result.MountainPoints + result.SprintPoints)); }
private static double CalculateRedNumberBonus(StageResult result) { //Not applicable if DNF if (!result.RiderCompletedStage) { return(0); } return(result.HasRedStartNumber ? 50000 : 0); }
private static double CalculateOverallClassificationBonus(StageResult result) { //Not applicable if DNF if (!result.RiderCompletedStage) { return(0); } return(result.ClassificationAfterStage <= OverallPalcementBonusInThousands.Length ? OverallPalcementBonusInThousands[result.ClassificationAfterStage - 1] * 1000 : 0); }
private static double CalculateTeamTimeTrialBonus(StageResult result) { //Not applicable if DNF if (!result.RiderCompletedStage || result.StageType != StageTypeEnum.TeamTimeTrial) { return(0); } return(result.StagePosition <= TeamTimeTrialBonusInThousands.Length ? TeamTimeTrialBonusInThousands[result.StagePosition - 1] * 1000 : 0); }
private static double CalculateStagePlacementBonus(StageResult result) { //Not applicable if team time trial or DNF if (!result.RiderCompletedStage || result.StageType == StageTypeEnum.TeamTimeTrial) { return(0); } return(result.StagePosition <= StagePlacementBonusInThousands.Length ? StagePlacementBonusInThousands[result.StagePosition - 1] * 1000 : 0); }
static void Exit(StageResult result) { Log.CloseAndFlush(); ExitResult er = ExitResult.STAGE_FAILED; if (result == StageResult.SUCCESS) { er = ExitResult.SUCCESS; } else { er = ExitResult.STAGE_FAILED; } Environment.Exit((int)er); }
public void StageResultModelToViewModelTest() { var model = new StageResult { TotalValue = 4, PointResults = new List <PointResult>(), StageName = "a", StageNumber = 1 }; var result = _Sut.Map <StageResultViewModel>(model); Assert.AreEqual(model.TotalValue, result.TotalValue); Assert.AreEqual(model.StageName, result.StageName); Assert.AreEqual(model.StageNumber, result.StageNumber); Assert.IsNotNull(result.PointResults); }
protected override void DisplayResult(StageResult result) { if (_userMesh != null && _scoreMesh != null && _coinMesh != null && _timeMesh != null) { UpdateScoreBoard(_userMesh, _scoreMesh, _coinMesh, _timeMesh); } switch (result) { case StageResult.Awesome: OpenResultPanel(0); break; case StageResult.Amazing: OpenResultPanel(1); break; } }
protected override StageResult Write() { Contract.Requires(TrainingRecords.Count > 0); Contract.Requires(TestRecords.Count > 0); StageResult r = StageResult.OUTPUT_ERROR; if ((r = Save(TrainingFile, TrainingRecords)) != StageResult.SUCCESS) { return(StageResult.OUTPUT_ERROR); } Info("Wrote {0} training records to file {1}.", TrainingRecords.Count, TrainingFile.FullName); if ((r = Save(TestFile, TestRecords)) != StageResult.SUCCESS) { return(StageResult.OUTPUT_ERROR); } Info("Wrote {0} test records to file {1}.", TestRecords.Count, TestFile.FullName); return(StageResult.SUCCESS); }
public void Update(float dt) { // DLog.Log("DefaultStage update"); updateCounter.Update(dt); if (!updateCounter.IsAvailable()) { return; } if (stageResult != StageResult.Undefined) { if (stageResult == StageResult.Completed && IsHeroDeadLosingConditionMet()) { stageResult = StageResult.Failed; return; } return; } // UpdateChallenges(updateCounter.PreviousAccumulatedDt()); UpdateWaves(updateCounter.PreviousAccumulatedDt()); UpdateActions(updateCounter.PreviousAccumulatedDt()); UpdateGoals(updateCounter.PreviousAccumulatedDt()); UpdateLosingConditions(updateCounter.PreviousAccumulatedDt()); bool anyLosingConditionMet = EvaluateAnyLosingConditionsMet(); if (anyLosingConditionMet) { stageResult = StageResult.Failed; return; } if (!environment.IsIdle()) { return; } bool allGoalsAreAchieved = EvaluateAllGoalsIsAchieved(); if (allGoalsAreAchieved) { stageResult = StageResult.Completed; } }
public static StageResult MarshalOptionsForStage(string[] args, string explicitAssemblyName, out Stage stage, out string optionsHelp) { optionsHelp = string.Empty; Stage s = null; Parser p = new Parser(); Type[] types = GetSubTypes <Stage>(explicitAssemblyName); if ((types == null || types.Length == 0) && explicitAssemblyName.IsNotEmpty()) { stage = null; L.Error("No assemblies matching the name {0}.dll in directory {1} were found.".F(explicitAssemblyName, AssemblyExtensions.GetExecutingAssemblyDirectoryName())); optionsHelp = "You must enter an assembly name to explicitly load. Valid assembly names are : {0}." .F(string.Join(", ", AllLoadedAssemblies.Select(a => a.GetName().Name).ToArray())); return(StageResult.INVALID_OPTIONS); } else { ClassifyBotLoadedAssemblies = types.Select(t => t.Assembly).Distinct().ToList(); if (ClassifyBotLoadedAssemblies.Count == 1) { L.Information("Loaded 1 ClassifyBot assembly: {1}.", ClassifyBotLoadedAssemblies.Count(), ClassifyBotLoadedAssemblies.Select(a => a.FullName)); } else { L.Information("Loaded {0} ClassifyBot assemblies: {1}.", ClassifyBotLoadedAssemblies.Count(), ClassifyBotLoadedAssemblies.Select(a => a.FullName)); } } ParserResult <object> options = p.ParseArguments(args, types); string oh = string.Empty; StageResult sr = StageResult.INVALID_OPTIONS; options .WithNotParsed((errors) => { oh = GetHelpForInvalidOptions(options, errors); sr = StageResult.INVALID_OPTIONS; }) .WithParsed((o) => { s = (Stage)o; sr = StageResult.CREATED; }); optionsHelp = oh; stage = s; return(sr); }
public static StageResult MarshalOptionsForStage <T>(string[] args, out T stage, out string optionsHelp) { optionsHelp = string.Empty; T s = default(T); Parser p = new Parser(); ParserResult <object> options = p.ParseArguments(args, typeof(T)); string oh = string.Empty; StageResult sr = StageResult.INVALID_OPTIONS; options .WithNotParsed((errors) => { oh = GetHelpForInvalidOptions(options, errors); sr = StageResult.INVALID_OPTIONS; }) .WithParsed((o) => { s = (T)o; sr = StageResult.CREATED; }); optionsHelp = oh; stage = s; return(sr); }
private static double CalculateLateArrivalPenalty(StageResult result) { if (!result.RiderStartedStage) { return(100000); } if (!result.RiderCompletedStage) { return(150000); } if (result.StageType == StageTypeEnum.TeamTimeTrial) { return(0); } var penalty = 3000 * (int)result.TimeDiffToWinner.TotalMinutes; return(penalty < 90000 ? -penalty : -90000); }
private void EvaluateDungeonResult() { StageResult stageResult = activeStage.EvaluationResult(); // DLog.Log("stage result " + stageResult); if (stageResult == StageResult.Failed) { dungeonResult = DungeonResult.Failed; NotifyDungeonResult(); } else if (stageResult == StageResult.Completed) { completedStagesCount++; if (IsLastStage()) { dungeonResult = DungeonResult.Completed; int indexOfActiveStage = stages.IndexOf(activeStage); NotifyStageCycle(indexOfActiveStage + 1, StageCycle.Clear); //DLog.Log("Dungeon: result: " + dungeonResult); NotifyDungeonResult(); } } }
private static double CalculateJerseyBonus(StageResult result) { //Not applicable if DNF if (!result.RiderCompletedStage) { return(0); } var bonus = 0.0; //Yellow bonus += result.ClassificationAfterStage == 1 ? 25000 : 0; //Green bonus += result.IsInGreen ? 25000 : 0; //Polka dots bonus += result.IsInPolkaDots ? 25000 : 0; //White bonus += result.IsInWhite ? 15000 : 0; return(bonus); }
public void Update(GameMainState gameMainState, StageResult stageResult) { foreach (KeyValuePair<int, EnemyBase> enemyObject in this.stageEnemyList) { enemyObject.Value.Update(gameMainState); } }
public void SetStageResult(StageResult result) { this.result = result; }
public static long CalculateScore(this long score, float time, int gold, int level, StageResult bonus) { long result = 0; switch (bonus) { case StageResult.Worst: result -= 300; break; case StageResult.Worse: result -= 200; break; case StageResult.Bad: result -= 100; break; case StageResult.Normal: result += 100; break; case StageResult.Good: result += 300; break; case StageResult.Great: result += 500; break; case StageResult.Awesome: result += 700; break; case StageResult.Amazing: result += 1000; break; } result += gold; result += level * 100; result += (long)time * 15; return(score + result); }
public Start(StageResult <TInput, TInputItemCache> initial, GeneratorContext context) : base(context) { this.@in = initial; }
protected virtual StageResult GetSuppliedStageResult() { var stageResult = new StageResult(); stageResult.Proceed = true; return stageResult; }
public void AfterExecution(IInvocation invocation, bool topLevelIntercept, StageResult state) { CacheCallStackContext callStackContext = null; try { var cacheAttributes = GetCacheAttributes(invocation.MethodInvocationTarget); if (invocation.Method.ReturnType == VoidType || cacheAttributes.NoCache) return; if (cacheEnabled && state.Proceed) { callStackContext = GetCallStackContext(); // Can the result be cached in the current context? if (!callStackContext.IsResultCacheable(invocation, cacheAttributes)) return; var cacheKey = state.State as string; if (string.IsNullOrEmpty(cacheKey)) cacheKey = cacheKeyGenerator.GenerateCacheKey(invocation.MethodInvocationTarget, invocation.Arguments); // If we cant calculate a cacheKey then we can't cache this model. if (string.IsNullOrEmpty(cacheKey)) return; if (invocation.ReturnValue != null) { // Create the value to cache var cacheValue = GetValueToCache(invocation, cacheAttributes); if (cacheAttributes.AbsoluteExpirationInSecondsPastMidnight != null) { DateTime cacheEntryExpiration = DateTime.Today.AddSeconds(cacheAttributes.AbsoluteExpirationInSecondsPastMidnight.Value); if (cacheEntryExpiration <= DateTime.Now) cacheEntryExpiration = cacheEntryExpiration.AddDays(1); // Expire the cache entry in the future // Absolute expiration : Only set this in the default cache. defaultCacheProvider.Insert(cacheKey, cacheValue, cacheEntryExpiration, Cache.NoSlidingExpiration); } else { // Sliding expiration InsertValueIntoAllCacheProviders(cacheKey, cacheValue, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(cacheExpiryMinutes)); } } else InsertValueIntoAllCacheProviders(cacheKey, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(cacheExpiryMinutes)); } } finally { (callStackContext ?? GetCallStackContext()) .Exit(); } }
private bool TryServeValueFromCache(IInvocation invocation, StageResult stageResult, CacheCallStackContext callStackContext, string cacheKey, ICacheProvider cacheProvider) { object cacheEntry; if (cacheProvider.TryGetCachedObject(cacheKey, out cacheEntry)) { if (cacheEntry == null) { invocation.ReturnValue = null; } else { SetReturnValueFromCacheEntry(invocation, cacheEntry); } stageResult.Proceed = false; // We're not going to run the "After" stage, and so we need to process exiting now callStackContext.Exit(); return true; } return false; }
public void ExtractorTests() { StageResult r = Driver.MarshalOptionsForStage <LanguageSamplesExtractor>(new string[] { "extract-langdata", "-f", "foo.json" }, out LanguageSamplesExtractor extractor, out string optionsHelp); Assert.Equal(StageResult.CREATED, r); }
public StageResult BeforeExecution(IInvocation invocation, bool topLevelIntercept) { var callStackContext = GetCallStackContext(); callStackContext.Enter(invocation); var cacheAttributes = GetCacheAttributes(invocation.MethodInvocationTarget); var stageResult = new StageResult{Proceed = true}; //check if the method has a return value, or is not to be cached if (invocation.Method.ReturnType == VoidType || cacheAttributes.NoCache) return stageResult; string cacheKey = cacheKeyGenerator.GenerateCacheKey(invocation.MethodInvocationTarget, invocation.Arguments); stageResult.State = cacheKey; //If we could not calculate a cacheKey then we cant cache this model. if (string.IsNullOrEmpty(cacheKey)) return stageResult; #if DEBUG // In Debug mode only, check to see if we've disabled caching explicitly from the Cache page. if (System.Web.HttpContext.Current != null) { var app = System.Web.HttpContext.Current.Application; var disabledPrefixes = app["DisabledCachePrefixes"] as List<string>; if (disabledPrefixes != null && disabledPrefixes.Any(x => cacheKey.StartsWith(x + "$"))) { stageResult.Proceed = true; return stageResult; } } #endif if (!TryServeValueFromCache(invocation, stageResult, callStackContext, cacheKey, defaultCacheProvider)) { //If it wasn't in the default cache but it is a group initialized type initialize it. (these are not put in a tertiary cache) if (cacheAttributes.CacheInitializerType != null) { InitializeCache(invocation, cacheAttributes.CacheInitializerType); // Try to serve the value from cache now that it's been initialized TryServeValueFromCache(invocation, stageResult, callStackContext, cacheKey, defaultCacheProvider); } else { //Look through the cache providers that are not the default. foreach (var cacheProvider in cacheProviders.Where(cacheProvider => cacheProvider != defaultCacheProvider)) { //If it has a match for the cache key if (TryServeValueFromCache(invocation, stageResult, callStackContext, cacheKey, cacheProvider)) { //Set that on the default cache providers so it can be found there on the next iteration. defaultCacheProvider.Insert(cacheKey, invocation.ReturnValue, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(cacheExpiryMinutes)); //We found it so stop looking through cache providers. break; } } } } return stageResult; }
private void stageCheckResult() { if (this.nowStageResult == StageResult.Playing && this.stageUfoCount == 0) { this.nowStageResult = StageResult.Win; } }