添加教堂
This commit is contained in:
24
Assets/Scripts/Mono/CollectableItem.cs
Normal file
24
Assets/Scripts/Mono/CollectableItem.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class CollectableItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private string _collectorTag;
|
||||
|
||||
[SerializeField]
|
||||
private int _itemID;
|
||||
|
||||
public int ItemID => _itemID;
|
||||
|
||||
public event EventHandler OnCollected;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.CompareTag(_collectorTag))
|
||||
{
|
||||
OnCollected?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Mono/CollectableItem.cs.meta
Normal file
2
Assets/Scripts/Mono/CollectableItem.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a9f457d7bf081d4dbe58265b66484ee
|
||||
25
Assets/Scripts/Mono/PlayerView.cs
Normal file
25
Assets/Scripts/Mono/PlayerView.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerView : MonoBehaviour
|
||||
{
|
||||
private ViewAlignmentDetector _viewAlignmentDetector;
|
||||
|
||||
[SerializeField]
|
||||
private Transform _headTransform;
|
||||
|
||||
[SerializeField]
|
||||
private Transform _targetTransform;
|
||||
|
||||
[SerializeField]
|
||||
private bool _isAligned;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_viewAlignmentDetector = new ViewAlignmentDetector(_headTransform, _targetTransform);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_isAligned = _viewAlignmentDetector.IsAligned();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Mono/PlayerView.cs.meta
Normal file
2
Assets/Scripts/Mono/PlayerView.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 662bc2e92d8d4b7489d223908a677938
|
||||
Reference in New Issue
Block a user