/// <summary>Execute a single config file.</summary> /// <param name="sessionContext">The session context.</param> /// <param name="configFile">The config file.</param> /// <param name="activity">The activity</param> /// <param name="fileType">The file types</param> /// <param name="measure">If it should measure.</param> /// <param name="fullPathToConfigFiles">The full Path To Config Files.</param> /// <returns>The success.</returns> private static Tuple <bool, int> ExecuteConfigFile(IWebGreaseContext sessionContext, string configFile, ActivityName activity, FileTypes fileType, bool measure, string fullPathToConfigFiles) { var configFileStart = DateTimeOffset.Now; var configFileInfo = new FileInfo(configFile); // Creates the context specific to the configuration file var fileContext = new WebGreaseContext(sessionContext, configFileInfo); var configFileSuccess = true; var fileSets = GetFileSets(fileContext.Configuration, fileType).ToArray(); if (fileSets.Length > 0 || (fileType.HasFlag(FileTypes.Image) && fileContext.Configuration.ImageDirectoriesToHash.Any())) { var configFileContentItem = ContentItem.FromFile(configFileInfo.FullName); configFileSuccess = sessionContext .SectionedActionGroup(fileType.ToString(), SectionIdParts.WebGreaseBuildTask, SectionIdParts.ConfigurationFile) .MakeCachable(configFileContentItem, new { activity, fileContext.Configuration }, activity == ActivityName.Bundle) // Cached action can only be skipped when it is the bundle activity, otherwise don't. .Execute(configFileCacheSection => { fileContext.Configuration.AllLoadedConfigurationFiles.ForEach(configFileCacheSection.AddSourceDependency); var success = true; fileContext.Log.Information("Activity Start: [{0}] for [{1}] on configuration file \"{2}\"".InvariantFormat(activity, fileType, configFile), MessageImportance.High); switch (activity) { case ActivityName.Bundle: // execute the bundle pipeline var bundleActivity = new BundleActivity(fileContext); success &= bundleActivity.Execute(fileSets); break; case ActivityName.Everything: // execute the full pipeline var everythingActivity = new EverythingActivity(fileContext); success &= everythingActivity.Execute(fileSets, fileType); break; } if (success && measure) { var configReportFile = Path.Combine(sessionContext.Configuration.ReportPath, (configFileInfo.Directory != null ? configFileInfo.Directory.Name + "." : string.Empty) + activity.ToString() + "." + fileType + "." + configFileInfo.Name); fileContext.Measure.WriteResults(configReportFile, configFileInfo.FullName, configFileStart); } fileContext.Log.Information("Activity End: [{0}] for [{1}] on configuration file \"{2}\"".InvariantFormat(activity, fileType, configFile), MessageImportance.High); return(success); }); } return(Tuple.Create(configFileSuccess, fileSets.Length)); }
// Start is called before the first frame update void Start() { GlobalStorage.LoadSpriteDictionary(); this.SelectedCategory = GlobalStorage.CurrentCategory; if (btnBack != null && btnBack.GetComponent <CommonButton>() != null) { btnBack.GetComponent <CommonButton>().SetCallback(() => { this.BtnBackClicked(); }); } if (categoryTitle != null) { categoryTitle.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(string.Format(@"images/category-title-{0}", this.SelectedCategory)); } // Ensure the first Stage var stage101 = GlobalStorage.LoadRecord(101); if (stage101 == null) { stage101 = StageRecord.Create(101); GlobalStorage.SaveRecord(stage101); } // Play animation to show title and pre activityManager = this.gameObject.GetComponent <ActivityManager>(); if (activityManager == null) { return; } activityManager.Initialize(false); var moveTo = categoryTitle.AddComponent <MoveTo>(); moveTo.Initialize(new Vector2(0, 5.5f), 0.6f); var delay = new DelayActivity(0.5f); activityManager.PushActivity(delay); var bundle = new BundleActivity(); for (int i = 0; i < 9; i++) { GameObject previewAnchor = this.previewAnchors[i]; GameObject preview = GameObject.Instantiate(StagePreviewPrefab); // preview.transform.parent = previewAnchor.transform; preview.transform.localPosition = previewAnchor.transform.position; preview.transform.localScale = new Vector3(1.5f, 1.5f, 1); var renderer = preview.GetComponent <StagePreviewRenderer>(); int stageId = this.SelectedCategory * 100 + i + 1; renderer.Initialize(stageId); renderer.SetCallback((stage) => { this.EnterStage(stage); }); var fadeIn = new FadeInActivity(preview, 0.6f); fadeIn.InitObject(); bundle.AddActivity(fadeIn); } activityManager.PushActivity(bundle); }
public void OnGameWin() { Debug.Log("OnGameWin"); // Save record StageRecord record = GlobalStorage.LoadRecord(this.StageId); if (record == null) { record = new StageRecord(); record.StageId = this.StageId; record.HighestScore = 0; } record.JustCompleted = true; int score = CalculateScore(); int gainRevealCount = 0; if (record.HighestScore < score) { gainRevealCount = score - record.HighestScore; record.HighestScore = score; } GlobalStorage.SaveRecord(record); if (gainRevealCount > 0) { var gameData = GlobalStorage.LoadGameData(); gameData.RevealCount += gainRevealCount; GlobalStorage.SaveGame(gameData); } int nextStageId = 0; if (this.StageId == 109) { nextStageId = 201; } else if (this.StageId == 209) { nextStageId = 301; } else { nextStageId = this.StageId + 1; } if (nextStageId > 0 && GlobalStorage.LoadRecord(nextStageId) == null) { StageRecord next = new StageRecord(); next.StageId = nextStageId; next.HighestScore = 0; GlobalStorage.SaveRecord(next); } if (this.StageId % 10 < 8 && GlobalStorage.LoadRecord(this.StageId + 2) == null) { StageRecord next = new StageRecord(); next.StageId = this.StageId + 2; next.HighestScore = 0; GlobalStorage.SaveRecord(next); } // Play animation to close the panels and show poem in full var activityManager = AquireActivityManager(); var fadeOut1 = new FadeOutActivity(this.PuzzleBoard, 1.5f); var fadeOut2 = new FadeOutActivity(this.HintBoard, 1.5f); var fadeOut3 = new FadeOutActivity(this.btnReveal, 1.5f); var fadeOut4 = new FadeOutActivity(this.btnBack, 1.5f); var fadeOut5 = new FadeOutActivity(this.btnReshuffle, 1.5f); ////var fadeOut6 = new FadeOutActivity(this.txtRevealCount, 1.5f); this.txtRevealCount.SetActive(false); this.btnRestart.SetActive(false); var bundle = new BundleActivity(); bundle.AddActivity(fadeOut1); bundle.AddActivity(fadeOut2); bundle.AddActivity(fadeOut3); bundle.AddActivity(fadeOut4); bundle.AddActivity(fadeOut5); ////bundle.AddActivity(fadeOut6); var gameObject = new GameObject("WinningPoem"); var renderer = gameObject.AddComponent <SpriteRenderer>(); renderer.sprite = Resources.Load <Sprite>(string.Format(@"images/stage_{0}_win", this.StageId)); renderer.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); gameObject.transform.localScale = new Vector3(0.55f, 0.55f, 1.0f); gameObject.transform.position = new Vector3(0f, 0f, -2.0f); activityManager.PushActivity(bundle); var fadeIn = new FadeInActivity(gameObject, 1.5f); activityManager.PushActivity(fadeIn); var receiveStar1 = new ReceiveCharActivity(this.gameObject, this.successStar1); receiveStar1.SetScales(3.0f, 6.0f); activityManager.PushActivity(receiveStar1); if (score > 1) { var receiveStar2 = new ReceiveCharActivity(this.gameObject, this.successStar2); receiveStar2.SetScales(3.0f, 6.0f); activityManager.PushActivity(receiveStar2); } if (score > 2) { var receiveStar3 = new ReceiveCharActivity(this.gameObject, this.successStar3); receiveStar3.SetScales(3.0f, 6.0f); activityManager.PushActivity(receiveStar3); } var showSuccess = new ReceiveCharActivity(this.gameObject, this.btnSuccess); showSuccess.SetScales(0.2f, 0.4f); activityManager.PushActivity(showSuccess); }