Example #1
0
    public IEnumerator Test_ShipDisablesItsCollidersInIntro()
    {
        ShipIntro      ship    = CreateShip();
        Player         player  = CreatePlayer();
        GameController gameCtr = CreateGameController(player);

        ship.gameCtr = gameCtr;
        GameObject shipModel = new GameObject("ShipModel");

        shipModel.transform.SetParent(ship.transform);
        BoxCollider shipCollider1 = shipModel.AddComponent <BoxCollider>();
        BoxCollider shipCollider2 = shipModel.AddComponent <BoxCollider>();

        yield return(new WaitForEndOfFrame());

        Assert.IsFalse(shipCollider1.enabled, "Box collider 1 was not disabled!");
        Assert.IsFalse(shipCollider2.enabled, "Box collider 2 was not disabled!");

        ship.animFinished = true;

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(shipCollider1.enabled, "Box collider 1 was not enabled again!");
        Assert.IsTrue(shipCollider2.enabled, "Box collider 2 was not enabled again!");
    }
Example #2
0
    public IEnumerator Test_ShipSignalizesGameControllerWhenIntroEnded()
    {
        ShipIntro      ship    = CreateShip();
        Player         player  = CreatePlayer();
        GameController gameCtr = CreateGameController(player);

        ship.gameCtr = gameCtr;

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(gameCtr.introPlaying, "Game controller did not know that intro is playing on game start!");

        ship.animFinished = true;

        yield return(new WaitForEndOfFrame());

        Assert.IsFalse(gameCtr.introPlaying, "Game controller wasn't informed that intro was finished!");
    }
Example #3
0
    public IEnumerator Test_ShipForcesPlayerAsChild()
    {
        ShipIntro      ship    = CreateShip();
        Player         player  = CreatePlayer();
        GameController gameCtr = CreateGameController(player);

        ship.gameCtr = gameCtr;
        Transform oldParent = player.transform.parent;

        yield return(new WaitForEndOfFrame());

        Assert.AreEqual(ship.transform, player.transform.parent, "Ship did not force player to be its child!");

        ship.animFinished = true;

        yield return(new WaitForEndOfFrame());

        Assert.AreNotEqual(ship.transform, player.transform.parent, "Ship did not release player as child!");
        Assert.AreEqual(oldParent, player.transform.parent, "Ship give player back to old parent!");
    }
Example #4
0
    public IEnumerator Test_ShipDisablesPlayerComponentsInIntro()
    {
        ShipIntro           ship      = CreateShip();
        Player              player    = CreatePlayer();
        BoxCollider         coll      = player.gameObject.AddComponent <BoxCollider>();
        CharacterController charContr = player.gameObject.AddComponent <CharacterController>();
        GameController      gameCtr   = CreateGameController(player);

        ship.gameCtr = gameCtr;

        yield return(new WaitForEndOfFrame());

        Assert.IsFalse(coll.enabled, "Box collider was not disabled!");
        Assert.IsFalse(charContr.enabled, "Character controller was not disabled!");

        ship.animFinished = true;

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(coll.enabled, "Box collider was not enabled again!");
        Assert.IsTrue(charContr.enabled, "Character controller was not enabled again!");
    }