GameUtil.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. namespace ET
  4. {
  5. public enum ActInfoType
  6. {
  7. LightPole = 1,//明
  8. BackPole = 2,//回
  9. DarkPole = 3,//暗
  10. Peng = 4,//碰
  11. Chi = 5//吃
  12. }
  13. public class GameUtil : Singleton<GameUtil>
  14. {
  15. private Scene scene;
  16. private List<GameObject> cardCloneItem = new List<GameObject>() { null,null};
  17. public void SetSceneComponent(Scene scene)
  18. {
  19. this.scene = scene;
  20. }
  21. public Scene GetSceneComponent()
  22. {
  23. return this.scene;
  24. }
  25. public void SetCardCloneItem(GameObject item,int index)
  26. {
  27. this.cardCloneItem[index] = item;
  28. }
  29. public GameObject GetCardCloneItem(int index)
  30. {
  31. return this.cardCloneItem[index];
  32. }
  33. public bool CheckIsSequence(List<int> cards)
  34. {
  35. if (cards == null || cards.Count < 3)
  36. {
  37. return false;
  38. }
  39. cards.Sort();
  40. int first = cards[0];
  41. for (int i = 1;i < cards.Count;i++)
  42. {
  43. if (first + 1 != cards[i])
  44. {
  45. return false;
  46. }
  47. first = cards[i];
  48. }
  49. return true;
  50. }
  51. //type == 0 碰
  52. //type == 1 gang
  53. public bool CheckIsSame(List<int> cards,int type)
  54. {
  55. int count = type == 0? 3 : 4;
  56. if (cards == null || cards.Count < count)
  57. {
  58. return false;
  59. }
  60. cards.Sort();
  61. int first = cards[0];
  62. for (int i = 1; i < cards.Count; i++)
  63. {
  64. if (first != cards[i])
  65. {
  66. return false;
  67. }
  68. }
  69. return true;
  70. }
  71. public GameObject InitializeObj(GameObject obj)
  72. {
  73. return UnityEngine.Object.Instantiate(obj);
  74. }
  75. }
  76. }