jeudi 19 octobre 2017

Simply check for multiple statments C#

Currently working on a small console game and was wondering if anyone has a simple way to shorten something like this:

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")

making a list or somthing and checking if map[playerX-1, playerY] is equal to any of the objects in it or something.

Thanks for the help in advance. Lukas Leder

Aucun commentaire:

Enregistrer un commentaire