- Players can now die (finally) - Solo players have a single cheat death per scene (reviving automatically after the first death) - group players have revive mechanic, where a player faints when his health gets to 0, creating a revive circle around him, other players can stand on it to revive him. if after x seconds they don't get revived they bleed out and stay perma death until scene changes or all players die - Multiple VFX added using post processing for cheat death, fainting, reviving, and perma death events. - stopped players from moving and pressing keys when dead - enemies now change target if they try to attack a dead/fainted target.
55 lines
1.2 KiB
C#
55 lines
1.2 KiB
C#
using Kryz.CharacterStats.Examples;
|
|
using Photon.Pun;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class RiftPlayer : MonoBehaviour
|
|
{
|
|
[Header("Class:")]
|
|
public GameTag classTag;
|
|
[Header("Events:")]
|
|
[SerializeField] private GameEvent_PhotonView onPlayerSpawned;
|
|
[SerializeField] private GameEvent_Player onPlayerDeath;
|
|
|
|
[HideInInspector]
|
|
public PhotonView photonView;
|
|
[HideInInspector]
|
|
public PlayerCharacterStats character;
|
|
|
|
public Transform projectileSpawnLocation;
|
|
|
|
private Health health;
|
|
|
|
private void Awake()
|
|
{
|
|
photonView = GetComponent<PhotonView>();
|
|
character = GetComponent<PlayerCharacterStats>();
|
|
health = GetComponent<Health>();
|
|
|
|
health.onDeath.AddListener(OnDeath);
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
onPlayerSpawned.Raise(this.photonView);
|
|
this.gameObject.name = photonView.Owner.NickName;
|
|
}
|
|
|
|
private void OnDeath()
|
|
{
|
|
if (!photonView.IsMine) return;
|
|
|
|
photonView.RPC(nameof(RPC_OnDeath), RpcTarget.All);
|
|
}
|
|
|
|
[PunRPC]
|
|
private void RPC_OnDeath()
|
|
{
|
|
onPlayerDeath.Raise(photonView.Owner);
|
|
}
|
|
|
|
|
|
}
|