public IEnumerator Test_SuspenseMusicPlaysInTeleportLocation()
    {
        MusicControl       mc       = CreateMusicControl();
        Player             player   = CreatePlayer();
        GameController     gameCtr  = CreateGameController(player);
        TeleportToPosition teleport = CreateTeleporter(new Vector3(1, 1, 1));

        teleport.GameCtr = gameCtr;

        yield return(new WaitForEndOfFrame());

        teleport.PlayerTeleport();

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(mc.source.isPlaying, "Music did not play in teleport location!");
        Assert.AreEqual(mc.suspenseBgMusic, mc.source.clip, "Teleporting down did not start suspense background music!");
        Assert.AreEqual(mc.suspenseMusicVolume, mc.source.volume, "Music did not have the right volume after teleporting down!");
        Assert.IsTrue(mc.source.loop, "Suspense music wasn't looping!");

        teleport.PlayerTeleport();

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(mc.source.isPlaying, "Music did not play after teleporting back up!");
        Assert.AreEqual(mc.normalBgMusic, mc.source.clip, "Did not return to normal background music after teleporting back up!");
        Assert.AreEqual(mc.normalMusicVolume, mc.source.volume, "Music did not have the right volume after teleporting back up!");
        Assert.IsTrue(mc.source.loop, "Normal music wasn't looping!");
    }
Example #2
0
    public IEnumerator Test_TeleporterTriggersBlackScreen()
    {
        Canvas blackScreenUI = new GameObject("BlackScreenUI").AddComponent <Canvas>();
        Image  black         = new GameObject("Black").AddComponent <Image>();

        black.gameObject.transform.SetParent(blackScreenUI.transform);

        Player         player  = CreatePlayer();
        GameController gameCtr = CreateGameController(player);

        gameCtr.introFadeDuration = 0;
        TeleportToPosition teleport = CreateTeleporter(new Vector3(1, 1, 1));

        teleport.GameCtr = gameCtr;

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(black.gameObject.activeSelf, "Black screen image was not activated on game start!");

        yield return(new WaitForSeconds(0.001f));

        teleport.PlayerTeleport();

        yield return(new WaitForSeconds(teleport.TeleportTime / 2));

        Assert.NotZero(black.canvasRenderer.GetAlpha(), "Black screen was not set visible during teleportation!");

        yield return(new WaitForSeconds(teleport.TeleportTime / 2));

        Assert.Zero(black.canvasRenderer.GetAlpha(), "Black screen was not set transparent after teleportation finished!");
    }
    public IEnumerator Test_SoundWhenTeleporting()
    {
        SoundEffectControl sfx      = CreateSFXControl(EffectToTest.teleport);
        Player             player   = CreatePlayer();
        GameController     gameCtr  = CreateGameController(player);
        TeleportToPosition teleport = CreateTeleporter(new Vector3(1, 1, 1));

        teleport.GameCtr = gameCtr;

        yield return(new WaitForEndOfFrame());

        teleport.PlayerTeleport();

        yield return(new WaitForSeconds(teleport.TeleportTime));

        Assert.IsTrue(sfx.playerSource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.teleport, sfx.playerSource.clip, "Player audio source did not play the right track!");
    }
Example #4
0
    public IEnumerator Test_TeleporterMovesPlayerToTeleportPosition()
    {
        Player             player   = CreatePlayer();
        GameController     gameCtr  = CreateGameController(player);
        TeleportToPosition teleport = CreateTeleporter(new Vector3(1, 1, 1));

        teleport.GameCtr = gameCtr;

        Vector3 playerPos = new Vector3(2, 3, 4);

        player.transform.position = playerPos;

        yield return(new WaitForEndOfFrame());

        teleport.PlayerTeleport();

        yield return(new WaitForSeconds(teleport.TeleportTime));

        Assert.AreNotEqual(playerPos, player.transform.position, "Player didn't get teleported at all!");
        Assert.AreEqual(teleport.TeleportTo.transform.position, player.transform.position, "Player did not get teleported to teleport position!");
    }
Example #5
0
    public IEnumerator Test_TeleporterIsBlockedWhileTeleportInProgress()
    {
        Player             player   = CreatePlayer();
        GameController     gameCtr  = CreateGameController(player);
        TeleportToPosition teleport = CreateTeleporter(new Vector3(1, 1, 1));

        teleport.GameCtr = gameCtr;

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(teleport.CanTeleport(), "Teleporter was blocked before any teleporting started!");

        teleport.PlayerTeleport();

        yield return(new WaitForEndOfFrame());

        Assert.IsFalse(teleport.CanTeleport(), "Teleporter was not blocked after teleporting started!");

        yield return(new WaitForSeconds(teleport.TeleportTime));

        Assert.IsTrue(teleport.CanTeleport(), "Teleporter was still blocked after teleporting finished!");
    }
Example #6
0
    public void OnTriggerEnter(Collider other)
    {
        Enemy enemy = other.gameObject.GetComponent <Enemy>();

        if (enemy != null)
        {
            GameCtr.StartBattle(enemy);
        }

        ItemDrop itemDrop = other.gameObject.GetComponent <ItemDrop>();

        if (itemDrop != null)
        {
            itemDrop.PlayerCollectItem();
        }

        TeleportToPosition teleport = other.gameObject.GetComponent <TeleportToPosition>();

        if (teleport != null)
        {
            teleport.PlayerTeleport();
        }
    }