Ejemplo n.º 1
0
    /**
     * <summary>
     * Lets this object respawn.
     * </summary>
     * <remarks>
     * See the class description for an explanation on how respawn positions are determined.
     * This method will also make this object visible using <see cref="GameObjectExtensions.MakeVisible"/>.
     * </remarks>
     */
    public void Respawn(RespawnReason reason = RespawnReason.Other)
    {
        var respawnPosition = RespawnPosition;

        // Move to position of the spawner when respawning
        if (TryGetComponent(out PhysicsEffects physicsEffects))
        {
            physicsEffects.Teleport(respawnPosition);
        }

        else if (TryGetComponent(out Rigidbody2D body))
        {
            body.position = respawnPosition;
        }

        else
        {
            this.transform.position = respawnPosition;
        }

        // Make visible again(, if we have been invisible)
        this.gameObject.MakeVisible();

        OnRespawn?.Invoke(respawnPosition, reason);
    }
Ejemplo n.º 2
0
 public static void AddRespawn(RespawnReason reason)
 {
     if (reason == RespawnReason.Sacrifice)
     {
         Sacrifices++;
     }
     else
     {
         Deaths++;
     }
 }
Ejemplo n.º 3
0
    public void RespawnPlayer(RespawnReason reason)
    {
        if (this.RemainingRespawns > 0)
        {
            Config.AddRespawn(reason);
            if (this.CurrentPlayer != null)
            {
                this.playerBodies.Add(this.CurrentPlayer);

                this.CurrentPlayer.GetComponent <PlayerController>().DisableMovement();
                this.RaiseRemainingRespawnsChanged();
            }

            this.SpawnPlayer();
        }
        else if (reason != RespawnReason.Sacrifice)
        {
            Config.AddRespawn(reason);
            this.ReloadCurrentLevel();
        }
    }
Ejemplo n.º 4
0
 public ChangeGameState(RespawnReason respawnReason)
 {
     Reason = ChangeGameStateReason.EnableRespawnScreen;
     Value  = (float)respawnReason;
 }
Ejemplo n.º 5
0
 public void Sacrifice(RespawnReason reason)
 {
     this.SoundController.PlayPlayerDeath();
     this.gameObject.layer = LayerMask.NameToLayer("Bodies");
     this.GameController?.RespawnPlayer(reason);
 }