ConvIndicator.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class ConvIndicator : MonoBehaviour
  6. {
  7. //public Sprite basicSprite;
  8. //public Sprite OptionalSprite;
  9. //public ConversationUI ConvUI;
  10. Conversation conv;
  11. Transform WorldLocation;
  12. bool active;
  13. public Image Icon;
  14. // Use this for initialization
  15. public void Init(Conversation conv,Transform worldLoc)
  16. {
  17. //if (conv.ConvType == ConversationType.Basic)
  18. // Icon.sprite = basicSprite;
  19. //else if (conv.ConvType == ConversationType.Optional)
  20. // Icon.sprite = OptionalSprite;
  21. this.conv = conv;
  22. WorldLocation = worldLoc;
  23. Show();
  24. }
  25. public void Show()
  26. {
  27. Icon.enabled = true;
  28. active = true;
  29. }
  30. void LateUpdate()
  31. {
  32. if (active)
  33. {
  34. Vector3 loc = WorldLocation.position;
  35. loc.x -= WorldLocation.localScale.x;
  36. loc.y += 4.5f * WorldLocation.localScale.x;
  37. transform.position = Camera.main.WorldToScreenPoint(loc);
  38. }
  39. }
  40. public void StartConversation()
  41. {
  42. //ConvUI.StartConversation(conv);
  43. Hide();
  44. }
  45. public void Hide()
  46. {
  47. Icon.enabled = false;
  48. active = false;
  49. }
  50. }