예제 #1
0
    //check logic game
    public void RuleChecker(GameObject obj1, GameObject obj2)
    {
        JewelObj        Jewel1  = obj1.GetComponent <JewelObj>();
        JewelObj        Jewel2  = obj2.GetComponent <JewelObj>();
        List <JewelObj> NeiObj1 = Ulti.ListPlus(Jewel1.GetCollumn(Jewel2.jewel.JewelPosition, Jewel1.jewel.JewelType, null),
                                                Jewel1.GetRow(Jewel2.jewel.JewelPosition, Jewel1.jewel.JewelType, null), Jewel1);
        List <JewelObj> NeiObj2 = Ulti.ListPlus(Jewel2.GetCollumn(Jewel1.jewel.JewelPosition, Jewel2.jewel.JewelType, null),
                                                Jewel2.GetRow(Jewel1.jewel.JewelPosition, Jewel2.jewel.JewelType, null), Jewel2);



        if (Jewel1.jewel.JewelType == 99 || Jewel2.jewel.JewelType == 99)
        {
            if (Jewel1.jewel.JewelType == 8 || Jewel2.jewel.JewelType == 8)
            {
                Jewel1.SetBackAnimation(obj2);
                Jewel2.SetBackAnimation(obj1);
                return;
            }
        }

        if (NeiObj1.Count >= 3 || NeiObj2.Count >= 3 || Jewel1.jewel.JewelType == 8 || Jewel2.jewel.JewelType == 8)
        {
            Ulti.MoveTo(obj1, obj2.transform.localPosition, 0.2f);
            Ulti.MoveTo(obj2, obj1.transform.localPosition, 0.2f);
            SwapJewelPosition(obj1, obj2);
            JewelProcess(NeiObj1, NeiObj2, obj1, obj2);
        }
        else
        {
            Jewel1.SetBackAnimation(obj2);
            Jewel2.SetBackAnimation(obj1);
        }
    }
예제 #2
0
    //check logic game
    public void RuleChecker(GameObject obj1, GameObject obj2)
    {
        JewelObj        Jewel1  = obj1.GetComponent <JewelObj>();
        JewelObj        Jewel2  = obj2.GetComponent <JewelObj>();
        List <JewelObj> NeiObj1 = Ulti.ListPlus(Jewel1.GetCollumn(Jewel2.jewel.JewelPosition, Jewel1.jewel.JewelType, null),
                                                Jewel1.GetRow(Jewel2.jewel.JewelPosition, Jewel1.jewel.JewelType, null), Jewel1);
        List <JewelObj> NeiObj2 = Ulti.ListPlus(Jewel2.GetCollumn(Jewel1.jewel.JewelPosition, Jewel2.jewel.JewelType, null),
                                                Jewel2.GetRow(Jewel1.jewel.JewelPosition, Jewel2.jewel.JewelType, null), Jewel2);



        if (Jewel1.jewel.JewelType == 99 || Jewel2.jewel.JewelType == 99)
        {
            if (Jewel1.jewel.JewelType == 8 || Jewel2.jewel.JewelType == 8)
            {
                Jewel1.SetBackAnimation(obj2);
                Jewel2.SetBackAnimation(obj1);
                return;
            }
        }

        if (NeiObj1.Count >= 3 || NeiObj2.Count >= 3 || Jewel1.jewel.JewelType == 8 || Jewel2.jewel.JewelType == 8)
        {
            Ulti.MoveTo(obj1, obj2.transform.localPosition, 0.2f);
            Ulti.MoveTo(obj2, obj1.transform.localPosition, 0.2f);
            SwapJewelPosition(obj1, obj2);
            JewelProcess(NeiObj1, NeiObj2, obj1, obj2);
        }
        else
        {
            //判断是否使用强制交换
            if (isExChange)
            {
                Ulti.MoveTo(obj1, obj2.transform.localPosition, 0.2f);
                Ulti.MoveTo(obj2, obj1.transform.localPosition, 0.2f);
                SwapJewelPosition(obj1, obj2);

                isExChange = false;
                prop_bg.SetActive(false);
                JewelSpawner.spawn.transform.position = new Vector3(0, 0, 0);
                JewelSpawner.spawn.transform.SetAsLastSibling();
            }
            else
            {
                Jewel1.SetBackAnimation(obj2);
                Jewel2.SetBackAnimation(obj1);
            }
        }
    }
    //消除检查
    public void RuleChecker(GameObject obj1, GameObject obj2)
    {
        // 获取对象上的宝石对象脚本
        JewelObj Jewel1 = obj1.GetComponent <JewelObj>();
        JewelObj Jewel2 = obj2.GetComponent <JewelObj>();

        LogUtils.TraceNow("Pointer:" + Jewel1.jewel.JewelPosition.x + "," + Jewel1.jewel.JewelPosition.y);
        LogUtils.TraceNow("Selected:" + Jewel2.jewel.JewelPosition.x + "," + Jewel2.jewel.JewelPosition.y);

        // (以obj2为中心)将横向要消除的对象列表与纵向要消除的对象列表合并
        List <JewelObj> NeiObj1 = Ulti.ListPlus(
            Jewel1.GetCollumn(Jewel2.jewel.JewelPosition, Jewel1.jewel.JewelType, null),
            Jewel1.GetRow(Jewel2.jewel.JewelPosition, Jewel1.jewel.JewelType, null),
            Jewel1);
        // (以obj1为中心)将横向要消除的对象列表与纵向要消除的对象列表合并
        List <JewelObj> NeiObj2 = Ulti.ListPlus(Jewel2.GetCollumn(Jewel1.jewel.JewelPosition, Jewel2.jewel.JewelType, null),
                                                Jewel2.GetRow(Jewel1.jewel.JewelPosition, Jewel2.jewel.JewelType, null), Jewel2);


        // 如果obj1或obj2的类型是星形
        if (Jewel1.jewel.JewelType == 99 || Jewel2.jewel.JewelType == 99)
        {
            // 同时obj1或obj2的类型是特殊技能-清除相同图块
            if (Jewel1.jewel.JewelType == 8 || Jewel2.jewel.JewelType == 8)
            {
                // 播放移动无效的动画
                Jewel1.SetBackAnimation(obj2);
                Jewel2.SetBackAnimation(obj1);
                return;
            }
        }
        // obj1或obj2消除列表>=3, 或 obj1或obj2的类型是特殊技能-清除相同图块
        if (NeiObj1.Count >= 3 || NeiObj2.Count >= 3 || Jewel1.jewel.JewelType == 8 || Jewel2.jewel.JewelType == 8)
        {
            // 交换obj1,obj2位置
            Ulti.MoveTo(obj1, obj2.transform.localPosition, 0.2f);
            Ulti.MoveTo(obj2, obj1.transform.localPosition, 0.2f);
            // 交换obj1,obj2在数组中位置
            SwapJewelPosition(obj1, obj2);
            // 进行消除运算
            JewelProcess(NeiObj1, NeiObj2, obj1, obj2);
        }
        else
        {
            // 播放移动无效的动画
            Jewel1.SetBackAnimation(obj2);
            Jewel2.SetBackAnimation(obj1);
        }
    }
예제 #4
0
    JewelObj MoveChecker(int x, int y, JewelObj obj)
    {
        vtmplist = getListPos(x, y);
        foreach (Vector2 item in vtmplist)
        {
            if (JewelSpawner.spawn.JewelGribScript[(int)item.x, (int)item.y] != null && JewelSpawner.spawn.JewelGribScript[(int)item.x, (int)item.y].jewel.JewelType == 8)
                return JewelSpawner.spawn.JewelGribScript[(int)item.x, (int)item.y];
            else
            {
                List<JewelObj> NeiObj1 = Ulti.ListPlus(obj.GetCollumn(item, obj.jewel.JewelType, null),
                                                       obj.GetRow(item, obj.jewel.JewelType, null), obj);
                if (NeiObj1.Count >= 3)
                    return JewelSpawner.spawn.JewelGribScript[(int)item.x, (int)item.y];
            }
        }

        return null;
    }
예제 #5
0
    JewelObj MoveChecker(int x, int y, JewelObj obj)
    {
        vtmplist = getListPos(x, y);
        foreach (Vector2 item in vtmplist)
        {
            if (JewelSpawner.spawn.JewelGribScript[(int)item.x, (int)item.y] != null && JewelSpawner.spawn.JewelGribScript[(int)item.x, (int)item.y].jewel.JewelType == 8)
            {
                return(JewelSpawner.spawn.JewelGribScript[(int)item.x, (int)item.y]);
            }
            else
            {
                List <JewelObj> NeiObj1 = Ulti.ListPlus(obj.GetCollumn(item, obj.jewel.JewelType, null),
                                                        obj.GetRow(item, obj.jewel.JewelType, null), obj);
                if (NeiObj1.Count >= 3)
                {
                    return(JewelSpawner.spawn.JewelGribScript[(int)item.x, (int)item.y]);
                }
            }
        }

        return(null);
    }
예제 #6
0
    //check logic game
    public void RuleChecker(GameObject obj1, GameObject obj2)
    {
        JewelObj Jewel1 = obj1.GetComponent <JewelObj>();
        JewelObj Jewel2 = obj2.GetComponent <JewelObj>();

        if (Jewel1.jewel.JewelPower == (int)GameController.Power.LUCKY)
        {
            Jewel1.jewel.JewelType = Supporter.sp.LuckyCheck(Jewel2.jewel.JewelPosition);
        }

        if (Jewel2.jewel.JewelPower == (int)GameController.Power.LUCKY)
        {
            Jewel2.jewel.JewelType = Supporter.sp.LuckyCheck(Jewel1.jewel.JewelPosition);
        }

        List <JewelObj> NeiObj1 = Ulti.ListPlus(Jewel1.GetCollumn(Jewel2.jewel.JewelPosition, Jewel1.jewel.JewelType, null),
                                                Jewel1.GetRow(Jewel2.jewel.JewelPosition, Jewel1.jewel.JewelType, null), Jewel1);
        List <JewelObj> NeiObj2 = Ulti.ListPlus(Jewel2.GetCollumn(Jewel1.jewel.JewelPosition, Jewel2.jewel.JewelType, null),
                                                Jewel2.GetRow(Jewel1.jewel.JewelPosition, Jewel2.jewel.JewelType, null), Jewel2);

        //Take a peek into the future destination
        SwapJewelPosition(obj1, obj2);
        bool hasCombo = ComboManager.Instance.ComboProcess(obj1);

        SwapJewelPosition(obj1, obj2);
        //After that, return to normal operations

        //If there is a combo, let combo operation handle it
        if (hasCombo)
        {
            return;
        }

        if (Jewel1.jewel.JewelType == 99 || Jewel2.jewel.JewelType == 99)
        {
            if (Jewel1.jewel.JewelType == 8 || Jewel2.jewel.JewelType == 8)
            {
                Jewel1.SetBackAnimation(obj2);
                Jewel2.SetBackAnimation(obj1);
                return;
            }
        }

        if (NeiObj1.Count >= 3 || NeiObj2.Count >= 3 || Jewel1.jewel.JewelType == 8 || Jewel2.jewel.JewelType == 8)
        {
            Ulti.MoveTo(obj1, obj2.transform.localPosition, 0.2f);
            Ulti.MoveTo(obj2, obj1.transform.localPosition, 0.2f);
            SwapJewelPosition(obj1, obj2);
            JewelProcess(NeiObj1, NeiObj2, obj1, obj2);

            if (Jewel1.jewel.JewelPower == (int)GameController.Power.LUCKY)
            {
                GameController.action._guestManager.GiveItemToFirstFoundGuest();
            }

            if (Jewel2.jewel.JewelPower == (int)GameController.Power.LUCKY)
            {
                GameController.action._guestManager.GiveItemToFirstFoundGuest();
            }

            if (NeiObj1.Count == 3 || NeiObj2.Count == 3)
            {
                Supporter.sp.SpawnARandomStripe(Jewel1.jewel.JewelType);
            }

            //Valid move, so minus a move
            MoveChecker();
        }
        else
        {
            Jewel1.SetBackAnimation(obj2);
            Jewel2.SetBackAnimation(obj1);
        }
    }