static char[,] FrogMove(Container container, char[,] mappos, Frog frog)//判断青蛙运动 { ConsoleKeyInfo keyInfo = Console.ReadKey(true); int y = frog.y; int x = frog.x; if (keyInfo.Key == ConsoleKey.RightArrow || keyInfo.Key == ConsoleKey.LeftArrow)//如果往左或者往右运动,就计算按键时差 { float oversecond = 0, startsecond = 0; startsecond = DateTime.Now.Millisecond; if (System.Math.Abs(startsecond - oversecond) < 100) { return(mappos); } else { if (!frog.Be_Brick(frog.x, frog.y + 1, container) && frog.airmove <= 0) { return(mappos); } else { frog.airmove--; oversecond = startsecond; if (keyInfo.Key == ConsoleKey.RightArrow) { if (frog.Be_Brick(frog.x + 1, frog.y, container)) { return(mappos); } //往左撞墙 else { frog.x++; Clear(mappos); mappos[frog.y, frog.x] = 'm'; } } else if (keyInfo.Key == ConsoleKey.LeftArrow) { if (frog.Be_Brick(frog.x - 1, frog.y, container)) { return(mappos); } //往右撞墙 else if (frog.x - 1 < 0) { frog.x++; return(mappos); } else { frog.x--; Clear(mappos); mappos[frog.y, frog.x] = 'm'; } } } } } if (keyInfo.Key == ConsoleKey.UpArrow && frog.Be_Brick(frog.x, frog.y + 1, container))//如果按键跳跃就计算是否站在地面上,是则跳跃,否则不跳跃 { frog.jump = true; frog.starty = frog.y; frog.airmove = 5; frog.jumpstart = DateTime.Now; } if (frog.Be_Glasses(frog.x, frog.y, container))//如果碰到眼镜,则捡到武器 { frog.arm = true; } if (keyInfo.Key == ConsoleKey.Spacebar && frog.arm == true)//如果持有武器且按键,则射击 { frog.attack = true; Bullet bullet = new Bullet(); container.bu.Add(bullet); bullet.x = frog.x; bullet.y = frog.y; bullet.startx = frog.x; } if (frog.Be_Timecoin(frog.x, frog.y, container))//碰到硬币 { container.ti.Remove((y + 1) * 100 + x); frog.timecoin++; } if (frog.Be_Brick(frog.x, frog.y + 1, container)) { frog.airmove = 5; } return(mappos); }