Exemplo n.º 1
0
 public static void GameOver()
 {
     GameState.State = GameState.States.Inactive;
     UIController.SetPanelActive(true);
     UIController.Panel.GetComponent <AudioSource>().Play(); //play game over sound effect
     UIController.SetFinalScore(Player.Points);
     SceneHelper.GetSpaceship().GetComponent <SpaceshipController>().GameOver();
     GameObject.Find("AsteroidBuilderHolder").GetComponent <AsteroidBuilder>().GameOver();
 }
Exemplo n.º 2
0
    private void MoveHorizontally()
    {
        _speed = baseSpeed;
        Vector2 position       = transform.position;
        Vector2 playerPosition = SceneHelper.GetSpaceship().transform.position;

        _direction = new Vector2(playerPosition.x - position.x, 0).normalized;

        Invoke(nameof(MoveToPlayer), slowPhaseDuration);
    }
Exemplo n.º 3
0
    private void MoveToPlayer()
    {
        _speed *= speedModifier;
        Vector2 position       = transform.position;
        Vector2 playerPosition = SceneHelper.GetSpaceship().transform.position;

        _direction = (playerPosition - position).normalized;

        Invoke(nameof(MoveHorizontally), fastPhaseDuration);
    }
Exemplo n.º 4
0
    private void Shoot()
    {
        GameObject newBullet = Instantiate(ResourcesLoader.GetBullet(), transform.position, transform.rotation);

        newBullet.tag = "EnemyBullet";
        var spaceshipController = SceneHelper.GetSpaceship().GetComponent <SpaceshipController>();
        var bulletForce         = spaceshipController.bulletForce;
        var bulletLifeTime      = spaceshipController.bulletLifeTime;

        newBullet.GetComponent <Rigidbody2D>().AddRelativeForce(
            new Vector2(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f)).normalized *bulletForce);
        Destroy(newBullet, bulletLifeTime);

        Invoke(nameof(Shoot), 1 / rateOfFire);
    }