Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. using System.Collections;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. public class Card : MonoBehaviour
  5. {
  6.  
  7. public static bool DO_NOT = false;
  8.  
  9. [SerializeField]
  10. private int _state;
  11. [SerializeField]
  12. private int _cardValue;
  13. [SerializeField]
  14. private bool _initialized = false;
  15.  
  16. private Sprite _cardBack;
  17. private Sprite _cardFace;
  18.  
  19. private GameObject _manager;
  20.  
  21. void Start()
  22. {
  23. _state = 1;
  24. _manager = GameObject.FindGameObjectWithTag("Manager");
  25. }
  26.  
  27. public void setupGraphics()
  28. {
  29. _cardBack = _manager.GetComponent<GameManager>().getCardBack ();
  30. _cardFace = _manager.GetComponent<GameManager>().getCardFace (_cardValue);
  31.  
  32. flipCard ();
  33. }
  34.  
  35. public void flipCard()
  36. {
  37.  
  38. if (_state == 0)
  39. _state = 1;
  40. else if (_state == 1)
  41. _state = 0;
  42.  
  43. if (_state == 0 && !DO_NOT)
  44. GetComponent<Image>().sprite = _cardBack;
  45. else if (_state == 1 && !DO_NOT)
  46. GetComponent<Image>().sprite = _cardFace;
  47.  
  48. }
  49.  
  50. public int cardValue
  51. {
  52. get { return _cardValue; }
  53. set { _cardValue = value; }
  54. }
  55.  
  56. public int state
  57. {
  58. get { return _state; }
  59. set { _state = value; }
  60.  
  61. }
  62.  
  63. public bool initialized
  64. {
  65. get { return _initialized; }
  66. set { _initialized = value; }
  67. }
  68.  
  69. public void falseCheck()
  70. {
  71. StartCoroutine(pause());
  72. }
  73.  
  74. IEnumerator pause()
  75. {
  76. yield return new WaitForSeconds(1);
  77. if (_state == 0)
  78. GetComponent<Image>().sprite = _cardBack;
  79. else if (_state == 1)
  80. GetComponent<Image>().sprite = _cardFace;
  81. DO_NOT = false;
  82. }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement