GameUtil.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System.Collections.Generic;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace ET
  5. {
  6. public enum ActInfoType
  7. {
  8. LightPole = 1,//明
  9. BackPole = 2,//回 //
  10. DarkPole = 3,//暗 // 手上3 外面1
  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 int curRequestCardVal = -1;
  19. public int curCardVal = -1;
  20. public Vector2 myHandCardSize = new Vector2(89,135);
  21. public Vector2 myShowCard = new Vector2(69,90);
  22. public void SetSceneComponent(Scene scene)
  23. {
  24. this.scene = scene;
  25. }
  26. public Scene GetSceneComponent()
  27. {
  28. return this.scene;
  29. }
  30. public void SetCardCloneItem(GameObject item,int index)
  31. {
  32. this.cardCloneItem[index] = item;
  33. }
  34. public GameObject GetCardCloneItem(int index)
  35. {
  36. return this.cardCloneItem[index];
  37. }
  38. public bool CheckIsSequence(List<int> cards)
  39. {
  40. if (cards == null || cards.Count < 3)
  41. {
  42. return false;
  43. }
  44. cards.Sort();
  45. int first = cards[0];
  46. for (int i = 1;i < cards.Count;i++)
  47. {
  48. if (first + 1 != cards[i])
  49. {
  50. return false;
  51. }
  52. first = cards[i];
  53. }
  54. return true;
  55. }
  56. //type == 0 碰
  57. //type == 1 gang
  58. public bool CheckIsSame(List<int> cards,int type)
  59. {
  60. int count = type == 0? 3 : 4;
  61. if (cards == null || cards.Count < count)
  62. {
  63. return false;
  64. }
  65. cards.Sort();
  66. int first = cards[0];
  67. for (int i = 1; i < cards.Count; i++)
  68. {
  69. if (first != cards[i])
  70. {
  71. return false;
  72. }
  73. }
  74. return true;
  75. }
  76. public GameObject InitializeObj(GameObject obj)
  77. {
  78. return UnityEngine.Object.Instantiate(obj);
  79. }
  80. }
  81. }