using System.Collections.Generic;
using UnityEngine;

namespace ET
{
    public enum ActInfoType
    {
        LightPole = 1,//明
        BackPole = 2,//回
        DarkPole = 3,//暗
        Peng = 4,//碰
        Chi = 5//吃
    }

    public class GameUtil : Singleton<GameUtil>
    {
        private Scene scene;
        private List<GameObject> cardCloneItem = new List<GameObject>() { null,null};

        public void SetSceneComponent(Scene scene)
        {
            this.scene = scene;
        }

        public Scene GetSceneComponent()
        {
            return this.scene;
        }

        public void SetCardCloneItem(GameObject item,int index)
        {
            this.cardCloneItem[index] = item;
        }

        public GameObject GetCardCloneItem(int index)
        {
            return this.cardCloneItem[index];
        }

        public bool CheckIsSequence(List<int> cards)
        {
            if (cards == null || cards.Count < 3)
            {
                return false;
            }
            cards.Sort();
            int first = cards[0];
            for (int i = 1;i < cards.Count;i++)
            {
                if (first + 1 != cards[i])
                {
                    return false;
                }
                first = cards[i];
            }
            return true;
        }

        //type == 0 碰
        //type == 1 gang
        public bool CheckIsSame(List<int> cards,int type)
        {
            int count = type == 0? 3 : 4;
            if (cards == null || cards.Count < count)
            {
                return false;
            }
            cards.Sort();
            int first = cards[0];
            for (int i = 1; i < cards.Count; i++)
            {
                if (first != cards[i])
                {
                    return false;
                }
            }
            return true;
        }

        public GameObject InitializeObj(GameObject obj)
        {
            return UnityEngine.Object.Instantiate(obj);
        }

    }
}