コード例 #1
0
    public void StartMapQueueCountIsFifteen()
    {
        //Arrange
        MapGenerationScript mapGeneration = new MapGenerationScript();
        var map = GetMapMock();
        mapGeneration.SetMapInterface(map);

        //Act
        mapGeneration.Start(new GameObject());
        Queue<GameObject> queue = (Queue<GameObject>)GetInstanceField(typeof(MapGenerationScript), mapGeneration, "mapQueue");

        //Assert
        Assert.AreEqual(queue.Count, 15);
    }
コード例 #2
0
    public void GenerateMapPieceDestroysLastPiece()
    {
        //Arrange
        MapGenerationScript mapGeneration = new MapGenerationScript();
        var map = GetMapMock();
        mapGeneration.SetMapInterface(map);
        mapGeneration.Start(new GameObject());
        Queue<GameObject> queue = (Queue<GameObject>)GetInstanceField(typeof(MapGenerationScript), mapGeneration, "mapQueue");

        //Act
        mapGeneration.GenerateMapPiece();

        //Assert
        map.Received().DestroyThis(queue.Dequeue()); // destroyed last map queue piece
    }
コード例 #3
0
    public void StartGeneratedFourteenPieces()
    {
        //Arrange
        MapGenerationScript mapGeneration = new MapGenerationScript();
        var map = GetMapMock();
        mapGeneration.SetMapInterface(map);
        SetGameObjectPrefabs(mapGeneration);

        //Act
        mapGeneration.Start(new GameObject());

        //Assert
        map.Received(14).InstantiateGameObject(Arg.Any<GameObject>(), Arg.Any<Vector3>(), Arg.Any<Quaternion>()); // exactly 15 times
        map.DidNotReceive().DestroyThis(Arg.Any<GameObject>()); // none of which were destroy calls
    }
コード例 #4
0
    public void StartBeginningPieceIsGround()
    {
        //Arrange
        MapGenerationScript mapGeneration = new MapGenerationScript();
        var map = GetMapMock();
        mapGeneration.SetMapInterface(map);
        GameObject ground = new GameObject();
        mapGeneration.Ground = ground;

        //Act
        mapGeneration.Start(new GameObject());

        //Assert
        map.Received().InstantiateGameObject(ground, new Vector3(0, 0, 0), Quaternion.identity);
    }
コード例 #5
0
 void Start()
 {
     NotificationCenter.DefaultCenter().AddObserver(this, "UserGenerateMapPiece");
     if (isServer)
     {
         mapGenerator = new MapGenerationScript();
         mapGenerator.SetMapInterface(this);
         mapGenerator.SetNotificationInterface(this);
         mapGenerator.Ground = Ground;
         mapGenerator.GroundT = GroundT;
         mapGenerator.BridgeF = BridgeF;
         mapGenerator.BridgeT = BridgeT;
         mapGenerator.BridgeU = BridgeU;
         mapGenerator.Start(startPiece);
     }
 }
コード例 #6
0
    public void GenerateMapPiece()
    {
        //Arrange
        MapGenerationScript mapGeneration = new MapGenerationScript();
        var map = GetMapMock();
        mapGeneration.SetMapInterface(map);
        mapGeneration.Start(new GameObject());
        map.ClearReceivedCalls();

        //Act
        mapGeneration.GenerateMapPiece();

        //Assert       
        map.Received(1).InstantiateGameObject(Arg.Any<GameObject>(), Arg.Any<Vector3>(), Arg.Any<Quaternion>()); // received only 2 calls, one is instantiate
        map.Received(1).DestroyThis(Arg.Any<GameObject>()); // one was a destroy call
    }
コード例 #7
0
    public void GenerateMapPiece()
    {
        //Arrange
        MapGenerationScript mapGeneration = new MapGenerationScript();
        var map = GetMapMock();

        mapGeneration.SetMapInterface(map);
        mapGeneration.Start(new GameObject());
        map.ClearReceivedCalls();

        //Act
        mapGeneration.GenerateMapPiece();

        //Assert
        map.Received(1).InstantiateGameObject(Arg.Any <GameObject>(), Arg.Any <Vector3>(), Arg.Any <Quaternion>()); // received only 2 calls, one is instantiate
        map.Received(1).DestroyThis(Arg.Any <GameObject>());                                                        // one was a destroy call
    }
コード例 #8
0
    public void StartBeginningPieceIsGround()
    {
        //Arrange
        MapGenerationScript mapGeneration = new MapGenerationScript();
        var map = GetMapMock();

        mapGeneration.SetMapInterface(map);
        GameObject ground = new GameObject();

        mapGeneration.Ground = ground;

        //Act
        mapGeneration.Start(new GameObject());

        //Assert
        map.Received().InstantiateGameObject(ground, new Vector3(0, 0, 0), Quaternion.identity);
    }
コード例 #9
0
    // Use this for initialization
    void Start () {
        mapGenerator = new MapGenerationScript();
        mapGenerator.SetMapInterface(this);
        mapGenerator.SetNotificationInterface(this);
        mapGenerator.Ground = Ground;
        mapGenerator.GroundT = GroundT;
        mapGenerator.BridgeF = BridgeF;
        mapGenerator.BridgeT = BridgeT;
        mapGenerator.BridgeU = BridgeU;
        mapGenerator.Start(startPiece);

        NotificationCenter.DefaultCenter().AddObserver(this, "UserGenerateMapPiece");
        NotificationCenter.DefaultCenter().AddObserver(this, "IncreaseLevel");

        if(!_debugging)
            StartCoroutine(GenerateMapPiece());
        Instantiate(car, new Vector3(0,0.25f,0), Quaternion.identity);
    }
コード例 #10
0
    // Use this for initialization
    void Start()
    {
        mapGenerator = new MapGenerationScript();
        mapGenerator.SetMapInterface(this);
        mapGenerator.SetNotificationInterface(this);
        mapGenerator.Ground  = Ground;
        mapGenerator.GroundT = GroundT;
        mapGenerator.BridgeF = BridgeF;
        mapGenerator.BridgeT = BridgeT;
        mapGenerator.BridgeU = BridgeU;
        mapGenerator.Start(startPiece);

        NotificationCenter.DefaultCenter().AddObserver(this, "UserGenerateMapPiece");
        NotificationCenter.DefaultCenter().AddObserver(this, "IncreaseLevel");

        if (!_debugging)
        {
            StartCoroutine(GenerateMapPiece());
        }
        Instantiate(car, new Vector3(0, 0.25f, 0), Quaternion.identity);
    }
コード例 #11
0
 private void SetGameObjectPrefabs(MapGenerationScript mapGeneration)
 {
     mapGeneration.Ground = new GameObject();
     mapGeneration.GroundT = new GameObject();
     mapGeneration.BridgeF = new GameObject();
     mapGeneration.BridgeT = new GameObject();
     mapGeneration.BridgeU = new GameObject();
 }