public void Preview_FileIncludedInPreviousGroup_WontBeCountedTwice() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { File.WriteAllText(from.Combine("test1.txt"), "Blah blah"); var source1 = new RawDirectoryGroup("1", from.Path, null, null); var source2 = new RawDirectoryGroup("2", from.Path, null, null); var groups = new List <FileGroup>(new[] { source1, source2 }); var progress = new StringBuilderProgress() { ShowVerbose = true }; var sync = new MirrorController(to.Path, groups, 100, progress); sync.GatherPreview(); Assert.AreEqual(1, source1.NewFileCount); Assert.AreEqual(0, source1.UpdateFileCount); Assert.AreEqual(0, source1.DeleteFileCount); Assert.AreEqual(9, source1.NetChangeInBytes); Assert.AreEqual(0, source2.NewFileCount); Assert.AreEqual(0, source2.UpdateFileCount); Assert.AreEqual(0, source2.DeleteFileCount); Assert.AreEqual(0, source2.NetChangeInBytes); } }
public void Run_GroupHasDoDeletePolicy_DeletionIsPropagated() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { File.WriteAllText(from.Combine("test1.txt"), "Blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null) { NormallyPropogateDeletions = true }; var groups = new List <FileGroup>(new[] { source }); var controller = new MirrorController(to.Path, groups, 100, new NullProgress()); controller.Run(); //should be there at the destination AssertFileExists(controller, source, to, "test1.txt"); File.Delete(from.Combine("test1.txt")); File.WriteAllText(from.Combine("test2.txt"), "Blah blah"); controller = new MirrorController(to.Path, groups, 100, new NullProgress()); controller.Run(); AssertFileDoesNotExist(controller, source, to, "test1.txt"); } }
public void Run_FileLocked_OtherFileCopied() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { System.IO.File.WriteAllText(from.Combine("test1.txt"), "Blah blah"); System.IO.File.WriteAllText(from.Combine("test2.txt"), "Blah blah blah"); System.IO.File.WriteAllText(from.Combine("test3.txt"), "Blah blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); var groups = new List <FileGroup>(new[] { source }); var progress = new StringBuilderProgress() { ShowVerbose = true }; var controller = new MirrorController(to.Path, groups, 100, progress); using (File.OpenWrite(from.Combine("test2.txt"))) //lock it up { controller.Run(); } AssertFileExists(controller, source, to, "test1.txt"); AssertFileExists(controller, source, to, "test3.txt"); AssertFileDoesNotExist(controller, source, to, "test2.txt"); Assert.That(progress.ErrorEncountered); } }
void Start() { lightSource = transform.parent.gameObject.GetComponent <MirrorController> (); partSys = GetComponentInChildren <ParticleSystem> (); lightBeam = GetComponent <LineRenderer> (); lightBeam.widthMultiplier = beamWidth; }
public void Run_PathHasDangerousCharacters_DoesCopy() { //couldn't make it break on what came to me over email: var problemPart = "07Support&F 7f3"; var problemPart = "{9}"; using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { using (var sub = new TemporaryFolder(from, problemPart)) { var fileName = "1.txt"; System.IO.File.WriteAllText(sub.Combine(fileName), "Blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); var groups = new List <FileGroup>(new[] { source }); var progress = new ConsoleProgress() { ShowVerbose = true }; var sync = new MirrorController(to.Path, groups, 100, progress); sync.Run(); string path = to.Combine("1", problemPart, fileName); Assert.That(File.Exists(path), path); } } }
public void Run_FileRemovedAndGroupHasDefaultDeletePolicy_FileIsDeletedFromDest() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { File.WriteAllText(from.Combine("test1.txt"), "Blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); //ensure this is the defualt Assert.IsFalse(source.NormallyPropogateDeletions); var groups = new List <FileGroup>(new[] { source }); var sync = new MirrorController(to.Path, groups, 100, new NullProgress()); sync.Run(); string destFile = to.Combine(sync.DestinationRootForThisUser, source.Name, "test1.txt"); Assert.IsTrue(File.Exists(destFile)); File.Delete(from.Combine("test1.txt")); sync = new MirrorController(to.Path, groups, 100, new NullProgress()); Assert.IsTrue(File.Exists(destFile)); sync.Run(); Assert.IsFalse(File.Exists(to.Combine("test1.txt"))); } }
public void GetAllMirror_ShouldReturnAllMirror() { var testProducts = FakeMirrorList(); var controller = new MirrorController(); int output = controller.GetMirrorFromDB2().Count; var result = controller.Get() as List <Mirror>; Assert.Equal(4, output); }
public void GetMirror_ShouldReturnCorrectMirror() { var testProducts = FakeMirrorList(); // create my list var controller = new MirrorController(); var result = controller.Get(4); Assert.NotNull(result); Assert.Equal(DateTime.Parse("21-11-20 00:00"), testProducts[0].DateTime); }
public override void OnInspectorGUI() { // インスタンス化 MirrorController Edit = target as MirrorController; EditorGUILayout.LabelField("カメラの回転速度"); Edit.RotateSpeed = EditorGUILayout.Slider("Slider", Edit.RotateSpeed, 0.0f, 10.0f); EditorGUILayout.MinMaxSlider(new GUIContent("カメラの角度制限"), ref Edit.XMinRadian, ref Edit.XMaxRadian, -90.0f, 90.0f); Edit.XMaxRadian = EditorGUILayout.Slider("XMaxRadian", Edit.XMaxRadian, -90.0f, 90.0f); Edit.XMinRadian = EditorGUILayout.Slider("XMinRadian", Edit.XMinRadian, -90.0f, 90.0f); EditorGUILayout.LabelField("MinDistance = ", Edit.XMinRadian.ToString()); EditorGUILayout.LabelField("MaxDistance = ", Edit.XMaxRadian.ToString()); }
public void Run_FileExcludedByPreviousGroup_ButIsCopiedByLaterGroup() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { File.WriteAllText(from.Combine("one.txt"), "Blah blah"); var source1 = new RawDirectoryGroup("1", from.Path, null, null); source1.Filter.FileNameExcludes.Add("*.txt"); var source2 = new RawDirectoryGroup("2", from.Path, null, null); var groups = new List <FileGroup>(new[] { source1, source2 }); var sync = new MirrorController(to.Path, groups, 100, new ConsoleProgress()); sync.Run(); AssertFileExists(sync, source2, to, "one.txt"); AssertFileDoesNotExist(sync, source1, to, "one.txt"); } }
public void AssertNotNullResult() { //................Act............ var expected = FakeMirrorList(); // fake data from own unit test class var controller = new MirrorController(); // .............Arrange........and define a type which you get the object var result = controller.Get() as List <Mirror>; //we need object value var actual = result; //............Asset.............. Assert.NotNull(result); Debug.Assert(expected != null, nameof(expected) + " != null"); // Assert.Equal(expected, actual); }
public void Preview_FilteredFile_WontBeCounted() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { File.WriteAllText(from.Combine("text.txt"), "Blah blah"); File.WriteAllText(from.Combine("info.info"), "deedeedee"); var source1 = new RawDirectoryGroup("1", from.Path, new [] { "*.info" }, null); var groups = new List <FileGroup>(new[] { source1 }); var sync = new MirrorController(to.Path, groups, 100, new NullProgress()); sync.GatherPreview(); Assert.AreEqual(1, source1.NewFileCount); Assert.AreEqual(0, source1.UpdateFileCount); Assert.AreEqual(0, source1.DeleteFileCount); Assert.AreEqual(9, source1.NetChangeInBytes); } }
public void Preview_EmptyDest_SingleFileWillBeCopied() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { System.IO.File.WriteAllText(from.Combine("test1.txt"), "Blah blah"); System.IO.File.WriteAllText(from.Combine("test2.txt"), "Blah blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); var groups = new List <FileGroup>(new[] { source }); var sync = new MirrorController(to.Path, groups, 100, new NullProgress()); sync.GatherPreview(); Assert.AreEqual(0, source.UpdateFileCount); Assert.AreEqual(0, source.DeleteFileCount); Assert.AreEqual(2, source.NewFileCount); Assert.AreEqual(23, source.NetChangeInBytes); } }
public void Run_EmptyDest_SingleFileIsBeCopied() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { System.IO.File.WriteAllText(from.Combine("1.txt"), "Blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); var groups = new List <FileGroup>(new[] { source }); var progress = new StringBuilderProgress() { ShowVerbose = true }; var sync = new MirrorController(to.Path, groups, 100, progress); sync.Run(); AssertFileExists(sync, source, to, "1.txt"); } }
public void Run_PathIsVeryLong_DoesCopy() { //we're adding this guid because teh normal tempfolder code can't handle this super deap thing, can't clear it out for us //as we re-run this test var guid = Guid.NewGuid().ToString(); using (var from = new TemporaryFolder("synctest_source" + guid)) using (var to = new TemporaryFolder("synctest_dest" + guid)) { string sub = from.Path; for (int i = 0; i < 10; i++) { sub = sub + Path.DirectorySeparatorChar + "OnePartOfTheDirectory" + i; Microsoft.Experimental.IO.LongPathDirectory.Create(sub); } var fileName = "1.txt"; using (var file = Microsoft.Experimental.IO.LongPathFile.Open(sub.CombineForPath(fileName), FileMode.CreateNew, FileAccess.ReadWrite)) { } var source = new RawDirectoryGroup("Group1", from.Path, null, null); var groups = new List <FileGroup>(new[] { source }); var progress = new ConsoleProgress() { ShowVerbose = true }; var sync = new MirrorController(to.Path, groups, 100, progress); sync.Run(); string path = sub.Replace("synctest_source" + guid, "synctest_dest" + guid + Path.DirectorySeparatorChar + "Group1").CombineForPath("1.txt"); Assert.That(LongPathFile.Exists(path), path); } }
public void Run_ToldToSkipExtensionButSourceHasUpperCaseOfExt_DoesNotCopy() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { File.WriteAllText(from.Combine("one.TXT"), "Blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); source.Filter.FileNameExcludes.Add("*.txt"); var groups = new List <FileGroup>(new[] { source }); var progress = new StringBuilderProgress() { ShowVerbose = true }; var sync = new MirrorController(to.Path, groups, 100, progress); sync.Run(); AssertFileDoesNotExist(sync, source, to, "one.txt"); // we don't get this progress yet Assert.That(progress.Text.ToLower().Contains("skip")); Assert.AreEqual(0, source.NewFileCount); Assert.AreEqual(0, source.UpdateFileCount); Assert.AreEqual(0, source.DeleteFileCount); } }
public void Run_FolderExcluded_IsSkipped() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { Directory.CreateDirectory(from.Combine("sub")); File.WriteAllText(from.Combine("sub", "one.txt"), "Blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); source.Filter.SubdirectoryExcludes.Add("sub"); var groups = new List <FileGroup>(new[] { source }); var progress = new StringBuilderProgress() { ShowVerbose = true }; var sync = new MirrorController(to.Path, groups, 100, progress); sync.Run(); // we don't get this progress yet Assert.That(progress.Text.ToLower().Contains("skip")); Assert.AreEqual(0, source.NewFileCount); Assert.AreEqual(0, source.UpdateFileCount); Assert.AreEqual(0, source.DeleteFileCount); } }
public void Run_FileInMercurialFolderRemoved_FileGetsDeletedFromDest() { using (var from = new TemporaryFolder("synctest_source")) using (var to = new TemporaryFolder("synctest_dest")) { Directory.CreateDirectory(from.Combine(".hg")); File.WriteAllText(from.Combine(".hg", "test1.txt"), "Blah blah"); var source = new RawDirectoryGroup("1", from.Path, null, null); //the key here is that even though the group calls for NO deletion, //we do it anyways inside of the mercurial folder (.hg) source.NormallyPropogateDeletions = false; var groups = new List <FileGroup>(new[] { source }); var controller = new MirrorController(to.Path, groups, 100, new NullProgress()); controller.Run(); AssertFileExists(controller, source, to, Path.Combine(".hg", "test1.txt")); File.Delete(from.Combine(".hg", "test1.txt")); controller = new MirrorController(to.Path, groups, 100, new NullProgress()); controller.Run(); AssertFileDoesNotExist(controller, source, to, Path.Combine(".hg", "test1.txt")); } }
private List <List <Vector2> > getPoints(Vector2 startingPosition, Vector2 startingDirection, int bounceNum) { //return a list of lines //the list inside the list are the positions for the the given line Vector2 currentPoint = startingPosition; Vector2 currentDirection = startingDirection; bool continueRayCasting = true; int bounceCounter = bounceNum; int maxBounceCounter = LightGraph.maxBounces; List <List <Vector2> > allLines = new List <List <Vector2> >(); List <Vector2> currentLines = new List <Vector2>(); currentLines.Add(startingPosition); while (continueRayCasting && bounceCounter < maxBounceCounter) { RaycastHit2D currentHit = this.shootRay(currentPoint, currentDirection); if (currentHit.collider != null) { currentLines.Add(currentHit.point); MirrorController mc = currentHit.collider.GetComponent <MirrorController>(); PassingMirrorController pmc = currentHit.collider.GetComponent <PassingMirrorController>(); if (mc != null) { Vector2 newDirection = Vector2.Reflect(currentDirection, currentHit.normal); newDirection = new Vector2(Mathf.Round(newDirection.x), Mathf.Round(newDirection.y)); Vector2 newPoint = currentHit.point + (newDirection * .005f); currentDirection = newDirection; currentPoint = newPoint; } else if (pmc != null) { Vector2 inverseDirection = -1 * currentDirection; Vector2 checkPoint = currentHit.point + (currentDirection * .25f); RaycastHit2D checkHit = this.shootRay(checkPoint, inverseDirection); Vector2 calculatedPoint = checkHit.point + (currentDirection * .19f); List <List <Vector2> > pointsThroughMirror = this.getPoints(calculatedPoint, currentDirection, bounceCounter + 1); allLines = this.combineLists(allLines, pointsThroughMirror); Vector2 newDirection = Vector2.Reflect(currentDirection, currentHit.normal); Vector2 newPoint = currentHit.point + (newDirection * .005f); currentDirection = newDirection; currentPoint = newPoint; } else { continueRayCasting = false; } } bounceCounter++; } if (currentLines.Count != 1) { allLines.Add(currentLines); } return(allLines); }
private void AssertFileExists(MirrorController controller, RawDirectoryGroup source, TemporaryFolder destFolder, string fileName) { string path = destFolder.Combine(controller.DestinationRootForThisUser, source.Name, fileName); Assert.IsTrue(File.Exists(path), path); }
private void DoInitialConfiguration(PlayerController player) { m_AIActor.sprite.SetSprite(player.sprite.Collection, player.sprite.GetCurrentSpriteDef().name); tk2dSprite m_HandSprite = m_AIActor.aiShooter.handObject.gameObject.AddComponent <tk2dSprite>(); ExpandUtility.DuplicateSprite(m_HandSprite, player.primaryHand.gameObject.GetComponent <tk2dSprite>()); m_AIActor.aiShooter.handObject.sprite.SetSprite(player.primaryHand.sprite.Collection, player.primaryHand.sprite.GetCurrentSpriteDef().name); // Generate BossCard based on current Player. Texture2D BossCardForeground = ExpandUtility.FlipTexture(Instantiate(player.BosscardSprites[0])); // Mirror thing will be used as static background. (will be the same for all possible boss cards) Texture2D BossCardBackground = ExpandAssets.LoadAsset <Texture2D>("MimicInMirror_BossCardBackground"); // Combine foreground boss card generated from PlayerController onto the static background image loased in earlier. Resolutions must match! Texture2D BossCardTexture = ExpandUtility.CombineTextures(BossCardBackground, BossCardForeground); GenericIntroDoer miniBossIntroDoer = gameObject.GetComponent <GenericIntroDoer>(); if (BossCardTexture) { miniBossIntroDoer.portraitSlideSettings.bossArtSprite = BossCardTexture; } if (player.characterIdentity == PlayableCharacters.Bullet) { m_AIActor.EnemySwitchState = "Metal_Bullet_Man"; } else if (player.characterIdentity == PlayableCharacters.Convict) { m_AIActor.EnemySwitchState = "Convict"; } else if (player.characterIdentity == PlayableCharacters.CoopCultist) { m_AIActor.EnemySwitchState = "Cultist"; } else if (player.characterIdentity == PlayableCharacters.Cosmonaut) { m_AIActor.EnemySwitchState = "Cosmonaut"; } else if (player.characterIdentity == PlayableCharacters.Guide) { m_AIActor.EnemySwitchState = "Guide"; } else if (player.characterIdentity == PlayableCharacters.Gunslinger) { m_AIActor.EnemySwitchState = "Gunslinger"; } else if (player.characterIdentity == PlayableCharacters.Ninja) { m_AIActor.EnemySwitchState = "Ninja"; } else if (player.characterIdentity == PlayableCharacters.Pilot) { m_AIActor.EnemySwitchState = "Rogue"; } else if (player.characterIdentity == PlayableCharacters.Robot) { m_AIActor.EnemySwitchState = "Robot"; } else if (player.characterIdentity == PlayableCharacters.Soldier) { m_AIActor.EnemySwitchState = "Marine"; } else if (player.characterIdentity == PlayableCharacters.Eevee) { m_AIActor.EnemySwitchState = "Convict"; ExpandShaders.ApplyParadoxPlayerShader(m_AIActor.sprite); } else { m_AIActor.EnemySwitchState = "Gun Cultist"; } List <tk2dSpriteAnimationClip> m_AnimationClips = new List <tk2dSpriteAnimationClip>(); foreach (tk2dSpriteAnimationClip clip in player.spriteAnimator.Library.clips) { if (!string.IsNullOrEmpty(clip.name)) { if (clip.name.ToLower() == "dodge") { m_AnimationClips.Add(clip); if (clip.frames != null && clip.frames.Length > 0) { if (!player.UseArmorlessAnim) { m_AIActor.sprite.SetSprite(clip.frames[0].spriteId); } } } else if (clip.name.ToLower() == "dodge_armorless") { m_AnimationClips.Add(clip); if (clip.frames != null && clip.frames.Length > 0) { if (player.UseArmorlessAnim) { m_AIActor.sprite.SetSprite(clip.frames[0].spriteId); } } } else if (clip.name.ToLower() == "run_down") { m_AnimationClips.Add(clip); } else if (clip.name.ToLower() == "run_down_armorless") { m_AnimationClips.Add(clip); } else if (clip.name.ToLower() == "death_shot") { m_AnimationClips.Add(clip); } else if (clip.name.ToLower() == "death_shot_armorless") { m_AnimationClips.Add(clip); } } } if (m_AnimationClips.Count > 0) { if (!m_AIActor.spriteAnimator.Library) { m_AIActor.spriteAnimator.Library = m_AIActor.gameObject.AddComponent <tk2dSpriteAnimation>(); } m_AIActor.spriteAnimator.Library.clips = m_AnimationClips.ToArray(); } MirrorController mirror = ExpandPrefabs.CurrsedMirror.GetComponent <MirrorController>(); MirrorBase = Instantiate(ExpandPrefabs.DoppelgunnerMirror, gameObject.transform.position - new Vector3(0.25f, 1), Quaternion.identity); ShatterSystem = Instantiate(mirror.ShatterSystem, MirrorBase.transform.position, Quaternion.identity); ShatterSystem.SetActive(false); ShatterSystem.transform.parent = MirrorBase.transform; MirrorShatterFX = Instantiate(ExpandPrefabs.DoppelgunnerMirrorFX, (MirrorBase.transform.position - Vector3.one), Quaternion.identity); MirrorShatterFX.SetActive(false); }
private void BuildBossPrefab(RoomHandler room) { AssetBundle expandSharedAssets1 = ResourceManager.LoadAssetBundle("ExpandSharedAuto"); List <string> m_MirrorMimicFadeInSprites = new List <string>() { "PlayerMimicMirror_MimicFadeIn_01", "PlayerMimicMirror_MimicFadeIn_02", "PlayerMimicMirror_MimicFadeIn_03", "PlayerMimicMirror_MimicFadeIn_04", "PlayerMimicMirror_MimicFadeIn_05", "PlayerMimicMirror_MimicFadeIn_06", "PlayerMimicMirror_MimicFadeIn_07", "PlayerMimicMirror_MimicFadeIn_08", "PlayerMimicMirror_MimicFadeIn_09", "PlayerMimicMirror_MimicFadeIn_10" }; List <string> m_MirrorCrackSprites = new List <string>() { "PlayerMimicMirror_MimicCrack_01", "PlayerMimicMirror_MimicCrack_02", "PlayerMimicMirror_MimicCrack_03", "PlayerMimicMirror_MimicCrack_04", "PlayerMimicMirror_MimicCrack_05" }; List <string> m_MirrorShatterFXSprites = new List <string>() { "PlayerMimicMirror_ShatterDebris_01", "PlayerMimicMirror_ShatterDebris_02", "PlayerMimicMirror_ShatterDebris_03", "PlayerMimicMirror_ShatterDebris_04", "PlayerMimicMirror_ShatterDebris_05", "PlayerMimicMirror_ShatterDebris_06", "PlayerMimicMirror_ShatterDebris_07", "PlayerMimicMirror_ShatterDebris_08", "PlayerMimicMirror_ShatterDebris_09", "PlayerMimicMirror_ShatterDebris_10" }; IntVector2 SpawnPosition = (gameObject.transform.PositionVector2().ToIntVector2() - room.area.basePosition); PlayerController CurrentPlayer = GameManager.Instance.PrimaryPlayer; GameObject m_CachedNewObject = new GameObject("Gungeoneer Mimic") { layer = 28 }; GenerateGungeoneerMimicBoss(expandSharedAssets1, m_CachedNewObject, CurrentPlayer); GameObject SpawnedBossObject = m_CachedNewObject.GetComponent <AIActor>().InstantiateObject(room, SpawnPosition, false); SpawnedBossObject.transform.parent = room.hierarchyParent; Destroy(m_CachedNewObject); PickupObject MimiclayItem = PickupObjectDatabase.GetById(Mimiclay.MimiclayPickupID); if (MimiclayItem) { SpawnedBossObject.GetComponent <AIActor>().AdditionalSafeItemDrops.Add(MimiclayItem); } MirrorController mirror = ExpandPrefabs.CurrsedMirrorPlacable.gameObject.GetComponent <MirrorController>(); GameObject MimicMirrorObject = new GameObject("MimicMirrorBase"); MimicMirrorObject.transform.position = (SpawnedBossObject.transform.position - new Vector3(0.25f, 1)); MimicMirrorObject.transform.parent = gameObject.transform; ItemBuilder.AddSpriteToObject(MimicMirrorObject, expandSharedAssets1.LoadAsset <Texture2D>("PlayerMimicMirror_Base"), false, false); tk2dSprite MirrorBaseSprite = MimicMirrorObject.GetComponent <tk2dSprite>(); SpriteBuilder.AddSpriteToCollection(expandSharedAssets1.LoadAsset <Texture2D>("PlayerMimicMirror_Broken"), MirrorBaseSprite.Collection); foreach (string SpriteName in m_MirrorMimicFadeInSprites) { SpriteBuilder.AddSpriteToCollection(expandSharedAssets1.LoadAsset <Texture2D>(SpriteName), MirrorBaseSprite.Collection); } foreach (string SpriteName in m_MirrorCrackSprites) { SpriteBuilder.AddSpriteToCollection(expandSharedAssets1.LoadAsset <Texture2D>(SpriteName), MirrorBaseSprite.Collection); } ExpandUtility.GenerateSpriteAnimator(MimicMirrorObject, AnimateDuringBossIntros: true, AlwaysIgnoreTimeScale: true, ignoreTimeScale: true); ExpandUtility.AddAnimation(MimicMirrorObject.GetComponent <tk2dSpriteAnimator>(), MirrorBaseSprite.Collection, m_MirrorMimicFadeInSprites, "PlayerMimicFadeIn", tk2dSpriteAnimationClip.WrapMode.Once, 8); ExpandUtility.AddAnimation(MimicMirrorObject.GetComponent <tk2dSpriteAnimator>(), MirrorBaseSprite.Collection, m_MirrorCrackSprites, "MirrorGlassCrack", tk2dSpriteAnimationClip.WrapMode.Once, 6); ExpandGungeoneerMimicIntroDoer playerMimicBossIntroDoer = SpawnedBossObject.GetComponent <ExpandGungeoneerMimicIntroDoer>(); playerMimicBossIntroDoer.MirrorBase = MimicMirrorObject; playerMimicBossIntroDoer.ShatterSystem = Instantiate(mirror.ShatterSystem, MimicMirrorObject.transform.position, Quaternion.identity); playerMimicBossIntroDoer.ShatterSystem.SetActive(false); playerMimicBossIntroDoer.ShatterSystem.transform.parent = MimicMirrorObject.transform; GameObject MimicMirrorFXObject = new GameObject("MirrorShatterFX"); MimicMirrorFXObject.transform.position = (MimicMirrorObject.transform.position - Vector3.one); MimicMirrorFXObject.transform.parent = gameObject.transform.parent; ItemBuilder.AddSpriteToObject(MimicMirrorFXObject, expandSharedAssets1.LoadAsset <Texture2D>("PlayerMimicMirror_ShatterDebris_01"), false, false); foreach (string SpriteName in m_MirrorShatterFXSprites) { SpriteBuilder.AddSpriteToCollection(expandSharedAssets1.LoadAsset <Texture2D>(SpriteName), MimicMirrorFXObject.GetComponent <tk2dSprite>().Collection); } ExpandUtility.GenerateSpriteAnimator(MimicMirrorFXObject, AnimateDuringBossIntros: true, AlwaysIgnoreTimeScale: true, ignoreTimeScale: true); ExpandUtility.AddAnimation(MimicMirrorFXObject.GetComponent <tk2dSpriteAnimator>(), MimicMirrorFXObject.GetComponent <tk2dSprite>().Collection, m_MirrorShatterFXSprites, "PlayerMimicShatter", tk2dSpriteAnimationClip.WrapMode.Once, 12); MimicMirrorFXObject.GetComponent <tk2dSprite>().HeightOffGround = 3.5f; MimicMirrorFXObject.GetComponent <tk2dSprite>().UpdateZDepth(); playerMimicBossIntroDoer.MirrorShatterFX = MimicMirrorFXObject; MimicMirrorFXObject.SetActive(false); expandSharedAssets1 = null; }
/// <summary> /// Loads all the 360 videos and their media objects from a url to an xml file. /// </summary> /// <param name="file_path">url of the xml file</param> public void LoadXmlFile(string file_path) { XmlDocument document = new XmlDocument(); document.Load(file_path); if (document.LastChild.Name.Equals("presentation360")) { XmlNode head = document.LastChild.FirstChild; XmlNode body = document.LastChild.LastChild; Dictionary <string, XmlNode> styles = new Dictionary <string, XmlNode>(); //reading head nodes foreach (XmlNode head_child in head.ChildNodes) { if (head_child.Name.Equals("style")) { string id_style = head_child.Attributes.GetNamedItem("id").Value; head_child.Attributes.RemoveNamedItem("id"); styles.Add(id_style, head_child); } } //reading video360 body nodes Dictionary <string, GameObject> scene_objects = new Dictionary <string, GameObject>(); foreach (XmlNode body_child in body.ChildNodes) { if (body_child.Name.Equals("scene360")) { string id = body_child.Attributes.GetNamedItem("id").Value; string src = body_child.Attributes.GetNamedItem("src").Value; float volume = 1f; XmlNode volume_node = body_child.Attributes.GetNamedItem("volume"); if (volume_node != null) { volume = float.Parse(volume_node.Value); } GameObject new_scene360 = AddVideo360(src: src, volume: volume); scene_objects.Add(id, new_scene360); AddAdditionalMedia(body_child, new_scene360, scene_objects, styles); } } foreach (string media_id in scene_objects.Keys) { GameObject curMedia; curMedia = scene_objects[media_id]; HotspotController hotspotController = curMedia.GetComponent <HotspotController>(); if (hotspotController != null) { if (scene_objects.Keys.Contains(hotspotController.on_focus_name)) { hotspotController.on_focus_object = scene_objects[hotspotController.on_focus_name]; } if (scene_objects.Keys.Contains(hotspotController.during_out_of_focus_name)) { hotspotController.during_out_of_focus_object = scene_objects[hotspotController.during_out_of_focus_name]; } } MirrorController mirrorController = curMedia.GetComponent <MirrorController>(); if (mirrorController != null) { if (scene_objects.Keys.Contains(mirrorController.file_path)) { mirrorController.src_hotspot_object = scene_objects[mirrorController.file_path]; } } MediaControllerAbstract mediaControllerAbstract = curMedia.GetComponent <MediaControllerAbstract>(); if (mediaControllerAbstract != null) { if (scene_objects.Keys.Contains(mediaControllerAbstract.on_select_name)) { mediaControllerAbstract.on_select_object = scene_objects[mediaControllerAbstract.on_select_name]; } mediaControllerAbstract.Load(); } } SetAsInitial(scene_objects[body.Attributes.GetNamedItem("entry").Value]); } }