57 lines
1.1 KiB
C#
57 lines
1.1 KiB
C#
using Photon.Pun;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PickupItem : MonoBehaviourPunCallbacks
|
|
{
|
|
public LootItemScriptableObject type;
|
|
public int count = 1;
|
|
|
|
public void OnPickup()
|
|
{
|
|
if(PhotonNetwork.IsMasterClient)
|
|
{
|
|
PhotonNetwork.Destroy(gameObject);
|
|
}
|
|
else
|
|
{
|
|
photonView.RPC("RpcDestroy", RpcTarget.MasterClient);
|
|
}
|
|
}
|
|
|
|
[PunRPC]
|
|
void RpcDestroy()
|
|
{
|
|
if (PhotonNetwork.IsMasterClient)
|
|
{
|
|
PhotonNetwork.Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
public void SetCount(int c){
|
|
photonView.RPC("RpcSetCount", RpcTarget.All, c);
|
|
count=c;
|
|
}
|
|
|
|
[PunRPC]
|
|
void RpcSetCount(int c){
|
|
count = c;
|
|
}
|
|
|
|
|
|
private void OnDrawGizmos()
|
|
{
|
|
if(type !=null)
|
|
{
|
|
if(type.isThrowable)
|
|
{
|
|
Gizmos.color = Color.red;
|
|
Gizmos.DrawWireSphere(transform.position, type.throwableDamageRange);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|