public async Task Syntax_Tree_Has_A_Single_Extra_Statement_When_There_Is_One_Augmentation() { // arrange var document = Sources.GetDocument(Sources.simple); var syntaxTree = await document.GetSyntaxTreeAsync(); var statementCount = syntaxTree.GetRoot().DescendantNodes().Count(n => n is StatementSyntax); var statement = (StatementSyntax)syntaxTree.GetRoot().DescendantNodes().Single(n => n.ToString() == @"Console.WriteLine(""Entry Point"");"); var augmentation = new Augmentation(statement, null, null, null, null); var augMap = new AugmentationMap(augmentation); var rewriter = new InstrumentationSyntaxRewriter( augMap.Data.Keys, new VariableLocationMap(), augMap ); // act var newTree = rewriter.ApplyToTree(syntaxTree); var newStatementCount = newTree.GetRoot().DescendantNodes().Count(n => n is StatementSyntax); // assert Assert.Equal(statementCount + 1, newStatementCount); }
// Callback function that triggers whenever the currentAugmentation property of this script is changed public void SwitchAugmentation(Augmentation oldVal, Augmentation newVal) { if (Active) { DeactivateAugmentation(); ActivateAugmentation(newVal); } }
private void Start() { device = Camera.main.gameObject; postProcess = Camera.main.GetComponent <PostProcess>(); moveWithDevice = false; Active = false; CurrentAugmentation = Augmentation.water; OnActiveChange += SwitchActive; OnAugmentationChange += SwitchAugmentation; }
// Set up and start all needed effects for the augmentation private void ActivateAugmentation(Augmentation type) { switch (type) { case Augmentation.water: postProcess.effectMaterial = ppUnderwater; fishManager.SetUp(); foreach (var particles in particleSystemsWater) { particles.Play(); } break; case Augmentation.fire: postProcess.effectMaterial = ppFire; randomSmoke.SetUp(); foreach (var particles in particleSystemsFire) { particles.Play(); } break; case Augmentation.snow: postProcess.effectMaterial = ppSnow; //randomSmoke.SetUp(); foreach (var particles in particleSystemsSnow) { particles.Play(); } break; case Augmentation.pixel: float pixelateVal = 20; ppPixel.SetFloat("_PixelsX", Screen.width / pixelateVal); ppPixel.SetFloat("_PixelsY", Screen.height / pixelateVal); postProcess.effectMaterial = ppPixel; break; } }