Exemplo n.º 1
0
    public void StartGame()
    {
        //StopCoroutine(GameOver());

        ChangeHealth(maxPlayerHealth);
        // healthBar.SetMaxHealth(maxPlayerHealth);
        // healthBar.SetHealth(maxPlayerHealth);
        skeletonsKilled = 0;
        scoreIndicator.ChangeScore(0);

        GameObject player = GameObject.FindGameObjectWithTag("Player");

        player.transform.position    = new Vector3(0f, -4f, 0f);
        player.transform.eulerAngles = new Vector3(0f, 0f, 0f);
        player.GetComponent <PlayerController>().health = maxPlayerHealth;

        player.GetComponent <Animator>().SetTrigger("isAlive");
        player.GetComponent <Animator>().Play("PlayerIdle");
        player.GetComponent <PlayerController>().enabled = true;
        player.GetComponent <PlayerController>().isDead  = false;

        mainMenu.SetActive(false);
        healthBar.gameObject.SetActive(true);
        scoreIndicator.gameObject.SetActive(true);

        Time.timeScale = 1f;

        enemySpawner         = GetComponent <EnemySpawner>();
        enemySpawner.enabled = true;
    }
    protected override IEnumerator playAnimation(Func <float, float> easeFunction)
    {
        float elapsedTime = 0;

        while (elapsedTime < duration)
        {
            transform.position = Vector3.Lerp(startPosition, endPosition, easeFunction(elapsedTime / duration));
            yield return(null);

            elapsedTime += Time.deltaTime;
        }
        transform.position = offscreen;
        inUse = false;
        scoreIndicator.ChangeScore();
    }