2021년 4학년 1학기 기업연계프로젝트2 컴퓨터소프트웨어공학과 <원광투어팀> 팀장 : 송유진 팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

58 lines
1.5 KiB

using Unity.FPS.AI;
using UnityEngine;
using UnityEngine.UI;
namespace Unity.FPS.UI
{
public class CompassMarker : MonoBehaviour
{
[Tooltip("Main marker image")] public Image MainImage;
[Tooltip("Canvas group for the marker")]
public CanvasGroup CanvasGroup;
[Header("Enemy element")] [Tooltip("Default color for the marker")]
public Color DefaultColor;
[Tooltip("Alternative color for the marker")]
public Color AltColor;
[Header("Direction element")] [Tooltip("Use this marker as a magnetic direction")]
public bool IsDirection;
[Tooltip("Text content for the direction")]
public TMPro.TextMeshProUGUI TextContent;
EnemyController m_EnemyController;
public void Initialize(CompassElement compassElement, string textDirection)
{
if (IsDirection && TextContent)
{
TextContent.text = textDirection;
}
else
{
m_EnemyController = compassElement.transform.GetComponent<EnemyController>();
if (m_EnemyController)
{
m_EnemyController.onDetectedTarget += DetectTarget;
m_EnemyController.onLostTarget += LostTarget;
LostTarget();
}
}
}
public void DetectTarget()
{
MainImage.color = AltColor;
}
public void LostTarget()
{
MainImage.color = DefaultColor;
}
}
}