Exemplo n.º 1
0
        protected virtual void SetZhuaGang(CpgData data)
        {
            for (int i = 0; i < CpgList.Count; i++)
            {
                MahjongCpg cpgPeng    = CpgList[i];
                int        arrowIndex = cpgPeng.ArrowCrossIndex;
                if (cpgPeng.Data.Type == EnGroupType.Peng && cpgPeng.Data.Card == data.Card)
                {
                    //保存碰的位子
                    Vector3 pengPos = cpgPeng.transform.localPosition;
                    cpgPeng.Delete();

                    MahjongCpg cpgZhuaGang = CpgMahjongCreater.CreateCpg(data, cpgPeng.AcrossIndex, arrowIndex);

                    cpgZhuaGang.transform.parent        = transform;
                    cpgZhuaGang.transform.localPosition = pengPos;
                    cpgZhuaGang.transform.localRotation = Quaternion.Euler(Vector3.zero);

                    CpgList[i] = cpgZhuaGang;

                    ////保存到本地
                    //CpgLocalSave.Instance.ChangeToZhuaGangType(Chair, data.Card);
                    break;
                }
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public virtual CpgData CreateCpg(ISFSObject data)
        {
            CpgData     ret  = null;
            EnGroupType type = EnGroupType.None;

            if (data.ContainsKey(RequestKeyOther.KeyTType))
            {
                type = (EnGroupType)(data.GetInt(RequestKeyOther.KeyTType));
            }
            else if (data.ContainsKey(RequestKey.KeyType))
            {
                type = (EnGroupType)(data.GetInt(RequestKey.KeyType));
            }

            switch (type)
            {
            case EnGroupType.Chi:
                ret = new CpgChi();
                break;

            case EnGroupType.Peng:
                ret = new CpgPeng();
                break;

            case EnGroupType.ZhuaGang:
                ret = new CpgZhuaGang();
                break;

            case EnGroupType.MingGang:
            case EnGroupType.AnGang:
                if (data.ContainsKey(RequestKeyOther.CardBao))
                {
                    ret = new CpgSelfGangBao();
                }
                else
                {
                    ret = new CpgSelfGang();
                }
                break;

            case EnGroupType.PengGang:
                ret = new CpgOtherGang();
                break;

            case EnGroupType.XFGang:
                ret = new CpgXFGang();
                break;

            case EnGroupType.YaoDan:
            case EnGroupType.JiuDan:
            case EnGroupType.ZFBDan:
            case EnGroupType.XFDan:
                ret = new CpgXfdGang();
                break;
            }

            ret.ParseData(data);
            return(ret);
        }
Exemplo n.º 4
0
        protected virtual void AddCpg(CpgData data, int index = UtilDef.DefInt)
        {
            MahjongCpg cpg = CpgMahjongCreater.CreateCpg(data, index);

            CpgList.Add(cpg);
            cpg.transform.parent        = transform;
            cpg.transform.localPosition = Vector3.zero;
            cpg.transform.localRotation = Quaternion.Euler(Vector3.zero);
        }
Exemplo n.º 5
0
        public static MahjongCpg CreateCpg(CpgData data, int index = UtilDef.DefInt, int arrowIndex = -1)
        {
            var createrFunc = GameObject.Find("GameData").GetComponent <CpgMjCreateFunc>();

            if (createrFunc != null)
            {
                return(createrFunc.CreateCpg(data, index, arrowIndex));
            }

            return(null);
        }
Exemplo n.º 6
0
        public int GetCpgIndex(int chair, CpgData data)
        {
            foreach (CpgSaveData cpgSaveData in _saveList[chair])
            {
                if (cpgSaveData.type == data.Type && CompareValue(cpgSaveData.value, data.AllCards().ToArray()))
                {
                    return(cpgSaveData.index);
                }
            }

            return(UtilDef.DefInt);
        }
Exemplo n.º 7
0
 public void SetCpg(CpgData data)
 {
     data.Chair = Chair;
     if (data.Type == EnGroupType.ZhuaGang)
     {
         SetZhuaGang(data);
     }
     else
     {
         AddCpg(data);
         SortGpg();
         ////保存到本地
         //MahjongCpg cpg = CpgList[CpgList.Count - 1];
         //CpgLocalSave.Instance.SaveCpg(Chair, new CpgSaveData(cpg.Data, cpg.AcrossIndex));
     }
 }
Exemplo n.º 8
0
        //创建之后的初始化
        public virtual void Init(CpgData data, int index, int arrowindex = UtilDef.NullArrowIndex)
        {
            _arrowCrossIndex = arrowindex;

            Data        = data;
            AcrossIndex = index;
            //加入麻将
            AddMahjong();
            //校验横着的位子
            if (GameConfig.IsCpgHeng && index == UtilDef.DefInt)
            {
                GetAcrossIndex();
            }
            //SortMahjong();

            //检查指示箭头和赖子杠头标志
            CheckSignAndArrow();
            SortMahjong();
        }
Exemplo n.º 9
0
 public CpgSaveData(CpgData data, int index)
 {
     type       = data.Type;
     value      = data.AllCards().ToArray();
     this.index = index;
 }
Exemplo n.º 10
0
 public override void Init(CpgData data, int index, int arrowindex = UtilDef.NullArrowIndex)
 {
     data.FromSeat = data.Seat;        ///暗杠特殊处理(隐藏角标显示处理)
     base.Init(data, index, arrowindex);
 }