public bool isNoMoreMove()
    {
        StopSuggestionAnim();
        AvaiableMove = new Vector2[2];
        AvaiableObj = new JewelObj[2];

        for (int x = 0; x < 7; x++)
        {
            for (int y = 0; y < 9; y++)
            {
                if (JewelSpawner.spawn.JewelGribScript[x, y] != null && GribManager.cell.GribCellObj[x, y].cell.CellEffect == 0)
                {
                    obj = JewelSpawner.spawn.JewelGribScript[x, y];
                    JewelObj obj1 = MoveChecker(x, y, obj);
                    if (obj1 != null)
                    {
                        AvaiableMove[0] = obj.jewel.JewelPosition;
                        AvaiableObj[0] = JewelSpawner.spawn.JewelGribScript[(int)AvaiableMove[0].x, (int)AvaiableMove[0].y];
                        AvaiableMove[1] = obj1.jewel.JewelPosition;
                        AvaiableObj[1] = JewelSpawner.spawn.JewelGribScript[(int)AvaiableMove[1].x, (int)AvaiableMove[1].y];
                        isNomove = false;
                        return true;
                    }

                }
            }
        }
        isNomove = true;
        return false;
    }
Exemple #2
0
    public void DestroyRandom()
    {
        //uu tien destroy ganh
        dropjewel();
        if (PLayerInfo.MODE == 1)
        {
            if (!isStar)
            {
                List <CellObj> listeff = getListCellEffect();

                if (listeff.Count > 0)
                {
                    CellObj tmp = listeff[Random.Range(0, listeff.Count)];
                    tmp.RemoveEffect();
                    EffectSpawner.effect.Thunder(GribManager.cell.GribCell[(int)tmp.cell.CellPosition.x, (int)tmp.cell.CellPosition.y].transform.position);
                }
                else
                {
                    destroynotempty();
                }
            }
            else
            {
                Vector2  vtmp = posUnderStar();
                JewelObj tmp  = JewelSpawner.spawn.JewelGribScript[(int)vtmp.x, (int)vtmp.y];
                if (tmp != null && tmp != JewelStar)
                {
                    tmp.Destroy();
                    EffectSpawner.effect.Thunder(GribManager.cell.GribCell[(int)tmp.jewel.JewelPosition.x, (int)tmp.jewel.JewelPosition.y].transform.position);
                }
            }
        }
    }
Exemple #3
0
    /// <summary>
    /// 使用协程播放下落动画
    /// </summary>
    /// <param name="obj"></param>
    /// <param name="NewPos"></param>
    /// <param name="speed"></param>
    /// <returns></returns>
    public static IEnumerator IEDrop(GameObject obj, Vector2 NewPos, float speed)
    {
        JewelObj   script = obj.GetComponent <JewelObj>();
        Collider2D coll   = obj.GetComponent <Collider2D>();

        if (obj != null)
        {
            Transform _tranform = obj.transform;
            coll.enabled  = false;
            script.isMove = true;
            //!!!! 注意显示游戏对象即:obj中transform的localPosition与逻辑地图中的NewPos是一样,均使用的是左下角0,0然后往上一格则为0,1
            //这就解决了显示对象数据向逻辑数据同步的问题,即显示对象按逻辑对象的x,y进行移动到指定位置。
            while (_tranform != null && _tranform.localPosition.y - NewPos.y > 0.1f)
            {
                _tranform.localPosition -= new Vector3(0, Time.smoothDeltaTime * speed);
                yield return(null);
            }
            if (_tranform != null)
            {
                //这块的数据和AS3中的闭包数据很像,即协程执行完比后,他的数据类似AS3中的闭包方法,即数据还是之前的数据.
                _tranform.localPosition = new Vector3(NewPos.x, NewPos.y);

                script.Bounce();
                script.RuleChecker();
                yield return(new WaitForSeconds(0.2f));

                //开启碰撞器组件
                if (coll != null)
                {
                    coll.enabled  = true;
                    script.isMove = false;
                }
            }
        }
    }
    ///
    /// <summary>
    /// 随机在一个宝石身上产生一个技能特效
    /// </summary>
    public void AddBonusPower()
    {
        // 产生技能次数
        int dem = 0;

        while (true)
        {
            dem++;
            // 超过63次,就不在给宝石赋予技能
            if (dem >= 63)
            {
                return;
            }
            // 随机一个宝石坐标
            int x = Random.Range(0, 7);
            int y = Random.Range(0, 9);
            // 获取对应宝石对象
            JewelObj tmp = JewelSpawner.spawn.JewelGribScript[x, y];
            // 该对象不为空,不是五彩宝石,没有宝石技能,所在格子是普通格子
            if (tmp != null && tmp.jewel.JewelType != 8 && tmp.jewel.JewelPower == 0 && GribManager.cell.GribCellObj[x, y].cell.CellEffect == 0)
            {
                //随机1种技能
                int r = Random.Range(2, 4);
                // 给宝石技能赋值
                tmp.jewel.JewelPower = r;
                // 生成火箭触发特效
                EffectSpawner.effect.ThunderRow(JewelSpawner.spawn.JewelGrib[x, y], r);
                return;
            }
        }
    }
Exemple #5
0
    public static IEnumerator IEDrop(GameObject obj, Vector2 NewPos, float speed)
    {
        JewelObj   script = obj.GetComponent <JewelObj>();
        Collider2D coll   = obj.GetComponent <Collider2D>();

        if (obj != null)
        {
            Transform _tranform = obj.transform;
            coll.enabled  = false;
            script.isMove = true;
            while (_tranform != null && _tranform.localPosition.y - NewPos.y > 0.1f)
            {
                _tranform.localPosition -= new Vector3(0, Time.smoothDeltaTime * speed);
                yield return(null);
            }
            if (_tranform != null)
            {
                _tranform.localPosition = new Vector3(NewPos.x, NewPos.y);

                script.Bounce();
                script.RuleChecker();
                yield return(new WaitForSeconds(0.2f));

                if (coll != null)
                {
                    coll.enabled  = true;
                    script.isMove = false;
                }
            }
        }
    }
    public GameObject JewelInstantiatebt(int x, int y)
    {
        GameObject tmp;

        tmp         = (GameObject)Instantiate(JewelObject);
        JewelScript = tmp.GetComponent <JewelObj>();

        tmp.transform.SetParent(JewelParent.transform, false);
        JewelScript.render.enabled = true;
        JewelGrib[x, y]            = ObjTmp;
        JewelGribScript[x, y]      = JewelScript;

        int r = 0;

        if (PLayerInfo.MODE == 1)
        {
            r = Random.Range(0, 6);
        }
        else
        {
            r = Random.Range(0, 7);
        }
        JewelScript.render.sprite       = JewelSprite[r];
        JewelScript.jewel.JewelPosition = new Vector2(x, 9);
        JewelScript.jewel.JewelType     = r;
        JewelScript.jewel.JewelPower    = 0;
        return(tmp);
    }
Exemple #7
0
    public void AddBonusPower()
    {
        return;

        int dem = 0;

        while (true)
        {
            dem++;
            if (dem >= 63)
            {
                return;
            }
            int      x   = Random.Range(0, GameController.WIDTH);
            int      y   = Random.Range(0, GameController.HEIGHT);
            JewelObj tmp = JewelSpawner.spawn.JewelGribScript[x, y];
            if (tmp != null && tmp.jewel.JewelType != 8 && tmp.jewel.JewelPower == 0 && GribManager.cell.GribCellObj[x, y].cell.CellEffect == 0)
            {
                int r = Random.Range(2, 4);
                tmp.jewel.JewelPower = r;
                EffectSpawner.effect.ThunderRow(JewelSpawner.spawn.JewelGrib[x, y], r);
                return;
            }
        }
    }
Exemple #8
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);
        }
    }
Exemple #9
0
 public static void TraceNowJewelObj(JewelObj obj = null)
 {
     if (obj != null)
     {
         LogUtils.TraceNow("JewelType:" + obj.jewel.JewelType + " " + obj.jewel.JewelPosition.x + "," + obj.jewel.JewelPosition.y);
     }
 }
    //swap map jewel position
    /// <summary>
    /// 交换Map中的宝石位置
    /// </summary>
    /// <param name="jewel1"></param>
    /// <param name="jewel2"></param>
    void SwapJewelPosition(GameObject jewel1, GameObject jewel2)
    {
        JewelObj tmp1 = jewel1.GetComponent <JewelObj>();
        JewelObj tmp2 = jewel2.GetComponent <JewelObj>();

        //交互宝时对象在Map中的位置
        Vector2 tmp = tmp1.jewel.JewelPosition;

        tmp1.jewel.JewelPosition = tmp2.jewel.JewelPosition;
        tmp2.jewel.JewelPosition = tmp;

        //交换对象
        GameObject Objtmp = JewelSpawner.spawn.JewelGrib[(int)tmp1.jewel.JewelPosition.x, (int)tmp1.jewel.JewelPosition.y];

        JewelSpawner.spawn.JewelGrib[(int)tmp1.jewel.JewelPosition.x, (int)tmp1.jewel.JewelPosition.y] = jewel2;
        JewelSpawner.spawn.JewelGrib[(int)tmp2.jewel.JewelPosition.x, (int)tmp2.jewel.JewelPosition.y] = Objtmp;

        //交换脚本
        JewelObj scripttmp = tmp1;

        JewelSpawner.spawn.JewelGribScript[(int)tmp2.jewel.JewelPosition.x, (int)tmp2.jewel.JewelPosition.y] = tmp2;
        JewelSpawner.spawn.JewelGribScript[(int)tmp1.jewel.JewelPosition.x, (int)tmp1.jewel.JewelPosition.y] = scripttmp;
        if (tmp1.jewel.JewelType == 99 || tmp2.jewel.JewelType == 99)
        {
            WinChecker();
        }
    }
Exemple #11
0
    public void SpawnARandomStripe(int jewelType)
    {
        for (int x = 0; x < GameController.WIDTH; x++)
        {
            for (int y = 0; y < GameController.HEIGHT; y++)
            {
                JewelObj tmp = JewelSpawner.spawn.JewelGribScript [x, y];
                if (tmp != null && tmp.jewel != null && tmp.jewel.JewelType == jewelType && tmp.jewel.JewelPower == 0)
                {
                    int rand = Random.Range(0, 2);
                    switch (rand)
                    {
                    case 0:
                        Supporter.sp.SpawnJewelPower(jewelType, (int)GameController.Power.STRIPED_HORIZONTAL, tmp.jewel.JewelPosition, true);
                        break;

                    case 1:
                        Supporter.sp.SpawnJewelPower(jewelType, (int)GameController.Power.STRIPED_VERTICAL, tmp.jewel.JewelPosition, true);
                        break;

                    default:
                        Supporter.sp.SpawnJewelPower(jewelType, (int)GameController.Power.STRIPED_VERTICAL, tmp.jewel.JewelPosition, true);
                        break;
                    }
                    return;
                }
            }
        }
    }
    public GameObject JewelInstantiate(int x, int y)
    {
        ObjTmp      = (GameObject)Instantiate(JewelObject);
        JewelScript = ObjTmp.GetComponent <JewelObj>();
        ObjTmp.transform.SetParent(JewelParent.transform, false);
        ObjTmp.transform.localPosition = new Vector3(ObjTmp.transform.localPosition.x + x * BaseDistance, ObjTmp.transform.localPosition.y + y * BaseDistance);
        JewelGrib[x, y]       = ObjTmp;
        JewelGribScript[x, y] = JewelScript;
        int r = 0;

        if (PLayerInfo.MODE == 1)
        {
            r = Random.Range(0, 6);
        }
        else
        {
            r = Random.Range(0, 7);
        }

        JewelScript.render.sprite       = JewelSprite[r];
        JewelScript.jewel.JewelPosition = new Vector2(x, y);
        JewelScript.jewel.JewelType     = r;

        return(ObjTmp);
    }
Exemple #13
0
    public bool isNoMoreMove()
    {
        StopSuggestionAnim();
        AvaiableMove = new Vector2[2];
        AvaiableObj  = new JewelObj[2];

        for (int x = 0; x < GameController.WIDTH; x++)
        {
            for (int y = 0; y < GameController.HEIGHT; y++)
            {
                if (JewelSpawner.spawn.JewelGribScript[x, y] != null && GribManager.cell.GribCellObj[x, y].cell.CellEffect == 0)
                {
                    obj = JewelSpawner.spawn.JewelGribScript[x, y];
                    JewelObj obj1 = MoveChecker(x, y, obj);
                    if (obj1 != null)
                    {
                        AvaiableMove[0] = obj.jewel.JewelPosition;
                        AvaiableObj[0]  = JewelSpawner.spawn.JewelGribScript[(int)AvaiableMove[0].x, (int)AvaiableMove[0].y];
                        AvaiableMove[1] = obj1.jewel.JewelPosition;
                        AvaiableObj[1]  = JewelSpawner.spawn.JewelGribScript[(int)AvaiableMove[1].x, (int)AvaiableMove[1].y];
                        isNomove        = false;
                        return(true);
                    }
                }
            }
        }
        isNomove = true;
        return(false);
    }
Exemple #14
0
    public void DestroyAdjacentJewel(JewelObj jewelObj, bool firstTime = true)
    {
        if (jewelObj == null || jewelObj.jewel == null)
        {
            print("NULL");
            return;
        }

        Jewel   centerJewel     = jewelObj.jewel;
        Vector2 centerJewel_Pos = centerJewel.JewelPosition;

        Vector2[] directions = GetAdjacentVectors(centerJewel_Pos);

        foreach (Vector2 direction in directions)
        {
            if (CheckOutOfBounds(direction))
            {
                JewelObj obj = JewelSpawner.spawn.JewelGribScript[(int)direction.x, (int)direction.y];
                if (obj != null)
                {
                    obj.Destroy();
                }
            }
        }

        if (firstTime)
        {
            StartCoroutine(DestroyAdjacentJewel_Again(centerJewel_Pos));
        }
    }
    // 消除相同类型对象
    IEnumerator DestroyType(int type, Vector3 pos)
    {
        // 激活禁选框
        NoSelect.SetActive(true);
        // 开启滑落检测
        dropjewel();
        // 遍历宝石列表
        for (int x = 0; x < 7; x++)
        {
            for (int y = 0; y < 9; y++)
            {
                JewelObj tmp = JewelSpawner.spawn.JewelGribScript[x, y];
                if (tmp != null && tmp.jewel.JewelType == type)
                {
                    // 播放特效
                    EffectSpawner.effect.MGE(pos, JewelSpawner.spawn.JewelGrib[x, y].transform.position);
                    // 销毁宝石对象
                    tmp.Destroy();
                }
            }
        }
        // 等0.2s
        yield return(new WaitForSeconds(0.2f));

        // 隐藏禁选框
        NoSelect.SetActive(false);
    }
Exemple #16
0
    IEnumerator WheelEffect_Async(Vector2 startpos, MotionDirection motionDirection)
    {
        int boundCol = GameController.HEIGHT;
        int boundRow = GameController.WIDTH;

        List <Vector2> dirs = new List <Vector2>();

        switch (motionDirection)
        {
        case MotionDirection.RIGHT:
            for (int i = (int)startpos.x; i < boundRow; i++)
            {
                dirs.Add(new Vector2((float)i, startpos.y));
            }
            break;

        case MotionDirection.LEFT:
            for (int i = (int)startpos.x; i > -1; i--)
            {
                dirs.Add(new Vector2((float)i, startpos.y));
            }
            break;

        case MotionDirection.UP:
            for (int i = (int)startpos.y; i < boundCol; i++)
            {
                dirs.Add(new Vector2(startpos.x, (float)i));
            }
            break;

        case MotionDirection.DOWN:
            for (int i = (int)startpos.y; i > -1; i--)
            {
                dirs.Add(new Vector2(startpos.x, (float)i));
            }
            break;
        }

        for (int i = 1; i < dirs.Count; i++)
        {
            JewelObj tmp = JewelSpawner.spawn.JewelGribScript [(int)dirs[i].x, (int)dirs[i].y];
            if (tmp != null)
            {
                if (i < 4)
                {
                    int random = Random.Range(6, 8);
                    Supporter.sp.SpawnJewelPower(tmp.jewel.JewelType, random, tmp.jewel.JewelPosition, true);
                }
                else
                {
                    tmp.Destroy();
                }
            }
        }
        yield return(new WaitForSeconds(1f));

        GameController.action.dropjewel();
    }
    // 对要消除数量分级,根据级别消除
    bool ListProcess(List <JewelObj> list, GameObject obj, GameObject obj1, int type)
    {
        Vector3 v;// 宝石对象坐标

        // 交换的对象
        if (obj1 != null)
        {
            // 获取对象坐标
            JewelScript = obj1.GetComponent <JewelObj>();
            v           = new Vector3(JewelScript.jewel.JewelPosition.x, JewelScript.jewel.JewelPosition.y);
        }
        // 本对象
        else
        {
            // 获取对象坐标
            JewelScript = obj.GetComponent <JewelObj>();
            v           = new Vector3(JewelScript.jewel.JewelPosition.x, JewelScript.jewel.JewelPosition.y);
        }
        // 获取列表数量
        int c = list.Count;

        if (c == 3)
        {
            // 消除宝石 生成新宝石
            DestroyJewel(list);
            // 增加特效计数
            EffectSpawner.effect.ComBoInc();
            // 开启滑落检测
            dropjewel();
            return(false);
        }
        else if (c == 4)
        {
            // 移动并消除宝石 生成新宝石
            ReGroup(list, type, (int)Power.BOOM, v);
            // 有限随机消除一个宝石对象
            DestroyRandom();
            // 增加特效计数
            EffectSpawner.effect.ComBoInc();
            // 开启滑落检测
            dropjewel();
        }
        else if (c >= 5)
        {
            // 移动并消除宝石 生成新宝石类型五彩
            ReGroup(list, 8, (int)Power.MAGIC, v);
            // 增加特效计数
            EffectSpawner.effect.ComBoInc();
            // (有限随机)随机删除一个宝石
            DestroyRandom();
            // (有限随机)随机删除一个宝石
            DestroyRandom();
            // 开启下落检查
            dropjewel();
        }

        return(true);
    }
Exemple #18
0
    IEnumerator Endgame()
    {
        GameController.action.dropjewel();
        yield return(new WaitForSeconds(2f));

        int movesLeft    = GameController.action.MoveLeft;
        int spawnPerMove = 2;

        int[] validPowers = new int[]
        {
            6,            //STRIPED_VERTICAL
            7,            //STRIPED_HORIZONTAL
            5,            //WRAPPER
        };

        int availableSlots = NormalJewelCount();          //measure to prevent stack overflow.Happens when there is no more available jewel

        for (int i = 0; i < movesLeft; i++)
        {
            for (int j = 0; j < spawnPerMove; j++)
            {
                if (availableSlots > 0)                 //measure to prevent stack overflow
                {
                    Vector2 location = GetRandomLocation();
                    int     rand     = Random.Range(0, validPowers.Length);
                    Supporter.sp.SpawnJewelPower(JewelSpawner.spawn.JewelGribScript [(int)location.x, (int)location.y].jewel.JewelType, validPowers[rand], location, true);
                    availableSlots--;
                }
            }

            yield return(new WaitForSeconds(0.5f));
        }

        yield return(new WaitForSeconds(2f));

        for (int x = 0; x < GameController.WIDTH; x++)
        {
            for (int y = 0; y < GameController.HEIGHT; y++)
            {
                JewelObj tmp = JewelSpawner.spawn.JewelGribScript [x, y];
                if (tmp != null && tmp.jewel != null)
                {
                    if (tmp.jewel.JewelPower != 0)
                    {
                        tmp.Destroy();
                        yield return(new WaitForSeconds(0.5f));
                    }
                }
            }
        }

        yield return(new WaitForSeconds(1.5f));

        Timer.timer.Win();
    }
    private void hammerSelect()
    {
        if (Input.GetMouseButtonUp(0) && (isDoHammer || isExChange || isMagic))
        {
            //锤子道具销毁宝石
            if (isDoHammer)
            {
                GameObject pointer = JewelTouchChecker(Input.mousePosition);
                if (pointer != null)
                {
                    JewelObj JewelScript = pointer.GetComponent <JewelObj>();
                    Supporter.sp.StopSuggestionAnim();
                    if (JewelScript != null && JewelScript.jewel.JewelType != 99)
                    {
                        JewelScript.Destroy();
                        dropjewel();
                    }
                }
            }
            //魔法道具
            if (isMagic)
            {
                GameObject pointer = JewelTouchChecker(Input.mousePosition);
                if (pointer != null)
                {
                    JewelObj JewelScript = pointer.GetComponent <JewelObj>();
                    Supporter.sp.StopSuggestionAnim();
                    if (JewelScript != null && JewelScript.jewel.JewelType != 99)
                    {
                        Vector3 v = new Vector3(JewelScript.jewel.JewelPosition.x, JewelScript.jewel.JewelPosition.y);
                        StartCoroutine(SpawnJewelPower(JewelScript.jewel.JewelType, (int)Power.BOOM, v));
                    }
                }
            }

#if IPHONE || ANDROID
            if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
#else
            if (EventSystem.current.IsPointerOverGameObject())
#endif
            {
                //点击UI
                if (EventSystem.current.currentSelectedGameObject == null || !EventSystem.current.currentSelectedGameObject.name.Contains("prop_"))
                {
                    Debug.Log("---点击UI 不为道具");
                    isDoHammer = false;
                    isExChange = false;
                    isMagic    = false;
                    prop_bg.SetActive(false);
                    JewelSpawner.spawn.transform.position = new Vector3(0, 0, 0);
                    JewelSpawner.spawn.transform.SetAsLastSibling();
                }
            }
        }
    }
Exemple #20
0
    void JewelObjInitializer(ref GameObject jewelObj, int x, int y, int type, int power)
    {
        JewelScript                     = jewelObj.GetComponent <JewelObj>();
        JewelGrib[x, y]                 = jewelObj;
        JewelGribScript[x, y]           = JewelScript;
        JewelScript.jewel.JewelPosition = new Vector2(x, y);
        JewelScript.jewel.JewelType     = type;
        JewelScript.jewel.JewelPower    = power;

        JewelScript.SetSkin(type, power);         //Have no idea why, had to improvise on the old code
    }
Exemple #21
0
    bool CheckForLShape(List <Vector2> line1, List <Vector2> line2, JewelObj intersectedJewel)
    {
        bool isAtCenter1 = CheckIfVectorAtCenter(line1, intersectedJewel.jewel.JewelPosition);
        bool isAtCenter2 = CheckIfVectorAtCenter(line2, intersectedJewel.jewel.JewelPosition);

        if ((!isAtCenter1 && !isAtCenter2))
        {
            return(true);
        }
        return(false);
    }
Exemple #22
0
    /// <summary>
    /// Check for occurances of combo
    /// </summary>
    /// <param name="jewel"> center jewel gameobject that needs checking </param>
    /// <returns></returns>
    public bool ComboProcess(GameObject obj)
    {
        JewelObj JewelObj = obj.GetComponent <JewelObj>();

        if (JewelObj != null)
        {
            return(ComboProcess(JewelObj.jewel));
        }
        else
        {
            return(false);
        }
    }
Exemple #23
0
    public IEnumerator DestroyAdjacentJewel_Again(Vector2 jewelPos)
    {
        yield return(new WaitForSeconds(GameController.DROP_DELAY + 1.5f));

        JewelObj obj = JewelSpawner.spawn.JewelGribScript[(int)jewelPos.x, (int)jewelPos.y];

        DestroyAdjacentJewel(obj, false);
        if (obj != null)
        {
            obj.Destroy();
        }
        GameController.action.dropjewel();
    }
Exemple #24
0
 public void Boom(Vector3 groundZero)
 {
     for (int x = 0; x < GameController.WIDTH; x++)
     {
         for (int y = 0; y < GameController.HEIGHT; y++)
         {
             JewelObj tmp = JewelSpawner.spawn.JewelGribScript [x, y];
             if (tmp != null && tmp.jewel != null)
             {
                 tmp.BoomEffect(groundZero);
             }
         }
     }
 }
Exemple #25
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>());
        }
    }
    //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);
        }
    }
Exemple #28
0
    GameObject Test(int x, int y, int r)
    {
        ObjTmp      = (GameObject)Instantiate(JewelObject);
        JewelScript = ObjTmp.GetComponent <JewelObj>();
        ObjTmp.transform.SetParent(JewelParent.transform, false);
        ObjTmp.transform.localPosition = new Vector3(x, y);
        ObjTmp.transform.GetChild(0).gameObject.transform.localScale = new Vector3(0, 0, 1);
        JewelGrib[x, y]       = ObjTmp;
        JewelGribScript[x, y] = JewelScript;


        JewelScript.SetSkin(r);
        JewelScript.jewel.JewelPosition = new Vector2(x, y);
        JewelScript.jewel.JewelType     = r;

        return(ObjTmp);
    }
Exemple #29
0
    public Vector2 GetRandomLocation(int offset_x, int offset_y)
    {
        int randWidth  = Random.Range(offset_x, GameController.WIDTH);
        int randHeight = Random.Range(offset_y, GameController.HEIGHT);

        JewelObj tmp = JewelSpawner.spawn.JewelGribScript [randWidth, randHeight];

        if (tmp != null)
        {
            if (tmp.jewel.JewelPower == 0)
            {
                return(new Vector2(randWidth, randHeight));
            }
        }

        return(GetRandomLocation(offset_x, offset_y));
    }
Exemple #30
0
    void ComboStripe_Color(int type)
    {
        for (int x = 0; x < GameController.WIDTH; x++)
        {
            for (int y = 0; y < GameController.HEIGHT; y++)
            {
                JewelObj tmp = JewelSpawner.spawn.JewelGribScript [x, y];
                if (tmp != null && tmp.jewel.JewelType == type)
                {
                    int random = Random.Range(6, 8);

                    StartCoroutine(SpawnJewelPower_Async(type, random, tmp.jewel.JewelPosition));
                }
            }
        }
        StartCoroutine(ActivateStripes(3.5f));;
    }
Exemple #31
0
 //Destroy a specific type of jewel
 IEnumerator DestroyJewelType(int type)
 {
     for (int x = 0; x < GameController.WIDTH; x++)
     {
         for (int y = 0; y < GameController.HEIGHT; y++)
         {
             JewelObj tmp = JewelSpawner.spawn.JewelGribScript [x, y];
             if (tmp != null && tmp.jewel.JewelType == type)
             {
                 EffectSpawner.effect.Thunder(GribManager.cell.GribCell[(int)tmp.jewel.JewelPosition.x, (int)tmp.jewel.JewelPosition.y].transform.position);
                 tmp.Destroy();
                 yield return(new WaitForSeconds(0.1f));
             }
         }
     }
     GameController.action.dropjewel();
 }
Exemple #32
0
    public static List<JewelObj> ListPlus(List<JewelObj> l1, List<JewelObj> l2, JewelObj bonus)
    {
        List<JewelObj> tmp = new List<JewelObj>();
        for (int i = l1.Count - 1; i >= 0; i--)
        {
            tmp.Add(l1[i]);
        }
        if (bonus != null)
            tmp.Add(bonus);

        for (int i = 0; i < l2.Count; i++)
        {
            tmp.Add(l2[i]);
        }

        return tmp;
    }
    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;
    }
Exemple #34
0
    bool ListProcess(List<JewelObj> list, GameObject obj, GameObject obj1, int type)
    {
        Vector3 v;
		int jewelType = 0;

        if (obj1 != null)
        {
            JewelScript = obj1.GetComponent<JewelObj>();
            v = new Vector3(JewelScript.jewel.JewelPosition.x, JewelScript.jewel.JewelPosition.y);
			jewelType = JewelScript.jewel.JewelType;
        }
        else
        {
            JewelScript = obj.GetComponent<JewelObj>();
            v = new Vector3(JewelScript.jewel.JewelPosition.x, JewelScript.jewel.JewelPosition.y);
			jewelType = JewelScript.jewel.JewelType;
        }

        int c = list.Count;
        if (c == 3)
        {
            DestroyJewel(list);
            EffectSpawner.effect.ComBoInc();
            dropjewel();
            return false;
        }
        else if (c == 4)
        {
            //ReGroup(list, type, (int)Power.BOOM, v);
			Direction dir = Supporter.sp.GetJewelListDirection(list);

			if(dir == Direction.VERTICAL)
				ReGroup(list,jewelType, (int)Power.STRIPED_VERTICAL, v);
			if(dir == Direction.HORIZONTAL)
				ReGroup(list, jewelType, (int)Power.STRIPED_HORIZONTAL, v);
		
            //DestroyRandom();
            EffectSpawner.effect.ComBoInc();
            dropjewel();
        }
        else if (c >= 5)
        {
			JewelShape shape;

			if (obj1 != null)
			 shape = Supporter.sp.GetJewelShape(list,obj1);
			else
			 shape = Supporter.sp.GetJewelShape(list,obj);

			if(shape == JewelShape.L_SHAPED)
			{
				ReGroup(list, jewelType, (int)Power.WRAPPER, v);
			}

			if(shape == JewelShape.T_SHAPED)
			{
				ReGroup(list, jewelType, (int)Power.WRAPPER, v);
			}

			if(shape == JewelShape.STRAIGHT)
			{
				ReGroup(list, 8, (int)Power.MAGIC, v);
			}

            //ReGroup(list, 8, (int)Power.MAGIC, v);
            EffectSpawner.effect.ComBoInc();
            //DestroyRandom();
            //DestroyRandom();
            dropjewel();
        }

        return true;
    }
Exemple #35
0
	public void DestroyAdjacentJewel(JewelObj jewelObj,bool firstTime = true)
	{

		if (jewelObj == null || jewelObj.jewel == null) {
			print ("NULL");
			return;
		}

		Jewel centerJewel = jewelObj.jewel;
		Vector2 centerJewel_Pos = centerJewel.JewelPosition;

		Vector2[] directions = GetAdjacentVectors(centerJewel_Pos);
		
		foreach(Vector2 direction in directions)
		{
			if (CheckOutOfBounds(direction))
			{
				JewelObj obj = JewelSpawner.spawn.JewelGribScript[(int)direction.x,(int)direction.y];
				if(obj != null)
					obj.Destroy();
			}
		}

		if (firstTime)
			StartCoroutine (DestroyAdjacentJewel_Again(centerJewel_Pos));
	}
Exemple #36
0
	bool CheckForLShape(List<Vector2> line1,List<Vector2> line2,JewelObj intersectedJewel)
	{
		bool isAtCenter1 = CheckIfVectorAtCenter (line1, intersectedJewel.jewel.JewelPosition);
		bool isAtCenter2 = CheckIfVectorAtCenter (line2, intersectedJewel.jewel.JewelPosition);
		if ((!isAtCenter1 && !isAtCenter2)) {
			return true;
		}
		return false;
	}
Exemple #37
0
    public GameObject JewelInstantiate(int x, int y)
    {
        ObjTmp = (GameObject)Instantiate(JewelObject);
        JewelScript = ObjTmp.GetComponent<JewelObj>();
        ObjTmp.transform.SetParent(JewelParent.transform, false);
        ObjTmp.transform.localPosition = new Vector3(ObjTmp.transform.localPosition.x + x * BaseDistance, ObjTmp.transform.localPosition.y + y * BaseDistance);
        JewelGrib[x, y] = ObjTmp;
        JewelGribScript[x, y] = JewelScript;
        int r = 0;

        if (PLayerInfo.MODE == 1)
            r = Random.Range(0, 6);
        else
            r = Random.Range(0, 7);

		JewelScript.SetSkin (r);
        JewelScript.jewel.JewelPosition = new Vector2(x, y);
        JewelScript.jewel.JewelType = r;

        return ObjTmp;
    }
    public GameObject SpawnJewelPower(int type, int power, Vector3 pos)
    {
        GameObject tmp;
        int x = (int)pos.x;
        int y = (int)pos.y;
        if (JewelGrib[x, y] != null)
            Destroy(JewelGrib[x, y]);
        if (type == 8)
        {
            tmp = (GameObject)Instantiate(JewelColor);
        }
        else
        {
            tmp = (GameObject)Instantiate(JewelObject);
        }

        JewelScript = tmp.GetComponent<JewelObj>();
        JewelScript.render.enabled = true;
        tmp.transform.SetParent(JewelParent.transform, false);
        tmp.transform.localPosition = new Vector3(x, y, pos.z);
        JewelGrib[x, y] = tmp;
        JewelGribScript[x, y] = JewelScript;
        if (type != 8)
            JewelScript.render.sprite = JewelSprite[type];
        JewelScript.jewel.JewelPosition = new Vector2(x, y);
        JewelScript.jewel.JewelType = type;
        JewelScript.jewel.JewelPower = power;
        tmp.GetComponent<Collider2D>().enabled = false;
        if (power == (int)GameController.Power.BOOM)
            EffectSpawner.effect.Enchant(tmp.transform.GetChild(0).gameObject);
        return tmp;
    }
    bool ListProcess(List<JewelObj> list, GameObject obj, GameObject obj1, int type)
    {
        Vector3 v;

        if (obj1 != null)
        {
            JewelScript = obj1.GetComponent<JewelObj>();
            v = new Vector3(JewelScript.jewel.JewelPosition.x, JewelScript.jewel.JewelPosition.y);
        }
        else
        {
            JewelScript = obj.GetComponent<JewelObj>();
            v = new Vector3(JewelScript.jewel.JewelPosition.x, JewelScript.jewel.JewelPosition.y);
        }

        int c = list.Count;
        if (c == 3)
        {
            DestroyJewel(list);
            EffectSpawner.effect.ComBoInc();
            dropjewel();
            return false;
        }
        else if (c == 4)
        {
            ReGroup(list, type, (int)Power.BOOM, v);
            DestroyRandom();
            EffectSpawner.effect.ComBoInc();
            dropjewel();
        }
        else if (c >= 5)
        {
            ReGroup(list, 8, (int)Power.MAGIC, v);
            EffectSpawner.effect.ComBoInc();
            DestroyRandom();
            DestroyRandom();
            dropjewel();
        }

        return true;
    }
Exemple #40
0
    public GameObject JewelInstantiatebt(int x, int y)
    {
        GameObject tmp;
        tmp = (GameObject)Instantiate(JewelObject);
        JewelScript = tmp.GetComponent<JewelObj>();

        tmp.transform.SetParent(JewelParent.transform, false);
        //JewelScript.render.enabled = true;
        JewelGrib[x, y] = ObjTmp;
        JewelGribScript[x, y] = JewelScript;

        int r = 0;

        if (PLayerInfo.MODE == 1)
            r = Random.Range(0, 6);
        else
            r = Random.Range(0, 7);

		JewelScript.SetSkin (r);
        JewelScript.jewel.JewelPosition = new Vector2(x, 9);
        JewelScript.jewel.JewelType = r;
        JewelScript.jewel.JewelPower = 0;
        return tmp;
    }
Exemple #41
0
    GameObject RJewelInstantiate(int x, int y)
    {
        ObjTmp = (GameObject)Instantiate(JewelObject);
        JewelScript = ObjTmp.GetComponent<JewelObj>();
        ObjTmp.transform.SetParent(JewelParent.transform, false);
        ObjTmp.transform.localPosition = new Vector3(x, y);
        ObjTmp.transform.GetChild(0).gameObject.transform.localScale = new Vector3(0, 0, 1);
        JewelGrib[x, y] = ObjTmp;
        JewelGribScript[x, y] = JewelScript;

        int r = randomjewel(x, y);

		JewelScript.SetSkin (r);
        JewelScript.jewel.JewelPosition = new Vector2(x, y);
        JewelScript.jewel.JewelType = r;

        return ObjTmp;
    }
Exemple #42
0
	void JewelObjInitializer(ref GameObject jewelObj,int x, int y,int type,int power)
	{
		JewelScript = jewelObj.GetComponent<JewelObj>();
		JewelGrib[x, y] = jewelObj;
		JewelGribScript[x, y] = JewelScript;
		JewelScript.jewel.JewelPosition = new Vector2(x, y);
		JewelScript.jewel.JewelType = type;
		JewelScript.jewel.JewelPower = power;

		JewelScript.SetSkin (type,power); //Have no idea why, had to improvise on the old code

	}
Exemple #43
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>();
 }
Exemple #44
0
    public List<JewelObj> GetRow(Vector2 Pos, int type, JewelObj bonus)
    {
        List<JewelObj> tmp1 = GetLeft(Pos, type);
        List<JewelObj> tmp2 = GetRight(Pos, type);
        if (tmp1.Count + tmp2.Count > 1)
        {
            return Ulti.ListPlus(tmp1, tmp2, bonus);
        }

        else
            return new List<JewelObj>();
    }
Exemple #45
0
    public void SpawnStar(Vector2 pos)
    {
        if (JewelGribScript[(int)pos.x, (int)pos.y] != null)
            Destroy(JewelGrib[(int)pos.x, (int)pos.y]);

        GameObject tmp = (GameObject)Instantiate(Star);
        tmp.name = "JewelStar";
        tmp.transform.SetParent(JewelParent.transform, false);
        tmp.transform.localPosition = new Vector3(pos.x, pos.y);
        tmp.transform.GetChild(0).gameObject.SetActive(false);
        JewelScript = tmp.GetComponent<JewelObj>();
        JewelScript.jewel.JewelPosition = pos;
        JewelGribScript[(int)pos.x, (int)pos.y] = JewelScript;
        JewelGrib[(int)pos.x, (int)pos.y] = tmp;
        GameController.action.JewelStar = JewelScript;

        StarEffect.SetActive(true);
    }