GameUtil.cs 2.1 KB

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