public void RespawnThisCharacter(float SpawnHealthPercentage) { transform.rotation = Quaternion.Euler(Vector3.forward); // DyingPhysicsTimerRunning = false; SetHealthCurrent(Mathf.RoundToInt(GetHealthMax() * SpawnHealthPercentage)); gameObject.layer = CharacterLayerID; CharAttention.OwnerPlayerRespawned(); SwitchActiveStateCharacterFollowGUI(true); if (GUIChar) { GUIChar.UpdateHealthHealingBar(GetHealthHealingPercentage()); GUIChar.UpdateHealthBar(GetHealthCurrentPercentage()); } MovementRateModfier = 1f; HindranceLevel = 0; CharacterIsDead = false; ResetAnimations(); DeathTimer.enabled = false; IsWalking = false; CameraController.Instance.GetCameraPositioner().UpdateCameraTargetsOnPlayerRespawn(this.gameObject); //GetComponent<Rigidbody>().isKinematic = false; LightOrbEffects.CharacterRevived(this); NavAgent.enabled = true; SpawnAndEquipStartingWeapons(); // Technically, it would be better (and possibly also would work) to disable the weapon dropping on death, however, this guarantees that the player is not stuck in activating a skill from before dying! this.enabled = true; }
// =================================== /SKILL ACTIVATION ==================================== // =================================== RESPAWNING ==================================== public void RespawnNearestCharacter() { List <Character> PlayersInAttentionRange = CharAttention.GetPlayersInAttentionRange(); Character ClosestDeadPlayer = null; float ClosestDeadPlayerDistance = RespawnMaxRange + 10; float CurrentDistance = 0; for (int i = 0; i < PlayersInAttentionRange.Count; i++) { if (PlayersInAttentionRange[i] && PlayersInAttentionRange[i].gameObject.layer == DeadCharacterLayerID) { CurrentDistance = Vector3.Distance(transform.position, PlayersInAttentionRange[i].transform.position); if (CurrentDistance < ClosestDeadPlayerDistance && CurrentDistance >= RespawnMinRange && CurrentDistance <= RespawnMaxRange) { ClosestDeadPlayerDistance = CurrentDistance; ClosestDeadPlayer = PlayersInAttentionRange[i]; } } } if (!ClosestDeadPlayer) { return; } ChangeHealthCurrent(Mathf.Max(-1 * (HealthCurrent - 1), -1 * Mathf.RoundToInt(GetHealthMax() * RespawnHealthCostPerc))); ((CharacterPlayer)(ClosestDeadPlayer)).RespawnThisCharacter(RespawnHealthGainPerc); }
public void UpdateMovePatternForMissingTarget() { if (CharAttention.GetPlayersInAttentionRange().Count <= 0) { ActiveMovePattern = BaseMovePattern; } else { DecideMovePattern(); } }
private void UpdateMovePattern() { if (CharAttention.GetPlayersInAttentionRange().Count <= 0) { return; } if (MovePatternEvaluationCycleTimer <= 0) { DecideMovePattern(); // MovePatternEvaluationCycleTimer = MovePatternEvaluationCycle; } else { MovePatternEvaluationCycleTimer -= Time.deltaTime; } }