using System; using PixelCrushers.DialogueSystem; using Sirenix.OdinInspector; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.UI; // ReSharper disable once CheckNamespace namespace BlueWaterProject { public class TycoonNpc : MonoBehaviour { public NpcStateMachine StateMachine { get; set; } public NavMeshAgent Agent { get; set; } public Transform VisaualLook { get; set; } public TycoonMapInfo MapInfo { get; set; } public Animator Animator { get; set; } [Title("FindTableState")] public bool DoSeat { get; set; } public Seat AssignedSeat { get; set; } [Title("FoodOrderState")] public Image BarkImg { get; set; } public Image BarkFillImg { get; set; } public Image FoodImg { get; set; } public Transform EmojiTransform { get; set; } public bool IsGetFood { get; set; } public bool IsGetDrink { get; set; } [Title("PayState")] public PayController PayController { get; set; } public GameObject PayTextObj { get; set; } public TextMeshProUGUI PayText { get; set; } public Animator PayTextAni { get; set; } public int Satisfaction { get; set; } = 25; private void Awake() { Agent = GetComponent(); VisaualLook = transform.Find("UnitRoot"); Animator = VisaualLook.GetComponent(); Agent.updateRotation = false; MapInfo = GameObject.Find("MapInfo").GetComponent(); BarkImg = transform.Find("Canvas/BarkImg").GetComponent(); BarkFillImg = transform.Find("Canvas/BarkFillImg").GetComponent(); FoodImg = transform.Find("Canvas/FoodImg").GetComponent(); EmojiTransform = transform.Find("Emoji"); PayController = MapInfo.Counter.GetComponent(); PayTextObj = transform.Find("Canvas/PayText").gameObject; PayText = PayTextObj.GetComponent(); PayTextAni = PayTextObj.GetComponent(); } private void Start() { StateMachine = gameObject.AddComponent(); var findTableState = new FindTableState(this); StateMachine.ChangeState(findTableState); } private void Update() { var isMoving = Agent.velocity.magnitude > 0.1f; Animator.SetBool("isRunning", isMoving); DialogueLua.SetVariable("Satisfaction", Satisfaction); if (Satisfaction <= -1) { var walkOutState = new WalkOutSate(this); StateMachine.ChangeState(walkOutState); } } } }