BrainStormObject.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using System;
  6. using System.Linq;
  7. public class BrainStormObject : MonoBehaviour
  8. {
  9. [Header("ƒvƒŒƒCƒ„�[")]
  10. public Player player;
  11. [Header("HandCards")]
  12. public List<HandCard> BrainStormHandCards = new List<HandCard>();
  13. public IEnumerator Init()
  14. {
  15. this.gameObject.SetActive(true);
  16. foreach (HandCard handCard in BrainStormHandCards)
  17. {
  18. handCard.gameObject.SetActive(true);
  19. handCard.transform.parent.gameObject.SetActive(true);
  20. }
  21. yield return new WaitForSeconds(Time.deltaTime);
  22. foreach (HandCard handCard in BrainStormHandCards)
  23. {
  24. handCard.gameObject.SetActive(false);
  25. handCard.gameObject.name = $"BrainStormObject_{player.PlayerName}";
  26. }
  27. }
  28. public IEnumerator BrainStormCoroutine(CardSource cardSource)
  29. {
  30. int count = -1;
  31. foreach (HandCard handCard in BrainStormHandCards)
  32. {
  33. if (handCard.gameObject.activeSelf)
  34. {
  35. count = BrainStormHandCards.IndexOf(handCard);
  36. if (handCard.cardSource == cardSource)
  37. {
  38. yield break;
  39. }
  40. }
  41. }
  42. if (-1 <= count && count <= BrainStormHandCards.Count - 2)
  43. {
  44. HandCard handCard = BrainStormHandCards[count + 1];
  45. handCard.gameObject.SetActive(true);
  46. handCard.SetUpHandCard(cardSource);
  47. handCard.SetUpHandCardImage();
  48. handCard.Outline_Select.gameObject.SetActive(true);
  49. handCard.SetOrangeOutline();
  50. handCard.SkillNameText.transform.parent.gameObject.SetActive(false);
  51. handCard.IsExecuting = false;
  52. }
  53. yield return null;
  54. }
  55. public void EndBrainStorm()
  56. {
  57. foreach (HandCard handCard in BrainStormHandCards)
  58. {
  59. handCard.gameObject.SetActive(false);
  60. }
  61. }
  62. public IEnumerator CloseBrainstrorm(CardSource cardSource)
  63. {
  64. foreach (HandCard handCard in BrainStormHandCards)
  65. {
  66. if (handCard.gameObject.activeSelf && handCard.cardSource == cardSource)
  67. {
  68. handCard.gameObject.SetActive(false);
  69. }
  70. }
  71. yield return null;
  72. }
  73. int _timerCount = 0;
  74. int _updateFrame = 20;
  75. private void Update()
  76. {
  77. #region Update only once every few frames
  78. _timerCount++;
  79. if (_timerCount < _updateFrame)
  80. {
  81. return;
  82. }
  83. else
  84. {
  85. _timerCount = 0;
  86. }
  87. #endregion
  88. RotationCards();
  89. }
  90. void RotationCards()
  91. {
  92. if (!player.isYou)
  93. {
  94. if (ContinuousController.instance != null)
  95. {
  96. Quaternion localRotation = Quaternion.Euler(0, 0, 0);
  97. if (ContinuousController.instance.reverseOpponentsCards)
  98. {
  99. localRotation = Quaternion.Euler(0, 0, 180);
  100. }
  101. foreach (HandCard handCard in BrainStormHandCards)
  102. {
  103. handCard.transform.localRotation = localRotation;
  104. }
  105. }
  106. }
  107. }
  108. }