예제 #1
0
    public void _13_AsteroidDirectionCanBeChanged()
    {
        ClearScene();
        AsteroidController asteroid = Object.Instantiate(asteroidPrefab, Vector3.zero, Quaternion.identity).GetComponent <AsteroidController>();

        asteroid.SetDirection(Vector2.up);
        Assert.IsTrue(asteroid.GetDirection() == Vector2.up);
    }
 public void Split()
 {
     if (splitCount < 2)
     {
         for (int i = 0; i < 2; i++)
         {
             AsteroidController asteroid = Instantiate(gameObject, transform.position, Quaternion.identity).GetComponent <AsteroidController>();
             asteroid.SetSplitCount(splitCount + 1);
             asteroid.SetDirection(new Vector2(Random.Range(-20.0f, 20.0f), Random.Range(-20.0f, 20.0f)));
         }
     }
     GameManager.AddToScore(splitCount);
     Instantiate(asteroidExplosion, transform.position, transform.GetChild(0).rotation).transform.localScale = transform.localScale;
     Destroy(gameObject);
 }
예제 #3
0
    public IEnumerator _20_AsteroidDoesntMoveDuringPause()
    {
        ClearScene();
        AsteroidController asteroid = Object.Instantiate(asteroidPrefab, Vector3.zero, Quaternion.identity).GetComponent <AsteroidController>();

        asteroid.SetDirection(Vector2.up);
        Vector3 startPosition = asteroid.transform.position;

        GameManager.IsPaused = true;

        for (int i = 0; i < 20; i++)
        {
            yield return(null);
        }

        Assert.IsTrue(asteroid.transform.position == startPosition);
    }
예제 #4
0
    public IEnumerator _14_AsteroidMovesAccordingToItsDirectionVector()
    {
        ClearScene();
        AsteroidController asteroid = Object.Instantiate(asteroidPrefab, Vector3.zero, Quaternion.identity).GetComponent <AsteroidController>();

        asteroid.SetDirection(Vector2.up);
        Assert.IsTrue(asteroid.GetDirection() == Vector2.up);

        float t = 0.5f;

        while (t > 0.0f)
        {
            t -= Time.deltaTime;
            yield return(null);
        }

        Assert.IsTrue(asteroid.transform.position.x == 0.0f && asteroid.transform.position.y > 0.0f);
    }