示例#1
0
    public void getNewPosition()
    {
        int newpos = (int)jewel.JewelPosition.y;
        int x      = (int)jewel.JewelPosition.x;
        int oldpos = (int)jewel.JewelPosition.y;

        for (int y = newpos - 1; y >= 0; y--)
        {
            if (GribManager.cell.Map[x, y] != 0 && GribManager.cell.GribCellObj[x, y].cell.CellEffect != 4 && JewelSpawner.spawn.JewelGribScript[x, y] == null)
            {
                newpos = y;
            }
            else if (GribManager.cell.Map[x, y] != 0 && GribManager.cell.GribCellObj[x, y].cell.CellEffect == 4)
            {
                break;
            }
        }
        JewelSpawner.spawn.JewelGribScript[x, (int)jewel.JewelPosition.y] = null;
        JewelSpawner.spawn.JewelGrib[x, (int)jewel.JewelPosition.y]       = null;

        jewel.JewelPosition = new Vector2(x, newpos);
        JewelSpawner.spawn.JewelGribScript[x, newpos] = this;
        JewelSpawner.spawn.JewelGrib[x, newpos]       = this.gameObject;
        if (oldpos != newpos)
        {
            StartCoroutine(Ulti.IEDrop(this.gameObject, jewel.JewelPosition, GameController.DROP_SPEED));
        }
    }
示例#2
0
    /// <summary>
    /// 重新调整JewelPosition的位置,并播放下落动画
    /// 此方法有点类似于排序,主要是处理当Map中有消除的方块后产生空位,此时需要将空位上方的方块移动到空位。
    /// (说白了就是冒泡排序,地图中消失的方块移动到后面)
    /// 将数组中Y轴的往下移动。全部移动完后,所有地图中空的位置均为后面的值,例如6、7、8这几个位置是空的)
    /// </summary>
    public void getNewPosition()
    {
        int newpos = (int)jewel.JewelPosition.y;    // 新的y坐标
        int x      = (int)jewel.JewelPosition.x;    // x坐标
        int oldpos = (int)jewel.JewelPosition.y;    // 初始的y坐标

        for (int y = newpos - 1; y >= 0; y--)       // 遍历从现在往下的jewelObj
        {
            // 如果该位置不是固定为空并且该位置没有冰崩特效并且该位置没有宝石对象
            if (GribManager.cell.Map[x, y] != 0 && GribManager.cell.GribCellObj[x, y].cell.CellEffect != 4 && JewelSpawner.spawn.JewelGribScript[x, y] == null)
            {
                newpos = y;
            }
            // 如果该位置不是固定为空并且该位置有冰崩特效
            else if (GribManager.cell.Map[x, y] != 0 && GribManager.cell.GribCellObj[x, y].cell.CellEffect == 4)
            {
                break;
            }
        }
        // 清空原坐标对象
        JewelSpawner.spawn.JewelGribScript[x, (int)jewel.JewelPosition.y] = null;
        JewelSpawner.spawn.JewelGrib[x, (int)jewel.JewelPosition.y]       = null;
        // 生成新坐标
        jewel.JewelPosition = new Vector2(x, newpos);
        JewelSpawner.spawn.JewelGribScript[x, newpos] = this;
        JewelSpawner.spawn.JewelGrib[x, newpos]       = this.gameObject;

        if (oldpos != newpos)
        {
            // 开始下落协程
            StartCoroutine(Ulti.IEDrop(this.gameObject, jewel.JewelPosition, GameController.DROP_SPEED));
        }
    }
示例#3
0
    /// <summary>
    /// 获取新位置  并进行下落动画
    /// </summary>
    public void getNewPosition()
    {
        int newpos = (int)Fruit.FruitPosition.y;
        int x      = (int)Fruit.FruitPosition.x;
        int oldpos = (int)Fruit.FruitPosition.y;

        for (int y = newpos; y >= 0; y--)
        {
            if (GridManager.grid.Map[x, y] != 0 && GridManager.grid.GridCellObj[x, y].Cell.CellEffect != 4 && FruitSpawner.spawn.FruitGridScript[x, y] == null)
            {
                newpos = y;
            }
            else if (GridManager.grid.Map[x, y] != 0 && GridManager.grid.GridCellObj[x, y].Cell.CellEffect == 4)
            {
                break;
            }

            FruitSpawner.spawn.FruitGridScript[x, (int)Fruit.FruitPosition.y] = null;
            FruitSpawner.spawn.FruitGrid[x, (int)Fruit.FruitPosition.y]       = null;

            Fruit.FruitPosition = new Vector2(x, newpos);
            FruitSpawner.spawn.FruitGridScript[x, newpos] = this;
            FruitSpawner.spawn.FruitGrid[x, newpos]       = this.gameObject;
            if (oldpos != newpos)
            {
                StartCoroutine(Ulti.IEDrop(this.gameObject, Fruit.FruitPosition, GameController.DROP_SPEED));
            }
        }
    }
    /// <summary>
    /// 产生新方块,并播放下落动画
    /// </summary>
    void Spawn()
    {
        int[] h = new int[7];
        for (int x = 0; x < 7; x++)
        {
            int s = 0;
            for (int y = 0; y < 9; y++)
            {
                if (GribManager.cell.GribCellObj[x, y] != null && GribManager.cell.GribCellObj[x, y].cell.CellEffect == 4)
                {
                    s = y + 1;
                }
            }
            for (int y = s; y < 9; y++)
            {
                if (GameController.action.GameState == (int)Timer.GameState.PLAYING)
                {
                    if (GribManager.cell.GribCellObj[x, y] != null && JewelSpawner.spawn.JewelGribScript[x, y] == null)
                    {
                        Object     temp = JewelSpawner.spawn.JewelGrib[x, y];
                        GameObject tmp  = JewelSpawner.spawn.JewelInstantiate(x, y);
                        if (PLayerInfo.MODE == 1 && Random.value > 0.99f)
                        {
                            tmp.GetComponent <JewelObj>().jewel.JewelPower = 4;
                            EffectSpawner.effect.Clock(tmp);
                        }
                        tmp.transform.localPosition = new Vector3(tmp.transform.localPosition.x, 10 + h[x]);
                        h[x]++;

                        //播放滑落动画
                        StartCoroutine(Ulti.IEDrop(tmp, new Vector2(x, y), GameController.DROP_SPEED));
                        JewelObj script = tmp.GetComponent <JewelObj>();
                        script.render.enabled = true;
                    }
                }
            }
        }
        StartCoroutine(checkNomoremove());
    }
示例#5
0
    void Spawn()
    {
        int[] h = new int[7];

        for (int x = 0; x < 7; x++)
        {
            int s = 0;
            for (int y = 0; y < 9; y++)
            {
                if (GridManager.grid.GridCellObj[x, y] != null && GridManager.grid.GridCellObj[x, y].Cell.CellEffect == 4)
                {
                    s = y + 1;
                }
            }
            for (int y = s; y < 9; y++)
            {
                if (GameController.gameController.GameState == (int)Timer.GameState.PLAYING)
                {
                    if (GridManager.grid.GridCellObj[x, y] != null && FruitSpawner.spawn.FruitGridScript[x, y] == null)
                    {
                        GameObject tmp = FruitSpawner.spawn.FruitInstantiate(x, y);
                        if (PlayerInfo.MODE == 1 && Random.value > 0.99f)
                        {
                            tmp.GetComponent <FruitObj>().Fruit.FruitType = 4;
                        }
                        tmp.transform.localPosition = new Vector3(tmp.transform.localPosition.x, 10 + h[x]);
                        h[x]++;
                        StartCoroutine(Ulti.IEDrop(tmp, new Vector2(x, y), GameController.DROP_SPEED));
                        FruitObj script = tmp.GetComponent <FruitObj>();
                        script.Render.enabled = true;
                    }
                }
            }
        }

        StartCoroutine(checkNoMoreMove());
    }