private void DieIfAble() { if (currentHealth <= 0) { currentHealth = 0; currentState = MovementState.DYING; currentLives--; if (photonView.isMine) { PlayDeathSound(); photonView.RPC("PlayDeathSound", PhotonTargets.Others); GeneratedGameManager behavior = FindObjectOfType <GeneratedGameManager>(); if (IsOutOfLives()) { behavior.DisplayAlert("Your light has gone out forever. You can still spectate though.", false, PlayerStateContainer.EXPLORER); behavior.photonView.RPC("DisplayAlert", PhotonTargets.Others, "An explorer has fallen, his light is out forever.", false, PlayerStateContainer.EXPLORER); } else { behavior.DisplayAlert("Your light has gone out! Go to a lit bonfire or another player to relight it.", false, PlayerStateContainer.EXPLORER); behavior.photonView.RPC("DisplayAlert", PhotonTargets.Others, "Someone's light has gone out! Help them relight it by finding them.", false, PlayerStateContainer.EXPLORER); } } } }
public void AddUpgrade() { numUpgrades++; GeneratedGameManager manager = FindObjectOfType <GeneratedGameManager>(); string message = PlayerStateContainer.Instance.TeamSelection == PlayerStateContainer.NIGHTMARE ? "Your attack has been upgraded." : "Your movement has been upgraded."; if (manager != null) { manager.DisplayAlert(message, true, PlayerStateContainer.Instance.TeamSelection); } else { FindObjectOfType <DemoSceneManager>().DisplayAlert(message, true, PlayerStateContainer.Instance.TeamSelection); } }
public void AddPowerup(Powerup p) { powerupDictionary[p] = Time.time; if (photonView.isMine) { GeneratedGameManager manager = FindObjectOfType <GeneratedGameManager>(); if (manager != null) { manager.DisplayAlert("You have been granted " + p.ToString(), true, PlayerStateContainer.Instance.TeamSelection); } else { FindObjectOfType <DemoSceneManager>().DisplayAlert("You have been granted " + p.ToString(), true, PlayerStateContainer.Instance.TeamSelection); } } }
// Brings the player back to life if they are within range of a bonfire that has living players near it. private void ResurrectIfAble() { if (!photonView.isMine || !IsDead() || IsOutOfLives()) { return; } bool ableToRes = false; BaseExplorer savior = null; Collider2D[] bonfires = Physics2D.OverlapCircleAll(transform.position, saveCollider.radius, whatIsBonfire); foreach (Collider2D fireCollider in bonfires) { BonfireBehavior behavior = fireCollider.gameObject.GetComponent <BonfireBehavior>(); if (behavior != null && behavior.IsLit()) { ableToRes = true; } } Collider2D[] players = Physics2D.OverlapCircleAll(transform.position, saveCollider.radius, whatIsExplorer); foreach (Collider2D collider in players) { BaseExplorer behavior = collider.gameObject.GetComponent <BaseExplorer>(); if (behavior != null && !behavior.IsOutOfHealth()) { ableToRes = true; behavior.photonView.RPC("ReceiveRescueEmbers", PhotonTargets.All, 10); savior = behavior; } } if (ableToRes) { currentHealth = maxHealth; GeneratedGameManager behavior = FindObjectOfType <GeneratedGameManager>(); behavior.photonView.RPC("DisplayAlert", PhotonTargets.Others, "An explorer has been saved! His light shines once more.", false, PlayerStateContainer.EXPLORER); behavior.DisplayAlert("You have been saved! Your light shines once more.", false, PlayerStateContainer.EXPLORER); PlayRelightSound(); photonView.RPC("PlayRelightSound", PhotonTargets.Others); } }