示例#1
0
        /// <summary>
        /// 生成格子
        /// </summary>
        /// <returns></returns>
        public RuntimeGrids generateGrids(Grid.Belong operer = Grid.Belong.Player)
        {
            var gridsSet = Grids.GridsSet;
            var grids    = gridsSet[Random.Range(0, gridsSet.Length)];

            return(new RuntimeGrids(grids, operer));
        }
示例#2
0
        /// <summary>
        /// 获取提升高度(被方块覆盖时)
        /// </summary>
        /// <returns></returns>
        public int getUpperY(int x, int y, Grid.Belong belong)
        {
            var grid = getGridLoopX(x, y);

            if (grid.belong == belong)
            {
                return(y);
            }
            // 向上试探
            do
            {
                if (belong == Grid.Belong.Player &&
                    ++y >= mapY)
                {
                    return(2 * mapY);
                }
                if (belong == Grid.Belong.Enemy &&
                    --y < 0)
                {
                    return(-mapY);
                }
                grid = getGridLoopX(x, y);
            } while (grid.belong != belong);

            return(y);
        }
示例#3
0
        /// <summary>
        /// 获取坠落高度
        /// </summary>
        /// <returns></returns>
        public int getFallingY(int x, int y, Grid.Belong belong)
        {
            var grid = getGridLoopX(x, y);

            if (grid.belong == belong)
            {
                // 向下试探
                do
                {
                    if (belong == Grid.Belong.Player &&
                        --y < 0)
                    {
                        return(-mapY);
                    }
                    if (belong == Grid.Belong.Enemy &&
                        ++y >= mapY)
                    {
                        return(2 * mapY);
                    }
                    grid = getGridLoopX(x, y);
                } while (grid.belong == belong);

                return(belong == Grid.Belong.Player ? y + 1 : y - 1);
            }
            return(getUpperY(x, y, belong));
        }
示例#4
0
        /// <summary>
        /// 判断某点的归属
        /// </summary>
        bool isPointValid(int x, int y, Grid.Belong belong)
        {
            var grid = getGridIgnoreY(x, y);

            if (grid == null)
            {
                return(false);
            }
            return(grid.belong != belong);
        }
示例#5
0
        /// <summary>
        /// 判断前方墙的高度
        /// </summary>
        public int judgeWall(int x, int y, Grid.Belong belong)
        {
            switch (belong)
            {
            case Grid.Belong.Player:
                return(judgePlayerWall(x, y));

            case Grid.Belong.Enemy:
                return(judgeEnemyWall(x, y));
            }
            return(2);
        }
示例#6
0
        /// <summary>
        /// 寻找穿透的地板
        /// </summary>
        /// <param name="x"></param>
        /// <param name="belong"></param>
        /// <returns></returns>
        public int findThrough(int x, bool direction, Grid.Belong belong)
        {
            int cnt = 0;

            for (int xx = x; cnt < 10; xx = forward(xx, direction))
            {
                var y = belong == Grid.Belong.Player ?
                        (mapY / 2 - 2) : (mapY / 2 + 1);

                var grid = getGrid(x, y);
                if (grid.belong == belong)
                {
                    return(xx);
                }
                cnt++;
            }
            return(-1);
        }
示例#7
0
 public RuntimeGrids(int gid, Grid.Belong operer)
 {
     gridsId = gid; this.operer = operer;
 }
示例#8
0
 public RuntimeGrids(Grids grids, Grid.Belong operer) :
     this(grids.id, operer)
 {
 }
示例#9
0
 /// <summary>
 /// 判断格子的归属
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="belong"></param>
 /// <returns></returns>
 public bool judgePosBelong(int x, int y, Grid.Belong belong)
 {
     return(getGrid(x, y)?.posBelong == belong);
 }
示例#10
0
 /// <summary>
 /// 改变方块
 /// </summary>
 public void changeGrid(int x, int y, Grid.Belong belong)
 {
     getGrid(x, y)?.changeBelong(belong);
 }