Exemplo n.º 1
0
    public void RuleChecker(GameObject obj1, GameObject obj2)
    {
        FruitObj        fruit1     = obj1.GetComponent <FruitObj>();
        FruitObj        fruit2     = obj2.GetComponent <FruitObj>();
        List <FruitObj> fruitObjs1 = Ulti.ListPlus(fruit1.GetCollumn(fruit2.Fruit.FruitPosition, fruit1.Fruit.FruitType, null), fruit1.GetRow(fruit2.Fruit.FruitPosition, fruit1.Fruit.FruitType, null), fruit1);

        List <FruitObj> fruitObjs2 = Ulti.ListPlus(fruit2.GetCollumn(fruit1.Fruit.FruitPosition, fruit2.Fruit.FruitType, null), fruit2.GetRow(fruit1.Fruit.FruitPosition, fruit2.Fruit.FruitType, null), fruit2);


        if (fruit1.Fruit.FruitType == 99 || fruit2.Fruit.FruitType == 99)
        {
            if (fruit1.Fruit.FruitType == 8 || fruit2.Fruit.FruitType == 8)
            {
                fruit1.SetBackAnimation(obj2);
                fruit2.SetBackAnimation(obj1);
                return;
            }
        }

        if (fruitObjs1.Count >= 3 || fruitObjs2.Count >= 3 || fruit1.Fruit.FruitType == 8 || fruit2.Fruit.FruitType == 8)
        {
            Ulti.MoveTo(obj1, obj2.transform.localPosition, 0.2f);
            Ulti.MoveTo(obj2, obj1.transform.localPosition, 0.2f);
            SwapFruitPosition(obj1, obj2);
            FruitProcess(fruitObjs1, fruitObjs2, obj1, obj2);
        }
        else
        {
            fruit1.SetBackAnimation(obj2);
            fruit2.SetBackAnimation(obj1);
        }
    }
Exemplo n.º 2
0
    public void RuleChecker()
    {
        if (jewel.JewelType != 99)
        {
            List <JewelObj> list = Ulti.ListPlus(GetRow(jewel.JewelPosition, jewel.JewelType, null),
                                                 GetCollumn(jewel.JewelPosition, jewel.JewelType, null),
                                                 this);

            if (list.Count >= 3)
            {
                listProcess(list);
                Checked = true;
            }
            else
            {
                //Detect end of move nly when there is no more move
                if (GameController.action.MoveLeft == 0)
                {
                    GameController.action.StartCountdown();
                }
            }
        }
        else
        {
            GameController.action.WinChecker();
        }
    }
Exemplo n.º 3
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);
        }
    }
Exemplo n.º 4
0
    public List <JewelObj> getList()
    {
        List <JewelObj> list = Ulti.ListPlus(GetRow(jewel.JewelPosition, jewel.JewelType, null),
                                             GetCollumn(jewel.JewelPosition, jewel.JewelType, null),
                                             this);

        return(list);
    }
Exemplo n.º 5
0
    public List <FruitObj> getList()
    {
        List <FruitObj> list = Ulti.ListPlus(GetRow(Fruit.FruitPosition, Fruit.FruitType, null),
                                             GetCollumn(Fruit.FruitPosition, Fruit.FruitType, null),
                                             this);

        return(list);
    }
Exemplo n.º 6
0
    // 获取本对象周围可以消除的列表的大小
    public int getListcount()
    {
        // 合并行,列消除列表
        List <JewelObj> list = Ulti.ListPlus(GetRow(jewel.JewelPosition, jewel.JewelType, null),
                                             GetCollumn(jewel.JewelPosition, jewel.JewelType, null),
                                             this);

        // 返回列表大小
        return(list.Count);
    }
Exemplo n.º 7
0
    public List <JewelObj> GetCollumn(Vector2 Pos, int type, JewelObj bonus)
    {
        List <JewelObj> tmp1 = GetTop(Pos, type);
        List <JewelObj> tmp2 = GetBot(Pos, type);

        if (tmp1.Count + tmp2.Count > 1)
        {
            return(Ulti.ListPlus(tmp1, tmp2, bonus));
        }
        else
        {
            return(new List <JewelObj>());
        }
    }
Exemplo n.º 8
0
    /// <summary>
    /// 获取同行相连
    /// </summary>
    /// <param name="Pos"></param>
    /// <param name="type"></param>
    /// <param name="bonus"></param>
    /// <returns></returns>
    public List <FruitObj> GetRow(Vector2 Pos, int type, FruitObj bonus)
    {
        List <FruitObj> tmp1 = GetLeft(Pos, type);
        List <FruitObj> tmp2 = GetRight(Pos, type);

        if (tmp1.Count + tmp2.Count > 1)
        {
            return(Ulti.ListPlus(tmp1, tmp2, bonus));
        }
        else
        {
            return(new List <FruitObj>());
        }
    }
Exemplo n.º 9
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);
            }
        }
    }
Exemplo n.º 10
0
    //消除检查
    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);
        }
    }
Exemplo n.º 11
0
 /// <summary>
 /// 游戏算法规则检查
 /// </summary>
 public void RuleChecker()
 {
     if (Fruit.FruitType != 99)
     {
         List <FruitObj> list = Ulti.ListPlus(GetRow(Fruit.FruitPosition, Fruit.FruitType, null), GetCollumn(Fruit.FruitPosition, Fruit.FruitType, null), this);
         if (list.Count >= 3)
         {
             listProcess(list);
             Checked = true;
         }
         else
         {
             GameController.gameController.WinChecker();
         }
     }
 }
Exemplo n.º 12
0
    /// <summary>
    /// 获取列消除List
    /// </summary>
    /// <param name="Pos"></param>
    /// <param name="type"></param>
    /// <param name="bonus"></param>
    /// <returns></returns>
    public List <JewelObj> GetCollumn(Vector2 Pos, int type, JewelObj bonus)
    {
        // 获取上边类型相同的对象列表
        List <JewelObj> tmp1 = GetTop(Pos, type);
        // 获取下边类型相同的对象列表
        List <JewelObj> tmp2 = GetBot(Pos, type);

        // 如果相同的类型数>=3
        if (tmp1.Count + tmp2.Count > 1)
        {
            // 返回合并两个list的list
            return(Ulti.ListPlus(tmp1, tmp2, bonus));
        }
        else
        {
            return(new List <JewelObj>());
        }
    }
Exemplo n.º 13
0
    public void RuleChecker()
    {
        if (jewel.JewelType != 99)
        {
            List <JewelObj> list = Ulti.ListPlus(GetRow(jewel.JewelPosition, jewel.JewelType, null),
                                                 GetCollumn(jewel.JewelPosition, jewel.JewelType, null),
                                                 this);

            if (list.Count >= 3)
            {
                listProcess(list);
                Checked = true;
            }
        }
        else
        {
            GameController.action.WinChecker();
        }
    }
Exemplo n.º 14
0
    /// <summary>
    /// 获取行消除List
    /// </summary>
    /// <param name="Pos"></param>
    /// <param name="type"></param>
    /// <param name="bonus"></param>
    /// <returns></returns>
    public List <JewelObj> GetRow(Vector2 Pos, int type, JewelObj bonus)
    {
        // 获取左边类型相同的对象列表
        List <JewelObj> tmp1 = GetLeft(Pos, type);
        // 获取右边类型相同的对象列表
        List <JewelObj> tmp2 = GetRight(Pos, type);

        // 如果相同的类型数>=3
        if (tmp1.Count + tmp2.Count > 1)
        {
            // 返回合并两个list的list
            return(Ulti.ListPlus(tmp1, tmp2, bonus));
        }

        else
        {
            // 返回空表
            return(new List <JewelObj>());
        }
    }
Exemplo n.º 15
0
 /// <summary>
 /// 返回可移动的物体
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="fruit"></param>
 /// <returns></returns>
 private FruitObj MoveChecker(int x, int y, FruitObj fruit)
 {
     vtmpList = getListPos(x, y);
     foreach (Vector2 item in vtmpList)
     {
         if (FruitSpawner.spawn.FruitGridScript[(int)item.x, (int)item.y] != null && FruitSpawner.spawn.FruitGridScript[(int)item.x, (int)item.y].Fruit.FruitType == 8)
         {
             return(FruitSpawner.spawn.FruitGridScript[(int)item.x, (int)item.y]);
         }
         else
         {
             List <FruitObj> objs = Ulti.ListPlus(fruit.GetCollumn(item, fruit.Fruit.FruitType, null), fruit.GetRow(item, fruit.Fruit.FruitType, null), fruit);
             if (objs.Count >= 3)
             {
                 return(FruitSpawner.spawn.FruitGridScript[(int)item.x, (int)item.y]);
             }
         }
     }
     return(null);
 }
Exemplo n.º 16
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);
    }
Exemplo n.º 17
0
 // 检查消除
 public void RuleChecker()
 {
     if (jewel.JewelType != 99)
     {
         // 获取该位置消除list
         List <JewelObj> list = Ulti.ListPlus(GetRow(jewel.JewelPosition, jewel.JewelType, null),
                                              GetCollumn(jewel.JewelPosition, jewel.JewelType, null),
                                              this);
         // 如果消除数>=3
         if (list.Count >= 3)
         {
             // 消除过程
             listProcess(list);
             Checked = true;
         }
     }
     else
     {
         // 检查是否赢了
         GameController.action.WinChecker();
     }
 }
Exemplo n.º 18
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);
        }
    }