/** * <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); }
public static void AddRespawn(RespawnReason reason) { if (reason == RespawnReason.Sacrifice) { Sacrifices++; } else { Deaths++; } }
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(); } }
public ChangeGameState(RespawnReason respawnReason) { Reason = ChangeGameStateReason.EnableRespawnScreen; Value = (float)respawnReason; }
public void Sacrifice(RespawnReason reason) { this.SoundController.PlayPlayerDeath(); this.gameObject.layer = LayerMask.NameToLayer("Bodies"); this.GameController?.RespawnPlayer(reason); }