コード例 #1
0
    // this function will start the coroutine Death

    public IEnumerator Death()
    {
        if (!canRunSpawnCode)
        {
            yield break;
        }
        else
        {
            canRunSpawnCode = false;
        }

        UnityEngine.Debug.Log("Starting Death IEnumerator");
        PlayerDeathStart.Invoke();
        Time.timeScale = 0.0f;                                       // will appear to freeze the game
        yield return(new WaitForSecondsRealtime(freezeFrameLength)); // how long to freeze the game

        // death animation
        PlayerDeathAfterFreeze.Invoke();
        GameObject sparks = Instantiate(PlayerDeathSparks, Player.transform.position, Quaternion.identity);

        Destroy(Player);

        // clearing all enemies from the map
        yield return(new WaitForSecondsRealtime(enemyClearDelay));

        stopAllSpawners();
        Time.timeScale = 1.0f;
        findEnemies();
        destroyEnemies();

        // respawn player
        if (lives > 0)
        {
            yield return(new WaitForSeconds(respawnDelay));

            respawnPlayer();
            Rebind();
            playerInputScript.Rebind();
            PlayerRespawn.Invoke();

            yield return(new WaitForSeconds(spawnerRestartDelay));

            startAllSpawners();
            EnemiesRestartRespawning.Invoke();
        }

        canRunSpawnCode = true;
    }
コード例 #2
0
ファイル: Client.cs プロジェクト: salt-mines/Sweating-Bullets
 internal void OnPlayerRespawn(PlayerInfo player)
 {
     PlayerRespawn?.Invoke(this, player);
 }