コード例 #1
0
ファイル: Toolbox.cs プロジェクト: Bloodyaugust/ld42
    IEnumerator LoadGame()
    {
        yield return(new WaitForSeconds(3));

        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
        for (int i = 0; i < enemies.Length; i++)
        {
            Destroy(enemies[i]);
        }

        Instantiate(PlayerPrefab, PlayerPrefab.transform.position, Quaternion.identity);

        GameLoaded.Invoke();

        CurrentWave = 0;

        _player       = GameObject.FindWithTag("Player");
        _playerDamage = _player.GetComponent <DamageFromContactWithTag>();
        _playerHealth = _player.GetComponent <Health>();

        _playerDamage.DamageTaken.AddListener(OnPlayerDamageTaken);
        _playerDamage.DamageIntervalHalf.AddListener(OnPlayerDamageHalfTaken);
        _playerDamage.DamageReset.AddListener(OnPlayerDamageReset);
        _playerHealth.Died.AddListener(OnPlayerDied);

        ProCamera2D.Instance.AddCameraTarget(_player.transform);
    }
コード例 #2
0
ファイル: Toolbox.cs プロジェクト: Bloodyaugust/ld42
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        if (scene.name == "game")
        {
            GameLoaded.Invoke();

            CurrentWave = 0;

            _player       = GameObject.FindWithTag("Player");
            _playerDamage = _player.GetComponent <DamageFromContactWithTag>();
            _playerHealth = _player.GetComponent <Health>();

            _playerDamage.DamageTaken.AddListener(OnPlayerDamageTaken);
            _playerDamage.DamageIntervalHalf.AddListener(OnPlayerDamageHalfTaken);
            _playerDamage.DamageReset.AddListener(OnPlayerDamageReset);
            _playerHealth.Died.AddListener(OnPlayerDied);

            ProCamera2D.Instance.AddCameraTarget(_player.transform);
        }
    }