- Turned multi job reward button click into a whole new content - Rift raids open up on multijob completion, allowing players to dive deep and take action into the rifts themselves
98 lines
2.8 KiB
C#
98 lines
2.8 KiB
C#
using Photon.Pun;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class NPCSightControllerBase : MonoBehaviour
|
|
{
|
|
[Header("Settings:")]
|
|
[SerializeField] protected float sightRangeAfterFirstVisualContact;
|
|
[SerializeField] protected float initialSightRange;
|
|
|
|
protected SphereCollider sight;
|
|
|
|
protected PhotonView photonView;
|
|
protected PhotonView otherView;
|
|
|
|
protected Taggable myTag;
|
|
protected Taggable possibleTarget;
|
|
|
|
protected NPCControllerBase npcController;
|
|
|
|
private void Awake()
|
|
{
|
|
npcController = GetComponentInParent<NPCControllerBase>();
|
|
myTag = GetComponentInParent<Taggable>();
|
|
photonView = GetComponentInParent<PhotonView>();
|
|
}
|
|
|
|
protected void Start()
|
|
{
|
|
if (!photonView.IsMine) return;
|
|
|
|
sight = this.gameObject.AddComponent<SphereCollider>();
|
|
sight.radius = initialSightRange;
|
|
sight.isTrigger = true;
|
|
}
|
|
|
|
protected virtual void OnTriggerEnter(Collider other)
|
|
{
|
|
if (!photonView.IsMine) return;
|
|
|
|
otherView = other.GetComponentInParent<PhotonView>();
|
|
if (otherView != null)
|
|
{
|
|
if (otherView == photonView) return;
|
|
}
|
|
|
|
possibleTarget = other.GetComponentInParent<Taggable>();
|
|
|
|
if (possibleTarget == null) return;
|
|
|
|
//if (possibleTarget.targetTag == myTag.targetTag || myTag.targetTag.AlliedTags.Contains(possibleTarget.targetTag)) return;
|
|
if (possibleTarget.HasSameTag(myTag.targetTag) || myTag.AlliedTagsContains(possibleTarget.targetTag)) return;
|
|
|
|
if (npcController.possibleTargets.Contains(possibleTarget)) return;
|
|
|
|
npcController.possibleTargets.Add(possibleTarget);
|
|
|
|
npcController.onPossibleTargetEnteredSight.Invoke();
|
|
sight.radius = sightRangeAfterFirstVisualContact;
|
|
}
|
|
|
|
protected virtual void OnTriggerExit(Collider other)
|
|
{
|
|
if (!photonView.IsMine) return;
|
|
|
|
otherView = other.GetComponentInParent<PhotonView>();
|
|
if (otherView != null)
|
|
{
|
|
if (otherView == photonView) return;
|
|
}
|
|
|
|
possibleTarget = other.GetComponentInParent<Taggable>();
|
|
|
|
if (possibleTarget == null) return;
|
|
|
|
if (possibleTarget.targetTag == myTag.targetTag) return;
|
|
|
|
if (!npcController.possibleTargets.Contains(possibleTarget)) return;
|
|
|
|
npcController.possibleTargets.Remove(possibleTarget);
|
|
|
|
npcController.onPossibleTargetExitedSight.Invoke();
|
|
}
|
|
|
|
|
|
protected virtual void OnDrawGizmosSelected()
|
|
{
|
|
Gizmos.DrawWireSphere(this.transform.position, sightRangeAfterFirstVisualContact);
|
|
}
|
|
|
|
public virtual void SetSightRange(float radius)
|
|
{
|
|
sightRangeAfterFirstVisualContact = radius;
|
|
sight.radius = radius;
|
|
}
|
|
}
|