Example #1
0
    IEnumerator Respawn()
    {
        int fullBlackTime = 2;                                                        //must be less than respawn time
        int increment     = 60;                                                       //60 increments per second
        int i             = 0;                                                        //starts at zero
        int totalWait     = increment * (GameInfo.PlayerRespawnTime - fullBlackTime); //total increments before finished

        while (i < totalWait)
        {
            if (Settings._quickBlackout)
            {
                VC.DeathFade(1f);         //set alpha value
            }
            else
            {
                VC.DeathFade((float)i / (float)totalWait);         //set alpha value
            }


            yield return(new WaitForSeconds(1f / increment));  //wait for fraction of second (frame)

            i++;                                               //
        }

        //if(newDay)
        //GameServer.GS.GameManagerInstance.NewDay();

        VC.DeathFade(1f);
        yield return(new WaitForSeconds(fullBlackTime));


        Model.gameObject.SetActive(true);
        r.isKinematic            = false;
        r.collisionDetectionMode = CollisionDetectionMode.Continuous;

        CamOverride    = null;
        RagdollEnabled = false;
        ToggleColliders();
        if (!RespawnInBed)
        {
            this.transform.position = GameServer.GS.GetNearestSpawn(this.transform.position);
        }
        else
        {
            this.transform.position = Vector3.zero; //To bed bed location to be;
        }

        MenuManager.MMInstance.SetScreen("HUD");
        VC.DeathFade(0f);

        RespawnInBed = false;

        yield return(new WaitForSeconds(1f));

        MRD.CmdRespawn();
    }