目前正在开发一款小型控制台游戏,并且想知道是否有人有简单的方法来缩短这样的事情:
if (map[playerX - 1, playerY] == "R1"
|| map[playerX - 1, playerY] == "R2"
|| map[playerX - 1, playerY] == "R3"
|| map[playerX - 1, playerY] == "Z1"
|| map[playerX - 1, playerY] == "Z2"
|| map[playerX - 1, playerY] == "Z3"
|| map[playerX - 1, playerY] == "S1 "
|| map[playerX - 1, playerY] == "S2"
|| map[playerX - 1, playerY] == "S3")
Run Code Online (Sandbox Code Playgroud)
制作一个列表或某物,并检查是否map[playerX-1, playerY]等于其中的任何对象或其他东西.
我在这里先向您的帮助表示感谢.Lukas Leder