Roxaq

InventoryCardPlace

Nov 10th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class InventoryCardPlace : MonoBehaviour
  5. {
  6.  
  7. public int InventoryPlaceIndex;
  8. public GameObject thisCard;
  9. private GameObject DATAHOLDER;
  10. private ConjurationTable _ConjurationTableLink;
  11.  
  12.  
  13. private bool hasCard;
  14.  
  15. void Awake()
  16. {
  17. _ConjurationTableLink = GameObject.FindWithTag("TableMaster").GetComponent<ConjurationTable>();
  18. DATAHOLDER = GameObject.Find("DataHolder");
  19. }
  20.  
  21. void Update()
  22. {
  23. if (!_ConjurationTableLink.CanDeployBattleCard() && !hasCard)
  24. {
  25. gameObject.GetComponent<BoxCollider>().enabled = false;
  26. }
  27. else
  28. {
  29. gameObject.GetComponent<BoxCollider>().enabled = true;
  30. }
  31. }
  32.  
  33. //Receber cartas no inventario da mesa de batalha
  34. public void ReceiveCard(GameObject card)
  35. {
  36. thisCard = card;
  37. //print("Received Card: Con: " + card.GetComponent<WarriorCard>().GetCardCon());
  38. _ConjurationTableLink.AddInventoryCard();
  39. DATAHOLDER.GetComponent<ConjurationData>().AddCard(card.GetComponent<WarriorCard>(), InventoryPlaceIndex);
  40.  
  41. hasCard = true;
  42. }
  43.  
  44. public void SetHasCard()
  45. {
  46. hasCard = true;
  47. }
  48.  
  49. //Remove cartas do inventario da mesa de batalha
  50. public void RemoveCard()
  51. {
  52. _ConjurationTableLink.RemoveInventoryCard();
  53. thisCard = null;
  54. DATAHOLDER.GetComponent<ConjurationData>().RemoveCard(InventoryPlaceIndex);
  55. hasCard = false;
  56. }
  57.  
  58. public GameObject ReturnCard()
  59. {
  60. return thisCard;
  61. }
  62.  
  63. public bool CanDropHere()
  64. {
  65. if (hasCard)
  66. {
  67. return false;
  68. }
  69. else
  70. {
  71. return true;
  72. }
  73. }
  74.  
  75. public Vector3 GetPosition()
  76. {
  77. return transform.position;
  78. }
  79. }
Add Comment
Please, Sign In to add comment