Beispiel #1
0
    public void PlayerDied()
    {
        if (hasDied)
        {
            return;
        }

        hasDied = true;

        AddStats();

        currentCam = Camera.main;

        deathPoint = playerOne.transform.position + new Vector3(0, 0, -10);

        Time.timeScale = .55f;

        currentCam.GetComponent <CameraFollow>().enabled = false;

        playerOne.GetComponent <SpriteRenderer>().enabled   = false;
        playerOne.GetComponent <PlayerController>().enabled = false;
        playerOne.GetComponent <Movement>().enabled         = false;

        Instantiate(endScreenPrefab);

        StartCoroutine(PlayerDiedZoom());

        MonsterSpawner mSpawner = FindObjectOfType <MonsterSpawner>();

        FindObjectOfType <EventSystem>().SetSelectedGameObject(FindObjectOfType <GameOver>().quitButton);

        stopSpawn = true;
        List <GameObject> enemies = mSpawner.SendList();

        foreach (var enemie in enemies)
        {
            enemie.GetComponentInChildren <EnemyDetection>().enabled = false;
            enemie.GetComponent <EnemyAI>().enabled = false;
            enemie.GetComponentInChildren <EnemyAttack>().isAttacking = false;
            enemie.GetComponentInChildren <EnemyAttack>().enabled     = false;
        }
    }