GameUtil.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 Vector2 otherHandCardSize = new Vector2(80,59);
  23. public Vector2 otherLeftCardSize = new Vector2(70,49);
  24. public void SetSceneComponent(Scene scene)
  25. {
  26. this.scene = scene;
  27. }
  28. public Scene GetSceneComponent()
  29. {
  30. return this.scene;
  31. }
  32. public void SetCardCloneItem(GameObject item,int index)
  33. {
  34. this.cardCloneItem[index] = item;
  35. }
  36. public GameObject GetCardCloneItem(int index)
  37. {
  38. return this.cardCloneItem[index];
  39. }
  40. public bool CheckIsSequence(List<int> cards)
  41. {
  42. if (cards == null || cards.Count < 3)
  43. {
  44. return false;
  45. }
  46. cards.Sort();
  47. int first = cards[0];
  48. for (int i = 1;i < cards.Count;i++)
  49. {
  50. if (first + 1 != cards[i])
  51. {
  52. return false;
  53. }
  54. first = cards[i];
  55. }
  56. return true;
  57. }
  58. //type == 0 碰
  59. //type == 1 gang
  60. public bool CheckIsSame(List<int> cards,int type)
  61. {
  62. int count = type == 0? 3 : 4;
  63. if (cards == null || cards.Count < count)
  64. {
  65. return false;
  66. }
  67. cards.Sort();
  68. int first = cards[0];
  69. for (int i = 1; i < cards.Count; i++)
  70. {
  71. if (first != cards[i])
  72. {
  73. return false;
  74. }
  75. }
  76. return true;
  77. }
  78. public GameObject InitializeObj(GameObject obj)
  79. {
  80. return UnityEngine.Object.Instantiate(obj);
  81. }
  82. }
  83. }