Exemplo n.º 1
0
        private void CheckCanMove()
        {
            bool isUpcollision    = false;
            bool isDowncollision  = false;
            bool isRightcollision = false;
            bool isLeftcollision  = false;

            foreach (Wall wall in GameManager.GetInstance().WallList)
            {
                if (_upray.Collision(wall.SourceRectangle))
                {
                    isUpcollision = true;
                }
                if (_downray.Collision(wall.SourceRectangle))
                {
                    isDowncollision = true;
                }
                if (_rightray.Collision(wall.SourceRectangle))
                {
                    isRightcollision = true;
                }
                if (_leftray.Collision(wall.SourceRectangle))
                {
                    isLeftcollision = true;
                }
            }
            if (isUpcollision)
            {
                _canUp = false;
            }
            else
            {
                _canUp = true;
            }
            if (isDowncollision)
            {
                _canDown = false;
            }
            else
            {
                _canDown = true;
            }
            if (isRightcollision)
            {
                _canRight = false;
            }
            else
            {
                _canRight = true;
            }
            if (isLeftcollision)
            {
                _canLeft = false;
            }
            else
            {
                _canLeft = true;
            }
        }