Advertisement
NomadicWarrior

Card script which is sprite

Mar 5th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Networking;
  5.  
  6. public class CardScript : NetworkBehaviour
  7. {
  8. public GameObject center;
  9. public Game _game;
  10.  
  11. public GameObject _singleton;
  12. public Singleton _singletonScript;
  13.  
  14. public GameObject[] Players;
  15. public GameObject Player;
  16. public Player _player;
  17.  
  18. private SpriteRenderer spriteColor;
  19.  
  20. public int C;
  21. public string cardName;
  22. public int cardScore;
  23. public int cardRank;
  24. public string cardSuit;
  25. public string turn;
  26.  
  27. public bool isPossible;
  28. public bool spawnedCard;
  29. public bool deletedCard;
  30. public bool cat;
  31. public int whichCard;
  32.  
  33. void Start ()
  34. {
  35. isPossible = false;
  36. deletedCard = false;
  37. cat = false;
  38. whichCard = 5;
  39.  
  40. _game = GameObject.Find("Game").GetComponent<Game>();
  41.  
  42. _singleton = GameObject.Find("SINGLETON");
  43. _singletonScript = _singleton.GetComponent<Singleton>();
  44.  
  45. spriteColor = gameObject.GetComponent<SpriteRenderer>();
  46.  
  47. turn = "First";
  48.  
  49. if (Players != null)
  50. {
  51. Players = GameObject.FindGameObjectsWithTag("Player");
  52. }
  53.  
  54. }
  55.  
  56. void Update ()
  57. {
  58. if (Players != null)
  59. {
  60. Players = GameObject.FindGameObjectsWithTag("Player");
  61. }
  62.  
  63. if (gameObject.name == "1(Clone)" || gameObject.name == "5(Clone)" || gameObject.name == "9(Clone)" || gameObject.name == "13(Clone)" || gameObject.name == "21(Clone)" || gameObject.name == "25(Clone)" || gameObject.name == "29(Clone)")
  64. {
  65. if (_singletonScript.RoundTrump == "Clubs")
  66. {
  67. cardSuit = "Trump";
  68. }
  69. else
  70. {
  71. cardSuit = "Clubs";
  72. }
  73. }
  74. else if (gameObject.name == "4(Clone)" || gameObject.name == "8(Clone)" || gameObject.name == "12(Clone)" || gameObject.name == "16(Clone)" || gameObject.name == "24(Clone)" || gameObject.name == "28(Clone)" || gameObject.name == "32(Clone)")
  75. {
  76. if (_singletonScript.RoundTrump == "Spades")
  77. {
  78. cardSuit = "Trump";
  79. }
  80. else
  81. {
  82. cardSuit = "Spades";
  83. }
  84. }
  85. else if (gameObject.name == "3(Clone)" || gameObject.name == "7(Clone)" || gameObject.name == "11(Clone)" || gameObject.name == "15(Clone)" || gameObject.name == "23(Clone)" || gameObject.name == "27(Clone)" || gameObject.name == "31(Clone)")
  86. {
  87. if (_singletonScript.RoundTrump == "Hearts")
  88. {
  89. cardSuit = "Trump";
  90. }
  91. else
  92. {
  93. cardSuit = "Hearts";
  94. }
  95. }
  96. else if (gameObject.name == "2(Clone)" || gameObject.name == "6(Clone)" || gameObject.name == "10(Clone)" || gameObject.name == "14(Clone)" || gameObject.name == "22(Clone)" || gameObject.name == "26(Clone)" || gameObject.name == "30(Clone)")
  97. {
  98. if (_singletonScript.RoundTrump == "Diamonds")
  99. {
  100. cardSuit = "Trump";
  101. }
  102. else
  103. {
  104. cardSuit = "Diamonds";
  105. }
  106. }
  107. else if (gameObject.name == "17(Clone)" || gameObject.name == "18(Clone)" || gameObject.name == "19(Clone)" || gameObject.name == "20(Clone)")
  108. {
  109. cardSuit = "Trump";
  110. }
  111.  
  112. if (_singletonScript.Turn != "First" && _singletonScript.playerMass[0] == _singletonScript._yourName)
  113. {
  114. whichCard = 0;
  115. }
  116. else if (_singletonScript.Turn != "Second" && _singletonScript.playerMass[1] == _singletonScript._yourName)
  117. {
  118. whichCard = 0;
  119. }
  120. else if (_singletonScript.Turn != "Third" && _singletonScript.playerMass[2] == _singletonScript._yourName)
  121. {
  122. whichCard = 0;
  123. }
  124. else if (_singletonScript.Turn != "Fourth" && _singletonScript.playerMass[3] == _singletonScript._yourName)
  125. {
  126. whichCard = 0;
  127. }
  128. else if (spawnedCard == true)
  129. {
  130. whichCard = 0;
  131. }
  132. else if (deletedCard == true)
  133. {
  134. whichCard = 0;
  135. }
  136. else if (_singletonScript.playerMass[0] == _singletonScript._yourName && _singletonScript.Turn == "First" && deletedCard != true && spawnedCard != true)
  137. {
  138. whichCard = 1;
  139. }
  140. else if (_singletonScript.FirstCardSuit == cardSuit && cardSuit != "Trump")
  141. {
  142. whichCard = 1;
  143. }
  144. else
  145. {
  146. whichCard = 3;
  147. }
  148.  
  149. if (whichCard == 0)
  150. {
  151. isPossible = false;
  152. }
  153. if (isPossible)
  154. {
  155. spriteColor.color = new Color(1f, 1f, 1f, 1f);
  156. }
  157. else if (!isPossible && spawnedCard == false)
  158. {
  159. spriteColor.color = new Color(0.3f, 0.3f, 0.3f, 1f);
  160. }
  161. }
  162.  
  163. public int playerNumber;
  164.  
  165. private void OnMouseDown()
  166. {
  167. if (isPossible)
  168. {
  169. if (_singletonScript.playerMass[0] == _singletonScript._yourName && _singletonScript.Turn == "First")
  170. {
  171. playerNumber = 1;
  172. Player.GetComponent<Player>().isCardTouched = true;
  173. Player.GetComponent<Player>().centerCardName = cardName;
  174. Player.GetComponent<Player>().stopper = 1;
  175. Player.GetComponent<Player>().num = 1;
  176. deletedCard = true;
  177. gameObject.transform.position = new Vector3(-100, 0, 0);
  178. }
  179.  
  180. if (_singletonScript.playerMass[1] == _singletonScript._yourName && _singletonScript.Turn == "Second")
  181. {
  182. Player.GetComponent<Player>().isCardTouched = true;
  183. Player.GetComponent<Player>().centerCardName = cardName;
  184. Player.GetComponent<Player>().stopper = 1;
  185. Player.GetComponent<Player>().num = 2;
  186. deletedCard = true;
  187. gameObject.transform.position = new Vector3(-100, 0, 0);
  188. }
  189.  
  190. if (_singletonScript.playerMass[2] == _singletonScript._yourName && _singletonScript.Turn == "Third")
  191. {
  192. Player.GetComponent<Player>().isCardTouched = true;
  193. Player.GetComponent<Player>().centerCardName = cardName;
  194. Player.GetComponent<Player>().stopper = 1;
  195. Player.GetComponent<Player>().num = 3;
  196. deletedCard = true;
  197. gameObject.transform.position = new Vector3(-100, 0, 0);
  198. }
  199.  
  200. if (_singletonScript.playerMass[3] == _singletonScript._yourName && _singletonScript.Turn == "Fourth")
  201. {
  202. Player.GetComponent<Player>().isCardTouched = true;
  203. Player.GetComponent<Player>().centerCardName = cardName;
  204. Player.GetComponent<Player>().stopper = 1;
  205. Player.GetComponent<Player>().num = 4;
  206. deletedCard = true;
  207. gameObject.transform.position = new Vector3(-100, 0, 0);
  208. }
  209. }
  210. }
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement