Пример #1
0
        //统一创建接口 cpgData 数据 index 为横着的index 为重连时读取本地留的位子
        public virtual MahjongCpg CreateCpg(CpgData data, int index = UtilDef.DefInt, int arrowindex = UtilDef.NullArrowIndex)
        {
            GameObject cpg = new GameObject();
            MahjongCpg ret = null;

            switch (data.Type)
            {
            case EnGroupType.Chi:
                ret = cpg.AddComponent <MahjongCpgChi>();
                break;

            case EnGroupType.Peng:
            case EnGroupType.PengGang:
                ret = cpg.AddComponent <MahjongCpg>();
                break;

            case EnGroupType.ZhuaGang:
                ret = cpg.AddComponent <MahjongCpgZhuaGang>();
                break;

            case EnGroupType.MingGang:
            case EnGroupType.AnGang:
                ret = cpg.AddComponent <MahjongCpgAngang>();
                break;

            case EnGroupType.XFGang:
                ret = cpg.AddComponent <MahjongCpgSelfGang>();
                break;
            }

            ret.Init(data, index, arrowindex);
            return(ret);
        }
Пример #2
0
        protected virtual void AddCpg(CpgData data, int index = MiscUtility.DefInt)
        {
            if (null == data)
            {
                return;
            }
            var fromInt = data.GetFromChair();

            index = fromInt == -1 ? index : fromInt;
            MahjongCpg cpg = MahjongUtility.CreateCpg(data, index);

            CpgList.Add(cpg);
            cpg.transform.ExSetParent(transform);
        }
Пример #3
0
        public static MahjongCpg CreateCpg(CpgData data, int index = MiscUtility.DefInt)
        {
            GameObject cpg = new GameObject();
            MahjongCpg ret = null;

            switch (data.Type)
            {
            case EnGroupType.Chi:
                ret = cpg.AddComponent <MahjongCpgChi>();
                break;

            case EnGroupType.JueGang:
            case EnGroupType.Peng:
            case EnGroupType.PengGang:
                ret = cpg.AddComponent <MahjongCpg>();
                break;

            case EnGroupType.ZhuaGang:
                ret = cpg.AddComponent <MahjongCpgZhuaGang>();
                break;

            case EnGroupType.MingGang:
            case EnGroupType.AnGang:
                ret = cpg.AddComponent <MahjongCpgAngang>();
                break;

            case EnGroupType.XFGang:
                ret = cpg.AddComponent <MahjongCpgXFGang>();
                break;

            case EnGroupType.YaoDan:
            case EnGroupType.JiuDan:
            case EnGroupType.ZFBDan:
            case EnGroupType.XFDan:
                ret = cpg.AddComponent <MahjongCpgXjfdGang>();
                break;

            case EnGroupType.AnJueGang:
                ret = cpg.AddComponent <MahjongCpgAnJuegang>();
                break;
            }
            ret.Init(data, index);
            return(ret);
        }
Пример #4
0
 protected virtual void SetZhuaGang(CpgData data)
 {
     if (null == data)
     {
         return;
     }
     for (int i = 0; i < CpgList.Count; i++)
     {
         MahjongCpg cpgPeng = CpgList[i];
         if (cpgPeng.Data.Type == EnGroupType.Peng && cpgPeng.Data.Card == data.Card)
         {
             //保存碰的位子
             Vector3 pengPos = cpgPeng.transform.localPosition;
             cpgPeng.OnReset();
             MahjongCpg cpgZhuaGang = MahjongUtility.CreateCpg(data, cpgPeng.AcrossIndex);
             cpgZhuaGang.transform.SetParent(transform);
             cpgZhuaGang.transform.localScale    = Vector3.one;
             cpgZhuaGang.transform.localPosition = pengPos;
             cpgZhuaGang.transform.localRotation = Quaternion.Euler(Vector3.zero);
             CpgList[i] = cpgZhuaGang;
             break;
         }
     }
 }