ChipManager.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. public class ChipManager : MonoBehaviour
  6. {
  7. public static ChipManager Instance { get; private set; }
  8. public float ChipSetSpace
  9. {
  10. get
  11. {
  12. return this.m_ChipSetSpace;
  13. }
  14. }
  15. public Vector3 ChipStackSpace
  16. {
  17. get
  18. {
  19. return this.m_ChipStackSpace;
  20. }
  21. }
  22. public float FallingLength
  23. {
  24. get
  25. {
  26. return this.m_FallingLength;
  27. }
  28. }
  29. public float FallingTime
  30. {
  31. get
  32. {
  33. return this.m_FallingTime;
  34. }
  35. }
  36. public int StackCount
  37. {
  38. get
  39. {
  40. return this.m_StackCount;
  41. }
  42. }
  43. public float TimeOffset
  44. {
  45. get
  46. {
  47. return this.m_TimeOffset;
  48. }
  49. }
  50. public List<ChipManager.Chip> ChipList
  51. {
  52. get
  53. {
  54. return this.m_ChipDataList;
  55. }
  56. }
  57. public ChipStack[] ChipStacks
  58. {
  59. get
  60. {
  61. return this.m_ChipStack;
  62. }
  63. }
  64. private void Awake()
  65. {
  66. ChipManager.Instance = this;
  67. this.m_ChipDataList = (from chip in this.ChipList
  68. orderby chip.value descending
  69. select chip).ToList<ChipManager.Chip>();
  70. foreach (ChipManager.Chip chip2 in this.m_ChipDataList)
  71. {
  72. chip2.chip_obj = Resources.Load<GameObject>(BlackjackGame.BlackJackResource("Prefab/Coin/" + chip2.chipname));
  73. }
  74. }
  75. private void StackCall()
  76. {
  77. if (this.StackEndCallBack != null)
  78. {
  79. this.StackEndCallBack();
  80. }
  81. this.StackEndCallBack = null;
  82. }
  83. public void StackEndAction()
  84. {
  85. if (this.m_ChipStack.Any((ChipStack chip) => !chip.ChipUpdateEnd))
  86. {
  87. return;
  88. }
  89. base.Invoke("StackCall", this.m_StackEndPause);
  90. }
  91. public void ClearBet()
  92. {
  93. BjPlayer.Instance.ClearBet();
  94. this.ResetStacks();
  95. }
  96. public void UpdateStacks()
  97. {
  98. foreach (ChipStack chipStack in this.ChipStacks)
  99. {
  100. chipStack.UpdateChips();
  101. }
  102. this.StackEndAction();
  103. }
  104. public void HardReset()
  105. {
  106. foreach (ChipStack chipStack in this.ChipStacks)
  107. {
  108. chipStack.IsWinningStack = false;
  109. }
  110. }
  111. public void ResetStacks()
  112. {
  113. foreach (ChipStack chipStack in this.ChipStacks)
  114. {
  115. chipStack.ResetChips();
  116. }
  117. }
  118. [SerializeField]
  119. private float m_StackEndPause = 0.5f;
  120. [SerializeField]
  121. [Header("チップの設置間隔(アニメーション開始時)")]
  122. private float m_ChipSetSpace = 0.5f;
  123. [SerializeField]
  124. [Header("チップの設置間隔(通常時)")]
  125. private Vector3 m_ChipStackSpace = Vector3.zero;
  126. [SerializeField]
  127. [Header("チップは最低この高さから落とす")]
  128. private float m_FallingLength = 2.75f;
  129. [SerializeField]
  130. [Header("チップのアニメーション所要時間")]
  131. private float m_FallingTime = 0.7f;
  132. [SerializeField]
  133. [Header("チップのアニメーションラグ時間")]
  134. private float m_TimeOffset = 0.05f;
  135. [SerializeField]
  136. [Header("この枚数毎にスタック")]
  137. private int m_StackCount = 10;
  138. [SerializeField]
  139. private List<ChipManager.Chip> m_ChipDataList = new List<ChipManager.Chip>();
  140. public Action StackEndCallBack;
  141. [SerializeField]
  142. [Header("チップを載せておく場所")]
  143. private ChipStack[] m_ChipStack = new ChipStack[4];
  144. [Serializable]
  145. public class Chip
  146. {
  147. public int value;
  148. public string chipname;
  149. [HideInInspector]
  150. public GameObject chip_obj;
  151. }
  152. }