ButtonArrowHandler.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using DG.Tweening;
  5. public class ButtonArrowHandler : MonoBehaviour
  6. {
  7. public enum ButtonState
  8. {
  9. Left,
  10. Right
  11. }
  12. public ButtonState CurButton;
  13. public void OnMouseDown()
  14. {
  15. Debug.Log("OnClick");
  16. transform.DOScale(1.1f, 0.2f).OnComplete(() => {
  17. transform.DOScale(1f, 0.2f);
  18. });
  19. switch(CurButton)
  20. {
  21. case ButtonState.Left:
  22. if (Core.Instance.CurIndexPlayer - 1 <= 0)
  23. {
  24. Core.Instance.CurIndexPlayer = 0;
  25. //return;
  26. }
  27. else
  28. {
  29. Core.Instance.CurIndexPlayer--;
  30. }
  31. break;
  32. case ButtonState.Right:
  33. if (Core.Instance.CurIndexPlayer + 1 >= Core.Instance.PlayerMalePrefabs.Count)
  34. {
  35. Core.Instance.CurIndexPlayer = Core.Instance.PlayerMalePrefabs.Count - 1;
  36. //return;
  37. }
  38. else
  39. {
  40. Core.Instance.CurIndexPlayer++;
  41. }
  42. break;
  43. }
  44. Core.Instance.GetPlayerForSelecting(Core.Instance.CurIndexPlayer, Core.Instance.CurGender);
  45. }
  46. }