36 lines
752 B
C#
36 lines
752 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class HitBox : MonoBehaviour
|
|
{
|
|
public HitBoxType type;
|
|
|
|
public PlayerNetwork player;
|
|
|
|
private void Awake()
|
|
{
|
|
player=transform.root.GetComponent<PlayerNetwork>();
|
|
player.RegisterHitbox(this);
|
|
GetComponent<Collider>().tag = "Player";
|
|
}
|
|
|
|
public void OnHit(int pid,Vector3 point, Transform shooter)
|
|
{
|
|
player.OnHit(pid, type, point, Vector3.Distance(point, shooter.position));
|
|
}
|
|
|
|
public void OnPunched(int pid, Vector3 point, Transform shooter){
|
|
player.OnHit(pid, 10, point, Vector3.Distance(point, shooter.position));
|
|
}
|
|
}
|
|
|
|
|
|
public enum HitBoxType
|
|
{
|
|
Head,
|
|
Body,
|
|
Hand,
|
|
Leg
|
|
}
|