示例#1
0
文件: Map.cs 项目: luunamten/SAVE
        private void genSmallBait(int res)
        {
            int blankSize = blank.Count;
            int sx        = blank[res][0];
            int sy        = blank[res][1];

            if (matrix[sy, sx] == 2 || matrix[sy, sx] == 3)
            {
                int loop = 0;
                foreach (int[] coord in blank)
                {
                    loop++;
                    if (matrix[coord[1], coord[0]] == 0)
                    {
                        sx = coord[0];
                        sy = coord[1];
                        break;
                    }
                }
                if (loop == blankSize)
                {
                    return;
                }
            }
            small = new SmallFood(sx, sy);
        }
示例#2
0
文件: Map.cs 项目: luunamten/SAVE
        public int work()
        {
            baitsWork();
            if (timeToSnakeGrow == 0)
            {
                matrix[sn.ly, sn.lx] = 0;
            }
            else
            {
                timeToSnakeGrow--;
            }

            sn.work();
            if (isSnakeDie())
            {
                GameOver = true;
                return(SNAKE_DIE);
            }
            matrix[sn.fy, sn.fx] = 2;

            int flag1 = smallBaitState(sn.fx, sn.fy);

            if (flag1 == SMALL_IS_EATED)
            {
                sn.grow(SmallFood.WORTH);
                small = null;
                genBaits();
                return(SmallFood.WORTH);
            }
            int flag2 = bigBaitState(sn.fx, sn.fy);

            if (flag2 == BIG_IS_EATED_LEFT)
            {
                removePartOfBigBait(big.X + 1, big.Y, big.X, big.Y);
                sn.grow(BigFood.WORTH);
                bigTime = 0;
                big     = null;
                return(BigFood.SCRORE);
            }
            if (flag2 == BIG_IS_EATED_RIGHT)
            {
                removePartOfBigBait(big.X, big.Y, big.X + 1, big.Y);
                sn.grow(BigFood.WORTH);
                bigTime = 0;
                big     = null;
                return(BigFood.SCRORE);
            }
            if (flag1 == SMALL_NO_EXIST && flag2 == BIG_NO_EXIST)
            {
                return(NO_BAIT);
            }
            else
            {
                return(NORMAL);
            }
        }
示例#3
0
文件: Map.cs 项目: luunamten/SAVE
        public void reset()
        {
            List <int[]> part = sn.getPart();
            int          size = part.Count;

            for (int i = 1; i < size; i++)
            {
                matrix[part[i][1], part[i][0]] = 0;
            }
            sn              = null;
            small           = null;
            big             = null;
            timeToSnakeGrow = 0;
            count           = 0;
            bigTime         = 0;
            GameOver        = false;
        }