Roxaq

ConjurationData

Nov 10th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. using UnityEngine;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5.  
  6. public class ConjurationData : MonoBehaviour
  7. {
  8.  
  9. public static ConjurationData Instance;
  10.  
  11. //Indentificadores de cartas
  12. private int CardNumber;
  13. private WarriorObject[] WarriorDeck = new WarriorObject[5];
  14. private int cardIndex;
  15. private int currentCardId;
  16.  
  17. //Variaveis dos jogadores
  18. private int _PlayerHealth;
  19. private int _PlayerCardCount;
  20.  
  21. private int _EnemyHealth;
  22.  
  23. //Variaveis de jogo
  24. private int maxCards;
  25. private float gameTime;
  26. private float conjurationTime;
  27. private bool hasGoneToBattle;
  28.  
  29.  
  30.  
  31. //Garante persistencia entre as cenas
  32. void Awake()
  33. {
  34. if (Instance == null)
  35. {
  36. DontDestroyOnLoad(gameObject);
  37. Instance = this;
  38. }
  39. else if (Instance != this)
  40. {
  41. Destroy(gameObject);
  42. }
  43. }
  44.  
  45. //Função de parametros da partida
  46. public void SetGameParameters(int nCards, int pLife, int gTime, int cTime)
  47. {
  48. maxCards = nCards;
  49. _PlayerHealth = pLife;
  50. _EnemyHealth = pLife;
  51. gameTime = gTime;
  52. conjurationTime = cTime;
  53. //Reseta o resto
  54. CardNumber = 0;
  55. Array.Clear(WarriorDeck, 0, 5);
  56. cardIndex = 0;
  57. currentCardId = 0;
  58. }
  59.  
  60. public void ResetCardNumber()
  61. {
  62. CardNumber = 0;
  63. }
  64.  
  65. public void SetHasGoneToBattle()
  66. {
  67. hasGoneToBattle = true;
  68. }
  69.  
  70. public bool GetHasGoneToBattle()
  71. {
  72. return hasGoneToBattle;
  73. }
  74.  
  75. ///Funções para acesso via mesa de conjuração
  76.  
  77. public float GetConjurationTime()
  78. {
  79. return conjurationTime;
  80. }
  81.  
  82. public int GetMaxCards()
  83. {
  84. return maxCards;
  85. }
  86.  
  87. //Adciona carta no inventario (mesa de conjuração)
  88. public void AddCard(WarriorCard newCard, int inventoryIndex)
  89. {
  90. CardNumber++;
  91. WarriorDeck[inventoryIndex] = new WarriorObject(newCard.GetCardId(), newCard.GetCardPod(), newCard.GetCardCon(), newCard.GetCardMaxCon(), inventoryIndex);
  92. }
  93.  
  94. public void ResetCardsDeck()
  95. {
  96. Array.Clear(WarriorDeck, 0, WarriorDeck.Length);
  97. }
  98.  
  99. //atualiza as cartas depois que o combate é encerrado
  100. public void UpdateCard(BattleCard updCard, int inventoryIndex)
  101. {
  102. WarriorDeck[inventoryIndex] = new WarriorObject(updCard.GetId(), updCard.GetPod(), updCard.GetCon(), updCard.GetMaxCon(), inventoryIndex);
  103. }
  104.  
  105. //Recupera uma carta
  106. public WarriorObject GetWarriorCard(int index)
  107. {
  108. return WarriorDeck[index];
  109. }
  110.  
  111. //Retira uma carta (mesa de conjuração)
  112. public void RemoveCard(int inventoryIndex)
  113. {
  114. CardNumber--;
  115. WarriorDeck[inventoryIndex] = null;
  116. }
  117.  
  118.  
  119. public int GetCardNumber()
  120. {
  121. return CardNumber;
  122. }
  123.  
  124. //Debug Function
  125. public void GetCardsPrint()
  126. {
  127.  
  128. for (int i = 0; i < WarriorDeck.Length; i++)
  129. {
  130. if (WarriorDeck[i] == null)
  131. {
  132. print("carta " + i + ": Vazia");
  133. }
  134. else
  135. {
  136. print("Carta " + i + ": " + WarriorDeck[i].GetCardID());
  137. }
  138. }
  139. }
  140.  
  141. //Funções de controle do jogador na mesa de batalha
  142. public void ReduceHealth()
  143. {
  144. if (_PlayerHealth == 0)
  145. {
  146. _PlayerHealth = 0;
  147. }
  148. else
  149. {
  150. _PlayerHealth--;
  151. }
  152. }
  153.  
  154. public void ReduceEnemyHealth()
  155. {
  156. if (_EnemyHealth == 0)
  157. {
  158. _EnemyHealth = 0;
  159. }
  160. else
  161. {
  162. _EnemyHealth--;
  163. }
  164. }
  165.  
  166. public int GetHealth()
  167. {
  168. return _PlayerHealth;
  169. }
  170.  
  171. public int GetEnemyHealth()
  172. {
  173. return _EnemyHealth;
  174. }
  175.  
  176. //Atualização das cartas do deck
  177. public void KillCard(int CardIndex)
  178. {
  179. CardNumber--;
  180. WarriorDeck[CardIndex] = null;
  181. }
  182.  
  183. //Variaveis para mesa de batalha
  184. public float GetGameTime()
  185. {
  186. return gameTime;
  187. }
  188. }
Advertisement
Add Comment
Please, Sign In to add comment