HasFlag always returns True

前端 未结 5 675
有刺的猬
有刺的猬 2021-01-06 07:39

There is a way to check if I got a flag in a series of flag?

Example:

[Flags]
Enum TestEnum
{
  ALIVE, DEAD, ALMOSTDEAD, HURT, OTHERS

}
// check if          


        
5条回答
  •  Happy的楠姐
    2021-01-06 08:22

    I think you are making a game, so you should make a class for this issue

    public class Player
    {
        bool isAlive;
        bool isHurt;
    ...
    }
    

    Later you could check your states like this:

    if (player.isAlive && player.isHurt)
    {
     //dosomething
    }
    

提交回复
热议问题