コード例 #1
0
    public IEnumerator RespawnPlayer(GameObject player)
    {
        Camera.main.GetComponent <CameraController> ().TurnOnShake();
        int playerId = player.GetComponent <PlayerTag> ().Id;

        respawnTicks [playerId] = 41;

        /*Time.timeScale = .1f;
         * for (int i = 0; i < 9; i++) {
         *      yield return new WaitForSeconds (.1f);
         *      Time.timeScale += .1f;
         *      if (Time.timeScale > 1f) Time.timeScale=1f;
         * }*/
        while (respawnTicks[playerId] > 0)
        {
            yield return(new WaitForSeconds(.5f));

            respawnTicks[playerId] -= 5;
        }

        player.SetActive(true);

        Base_WeaponManager   weaponManager    = player.GetComponent <Base_WeaponManager> ();
        Player_Health        healthScript     = player.GetComponent <Player_Health> ();
        Base_Player_Movement movementScript   = player.GetComponent <Base_Player_Movement> ();
        PlayerController     playerController = player.GetComponent <PlayerController> ();

        weaponManager.RefreshWeapons();

        float tempHealth = healthScript.Health_Max;

        tempHealth = Mathf.Ceil(tempHealth * 1.33f);
        healthScript.SetHealth(tempHealth, tempHealth, 0f);

        movementScript.ResetMovementValues();
        playerController.SetInputActive(true);
        playerController.RefreshCanSwitch();
        player.transform.position = spawnPoints [playerId].position;
        healthScript.StartCoroutine(healthScript.InvincibilityRoutine(60f));
        healthScript.ResetHarsh();
        //PowerupManager powMan = player.GetComponent<PowerupManager> ();
        //powMan.Reset (); TODO

        if (gameMode != GAMEMODE.PVE || gameMode != GAMEMODE.PVP_GUNS)
        {
            player.GetComponent <PlayerEnemyHandler> ().GiveEnemy(1);
        }
    }