using Photon.Pun.Demo.PunBasics;
using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using TPSBR;
using UnityEngine;
public class EnemyHealth : MonoBehaviourPunCallbacks
{
public float health;
// değiştirilen kodlar.
playermanager playerManager;
PhotonView PV;
[HideInInspector] public bool isDead;
Animator animator;
private void Awake()
{
PV = GetComponent<PhotonView>();
playerManager = PhotonView.Find((int)PV.InstantiationData[0]).GetComponent<playermanager>();
}
private void Start()
{
animator = GetComponent<Animator>();
}
[PunRPC]
public void RPC_TakeDamage(float damage)
{
if (PV.IsMine)
return;
health -= damage;
if (health <= 0)
{
Die();
}
else Debug.Log("Hit");
}
void Die()
{
playerManager.Die();
}
/* public void TakeDamage(float damage)
{
if (health > 0)
{
health -= damage;
if (health <= 0) Die();
else Debug.Log("Hit");
}
}
void Die()
{
playerManager.Die();
Debug.Log("Death");
}*/
}using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using System.IO;
namespace TPSBR.
{
public class playermanager : MonoBehaviour.
{
GameObject Controller;
PhotonView PV;
void Awake()
{
PV = GetComponent<PhotonView>();
}
void Start()
{
if (PV.IsMine)
{
CreateController();
}
}
void CreateController()
{
Controller= PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "player"), Vector3.zero, Quaternion.identity,0,new object[] {PV.ViewID});
}
public void Die()
{
if (Controller != null)
{
PhotonNetwork.Destroy(Controller);
}
if (PV.IsMine)
{
CreateController();
}
}
}